Skip to contentSkip to conversation

dmaengine: Use unique debugfs names

PATCH Applied Linus Walleij 3 participants 3 messages Nov 2 – Nov 20 dmaengine

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 dmaengine: Use unique debugfs names

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.

---
Fix duplicate direntry.
---
Changes in v2:
- Rebased on v7.4-rc1
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 drivers/dma/dmaengine.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
drivers/dma/dmaengine.c +19 -2
index 34be53487a21..7eb8d53b4863 100644
@@ -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: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20260918-dmaengine-fixes-5c893ce71049

Best regards,

Signature · 1 line
Linus Walleij <[email protected]>
Reviewed-by on v2 1/1
#1 lore raw
Quoted 10 lines · 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.

---

Quoted 57 lines

Fix duplicate direntry.
---
Changes in v2:
- Rebased on v7.4-rc1
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 drivers/dma/dmaengine.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
drivers/dma/dmaengine.c +19 -3
index 34be53487a21..7eb8d53b4863 100644
@@ -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: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20260918-dmaengine-fixes-5c893ce71049

Best regards,
--
Linus Walleij <[email protected]>

maintainer Applied
#2 lore raw
In reply to Linus Walleij
Quoted 9 lines · 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.

[...]

Applied, thanks!

[1/1] dmaengine: Use unique debugfs names

      commit: e65c7ef7a0b920c42e67d52e70f2e5ebd63bc918

Best regards,

Signature · 1 line
~Vinod