Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dmaengine: add channel device name to channel registration

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>

authored by

Amelie Delaunay and committed by
Vinod Koul
10b8e0fd 20884738

+13 -8
+10 -6
drivers/dma/dmaengine.c
··· 1037 1037 } 1038 1038 1039 1039 static int __dma_async_device_channel_register(struct dma_device *device, 1040 - struct dma_chan *chan) 1040 + struct dma_chan *chan, 1041 + const char *name) 1041 1042 { 1042 1043 int rc; 1043 1044 ··· 1067 1066 chan->dev->device.parent = device->dev; 1068 1067 chan->dev->chan = chan; 1069 1068 chan->dev->dev_id = device->dev_id; 1070 - dev_set_name(&chan->dev->device, "dma%dchan%d", 1071 - device->dev_id, chan->chan_id); 1069 + if (!name) 1070 + dev_set_name(&chan->dev->device, "dma%dchan%d", device->dev_id, chan->chan_id); 1071 + else 1072 + dev_set_name(&chan->dev->device, name); 1072 1073 rc = device_register(&chan->dev->device); 1073 1074 if (rc) 1074 1075 goto err_out_ida; ··· 1090 1087 } 1091 1088 1092 1089 int dma_async_device_channel_register(struct dma_device *device, 1093 - struct dma_chan *chan) 1090 + struct dma_chan *chan, 1091 + const char *name) 1094 1092 { 1095 1093 int rc; 1096 1094 1097 - rc = __dma_async_device_channel_register(device, chan); 1095 + rc = __dma_async_device_channel_register(device, chan, name); 1098 1096 if (rc < 0) 1099 1097 return rc; 1100 1098 ··· 1207 1203 1208 1204 /* represent channels in sysfs. Probably want devs too */ 1209 1205 list_for_each_entry(chan, &device->channels, device_node) { 1210 - rc = __dma_async_device_channel_register(device, chan); 1206 + rc = __dma_async_device_channel_register(device, chan, NULL); 1211 1207 if (rc < 0) 1212 1208 goto err_out; 1213 1209 }
+1 -1
drivers/dma/idxd/dma.c
··· 269 269 desc->txd.tx_submit = idxd_dma_tx_submit; 270 270 } 271 271 272 - rc = dma_async_device_channel_register(dma, chan); 272 + rc = dma_async_device_channel_register(dma, chan, NULL); 273 273 if (rc < 0) { 274 274 kfree(idxd_chan); 275 275 return rc;
+2 -1
include/linux/dmaengine.h
··· 1575 1575 int dmaenginem_async_device_register(struct dma_device *device); 1576 1576 void dma_async_device_unregister(struct dma_device *device); 1577 1577 int dma_async_device_channel_register(struct dma_device *device, 1578 - struct dma_chan *chan); 1578 + struct dma_chan *chan, 1579 + const char *name); 1579 1580 void dma_async_device_channel_unregister(struct dma_device *device, 1580 1581 struct dma_chan *chan); 1581 1582 void dma_run_dependencies(struct dma_async_tx_descriptor *tx);