DMA Engine development
 help / color / mirror / Atom feed
* [PATCH] dmaengine: Use unique debugfs names
@ 2026-09-18  9:15 Linus Walleij
  2026-09-18 14:34 ` Frank Li
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Linus Walleij @ 2026-09-18  9:15 UTC (permalink / raw)
  To: Vinod Koul, Frank Li; +Cc: dmaengine, Linus Walleij

DMA40 registers multiple dma_device instances for the same platform
device. The DMAengine debugfs code uses dev_name(dma_dev->dev) as the
directory name, so the second and third registrations try to create the
same directory and print duplicate-name warnings.

Keep the existing device-name directory for the first registration, but
use a dev_id-suffixed fallback when that name already exists.

Assisted-by: LLM
Signed-off-by: Linus Walleij <linusw@kernel.org>
---
Fix duplicate direntry.
---
 drivers/dma/dmaengine.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 6ffd8bd82154..a1c388def67a 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -33,6 +33,7 @@
 
 #include <linux/acpi.h>
 #include <linux/acpi_dma.h>
+#include <linux/dcache.h>
 #include <linux/device.h>
 #include <linux/dma-mapping.h>
 #include <linux/dmaengine.h>
@@ -70,8 +71,24 @@ static struct dentry *rootdir;
 
 static void dmaengine_debug_register(struct dma_device *dma_dev)
 {
-	dma_dev->dbg_dev_root = debugfs_create_dir(dev_name(dma_dev->dev),
-						   rootdir);
+	const char *name = dev_name(dma_dev->dev);
+	struct dentry *dentry;
+	char *uniq;
+
+	dentry = debugfs_lookup(name, rootdir);
+	if (dentry) {
+		dput(dentry);
+
+		uniq = kasprintf(GFP_KERNEL, "%s.%d", name, dma_dev->dev_id);
+		if (!uniq)
+			return;
+
+		dma_dev->dbg_dev_root = debugfs_create_dir(uniq, rootdir);
+		kfree(uniq);
+	} else {
+		dma_dev->dbg_dev_root = debugfs_create_dir(name, rootdir);
+	}
+
 	if (IS_ERR(dma_dev->dbg_dev_root))
 		dma_dev->dbg_dev_root = NULL;
 }

---
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
change-id: 20260918-dmaengine-fixes-5c893ce71049

Best regards,
-- 
Linus Walleij <linusw@kernel.org>


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] dmaengine: Use unique debugfs names
  2026-09-18  9:15 [PATCH] dmaengine: Use unique debugfs names Linus Walleij
@ 2026-09-18 14:34 ` Frank Li
  2026-09-18 14:55   ` Linus Walleij
  2026-09-27  8:58 ` Linus Walleij
  2026-10-13 21:31 ` Frank Li
  2 siblings, 1 reply; 5+ messages in thread
From: Frank Li @ 2026-09-18 14:34 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Vinod Koul, Frank Li, dmaengine

On Fri, Sep 18, 2026 at 11:15:14AM +0200, Linus Walleij wrote:
> DMA40 registers multiple dma_device instances for the same platform
> device.

d40_dmaengine_init() ? I see just register one dmaengine device. I think
it may have other problems.

Frank

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] dmaengine: Use unique debugfs names
  2026-09-18 14:34 ` Frank Li
@ 2026-09-18 14:55   ` Linus Walleij
  0 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2026-09-18 14:55 UTC (permalink / raw)
  To: Frank Li; +Cc: Vinod Koul, Frank Li, dmaengine

On Fri, Sep 18, 2026 at 4:34 PM Frank Li <Frank.li@oss.nxp.com> wrote:
> On Fri, Sep 18, 2026 at 11:15:14AM +0200, Linus Walleij wrote:

> > DMA40 registers multiple dma_device instances for the same platform
> > device.
>
> d40_dmaengine_init() ? I see just register one dmaengine device. I think
> it may have other problems.

It certainly has other problems because I have a serires of 21 patches
and counting just for the dma40 driver, haha :D

But this patch addresses a real problem.

They are declared together in struct d40_base.

Each gets its own channel list through d40_chan_init(), which points
every channel back to the corresponding dma_device:

d40c->chan.device = dma;
list_add_tail(&d40c->chan.device_node, &dma->channels);

All three deliberately receive the same parent device in
See d40_ops_init():

dev->dev = base->dev;

They are then registered independently:

dmaenginem_async_device_register(&base->dma_slave);
dmaenginem_async_device_register(&base->dma_memcpy);
dmaenginem_async_device_register(&base->dma_both);

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] dmaengine: Use unique debugfs names
  2026-09-18  9:15 [PATCH] dmaengine: Use unique debugfs names Linus Walleij
  2026-09-18 14:34 ` Frank Li
