iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 12/12] iommu/exynos: add debugfs entries for System MMU
@ 2012-12-26  1:54 Cho KyongHo
       [not found] ` <003f01cde30b$f2891d30$d79b5790$%cho-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Cho KyongHo @ 2012-12-26  1:54 UTC (permalink / raw)
  To: 'Linux ARM Kernel', 'Linux IOMMU',
	'Linux Kernel', 'Linux Samsung SOC'
  Cc: 'Kukjin Kim', 'Hyunwoong Kim',
	'Prathyush', 'Subash Patel',
	'Rahul Sharma'

This commit adds debugfs directory and nodes for inspecting internal
state of System MMU.

Signed-off-by: KyongHo Cho <pullip.cho-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
---
 drivers/iommu/exynos-iommu.c | 204 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 198 insertions(+), 6 deletions(-)

diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index 9753e0e..78c0eb7 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -26,12 +26,17 @@
 #include <linux/list.h>
 #include <linux/memblock.h>
 #include <linux/export.h>
+#include <linux/fs.h>
+#include <linux/seq_file.h>
+#include <linux/debugfs.h>
 #include <linux/string.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
 
 #include <asm/cacheflush.h>
 
+#define MODULE_NAME "exynos-sysmmu"
+
 /* We does not consider super section mapping (16MB) */
 #define SECT_ORDER 20
 #define LPAGE_ORDER 16
@@ -223,6 +228,7 @@ struct sysmmu_drvdata {
 	struct sysmmu_prefbuf pbufs[MAX_NUM_PBUF];
 	int num_pbufs;
 	struct sysmmu_version ver;
+	struct dentry *debugfs_root;
 	struct iommu_domain *domain;
 	unsigned long pgtable;
 	bool runtime_active;
@@ -1066,6 +1072,8 @@ static void __init __sysmmu_init_mmuname(struct device *sysmmu,
 	}
 }
 
+static void __create_debugfs_entry(struct sysmmu_drvdata *drvdata);
+
 static int __init exynos_sysmmu_probe(struct platform_device *pdev)
 {
 	int i, ret;
@@ -1134,6 +1142,8 @@ static int __init exynos_sysmmu_probe(struct platform_device *pdev)
 
 		data->runtime_active = !pm_runtime_enabled(dev);
 
+		__create_debugfs_entry(data);
+
 		platform_set_drvdata(pdev, data);
 
 		dev->archdata.iommu = &sysmmu_placeholder;
@@ -1238,7 +1248,7 @@ static struct platform_driver exynos_sysmmu_driver __refdata = {
 	.probe		= exynos_sysmmu_probe,
 	.driver		= {
 		.owner		= THIS_MODULE,
-		.name		= "exynos-sysmmu",
+		.name		= MODULE_NAME,
 		.pm		= &__pm_ops,
 		.of_match_table = of_match_ptr(sysmmu_of_match),
 	}
@@ -1631,6 +1641,8 @@ static struct iommu_ops exynos_iommu_ops = {
 	.pgsize_bitmap = SECT_SIZE | LPAGE_SIZE | SPAGE_SIZE,
 };
 
+static struct dentry *sysmmu_debugfs_root; /* /sys/kernel/debug/sysmmu */
+
 static int __init exynos_iommu_init(void)
 {
 	int ret;
@@ -1642,17 +1654,197 @@ static int __init exynos_iommu_init(void)
 		return -ENOMEM;
 	}
 
-	ret = platform_driver_register(&exynos_sysmmu_driver);
+	ret = bus_set_iommu(&platform_bus_type, &exynos_iommu_ops);
+	if (ret) {
+		kmem_cache_destroy(lv2table_kmem_cache);
+		pr_err("%s: Failed to register IOMMU ops\n", __func__);
+		return -EFAULT;
+	}
 
-	if (ret == 0)
-		ret = bus_set_iommu(&platform_bus_type, &exynos_iommu_ops);
+	sysmmu_debugfs_root = debugfs_create_dir("sysmmu", NULL);
+	if (!sysmmu_debugfs_root)
+		pr_err("%s: Failed to create debugfs entry, 'sysmmu'\n",
+							__func__);
+	if (IS_ERR(sysmmu_debugfs_root))
+		sysmmu_debugfs_root = NULL;
 
+	ret = platform_driver_register(&exynos_sysmmu_driver);
 	if (ret) {
-		pr_err("%s: Failed to register exynos-iommu driver.\n",
-								__func__);
 		kmem_cache_destroy(lv2table_kmem_cache);
+		pr_err("%s: Failed to register System MMU driver\n", __func__);
 	}
 
 	return ret;
 }
 subsys_initcall(exynos_iommu_init);
+
+static int debug_string_show(struct seq_file *s, void *unused)
+{
+	char *str = s->private;
+
+	seq_printf(s, "%s\n", str);
+
+	return 0;
+}
+
+static int debug_sysmmu_list_show(struct seq_file *s, void *unused)
+{
+	struct sysmmu_drvdata *drvdata = s->private;
+	struct platform_device *pdev = to_platform_device(drvdata->sysmmu);
+	int idx, maj, min, ret;
+
+	seq_printf(s, "SysMMU Name | Ver | SFR Base\n");
+
+	if (pm_runtime_enabled(drvdata->sysmmu)) {
+		ret = pm_runtime_get_sync(drvdata->sysmmu);
+		if (ret < 0)
+			return ret;
+	}
+
+	for (idx = 0; idx < drvdata->nsfrs; idx++) {
+		struct resource *res;
+
+		res = platform_get_resource(pdev, IORESOURCE_MEM, idx);
+		if (!res)
+			break;
+
+		maj = __sysmmu_version(drvdata, idx, &min);
+
+		if (drvdata->mmuname) {
+			if (maj == 0)
+				seq_printf(s, "%11.s | N/A | 0x%08x\n",
+					drvdata->mmuname[idx], res->start);
+			else
+				seq_printf(s, "%11.s | %d.%d | 0x%08x\n",
+				drvdata->mmuname[idx], maj, min, res->start);
+		} else {
+			if (maj == 0)
+				seq_printf(s, "N/A | 0x%08x\n", res->start);
+			else
+				seq_printf(s, "%d.%d | 0x%08x\n",
+							maj, min, res->start);
+		}
+	}
+
+	if (pm_runtime_enabled(drvdata->sysmmu))
+		pm_runtime_put(drvdata->sysmmu);
+
+	return 0;
+}
+
+static int debug_next_sibling_show(struct seq_file *s, void *unused)
+{
+	struct device *dev = s->private;
+
+	if (dev->parent &&
+		!strncmp(dev_name(dev->parent),
+			MODULE_NAME, strlen(MODULE_NAME)))
+		seq_printf(s, "%s\n", dev_name(dev->parent));
+	return 0;
+}
+
+static int __show_master(struct device *dev, void *data)
+{
+	struct seq_file *s = data;
+
+	if (strncmp(dev_name(dev), MODULE_NAME, strlen(MODULE_NAME)))
+		seq_printf(s, "%s\n", dev_name(dev));
+	return 0;
+}
+
+static int debug_master_show(struct seq_file *s, void *unused)
+{
+	struct device *dev = s->private;
+
+	device_for_each_child(dev, s, __show_master);
+	return 0;
+}
+
+static int debug_string_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, debug_string_show, inode->i_private);
+}
+
+static int debug_sysmmu_list_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, debug_sysmmu_list_show, inode->i_private);
+}
+
+static int debug_next_sibling_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, debug_next_sibling_show, inode->i_private);
+}
+
+static int debug_master_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, debug_master_show, inode->i_private);
+}
+
+static const struct file_operations debug_string_fops = {
+	.open = debug_string_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+};
+
+static const struct file_operations debug_sysmmu_list_fops = {
+	.open = debug_sysmmu_list_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+};
+
+static const struct file_operations debug_next_sibling_fops = {
+	.open = debug_next_sibling_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+};
+
+static const struct file_operations debug_master_fops = {
+	.open = debug_master_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+};
+
+static void __init __create_debugfs_entry(struct sysmmu_drvdata *drvdata)
+{
+	if (!sysmmu_debugfs_root)
+		return;
+
+	drvdata->debugfs_root = debugfs_create_dir(dev_name(drvdata->sysmmu),
+							sysmmu_debugfs_root);
+	if (!drvdata->debugfs_root)
+		dev_err(drvdata->sysmmu, "Failed to create debugfs dentry\n");
+	if (IS_ERR(drvdata->debugfs_root))
+		drvdata->debugfs_root = NULL;
+
+	if (!drvdata->debugfs_root)
+		return;
+
+	if (!debugfs_create_u32("enable", 0664, drvdata->debugfs_root,
+						&drvdata->activations))
+		dev_err(drvdata->sysmmu,
+				"Failed to create debugfs file 'enable'\n");
+
+	if (!debugfs_create_x32("pagetable", 0664, drvdata->debugfs_root,
+						(u32 *)&drvdata->pgtable))
+		dev_err(drvdata->sysmmu,
+				"Failed to create debugfs file 'pagetable'\n");
+
+	if (!debugfs_create_file("sysmmu_list", 0444, drvdata->debugfs_root,
+					drvdata, &debug_sysmmu_list_fops))
+		dev_err(drvdata->sysmmu,
+			"Failed to create debugfs file 'sysmmu_list'\n");
+
+	if (!debugfs_create_file("next_sibling", 0x444, drvdata->debugfs_root,
+				drvdata->sysmmu, &debug_next_sibling_fops))
+		dev_err(drvdata->sysmmu,
+			"Failed to create debugfs file 'next_siblings'\n");
+
+	if (!debugfs_create_file("master", 0x444, drvdata->debugfs_root,
+				drvdata->sysmmu, &debug_master_fops))
+		dev_err(drvdata->sysmmu,
+			"Failed to create debugfs file 'next_siblings'\n");
+}
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v6 12/12] iommu/exynos: add debugfs entries for System MMU
       [not found] ` <003f01cde30b$f2891d30$d79b5790$%cho-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
