Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dmaengine: Create debug directories for DMA devices

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>

authored by

Peter Ujfalusi and committed by
Vinod Koul
26cf132d db8d9b4c

+44 -1
+27 -1
drivers/dma/dmaengine.c
··· 62 62 #ifdef CONFIG_DEBUG_FS 63 63 #include <linux/debugfs.h> 64 64 65 + static struct dentry *rootdir; 66 + 67 + static void dmaengine_debug_register(struct dma_device *dma_dev) 68 + { 69 + dma_dev->dbg_dev_root = debugfs_create_dir(dev_name(dma_dev->dev), 70 + rootdir); 71 + if (IS_ERR(dma_dev->dbg_dev_root)) 72 + dma_dev->dbg_dev_root = NULL; 73 + } 74 + 75 + static void dmaengine_debug_unregister(struct dma_device *dma_dev) 76 + { 77 + debugfs_remove_recursive(dma_dev->dbg_dev_root); 78 + dma_dev->dbg_dev_root = NULL; 79 + } 80 + 65 81 static void dmaengine_dbg_summary_show(struct seq_file *s, 66 82 struct dma_device *dma_dev) 67 83 { ··· 123 107 124 108 static void __init dmaengine_debugfs_init(void) 125 109 { 126 - struct dentry *rootdir = debugfs_create_dir("dmaengine", NULL); 110 + rootdir = debugfs_create_dir("dmaengine", NULL); 127 111 128 112 /* /sys/kernel/debug/dmaengine/summary */ 129 113 debugfs_create_file("summary", 0444, rootdir, NULL, ··· 131 115 } 132 116 #else 133 117 static inline void dmaengine_debugfs_init(void) { } 118 + static inline int dmaengine_debug_register(struct dma_device *dma_dev) 119 + { 120 + return 0; 121 + } 122 + 123 + static inline void dmaengine_debug_unregister(struct dma_device *dma_dev) { } 134 124 #endif /* DEBUG_FS */ 135 125 136 126 /* --- sysfs implementation --- */ ··· 1287 1265 dma_channel_rebalance(); 1288 1266 mutex_unlock(&dma_list_mutex); 1289 1267 1268 + dmaengine_debug_register(device); 1269 + 1290 1270 return 0; 1291 1271 1292 1272 err_out: ··· 1321 1297 void dma_async_device_unregister(struct dma_device *device) 1322 1298 { 1323 1299 struct dma_chan *chan, *n; 1300 + 1301 + dmaengine_debug_unregister(device); 1324 1302 1325 1303 list_for_each_entry_safe(chan, n, &device->channels, device_node) 1326 1304 __dma_async_device_channel_unregister(device, chan);
+16
drivers/dma/dmaengine.h
··· 182 182 struct dma_chan *dma_get_slave_channel(struct dma_chan *chan); 183 183 struct dma_chan *dma_get_any_slave_channel(struct dma_device *device); 184 184 185 + #ifdef CONFIG_DEBUG_FS 186 + #include <linux/debugfs.h> 187 + 188 + static inline struct dentry * 189 + dmaengine_get_debugfs_root(struct dma_device *dma_dev) { 190 + return dma_dev->dbg_dev_root; 191 + } 192 + #else 193 + struct dentry; 194 + static inline struct dentry * 195 + dmaengine_get_debugfs_root(struct dma_device *dma_dev) 196 + { 197 + return NULL; 198 + } 199 + #endif /* CONFIG_DEBUG_FS */ 200 + 185 201 #endif
+1
include/linux/dmaengine.h
··· 902 902 /* debugfs support */ 903 903 #ifdef CONFIG_DEBUG_FS 904 904 void (*dbg_summary_show)(struct seq_file *s, struct dma_device *dev); 905 + struct dentry *dbg_dev_root; 905 906 #endif 906 907 }; 907 908