]> www.infradead.org Git - users/hch/uuid.git/commitdiff
dmaengine: add channel device name to channel registration
authorAmelie Delaunay <amelie.delaunay@foss.st.com>
Fri, 31 May 2024 15:07:10 +0000 (17:07 +0200)
committerVinod Koul <vkoul@kernel.org>
Tue, 11 Jun 2024 18:25:34 +0000 (23:55 +0530)
Channel device name is used for sysfs, but also by dmatest filter function.

With dynamic channel registration, channels can be registered after dma
controller registration. Users may want to have specific channel names.

If name is NULL, the channel name relies on previous implementation,
dma<controller_device_id>chan<channel_device_id>.

Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Link: https://lore.kernel.org/r/20240531150712.2503554-11-amelie.delaunay@foss.st.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/dmaengine.c
drivers/dma/idxd/dma.c
include/linux/dmaengine.h

index 491b222402216a4a7bee1627b3e559321af33f36..c380a4dda77a045ed768c929f1a0e1fea1fe8e91 100644 (file)
@@ -1037,7 +1037,8 @@ static int get_dma_id(struct dma_device *device)
 }
 
 static int __dma_async_device_channel_register(struct dma_device *device,
-                                              struct dma_chan *chan)
+                                              struct dma_chan *chan,
+                                              const char *name)
 {
        int rc;
 
@@ -1066,8 +1067,10 @@ static int __dma_async_device_channel_register(struct dma_device *device,
        chan->dev->device.parent = device->dev;
        chan->dev->chan = chan;
        chan->dev->dev_id = device->dev_id;
-       dev_set_name(&chan->dev->device, "dma%dchan%d",
-                    device->dev_id, chan->chan_id);
+       if (!name)
+               dev_set_name(&chan->dev->device, "dma%dchan%d", device->dev_id, chan->chan_id);
+       else
+               dev_set_name(&chan->dev->device, name);
        rc = device_register(&chan->dev->device);
        if (rc)
                goto err_out_ida;
@@ -1087,11 +1090,12 @@ static int __dma_async_device_channel_register(struct dma_device *device,
 }
 
 int dma_async_device_channel_register(struct dma_device *device,
-                                     struct dma_chan *chan)
+                                     struct dma_chan *chan,
+                                     const char *name)
 {
        int rc;
 
-       rc = __dma_async_device_channel_register(device, chan);
+       rc = __dma_async_device_channel_register(device, chan, name);
        if (rc < 0)
                return rc;
 
@@ -1203,7 +1207,7 @@ int dma_async_device_register(struct dma_device *device)
 
        /* represent channels in sysfs. Probably want devs too */
        list_for_each_entry(chan, &device->channels, device_node) {
-               rc = __dma_async_device_channel_register(device, chan);
+               rc = __dma_async_device_channel_register(device, chan, NULL);
                if (rc < 0)
                        goto err_out;
        }
index cd835eabd31b08c1ccfa41d378743e1845232bdf..dbecd699237e3ac5a73b49ed2097a897abc9a043 100644 (file)
@@ -269,7 +269,7 @@ static int idxd_register_dma_channel(struct idxd_wq *wq)
                desc->txd.tx_submit = idxd_dma_tx_submit;
        }
 
-       rc = dma_async_device_channel_register(dma, chan);
+       rc = dma_async_device_channel_register(dma, chan, NULL);
        if (rc < 0) {
                kfree(idxd_chan);
                return rc;
index 752dbde4cec1f8073e225961a41bc91435583350..73537fddbb5224a89fa221a749619fb58831f843 100644 (file)
@@ -1575,7 +1575,8 @@ int dma_async_device_register(struct dma_device *device);
 int dmaenginem_async_device_register(struct dma_device *device);
 void dma_async_device_unregister(struct dma_device *device);
 int dma_async_device_channel_register(struct dma_device *device,
-                                     struct dma_chan *chan);
+                                     struct dma_chan *chan,
+                                     const char *name);
 void dma_async_device_channel_unregister(struct dma_device *device,
                                         struct dma_chan *chan);
 void dma_run_dependencies(struct dma_async_tx_descriptor *tx);