@ 2013-05-18  5:26   ` Prathyush K
  0 siblings, 0 replies; 2+ messages in thread
From: Prathyush K @ 2013-05-18  5:26 UTC (permalink / raw)
  To: Cho KyongHo
  Cc: Kukjin Kim, Hyunwoong Kim, Prathyush, Subash Patel, Linux Kernel,
	Linux IOMMU, Linux Samsung SOC, Linux ARM Kernel, Rahul Sharma


[-- Attachment #1.1: Type: text/plain, Size: 10583 bytes --]

Hi Mr. Cho,

any update on this patchset? Are you working on v7?

Regards,
Prathyush



On Wed, Dec 26, 2012 at 7:24 AM, Cho KyongHo <pullip.cho-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> wrote:

> This commit adds debugfs directory and nodes for inspecting internal
> state of System MMU.
>
> Signed-off-by: KyongHo Cho <pullip.cho-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
> ---
>  drivers/iommu/exynos-iommu.c | 204
> +++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 198 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
> index 9753e0e..78c0eb7 100644
> --- a/drivers/iommu/exynos-iommu.c
> +++ b/drivers/iommu/exynos-iommu.c
> @@ -26,12 +26,17 @@
>  #include <linux/list.h>
>  #include <linux/memblock.h>
>  #include <linux/export.h>
> +#include <linux/fs.h>
> +#include <linux/seq_file.h>
> +#include <linux/debugfs.h>
>  #include <linux/string.h>
>  #include <linux/of.h>
>  #include <linux/of_platform.h>
>
>  #include <asm/cacheflush.h>
>
> +#define MODULE_NAME "exynos-sysmmu"
> +
>  /* We does not consider super section mapping (16MB) */
>  #define SECT_ORDER 20
>  #define LPAGE_ORDER 16
> @@ -223,6 +228,7 @@ struct sysmmu_drvdata {
>         struct sysmmu_prefbuf pbufs[MAX_NUM_PBUF];
>         int num_pbufs;
>         struct sysmmu_version ver;
> +       struct dentry *debugfs_root;
>         struct iommu_domain *domain;
>         unsigned long pgtable;
>         bool runtime_active;
> @@ -1066,6 +1072,8 @@ static void __init __sysmmu_init_mmuname(struct
> device *sysmmu,
>         }
>  }
>
> +static void __create_debugfs_entry(struct sysmmu_drvdata *drvdata);
> +
>  static int __init exynos_sysmmu_probe(struct platform_device *pdev)
>  {
>         int i, ret;
> @@ -1134,6 +1142,8 @@ static int __init exynos_sysmmu_probe(struct
> platform_device *pdev)
>
>                 data->runtime_active = !pm_runtime_enabled(dev);
>
> +               __create_debugfs_entry(data);
> +
>                 platform_set_drvdata(pdev, data);
>
>                 dev->archdata.iommu = &sysmmu_placeholder;
> @@ -1238,7 +1248,7 @@ static struct platform_driver exynos_sysmmu_driver
> __refdata = {
>         .probe          = exynos_sysmmu_probe,
>         .driver         = {
>                 .owner          = THIS_MODULE,
> -               .name           = "exynos-sysmmu",
> +               .name           = MODULE_NAME,
>                 .pm             = &__pm_ops,
>                 .of_match_table = of_match_ptr(sysmmu_of_match),
>         }
> @@ -1631,6 +1641,8 @@ static struct iommu_ops exynos_iommu_ops = {
>         .pgsize_bitmap = SECT_SIZE | LPAGE_SIZE | SPAGE_SIZE,
>  };
>
> +static struct dentry *sysmmu_debugfs_root; /* /sys/kernel/debug/sysmmu */
> +
>  static int __init exynos_iommu_init(void)
>  {
>         int ret;
> @@ -1642,17 +1654,197 @@ static int __init exynos_iommu_init(void)
>                 return -ENOMEM;
>         }
>
> -       ret = platform_driver_register(&exynos_sysmmu_driver);
> +       ret = bus_set_iommu(&platform_bus_type, &exynos_iommu_ops);
> +       if (ret) {
> +               kmem_cache_destroy(lv2table_kmem_cache);
> +               pr_err("%s: Failed to register IOMMU ops\n", __func__);
> +               return -EFAULT;
> +       }
>
> -       if (ret == 0)
> -               ret = bus_set_iommu(&platform_bus_type, &exynos_iommu_ops);
> +       sysmmu_debugfs_root = debugfs_create_dir("sysmmu", NULL);
> +       if (!sysmmu_debugfs_root)
> +               pr_err("%s: Failed to create debugfs entry, 'sysmmu'\n",
> +                                                       __func__);
> +       if (IS_ERR(sysmmu_debugfs_root))
> +               sysmmu_debugfs_root = NULL;
>
> +       ret = platform_driver_register(&exynos_sysmmu_driver);
>         if (ret) {
> -               pr_err("%s: Failed to register exynos-iommu driver.\n",
> -                                                               __func__);
>                 kmem_cache_destroy(lv2table_kmem_cache);
> +               pr_err("%s: Failed to register System MMU driver\n",
> __func__);
>         }
>
>         return ret;
>  }
>  subsys_initcall(exynos_iommu_init);
> +
> +static int debug_string_show(struct seq_file *s, void *unused)
> +{
> +       char *str = s->private;
> +
> +       seq_printf(s, "%s\n", str);
> +
> +       return 0;
> +}
> +
> +static int debug_sysmmu_list_show(struct seq_file *s, void *unused)
> +{
> +       struct sysmmu_drvdata *drvdata = s->private;
> +       struct platform_device *pdev = to_platform_device(drvdata->sysmmu);
> +       int idx, maj, min, ret;
> +
> +       seq_printf(s, "SysMMU Name | Ver | SFR Base\n");
> +
> +       if (pm_runtime_enabled(drvdata->sysmmu)) {
> +               ret = pm_runtime_get_sync(drvdata->sysmmu);
> +               if (ret < 0)
> +                       return ret;
> +       }
> +
> +       for (idx = 0; idx < drvdata->nsfrs; idx++) {
> +               struct resource *res;
> +
> +               res = platform_get_resource(pdev, IORESOURCE_MEM, idx);
> +               if (!res)
> +                       break;
> +
> +               maj = __sysmmu_version(drvdata, idx, &min);
> +
> +               if (drvdata->mmuname) {
> +                       if (maj == 0)
> +                               seq_printf(s, "%11.s | N/A | 0x%08x\n",
> +                                       drvdata->mmuname[idx], res->start);
> +                       else
> +                               seq_printf(s, "%11.s | %d.%d | 0x%08x\n",
> +                               drvdata->mmuname[idx], maj, min,
> res->start);
> +               } else {
> +                       if (maj == 0)
> +                               seq_printf(s, "N/A | 0x%08x\n",
> res->start);
> +                       else
> +                               seq_printf(s, "%d.%d | 0x%08x\n",
> +                                                       maj, min,
> res->start);
> +               }
> +       }
> +
> +       if (pm_runtime_enabled(drvdata->sysmmu))
> +               pm_runtime_put(drvdata->sysmmu);
> +
> +       return 0;
> +}
> +
> +static int debug_next_sibling_show(struct seq_file *s, void *unused)
> +{
> +       struct device *dev = s->private;
> +
> +       if (dev->parent &&
> +               !strncmp(dev_name(dev->parent),
> +                       MODULE_NAME, strlen(MODULE_NAME)))
> +               seq_printf(s, "%s\n", dev_name(dev->parent));
> +       return 0;
> +}
> +
> +static int __show_master(struct device *dev, void *data)
> +{
> +       struct seq_file *s = data;
> +
> +       if (strncmp(dev_name(dev), MODULE_NAME, strlen(MODULE_NAME)))
> +               seq_printf(s, "%s\n", dev_name(dev));
> +       return 0;
> +}
> +
> +static int debug_master_show(struct seq_file *s, void *unused)
> +{
> +       struct device *dev = s->private;
> +
> +       device_for_each_child(dev, s, __show_master);
> +       return 0;
> +}
> +
> +static int debug_string_open(struct inode *inode, struct file *file)
> +{
> +       return single_open(file, debug_string_show, inode->i_private);
> +}
> +
> +static int debug_sysmmu_list_open(struct inode *inode, struct file *file)
> +{
> +       return single_open(file, debug_sysmmu_list_show, inode->i_private);
> +}
> +
> +static int debug_next_sibling_open(struct inode *inode, struct file *file)
> +{
> +       return single_open(file, debug_next_sibling_show,
> inode->i_private);
> +}
> +
> +static int debug_master_open(struct inode *inode, struct file *file)
> +{
> +       return single_open(file, debug_master_show, inode->i_private);
> +}
> +
> +static const struct file_operations debug_string_fops = {
> +       .open = debug_string_open,
> +       .read = seq_read,
> +       .llseek = seq_lseek,
> +       .release = single_release,
> +};
> +
> +static const struct file_operations debug_sysmmu_list_fops = {
> +       .open = debug_sysmmu_list_open,
> +       .read = seq_read,
> +       .llseek = seq_lseek,
> +       .release = single_release,
> +};
> +
> +static const struct file_operations debug_next_sibling_fops = {
> +       .open = debug_next_sibling_open,
> +       .read = seq_read,
> +       .llseek = seq_lseek,
> +       .release = single_release,
> +};
> +
> +static const struct file_operations debug_master_fops = {
> +       .open = debug_master_open,
> +       .read = seq_read,
> +       .llseek = seq_lseek,
> +       .release = single_release,
> +};
> +
> +static void __init __create_debugfs_entry(struct sysmmu_drvdata *drvdata)
> +{
> +       if (!sysmmu_debugfs_root)
> +               return;
> +
> +       drvdata->debugfs_root =
> debugfs_create_dir(dev_name(drvdata->sysmmu),
> +
> sysmmu_debugfs_root);
> +       if (!drvdata->debugfs_root)
> +               dev_err(drvdata->sysmmu, "Failed to create debugfs
> dentry\n");
> +       if (IS_ERR(drvdata->debugfs_root))
> +               drvdata->debugfs_root = NULL;
> +
> +       if (!drvdata->debugfs_root)
> +               return;
> +
> +       if (!debugfs_create_u32("enable", 0664, drvdata->debugfs_root,
> +                                               &drvdata->activations))
> +               dev_err(drvdata->sysmmu,
> +                               "Failed to create debugfs file
> 'enable'\n");
> +
> +       if (!debugfs_create_x32("pagetable", 0664, drvdata->debugfs_root,
> +                                               (u32 *)&drvdata->pgtable))
> +               dev_err(drvdata->sysmmu,
> +                               "Failed to create debugfs file
> 'pagetable'\n");
> +
> +       if (!debugfs_create_file("sysmmu_list", 0444,
> drvdata->debugfs_root,
> +                                       drvdata, &debug_sysmmu_list_fops))
> +               dev_err(drvdata->sysmmu,
> +                       "Failed to create debugfs file 'sysmmu_list'\n");
> +
> +       if (!debugfs_create_file("next_sibling", 0x444,
> drvdata->debugfs_root,
> +                               drvdata->sysmmu, &debug_next_sibling_fops))
> +               dev_err(drvdata->sysmmu,
> +                       "Failed to create debugfs file 'next_siblings'\n");
> +
> +       if (!debugfs_create_file("master", 0x444, drvdata->debugfs_root,
> +                               drvdata->sysmmu, &debug_master_fops))
> +               dev_err(drvdata->sysmmu,
> +                       "Failed to create debugfs file 'next_siblings'\n");
> +}
> --
> 1.8.0
>
>
> _______________________________________________
> iommu mailing list
> iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
> https://lists.linuxfoundation.org/mailman/listinfo/iommu
>

[-- Attachment #1.2: Type: text/html, Size: 12782 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-05-18  5:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-26  1:54 [PATCH v6 12/12] iommu/exynos: add debugfs entries for System MMU Cho KyongHo
     [not found] ` <003f01cde30b$f2891d30$d79b5790$%cho-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2013-05-18  5:26   ` Prathyush K

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).