aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorCorentin Labbe <clabbe@baylibre.com>2019-01-18 08:44:18 -0500
committerChristoph Hellwig <hch@lst.de>2019-02-01 04:06:44 -0500
commit0a3b192c26da198fce38e1ee242a34f558670246 (patch)
tree50c7205f8335fed7863f9446db981936cd350a6e /kernel
parent8e4d81b98b7859b120dd142c8634f625db118b30 (diff)
dma-debug: add dumping facility via debugfs
While debugging a DMA mapping leak, I needed to access debug_dma_dump_mappings() but easily from user space. This patch adds a /sys/kernel/debug/dma-api/dump file which contain all current DMA mapping. Signed-off-by: Corentin Labbe <clabbe@baylibre.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/dma/debug.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c
index 56cd836a902c..45d51e8e26f6 100644
--- a/kernel/dma/debug.c
+++ b/kernel/dma/debug.c
@@ -829,6 +829,33 @@ static const struct file_operations filter_fops = {
829 .llseek = default_llseek, 829 .llseek = default_llseek,
830}; 830};
831 831
832static int dump_show(struct seq_file *seq, void *v)
833{
834 int idx;
835
836 for (idx = 0; idx < HASH_SIZE; idx++) {
837 struct hash_bucket *bucket = &dma_entry_hash[idx];
838 struct dma_debug_entry *entry;
839 unsigned long flags;
840
841 spin_lock_irqsave(&bucket->lock, flags);
842 list_for_each_entry(entry, &bucket->list, list) {
843 seq_printf(seq,
844 "%s %s %s idx %d P=%llx N=%lx D=%llx L=%llx %s %s\n",
845 dev_name(entry->dev),
846 dev_driver_string(entry->dev),
847 type2name[entry->type], idx,
848 phys_addr(entry), entry->pfn,
849 entry->dev_addr, entry->size,
850 dir2name[entry->direction],
851 maperr2str[entry->map_err_type]);
852 }
853 spin_unlock_irqrestore(&bucket->lock, flags);
854 }
855 return 0;
856}
857DEFINE_SHOW_ATTRIBUTE(dump);
858
832static void dma_debug_fs_init(void) 859static void dma_debug_fs_init(void)
833{ 860{
834 struct dentry *dentry = debugfs_create_dir("dma-api", NULL); 861 struct dentry *dentry = debugfs_create_dir("dma-api", NULL);
@@ -841,6 +868,7 @@ static void dma_debug_fs_init(void)
841 debugfs_create_u32("min_free_entries", 0444, dentry, &min_free_entries); 868 debugfs_create_u32("min_free_entries", 0444, dentry, &min_free_entries);
842 debugfs_create_u32("nr_total_entries", 0444, dentry, &nr_total_entries); 869 debugfs_create_u32("nr_total_entries", 0444, dentry, &nr_total_entries);
843 debugfs_create_file("driver_filter", 0644, dentry, NULL, &filter_fops); 870 debugfs_create_file("driver_filter", 0644, dentry, NULL, &filter_fops);
871 debugfs_create_file("dump", 0444, dentry, NULL, &dump_fops);
844} 872}
845 873
846static int device_dma_allocations(struct device *dev, struct dma_debug_entry **out_entry) 874static int device_dma_allocations(struct device *dev, struct dma_debug_entry **out_entry)