diff mbox

[09/10] iommu/exynos: Make use of iommu_device_register interface

Message ID 1486397429-29327-10-git-send-email-joro@8bytes.org (mailing list archive)
State Not Applicable
Headers show

Commit Message

Joerg Roedel Feb. 6, 2017, 4:10 p.m. UTC
From: Joerg Roedel <jroedel@suse.de>

Register Exynos IOMMUs to the IOMMU core and make them
visible in sysfs. This patch does not add the links between
IOMMUs and translated devices yet.

Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
 drivers/iommu/exynos-iommu.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

kernel test robot Feb. 7, 2017, 5:12 a.m. UTC | #1
Hi Joerg,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.10-rc7]
[cannot apply to iommu/next next-20170206]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Joerg-Roedel/Let-IOMMU-core-know-about-individual-IOMMUs/20170207-003931
config: arm-allyesconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=arm 

Note: the linux-review/Joerg-Roedel/Let-IOMMU-core-know-about-individual-IOMMUs/20170207-003931 HEAD 0b8fd0f8bbcfb693621ee90abffb0774c143549d builds fine.
      It only hurts bisectibility.

All errors (new ones prefixed by >>):

   drivers/iommu/exynos-iommu.c: In function 'exynos_sysmmu_probe':
>> drivers/iommu/exynos-iommu.c:624:13: error: 'struct iommu_device' has no member named 'fwnode'
     data->iommu.fwnode = &dev->of_node->fwnode;
                ^

vim +624 drivers/iommu/exynos-iommu.c

   618		ret = iommu_device_sysfs_add(&data->iommu, &pdev->dev, NULL,
   619					     "sysmmu.%pa", &ioaddr);
   620		if (ret)
   621			return ret;
   622	
   623		data->iommu.ops    = &exynos_iommu_ops;
 > 624		data->iommu.fwnode = &dev->of_node->fwnode;
   625	
   626		ret = iommu_device_register(&data->iommu);
   627		if (ret)

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Marek Szyprowski Feb. 7, 2017, 12:36 p.m. UTC | #2
Hi Joerg,

