From: Xiang Chen chenxiang66@hisilicon.com
We plan to create debugfs dir related to iova as follows: /sys/kernel/debug/iommu/iovad/domainx/<properties> So create a iovad debugfs dir under iommu debugfs dir.
Signed-off-by: Xiang Chen chenxiang66@hisilicon.com --- drivers/iommu/iommu-debugfs.c | 12 ++++++++++++ drivers/iommu/iova.c | 2 ++ include/linux/iommu.h | 6 ++++++ include/linux/iova.h | 1 + 4 files changed, 21 insertions(+)
diff --git a/drivers/iommu/iommu-debugfs.c b/drivers/iommu/iommu-debugfs.c index f035489..75d9b9a 100644 --- a/drivers/iommu/iommu-debugfs.c +++ b/drivers/iommu/iommu-debugfs.c @@ -13,6 +13,8 @@
struct dentry *iommu_debugfs_dir; EXPORT_SYMBOL_GPL(iommu_debugfs_dir); +struct dentry *iovad_debugfs_dir; +EXPORT_SYMBOL_GPL(iovad_debugfs_dir);
/** * iommu_debugfs_setup - create the top-level iommu directory in debugfs @@ -49,3 +51,13 @@ void iommu_debugfs_setup(void) pr_warn("*************************************************************\n"); } } + +void debugfs_create_iovad_dir(void) +{ + iovad_debugfs_dir = debugfs_create_dir("iovad", iommu_debugfs_dir); +} + +void debugfs_destroy_iovad_dir(void) +{ + debugfs_remove_recursive(iovad_debugfs_dir); +} diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c index 59926d5..0374e23b 100644 --- a/drivers/iommu/iova.c +++ b/drivers/iommu/iova.c @@ -336,6 +336,7 @@ int iova_cache_get(void) iova_cache_users++; mutex_unlock(&iova_cache_mutex);
+ debugfs_create_iovad_dir(); return 0; } EXPORT_SYMBOL_GPL(iova_cache_get); @@ -353,6 +354,7 @@ void iova_cache_put(void) kmem_cache_destroy(iova_cache); } mutex_unlock(&iova_cache_mutex); + debugfs_destroy_iovad_dir(); } EXPORT_SYMBOL_GPL(iova_cache_put);
diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 32d4480..8dbc5cf 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -1020,8 +1020,14 @@ static inline size_t iommu_map_sgtable(struct iommu_domain *domain, #ifdef CONFIG_IOMMU_DEBUGFS extern struct dentry *iommu_debugfs_dir; void iommu_debugfs_setup(void); +extern struct dentry *iovad_debugfs_dir; +void debugfs_create_iovad_dir(void); +void debugfs_destroy_iovad_dir(void); + #else static inline void iommu_debugfs_setup(void) {} +static inline void debugfs_create_iovad_dir(void) {} +static inline void debugfs_destroy_iovad_dir(void) {} #endif
#endif /* __LINUX_IOMMU_H */ diff --git a/include/linux/iova.h b/include/linux/iova.h index 7006d9f..9386e77 100644 --- a/include/linux/iova.h +++ b/include/linux/iova.h @@ -14,6 +14,7 @@ #include <linux/rbtree.h> #include <linux/atomic.h> #include <linux/dma-mapping.h> +#include <linux/iommu.h>
/* iova structure */ struct iova {