
From: Xiang Chen <chenxiang66@hisilicon.com> Create iommu domain debugfs dir under ivoad debugfs dir, and the domain id is the same as the group id. Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com> --- drivers/iommu/iommu-debugfs.c | 16 ++++++++++++++++ drivers/iommu/iommu.c | 19 ++++--------------- include/linux/iommu.h | 23 ++++++++++++++++++++++- 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/drivers/iommu/iommu-debugfs.c b/drivers/iommu/iommu-debugfs.c index 75d9b9a..224b90f 100644 --- a/drivers/iommu/iommu-debugfs.c +++ b/drivers/iommu/iommu-debugfs.c @@ -61,3 +61,19 @@ void debugfs_destroy_iovad_dir(void) { debugfs_remove_recursive(iovad_debugfs_dir); } + +void debugfs_create_domain_dir(struct iommu_group *group) +{ + struct iommu_domain *domain = group->domain; + char name[1024]; + + snprintf(name, 1024, "iommu_domain%d", group->id); + domain->domain_dir = debugfs_create_dir(name, iovad_debugfs_dir); +} + +void debugfs_destroy_domain_dir(struct iommu_group *group) +{ + struct iommu_domain *domain = group->domain; + + debugfs_remove_recursive(domain->domain_dir); +} diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 9a7ced0..3f328ae 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -34,21 +34,6 @@ static unsigned int iommu_def_domain_type __read_mostly; static bool iommu_dma_strict __read_mostly = true; static u32 iommu_cmd_line __read_mostly; -struct iommu_group { - struct kobject kobj; - struct kobject *devices_kobj; - struct list_head devices; - struct mutex mutex; - struct blocking_notifier_head notifier; - void *iommu_data; - void (*iommu_data_release)(void *iommu_data); - char *name; - int id; - struct iommu_domain *default_domain; - struct iommu_domain *domain; - struct list_head entry; -}; - struct group_device { struct list_head list; struct device *dev; @@ -292,6 +277,8 @@ int iommu_probe_device(struct device *dev) if (ops->probe_finalize) ops->probe_finalize(dev); + debugfs_create_domain_dir(group); + return 0; err_release: @@ -570,6 +557,8 @@ static void iommu_group_release(struct kobject *kobj) pr_debug("Releasing group %d\n", group->id); + debugfs_destroy_domain_dir(group); + if (group->iommu_data_release) group->iommu_data_release(group->iommu_data); diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 8dbc5cf..ef75bdb6 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -33,7 +33,21 @@ #define IOMMU_PRIV (1 << 5) struct iommu_ops; -struct iommu_group; +struct iommu_group { + struct kobject kobj; + struct kobject *devices_kobj; + struct list_head devices; + struct mutex mutex; + struct blocking_notifier_head notifier; + void *iommu_data; + void (*iommu_data_release)(void *iommu_data); + char *name; + int id; + struct iommu_domain *default_domain; + struct iommu_domain *domain; + struct list_head entry; +}; + struct bus_type; struct device; struct iommu_domain; @@ -87,6 +101,9 @@ struct iommu_domain { void *handler_token; struct iommu_domain_geometry geometry; void *iova_cookie; +#ifdef CONFIG_IOMMU_DEBUGFS + struct dentry *domain_dir; +#endif }; enum iommu_cap { @@ -1023,11 +1040,15 @@ void iommu_debugfs_setup(void); extern struct dentry *iovad_debugfs_dir; void debugfs_create_iovad_dir(void); void debugfs_destroy_iovad_dir(void); +void debugfs_create_domain_dir(struct iommu_group *group); +void debugfs_destroy_domain_dir(struct iommu_group *group); #else static inline void iommu_debugfs_setup(void) {} static inline void debugfs_create_iovad_dir(void) {} static inline void debugfs_destroy_iovad_dir(void) {} +static inline void debugfs_create_domain_dir(struct iommu_group *group) {} +static inline void debugfs_destroy_domain_dir(struct iommu_group *group) {} #endif #endif /* __LINUX_IOMMU_H */ -- 2.8.1