* [PATCH/RFC] dmaengine: Create symlinks from DMA channels to slaves
@ 2019-06-07 11:38 Geert Uytterhoeven
2019-06-10 7:54 ` Vinod Koul
0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2019-06-07 11:38 UTC (permalink / raw)
To: Dan Williams, Vinod Koul
Cc: dmaengine, linux-renesas-soc, linux-kernel, Geert Uytterhoeven
Currently it is not easy to find out which DMA channels are in use, and
by which slave devices.
Fix this by creating in sysfs a "slave" symlink from the DMA channel to
the actual slave device when a channel is requested, and removing it
again when the channel is released.
For now this is limited to DT and ACPI.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Questions:
1. Do you think this is useful?
2. Should backlinks (e.g. "dma:<name>") be created from the slave
device to the DMA channel?
This requires storing the name in struct dma_chan, for later
symlink removal.
3. Should this be extended to other ways of requesting channels?
In many cases, no device pointer is available, so a device pointer
parameter has to be added to all DMA channel request APIs that
don't have it yet.
---
drivers/dma/dmaengine.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 03ac4b96117cd8db..c11476f76fc96bcf 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -706,6 +706,10 @@ struct dma_chan *dma_request_chan(struct device *dev, const char *name)
if (chan) {
/* Valid channel found or requester needs to be deferred */
+ if (!IS_ERR(chan) &&
+ sysfs_create_link(&chan->dev->device.kobj, &dev->kobj,
+ "slave"))
+ dev_err(dev, "Cannot create DMA slave symlink\n");
if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER)
return chan;
}
@@ -786,6 +790,7 @@ void dma_release_channel(struct dma_chan *chan)
/* drop PRIVATE cap enabled by __dma_request_channel() */
if (--chan->device->privatecnt == 0)
dma_cap_clear(DMA_PRIVATE, chan->device->cap_mask);
+ sysfs_remove_link(&chan->dev->device.kobj, "slave");
mutex_unlock(&dma_list_mutex);
}
EXPORT_SYMBOL_GPL(dma_release_channel);
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH/RFC] dmaengine: Create symlinks from DMA channels to slaves
2019-06-07 11:38 [PATCH/RFC] dmaengine: Create symlinks from DMA channels to slaves Geert Uytterhoeven
@ 2019-06-10 7:54 ` Vinod Koul
0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2019-06-10 7:54 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Dan Williams, dmaengine, linux-renesas-soc, linux-kernel
On 07-06-19, 13:38, Geert Uytterhoeven wrote:
> Currently it is not easy to find out which DMA channels are in use, and
> by which slave devices.
>
> Fix this by creating in sysfs a "slave" symlink from the DMA channel to
> the actual slave device when a channel is requested, and removing it
> again when the channel is released.
>
> For now this is limited to DT and ACPI.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> Questions:
> 1. Do you think this is useful?
Yes for me at least :)
> 2. Should backlinks (e.g. "dma:<name>") be created from the slave
> device to the DMA channel?
> This requires storing the name in struct dma_chan, for later
> symlink removal.
that would certainly be more helpful
> 3. Should this be extended to other ways of requesting channels?
> In many cases, no device pointer is available, so a device pointer
> parameter has to be added to all DMA channel request APIs that
> don't have it yet.
I think that would need to be done.
> ---
> drivers/dma/dmaengine.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
> index 03ac4b96117cd8db..c11476f76fc96bcf 100644
> --- a/drivers/dma/dmaengine.c
> +++ b/drivers/dma/dmaengine.c
> @@ -706,6 +706,10 @@ struct dma_chan *dma_request_chan(struct device *dev, const char *name)
>
> if (chan) {
> /* Valid channel found or requester needs to be deferred */
> + if (!IS_ERR(chan) &&
> + sysfs_create_link(&chan->dev->device.kobj, &dev->kobj,
> + "slave"))
> + dev_err(dev, "Cannot create DMA slave symlink\n");
> if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER)
> return chan;
> }
> @@ -786,6 +790,7 @@ void dma_release_channel(struct dma_chan *chan)
> /* drop PRIVATE cap enabled by __dma_request_channel() */
> if (--chan->device->privatecnt == 0)
> dma_cap_clear(DMA_PRIVATE, chan->device->cap_mask);
> + sysfs_remove_link(&chan->dev->device.kobj, "slave");
> mutex_unlock(&dma_list_mutex);
> }
> EXPORT_SYMBOL_GPL(dma_release_channel);
> --
> 2.17.1
--
~Vinod
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-10 7:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-07 11:38 [PATCH/RFC] dmaengine: Create symlinks from DMA channels to slaves Geert Uytterhoeven
2019-06-10 7:54 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).