forked from mirrors/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>
This commit is contained in:
		
							parent
							
								
									db8d9b4c9b
								
							
						
					
					
						commit
						26cf132de6
					
				
					 3 changed files with 44 additions and 1 deletions
				
			
		|  | @ -62,6 +62,22 @@ static long dmaengine_ref_count; | ||||||
| #ifdef CONFIG_DEBUG_FS | #ifdef CONFIG_DEBUG_FS | ||||||
| #include <linux/debugfs.h> | #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, | static void dmaengine_dbg_summary_show(struct seq_file *s, | ||||||
| 				       struct dma_device *dma_dev) | 				       struct dma_device *dma_dev) | ||||||
| { | { | ||||||
|  | @ -107,7 +123,7 @@ DEFINE_SHOW_ATTRIBUTE(dmaengine_summary); | ||||||
| 
 | 
 | ||||||
| static void __init dmaengine_debugfs_init(void) | 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 */ | 	/* /sys/kernel/debug/dmaengine/summary */ | ||||||
| 	debugfs_create_file("summary", 0444, rootdir, NULL, | 	debugfs_create_file("summary", 0444, rootdir, NULL, | ||||||
|  | @ -115,6 +131,12 @@ static void __init dmaengine_debugfs_init(void) | ||||||
| } | } | ||||||
| #else | #else | ||||||
| static inline void dmaengine_debugfs_init(void) { } | 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 */ | #endif	/* DEBUG_FS */ | ||||||
| 
 | 
 | ||||||
| /* --- sysfs implementation --- */ | /* --- sysfs implementation --- */ | ||||||
|  | @ -1265,6 +1287,8 @@ int dma_async_device_register(struct dma_device *device) | ||||||
| 	dma_channel_rebalance(); | 	dma_channel_rebalance(); | ||||||
| 	mutex_unlock(&dma_list_mutex); | 	mutex_unlock(&dma_list_mutex); | ||||||
| 
 | 
 | ||||||
|  | 	dmaengine_debug_register(device); | ||||||
|  | 
 | ||||||
| 	return 0; | 	return 0; | ||||||
| 
 | 
 | ||||||
| err_out: | err_out: | ||||||
|  | @ -1298,6 +1322,8 @@ void dma_async_device_unregister(struct dma_device *device) | ||||||
| { | { | ||||||
| 	struct dma_chan *chan, *n; | 	struct dma_chan *chan, *n; | ||||||
| 
 | 
 | ||||||
|  | 	dmaengine_debug_unregister(device); | ||||||
|  | 
 | ||||||
| 	list_for_each_entry_safe(chan, n, &device->channels, device_node) | 	list_for_each_entry_safe(chan, n, &device->channels, device_node) | ||||||
| 		__dma_async_device_channel_unregister(device, chan); | 		__dma_async_device_channel_unregister(device, chan); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -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_slave_channel(struct dma_chan *chan); | ||||||
| struct dma_chan *dma_get_any_slave_channel(struct dma_device *device); | 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 | #endif | ||||||
|  |  | ||||||
|  | @ -902,6 +902,7 @@ struct dma_device { | ||||||
| 	/* debugfs support */ | 	/* debugfs support */ | ||||||
| #ifdef CONFIG_DEBUG_FS | #ifdef CONFIG_DEBUG_FS | ||||||
| 	void (*dbg_summary_show)(struct seq_file *s, struct dma_device *dev); | 	void (*dbg_summary_show)(struct seq_file *s, struct dma_device *dev); | ||||||
|  | 	struct dentry *dbg_dev_root; | ||||||
| #endif | #endif | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Peter Ujfalusi
						Peter Ujfalusi