On 2017-02-06 17:10, Joerg Roedel wrote:
> From: Joerg Roedel <jroedel@suse.de>
>
> Register Exynos IOMMUs to the IOMMU core and make them
> visible in sysfs. This patch does not add the links between
> IOMMUs and translated devices yet.
>
> Cc: Marek Szyprowski <m.szyprowski@samsung.com>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-samsung-soc@vger.kernel.org
> Signed-off-by: Joerg Roedel <jroedel@suse.de>
> ---
>   drivers/iommu/exynos-iommu.c | 16 ++++++++++++++++
>   1 file changed, 16 insertions(+)
>
> diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
> index 57ba0d3..90f0f52 100644
> --- a/drivers/iommu/exynos-iommu.c
> +++ b/drivers/iommu/exynos-iommu.c
> @@ -276,6 +276,8 @@ struct sysmmu_drvdata {
>   	struct list_head owner_node;	/* node for owner controllers list */
>   	phys_addr_t pgtable;		/* assigned page table structure */
>   	unsigned int version;		/* our version */
> +
> +	struct iommu_device iommu;	/* IOMMU core handle */
>   };
>   
>   static struct exynos_iommu_domain *to_exynos_domain(struct iommu_domain *dom)
> @@ -556,6 +558,7 @@ static int __init exynos_sysmmu_probe(struct platform_device *pdev)
>   	struct device *dev = &pdev->dev;
>   	struct sysmmu_drvdata *data;
>   	struct resource *res;
> +	resource_size_t ioaddr;
>   
>   	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
>   	if (!data)
> @@ -565,6 +568,7 @@ static int __init exynos_sysmmu_probe(struct platform_device *pdev)
>   	data->sfrbase = devm_ioremap_resource(dev, res);
>   	if (IS_ERR(data->sfrbase))
>   		return PTR_ERR(data->sfrbase);
> +	ioaddr = res->start;
>   
>   	irq = platform_get_irq(pdev, 0);
>   	if (irq <= 0) {
> @@ -611,6 +615,18 @@ static int __init exynos_sysmmu_probe(struct platform_device *pdev)
>   	data->sysmmu = dev;
>   	spin_lock_init(&data->lock);
>   
> +	ret = iommu_device_sysfs_add(&data->iommu, &pdev->dev, NULL,
> +				     "sysmmu.%pa", &ioaddr);

Can we stick to the common name across the /sysfs and use 
dev_name(data->sysmmu)
or even dev_name(dev) here?

ret = iommu_device_sysfs_add(&data->iommu, &pdev->dev, NULL, 
dev_name(dev));

> +	if (ret)
> +		return ret;
> +
> +	data->iommu.ops    = &exynos_iommu_ops;
> +	data->iommu.fwnode = &dev->of_node->fwnode;
> +
> +	ret = iommu_device_register(&data->iommu);
> +	if (ret)
> +		return ret;
> +
>   	platform_set_drvdata(pdev, data);
>   
>   	__sysmmu_get_version(data);

Best regards
Joerg Roedel Feb. 8, 2017, 1:57 p.m. UTC | #3
Hi Marek,

On Tue, Feb 07, 2017 at 01:36:15PM +0100, Marek Szyprowski wrote:
> >+	ret = iommu_device_sysfs_add(&data->iommu, &pdev->dev, NULL,
> >+				     "sysmmu.%pa", &ioaddr);
> 
> Can we stick to the common name across the /sysfs and use
> dev_name(data->sysmmu)
> or even dev_name(dev) here?
> 
> ret = iommu_device_sysfs_add(&data->iommu, &pdev->dev, NULL,
> dev_name(dev));

That means that we have multiple 'struct device' with the same name,
no? I think will lead to confusion when using dev_printk, as its not
clear anymore which device is refered to in the message.


	Joerg

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marek Szyprowski Feb. 8, 2017, 2:09 p.m. UTC | #4
Hi Joerg,

On 2017-02-08 14:57, Joerg Roedel wrote:
> On Tue, Feb 07, 2017 at 01:36:15PM +0100, Marek Szyprowski wrote:
>>> +	ret = iommu_device_sysfs_add(&data->iommu, &pdev->dev, NULL,
>>> +				     "sysmmu.%pa", &ioaddr);
>> Can we stick to the common name across the /sysfs and use
>> dev_name(data->sysmmu)
>> or even dev_name(dev) here?
>>
>> ret = iommu_device_sysfs_add(&data->iommu, &pdev->dev, NULL,
>> dev_name(dev));
> That means that we have multiple 'struct device' with the same name,
> no? I think will lead to confusion when using dev_printk, as its not
> clear anymore which device is refered to in the message.

Each sysmmu device has unique name, like every other platform device
instantiated from device tree. Here is an example from the OdroidXU3
(Exynos5422 based):

# ls -1 /sys/bus/platform/devices/ | grep sysmmu
10a60000.sysmmu
10a70000.sysmmu
11200000.sysmmu
11210000.sysmmu
11d40000.sysmmu
11f10000.sysmmu
11f20000.sysmmu
12880000.sysmmu
12890000.sysmmu
128a0000.sysmmu
128c0000.sysmmu
128d0000.sysmmu
128e0000.sysmmu
13e80000.sysmmu
13e90000.sysmmu
14640000.sysmmu
14650000.sysmmu
14680000.sysmmu

IMHO there is no need for open coding new unique names if device name,
which already contains the base address, can be used instead.

Best regards
diff mbox

Patch

diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index 57ba0d3..90f0f52 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -276,6 +276,8 @@  struct sysmmu_drvdata {
 	struct list_head owner_node;	/* node for owner controllers list */
 	phys_addr_t pgtable;		/* assigned page table structure */
 	unsigned int version;		/* our version */
+
+	struct iommu_device iommu;	/* IOMMU core handle */
 };
 
 static struct exynos_iommu_domain *to_exynos_domain(struct iommu_domain *dom)
@@ -556,6 +558,7 @@  static int __init exynos_sysmmu_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct sysmmu_drvdata *data;
 	struct resource *res;
+	resource_size_t ioaddr;
 
 	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
@@ -565,6 +568,7 @@  static int __init exynos_sysmmu_probe(struct platform_device *pdev)
 	data->sfrbase = devm_ioremap_resource(dev, res);
 	if (IS_ERR(data->sfrbase))
 		return PTR_ERR(data->sfrbase);
+	ioaddr = res->start;
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq <= 0) {
@@ -611,6 +615,18 @@  static int __init exynos_sysmmu_probe(struct platform_device *pdev)
 	data->sysmmu = dev;
 	spin_lock_init(&data->lock);
 
+	ret = iommu_device_sysfs_add(&data->iommu, &pdev->dev, NULL,
+				     "sysmmu.%pa", &ioaddr);
+	if (ret)
+		return ret;
+
+	data->iommu.ops    = &exynos_iommu_ops;
+	data->iommu.fwnode = &dev->of_node->fwnode;
+
+	ret = iommu_device_register(&data->iommu);
+	if (ret)
+		return ret;
+
 	platform_set_drvdata(pdev, data);
 
 	__sysmmu_get_version(data);