@ 2026-09-27  8:58 ` Linus Walleij
  2026-10-13 21:31 ` Frank Li
  2 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2026-09-27  8:58 UTC (permalink / raw)
  To: Vinod Koul, Frank Li; +Cc: dmaengine

Hi folks,

On Fri, Sep 18, 2026 at 11:15 AM Linus Walleij <linusw@kernel.org> wrote:

> DMA40 registers multiple dma_device instances for the same platform
> device. The DMAengine debugfs code uses dev_name(dma_dev->dev) as the
> directory name, so the second and third registrations try to create the
> same directory and print duplicate-name warnings.
>
> Keep the existing device-name directory for the first registration, but
> use a dev_id-suffixed fallback when that name already exists.
>
> Assisted-by: LLM
> Signed-off-by: Linus Walleij <linusw@kernel.org>

Can we apply this patch?

I think it solves a pretty straight-forward issue with the same
device adding multiple engines.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] dmaengine: Use unique debugfs names
  2026-09-18  9:15 [PATCH] dmaengine: Use unique debugfs names Linus Walleij
  2026-09-18 14:34 ` Frank Li
  2026-09-27  8:58 ` Linus Walleij
@ 2026-10-13 21:31 ` Frank Li
  2 siblings, 0 replies; 5+ messages in thread
From: Frank Li @ 2026-10-13 21:31 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Vinod Koul, Frank Li, dmaengine

On Fri, Sep 18, 2026 at 11:15:14AM +0200, Linus Walleij wrote:
> DMA40 registers multiple dma_device instances for the same platform
> device. The DMAengine debugfs code uses dev_name(dma_dev->dev) as the
> directory name, so the second and third registrations try to create the
> same directory and print duplicate-name warnings.
>
> Keep the existing device-name directory for the first registration, but
> use a dev_id-suffixed fallback when that name already exists.
>
> Assisted-by: LLM
> Signed-off-by: Linus Walleij <linusw@kernel.org>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

> Fix duplicate direntry.
> ---
>  drivers/dma/dmaengine.c | 21 +++++++++++++++++++--
>  1 file changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
> index 6ffd8bd82154..a1c388def67a 100644
> --- a/drivers/dma/dmaengine.c
> +++ b/drivers/dma/dmaengine.c
> @@ -33,6 +33,7 @@
>
>  #include <linux/acpi.h>
>  #include <linux/acpi_dma.h>
> +#include <linux/dcache.h>
>  #include <linux/device.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/dmaengine.h>
> @@ -70,8 +71,24 @@ static struct dentry *rootdir;
>
>  static void dmaengine_debug_register(struct dma_device *dma_dev)
>  {
> -	dma_dev->dbg_dev_root = debugfs_create_dir(dev_name(dma_dev->dev),
> -						   rootdir);
> +	const char *name = dev_name(dma_dev->dev);
> +	struct dentry *dentry;
> +	char *uniq;
> +
> +	dentry = debugfs_lookup(name, rootdir);
> +	if (dentry) {
> +		dput(dentry);
> +
> +		uniq = kasprintf(GFP_KERNEL, "%s.%d", name, dma_dev->dev_id);
> +		if (!uniq)
> +			return;
> +
> +		dma_dev->dbg_dev_root = debugfs_create_dir(uniq, rootdir);
> +		kfree(uniq);
> +	} else {
> +		dma_dev->dbg_dev_root = debugfs_create_dir(name, rootdir);
> +	}
> +
>  	if (IS_ERR(dma_dev->dbg_dev_root))
>  		dma_dev->dbg_dev_root = NULL;
>  }
>
> ---
> base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
> change-id: 20260918-dmaengine-fixes-5c893ce71049
>
> Best regards,
> --
> Linus Walleij <linusw@kernel.org>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-10-13 21:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-18  9:15 [PATCH] dmaengine: Use unique debugfs names Linus Walleij
2026-09-18 14:34 ` Frank Li
2026-09-18 14:55   ` Linus Walleij
2026-09-27  8:58 ` Linus Walleij
2026-10-13 21:31 ` Frank Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox