powerpc/iommu/debug: Add debugfs entries for IOMMU tables
PATCH 1/1 powerpc/iommu/debug: Add debugfs entries for IOMMU tables
This adds a folder per LIOBN under /sys/kernel/debug/iommu with IOMMU table parameters.
This is enabled by CONFIG_IOMMU_DEBUGFS.
Signed-off-by Alexey Kardashevskiy <[email protected]>
---
The first use is to find leaks:
while [ true ] ; do echo $( date ; sudo find /sys/kernel/debug/iommu -iname weight -exec cat {} \; ) ; sleep 1 ; done
None found yet though.
--- arch/powerpc/kernel/iommu.c | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
arch/powerpc/kernel/iommu.c +46 -0
@@ -25,6 +25,7 @@#include <linux/pci.h> #include <linux/iommu.h> #include <linux/sched.h> +#include <linux/debugfs.h> #include <asm/io.h> #include <asm/prom.h> #include <asm/iommu.h>
@@ -38,6 +39,47 @@#define DBG (...) +#ifdef CONFIG_IOMMU_DEBUGFS +static int iommu_debugfs_weight_get (void *data,u64 *val) +{ +struct iommu_table *tbl = data; + *val =bitmap_weight (tbl->it_map, tbl->it_size); +return 0 ; +} +DEFINE_DEBUGFS_ATTRIBUTE (iommu_debugfs_fops_weight, iommu_debugfs_weight_get,NULL ,"%llu\n" ); + +static void iommu_debugfs_add (struct iommu_table *tbl) +{ +char name[10 ]; +struct dentry *liobn_entry; + +sprintf (name,"%08lx" , tbl->it_index); + liobn_entry =debugfs_create_dir (name, iommu_debugfs_dir); + +debugfs_create_file_unsafe ("weight" ,0400 , liobn_entry, tbl, &iommu_debugfs_fops_weight); +debugfs_create_ulong ("it_size" ,0400 , liobn_entry, &tbl->it_size); +debugfs_create_ulong ("it_page_shift" ,0400 , liobn_entry, &tbl->it_page_shift); +debugfs_create_ulong ("it_reserved_start" ,0400 , liobn_entry, &tbl->it_reserved_start); +debugfs_create_ulong ("it_reserved_end" ,0400 , liobn_entry, &tbl->it_reserved_end); +debugfs_create_ulong ("it_indirect_levels" ,0400 , liobn_entry, &tbl->it_indirect_levels); +debugfs_create_ulong ("it_level_size" ,0400 , liobn_entry, &tbl->it_level_size); +} + +static void iommu_debugfs_del (struct iommu_table *tbl) +{ +char name[10 ]; +struct dentry *liobn_entry; + +sprintf (name,"%08lx" , tbl->it_index); + liobn_entry =debugfs_lookup (name, iommu_debugfs_dir); +if (liobn_entry) +debugfs_remove (liobn_entry); +} +#else +static void iommu_debugfs_add (struct iommu_table *tbl){} +static void iommu_debugfs_del (struct iommu_table *tbl){} +#endif +static int novmerge;static void __iommu_free (struct iommu_table *,dma_addr_t ,unsigned int );
@@ -725,6 +767,8 @@ struct iommu_table *iommu_init_table(struct iommu_table *tbl, int nid, welcomed =1 ; } +iommu_debugfs_add (tbl); +return tbl; }
@@ -744,6 +788,8 @@ static void iommu_table_free(struct kref *kref)return ; } +iommu_debugfs_del (tbl); +iommu_table_release_pages (tbl);/* verify that table contains no entries */
Signature · 1 line
2.17.1
Michael Ellerman
AppliedQuoted 4 lines · Alexey Kardashevskiy
This adds a folder per LIOBN under
/sys/kernel/debug/iommuwith IOMMU table parameters.This is enabled by
CONFIG_IOMMU_DEBUGFS.
Applied to powerpc/next.
[1/1] powerpc/iommu/debug: Add debugfs entries for IOMMU tables
https://git.kernel.org/powerpc/c/691602aab9c3cce31d3ff9529c09b7922a5f6224
cheers