]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
dmaengine: Create debug directories for DMA devices
authorPeter Ujfalusi <peter.ujfalusi@ti.com>
Fri, 6 Mar 2020 14:28:39 +0000 (16:28 +0200)
committerVinod Koul <vkoul@kernel.org>
Wed, 11 Mar 2020 09:26:14 +0000 (14:56 +0530)
Create a placeholder directory for each registered DMA device.

DMA drivers can use the dmaengine_get_debugfs_root() call to get their
debugfs root and can populate with custom files to aim debugging.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Link: https://lore.kernel.org/r/20200306142839.17910-4-peter.ujfalusi@ti.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/dmaengine.c
drivers/dma/dmaengine.h
include/linux/dmaengine.h

index 509abc8e8378135ae0527f6901ed4c1a6fc426da..5a442752e07d351c3f37c8f6d8839f4e16890f3f 100644 (file)
@@ -62,6 +62,22 @@ static long dmaengine_ref_count;
 #ifdef CONFIG_DEBUG_FS
 #include <linux/debugfs.h>
 
+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);
+       if (IS_ERR(dma_dev->dbg_dev_root))
+               dma_dev->dbg_dev_root = NULL;
+}
+
+static void dmaengine_debug_unregister(struct dma_device *dma_dev)
+{
+       debugfs_remove_recursive(dma_dev->dbg_dev_root);
+       dma_dev->dbg_dev_root = NULL;
+}
+
 static void dmaengine_dbg_summary_show(struct seq_file *s,
                                       struct dma_device *dma_dev)
 {
@@ -107,7 +123,7 @@ DEFINE_SHOW_ATTRIBUTE(dmaengine_summary);
 
 static void __init dmaengine_debugfs_init(void)
 {
-       struct dentry *rootdir = debugfs_create_dir("dmaengine", NULL);
+       rootdir = debugfs_create_dir("dmaengine", NULL);
 
        /* /sys/kernel/debug/dmaengine/summary */
        debugfs_create_file("summary", 0444, rootdir, NULL,
@@ -115,6 +131,12 @@ static void __init dmaengine_debugfs_init(void)
 }
 #else
 static inline void dmaengine_debugfs_init(void) { }
+static inline int dmaengine_debug_register(struct dma_device *dma_dev)
+{
+       return 0;
+}
+
+static inline void dmaengine_debug_unregister(struct dma_device *dma_dev) { }
 #endif /* DEBUG_FS */
 
 /* --- sysfs implementation --- */
@@ -1265,6 +1287,8 @@ int dma_async_device_register(struct dma_device *device)
        dma_channel_rebalance();
        mutex_unlock(&dma_list_mutex);
 
+       dmaengine_debug_register(device);
+
        return 0;
 
 err_out:
@@ -1298,6 +1322,8 @@ void dma_async_device_unregister(struct dma_device *device)
 {
        struct dma_chan *chan, *n;
 
+       dmaengine_debug_unregister(device);
+
        list_for_each_entry_safe(chan, n, &device->channels, device_node)
                __dma_async_device_channel_unregister(device, chan);
 
index e8a320c9e57c2d7448c2d67e20bda82178ac4d35..1bfbd64b13717e0f7e1136c191986fc6384c99ac 100644 (file)
@@ -182,4 +182,20 @@ dmaengine_desc_callback_valid(struct dmaengine_desc_callback *cb)
 struct dma_chan *dma_get_slave_channel(struct dma_chan *chan);
 struct dma_chan *dma_get_any_slave_channel(struct dma_device *device);
 
+#ifdef CONFIG_DEBUG_FS
+#include <linux/debugfs.h>
+
+static inline struct dentry *
+dmaengine_get_debugfs_root(struct dma_device *dma_dev) {
+       return dma_dev->dbg_dev_root;
+}
+#else
+struct dentry;
+static inline struct dentry *
+dmaengine_get_debugfs_root(struct dma_device *dma_dev)
+{
+       return NULL;
+}
+#endif /* CONFIG_DEBUG_FS */
+
 #endif
index 72920b5cf2d738c7ac4c983f6637dcd83f98773f..21065c04c4ac3bb380398bc45a6a7f28cdaa1d00 100644 (file)
@@ -902,6 +902,7 @@ struct dma_device {
        /* debugfs support */
 #ifdef CONFIG_DEBUG_FS
        void (*dbg_summary_show)(struct seq_file *s, struct dma_device *dev);
+       struct dentry *dbg_dev_root;
 #endif
 };