On 20/01/2020 11.01, Geert Uytterhoeven wrote: > Hi Peter, > > On Fri, Jan 17, 2020 at 9:08 PM Peter Ujfalusi <peter.ujfalusi@xxxxxx> wrote: >> On 1/17/20 5:30 PM, Geert Uytterhoeven wrote: >>> Currently it is not easy to find out which DMA channels are in use, and >>> which slave devices are using which channels. >>> >>> Fix this by creating two symlinks between the DMA channel and the actual >>> slave device when a channel is requested: >>> 1. A "slave" symlink from DMA channel to slave device, >> >> Have you considered similar link name as on the slave device: >> slave:<name> >> >> That way it would be easier to grasp which channel is used for what >> purpose by only looking under /sys/class/dma/ and no need to check the >> slave device. > > Would this really provide more information? > The device name is already provided in the target of the symlink: > > root@koelsch:~# readlink > /sys/devices/platform/soc/e6720000.dma-controller/dma/dma1chan2/slave > ../../../ee140000.sd e6720000.dma-controller/dma/dma1chan2/slave -> ../../../ee140000.sd e6720000.dma-controller/dma/dma1chan3/slave -> ../../../ee140000.sd It is hard to tell which one is the tx and RX channel without looking under the ee140000.sd: ee140000.sd/dma:rx -> ../e6720000.dma-controller/dma/dma1chan3 ee140000.sd/dma:tx -> ../e6720000.dma-controller/dma/dma1chan2 Another option would be to not have symlinks, but a debugfs file where this information can be extracted and would only compiled if debugfs is enabled. >>> 2. A "dma:<name>" symlink slave device to DMA channel. >>> When the channel is released, the symlinks are removed again. >>> The latter requires keeping track of the slave device and the channel >>> name in the dma_chan structure. >>> >>> Note that this is limited to channel request functions for requesting an >>> exclusive slave channel that take a device pointer (dma_request_chan() >>> and dma_request_slave_channel*()). >>> >>> Signed-off-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx> >>> --- >>> v2: >>> - Add DMA_SLAVE_NAME macro, >>> - Also handle channels from FIXME, >>> - Add backlinks from slave device to DMA channel, >>> >>> On r8a7791/koelsch, the following new symlinks are created: >>> >>> /sys/devices/platform/soc/ >>> ├── e6700000.dma-controller/dma/dma0chan0/slave -> ../../../e6e20000.spi >>> ├── e6700000.dma-controller/dma/dma0chan1/slave -> ../../../e6e20000.spi >>> ├── e6700000.dma-controller/dma/dma0chan2/slave -> ../../../ee100000.sd >>> ├── e6700000.dma-controller/dma/dma0chan3/slave -> ../../../ee100000.sd >>> ├── e6700000.dma-controller/dma/dma0chan4/slave -> ../../../ee160000.sd >>> ├── e6700000.dma-controller/dma/dma0chan5/slave -> ../../../ee160000.sd >>> ├── e6700000.dma-controller/dma/dma0chan6/slave -> ../../../e6e68000.serial >>> ├── e6700000.dma-controller/dma/dma0chan7/slave -> ../../../e6e68000.serial >>> ├── e6720000.dma-controller/dma/dma1chan0/slave -> ../../../e6b10000.spi >>> ├── e6720000.dma-controller/dma/dma1chan1/slave -> ../../../e6b10000.spi >>> ├── e6720000.dma-controller/dma/dma1chan2/slave -> ../../../ee140000.sd >>> ├── e6720000.dma-controller/dma/dma1chan3/slave -> ../../../ee140000.sd >>> ├── e6b10000.spi/dma:rx -> ../e6720000.dma-controller/dma/dma1chan1 >>> ├── e6b10000.spi/dma:tx -> ../e6720000.dma-controller/dma/dma1chan0 >>> ├── e6e20000.spi/dma:rx -> ../e6700000.dma-controller/dma/dma0chan1 >>> ├── e6e20000.spi/dma:tx -> ../e6700000.dma-controller/dma/dma0chan0 >>> ├── e6e68000.serial/dma:rx -> ../e6700000.dma-controller/dma/dma0chan7 >>> ├── e6e68000.serial/dma:tx -> ../e6700000.dma-controller/dma/dma0chan6 >>> ├── ee100000.sd/dma:rx -> ../e6700000.dma-controller/dma/dma0chan3 >>> ├── ee100000.sd/dma:tx -> ../e6700000.dma-controller/dma/dma0chan2 >>> ├── ee140000.sd/dma:rx -> ../e6720000.dma-controller/dma/dma1chan3 >>> ├── ee140000.sd/dma:tx -> ../e6720000.dma-controller/dma/dma1chan2 >>> ├── ee160000.sd/dma:rx -> ../e6700000.dma-controller/dma/dma0chan5 >>> └── ee160000.sd/dma:tx -> ../e6700000.dma-controller/dma/dma0chan4 > > > Gr{oetje,eeting}s, > > Geert > - Péter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki