Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1734035 > unrolled thread
| Started by | Liviu Dudau <Liviu.Dudau@arm.com> |
|---|---|
| First post | 2017-09-18 13:10 +0200 |
| Last post | 2017-09-20 16:20 +0200 |
| Articles | 5 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] iommu/ipmmu-vmsa: Do not replace bus IOMMU ops on driver init. Liviu Dudau <Liviu.Dudau@arm.com> - 2017-09-18 13:10 +0200
Re: [PATCH] iommu/ipmmu-vmsa: Do not replace bus IOMMU ops on driver init. Laurent Pinchart <laurent.pinchart@ideasonboard.com> - 2017-09-19 09:10 +0200
Re: [PATCH] iommu/ipmmu-vmsa: Do not replace bus IOMMU ops on driver init. Liviu Dudau <Liviu.Dudau@arm.com> - 2017-09-19 11:50 +0200
Re: [PATCH] iommu/ipmmu-vmsa: Do not replace bus IOMMU ops on driver init. Robin Murphy <robin.murphy@arm.com> - 2017-09-19 12:50 +0200
[PATCH v2] iommu/ipmmu-vmsa: Do not replace bus IOMMU ops on driver init. Liviu Dudau <Liviu.Dudau@arm.com> - 2017-09-20 16:20 +0200
| From | Liviu Dudau <Liviu.Dudau@arm.com> |
|---|---|
| Date | 2017-09-18 13:10 +0200 |
| Subject | [PATCH] iommu/ipmmu-vmsa: Do not replace bus IOMMU ops on driver init. |
| Message-ID | <ur265-5yD-1@gated-at.bofh.it> |
If the IPMMU driver is compiled in the kernel it will replace the
platform bus IOMMU ops on running the ipmmu_init() function, regardless
if there is any IPMMU hardware present or not. This screws up systems
that just want to build a generic kernel that runs on multiple platforms
and use a different IOMMU implementation.
Move the bus_set_iommu() call at the end of the ipmmu_probe() function
when we know that hardware is present. With current IOMMU framework it
should be safe (at least for OF case).
Now that the ipmmu_init() and ipmmu_exit() functions are simple calls to
platform_driver_register() and platform_driver_unregister(), replace
them with the module_platform_driver() macro call.
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
drivers/iommu/ipmmu-vmsa.c | 29 +++++------------------------
1 file changed, 5 insertions(+), 24 deletions(-)
diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index 2a38aa15be17d..c60569c74678d 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -1055,10 +1055,11 @@ static int ipmmu_probe(struct platform_device *pdev)
ipmmu_device_reset(mmu);
/*
- * We can't create the ARM mapping here as it requires the bus to have
- * an IOMMU, which only happens when bus_set_iommu() is called in
- * ipmmu_init() after the probe function returns.
+ * Now that we have validated the presence of the hardware, set
+ * the bus IOMMU ops to enable future domain and device setup.
*/
+ if (!iommu_present(&platform_bus_type))
+ bus_set_iommu(&platform_bus_type, &ipmmu_ops);
spin_lock(&ipmmu_devices_lock);
list_add(&mmu->list, &ipmmu_devices);
@@ -1100,27 +1101,7 @@ static struct platform_driver ipmmu_driver = {
.remove = ipmmu_remove,
};
-static int __init ipmmu_init(void)
-{
- int ret;
-
- ret = platform_driver_register(&ipmmu_driver);
- if (ret < 0)
- return ret;
-
- if (!iommu_present(&platform_bus_type))
- bus_set_iommu(&platform_bus_type, &ipmmu_ops);
-
- return 0;
-}
-
-static void __exit ipmmu_exit(void)
-{
- return platform_driver_unregister(&ipmmu_driver);
-}
-
-subsys_initcall(ipmmu_init);
-module_exit(ipmmu_exit);
+module_platform_driver(ipmmu_driver);
MODULE_DESCRIPTION("IOMMU API for Renesas VMSA-compatible IPMMU");
MODULE_AUTHOR("Laurent Pinchart <laurent.pinchart@ideasonboard.com>");
--
2.14.1
[toc] | [next] | [standalone]
| From | Laurent Pinchart <laurent.pinchart@ideasonboard.com> |
|---|---|
| Date | 2017-09-19 09:10 +0200 |
| Message-ID | <urkPo-13s-11@gated-at.bofh.it> |
| In reply to | #1734035 |
Hi Liviu,
Thank you for the patch.
On Monday, 18 September 2017 13:04:44 EEST Liviu Dudau wrote:
> If the IPMMU driver is compiled in the kernel it will replace the
> platform bus IOMMU ops on running the ipmmu_init() function, regardless
> if there is any IPMMU hardware present or not. This screws up systems
> that just want to build a generic kernel that runs on multiple platforms
> and use a different IOMMU implementation.
>
> Move the bus_set_iommu() call at the end of the ipmmu_probe() function
> when we know that hardware is present. With current IOMMU framework it
> should be safe (at least for OF case).
If I recall correctly the issue is that the IPMMU might be probed after bus
master devices when using the legacy IOMMU DT integration, which the ipmmu-
vmsa driver does on ARM32. Calling bus_set_iommu() from the probe function
will then result in some devices losing IOMMU support.
> Now that the ipmmu_init() and ipmmu_exit() functions are simple calls to
> platform_driver_register() and platform_driver_unregister(), replace
> them with the module_platform_driver() macro call.
>
> Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
> Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
> drivers/iommu/ipmmu-vmsa.c | 29 +++++------------------------
> 1 file changed, 5 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
> index 2a38aa15be17d..c60569c74678d 100644
> --- a/drivers/iommu/ipmmu-vmsa.c
> +++ b/drivers/iommu/ipmmu-vmsa.c
> @@ -1055,10 +1055,11 @@ static int ipmmu_probe(struct platform_device *pdev)
> ipmmu_device_reset(mmu);
>
> /*
> - * We can't create the ARM mapping here as it requires the bus to have
> - * an IOMMU, which only happens when bus_set_iommu() is called in
> - * ipmmu_init() after the probe function returns.
> + * Now that we have validated the presence of the hardware, set
> + * the bus IOMMU ops to enable future domain and device setup.
> */
> + if (!iommu_present(&platform_bus_type))
> + bus_set_iommu(&platform_bus_type, &ipmmu_ops);
>
> spin_lock(&ipmmu_devices_lock);
> list_add(&mmu->list, &ipmmu_devices);
What branch is this patch based on ? ipmmu_devices_lock isn't in mainline.
> @@ -1100,27 +1101,7 @@ static struct platform_driver ipmmu_driver = {
> .remove = ipmmu_remove,
> };
>
> -static int __init ipmmu_init(void)
> -{
> - int ret;
> -
> - ret = platform_driver_register(&ipmmu_driver);
> - if (ret < 0)
> - return ret;
> -
> - if (!iommu_present(&platform_bus_type))
> - bus_set_iommu(&platform_bus_type, &ipmmu_ops);
> -
> - return 0;
> -}
> -
> -static void __exit ipmmu_exit(void)
> -{
> - return platform_driver_unregister(&ipmmu_driver);
> -}
> -
> -subsys_initcall(ipmmu_init);
> -module_exit(ipmmu_exit);
> +module_platform_driver(ipmmu_driver);
>
> MODULE_DESCRIPTION("IOMMU API for Renesas VMSA-compatible IPMMU");
> MODULE_AUTHOR("Laurent Pinchart <laurent.pinchart@ideasonboard.com>");
--
Regards,
Laurent Pinchart
[toc] | [prev] | [next] | [standalone]
| From | Liviu Dudau <Liviu.Dudau@arm.com> |
|---|---|
| Date | 2017-09-19 11:50 +0200 |
| Subject | Re: [PATCH] iommu/ipmmu-vmsa: Do not replace bus IOMMU ops on driver init. |
| Message-ID | <urnkf-39c-31@gated-at.bofh.it> |
| In reply to | #1734697 |
On Tue, Sep 19, 2017 at 10:07:58AM +0300, Laurent Pinchart wrote:
> Hi Liviu,
>
> Thank you for the patch.
>
> On Monday, 18 September 2017 13:04:44 EEST Liviu Dudau wrote:
> > If the IPMMU driver is compiled in the kernel it will replace the
> > platform bus IOMMU ops on running the ipmmu_init() function, regardless
> > if there is any IPMMU hardware present or not. This screws up systems
> > that just want to build a generic kernel that runs on multiple platforms
> > and use a different IOMMU implementation.
> >
> > Move the bus_set_iommu() call at the end of the ipmmu_probe() function
> > when we know that hardware is present. With current IOMMU framework it
> > should be safe (at least for OF case).
>
> If I recall correctly the issue is that the IPMMU might be probed after bus
> master devices when using the legacy IOMMU DT integration, which the ipmmu-
> vmsa driver does on ARM32. Calling bus_set_iommu() from the probe function
> will then result in some devices losing IOMMU support.
This is on arm64, on the Arm Juno board.
>
> > Now that the ipmmu_init() and ipmmu_exit() functions are simple calls to
> > platform_driver_register() and platform_driver_unregister(), replace
> > them with the module_platform_driver() macro call.
> >
> > Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
> > Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > ---
> > drivers/iommu/ipmmu-vmsa.c | 29 +++++------------------------
> > 1 file changed, 5 insertions(+), 24 deletions(-)
> >
> > diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
> > index 2a38aa15be17d..c60569c74678d 100644
> > --- a/drivers/iommu/ipmmu-vmsa.c
> > +++ b/drivers/iommu/ipmmu-vmsa.c
> > @@ -1055,10 +1055,11 @@ static int ipmmu_probe(struct platform_device *pdev)
> > ipmmu_device_reset(mmu);
> >
> > /*
> > - * We can't create the ARM mapping here as it requires the bus to have
> > - * an IOMMU, which only happens when bus_set_iommu() is called in
> > - * ipmmu_init() after the probe function returns.
> > + * Now that we have validated the presence of the hardware, set
> > + * the bus IOMMU ops to enable future domain and device setup.
> > */
> > + if (!iommu_present(&platform_bus_type))
> > + bus_set_iommu(&platform_bus_type, &ipmmu_ops);
> >
> > spin_lock(&ipmmu_devices_lock);
> > list_add(&mmu->list, &ipmmu_devices);
>
> What branch is this patch based on ? ipmmu_devices_lock isn't in mainline.
drm-next. :)
Looks like things have move forward since I've made the patch before
LPC, will update and resend.
Best regards,
Liviu
>
> > @@ -1100,27 +1101,7 @@ static struct platform_driver ipmmu_driver = {
> > .remove = ipmmu_remove,
> > };
> >
> > -static int __init ipmmu_init(void)
> > -{
> > - int ret;
> > -
> > - ret = platform_driver_register(&ipmmu_driver);
> > - if (ret < 0)
> > - return ret;
> > -
> > - if (!iommu_present(&platform_bus_type))
> > - bus_set_iommu(&platform_bus_type, &ipmmu_ops);
> > -
> > - return 0;
> > -}
> > -
> > -static void __exit ipmmu_exit(void)
> > -{
> > - return platform_driver_unregister(&ipmmu_driver);
> > -}
> > -
> > -subsys_initcall(ipmmu_init);
> > -module_exit(ipmmu_exit);
> > +module_platform_driver(ipmmu_driver);
> >
> > MODULE_DESCRIPTION("IOMMU API for Renesas VMSA-compatible IPMMU");
> > MODULE_AUTHOR("Laurent Pinchart <laurent.pinchart@ideasonboard.com>");
>
> --
> Regards,
>
> Laurent Pinchart
>
--
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯
[toc] | [prev] | [next] | [standalone]
| From | Robin Murphy <robin.murphy@arm.com> |
|---|---|
| Date | 2017-09-19 12:50 +0200 |
| Subject | Re: [PATCH] iommu/ipmmu-vmsa: Do not replace bus IOMMU ops on driver init. |
| Message-ID | <urogh-4jM-5@gated-at.bofh.it> |
| In reply to | #1734697 |
Hi Laurent,
On 19/09/17 08:07, Laurent Pinchart wrote:
> Hi Liviu,
>
> Thank you for the patch.
>
> On Monday, 18 September 2017 13:04:44 EEST Liviu Dudau wrote:
>> If the IPMMU driver is compiled in the kernel it will replace the
>> platform bus IOMMU ops on running the ipmmu_init() function, regardless
>> if there is any IPMMU hardware present or not. This screws up systems
>> that just want to build a generic kernel that runs on multiple platforms
>> and use a different IOMMU implementation.
>>
>> Move the bus_set_iommu() call at the end of the ipmmu_probe() function
>> when we know that hardware is present. With current IOMMU framework it
>> should be safe (at least for OF case).
>
> If I recall correctly the issue is that the IPMMU might be probed after bus
> master devices when using the legacy IOMMU DT integration, which the ipmmu-
> vmsa driver does on ARM32. Calling bus_set_iommu() from the probe function
> will then result in some devices losing IOMMU support.
Yes, that used to be the problem, but since IPMMU uses the generic
bindings and iommu_device_register(), it should now benefit from client
probe-deferral even when it doesn't support of_xlate().
Robin.
>> Now that the ipmmu_init() and ipmmu_exit() functions are simple calls to
>> platform_driver_register() and platform_driver_unregister(), replace
>> them with the module_platform_driver() macro call.
>>
>> Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
>> Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
>> ---
>> drivers/iommu/ipmmu-vmsa.c | 29 +++++------------------------
>> 1 file changed, 5 insertions(+), 24 deletions(-)
>>
>> diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
>> index 2a38aa15be17d..c60569c74678d 100644
>> --- a/drivers/iommu/ipmmu-vmsa.c
>> +++ b/drivers/iommu/ipmmu-vmsa.c
>> @@ -1055,10 +1055,11 @@ static int ipmmu_probe(struct platform_device *pdev)
>> ipmmu_device_reset(mmu);
>>
>> /*
>> - * We can't create the ARM mapping here as it requires the bus to have
>> - * an IOMMU, which only happens when bus_set_iommu() is called in
>> - * ipmmu_init() after the probe function returns.
>> + * Now that we have validated the presence of the hardware, set
>> + * the bus IOMMU ops to enable future domain and device setup.
>> */
>> + if (!iommu_present(&platform_bus_type))
>> + bus_set_iommu(&platform_bus_type, &ipmmu_ops);
>>
>> spin_lock(&ipmmu_devices_lock);
>> list_add(&mmu->list, &ipmmu_devices);
>
> What branch is this patch based on ? ipmmu_devices_lock isn't in mainline.
>
>> @@ -1100,27 +1101,7 @@ static struct platform_driver ipmmu_driver = {
>> .remove = ipmmu_remove,
>> };
>>
>> -static int __init ipmmu_init(void)
>> -{
>> - int ret;
>> -
>> - ret = platform_driver_register(&ipmmu_driver);
>> - if (ret < 0)
>> - return ret;
>> -
>> - if (!iommu_present(&platform_bus_type))
>> - bus_set_iommu(&platform_bus_type, &ipmmu_ops);
>> -
>> - return 0;
>> -}
>> -
>> -static void __exit ipmmu_exit(void)
>> -{
>> - return platform_driver_unregister(&ipmmu_driver);
>> -}
>> -
>> -subsys_initcall(ipmmu_init);
>> -module_exit(ipmmu_exit);
>> +module_platform_driver(ipmmu_driver);
>>
>> MODULE_DESCRIPTION("IOMMU API for Renesas VMSA-compatible IPMMU");
>> MODULE_AUTHOR("Laurent Pinchart <laurent.pinchart@ideasonboard.com>");
>
[toc] | [prev] | [next] | [standalone]
| From | Liviu Dudau <Liviu.Dudau@arm.com> |
|---|---|
| Date | 2017-09-20 16:20 +0200 |
| Subject | [PATCH v2] iommu/ipmmu-vmsa: Do not replace bus IOMMU ops on driver init. |
| Message-ID | <urO14-4b1-9@gated-at.bofh.it> |
| In reply to | #1734035 |
If the IPMMU driver is compiled in the kernel it will replace the
platform bus IOMMU ops on running the ipmmu_init() function, regardless
if there is any IPMMU hardware present or not. This screws up systems
that just want to build a generic kernel that runs on multiple platforms
and use a different IOMMU implementation.
Move the bus_set_iommu() call at the end of the ipmmu_probe() function
when we know that hardware is present. With current IOMMU framework it
should be safe (at least for OF case).
Now that the ipmmu_init() and ipmmu_exit() functions are simple calls to
platform_driver_register() and platform_driver_unregister(), replace
them with the module_platform_driver() macro call.
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
drivers/iommu/ipmmu-vmsa.c | 29 +++++------------------------
1 file changed, 5 insertions(+), 24 deletions(-)
diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index 195d6e93ac718..31912997bffdf 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -966,10 +966,11 @@ static int ipmmu_probe(struct platform_device *pdev)
return ret;
/*
- * We can't create the ARM mapping here as it requires the bus to have
- * an IOMMU, which only happens when bus_set_iommu() is called in
- * ipmmu_init() after the probe function returns.
+ * Now that we have validated the presence of the hardware, set
+ * the bus IOMMU ops to enable future domain and device setup.
*/
+ if (!iommu_present(&platform_bus_type))
+ bus_set_iommu(&platform_bus_type, &ipmmu_ops);
platform_set_drvdata(pdev, mmu);
@@ -1006,27 +1007,7 @@ static struct platform_driver ipmmu_driver = {
.remove = ipmmu_remove,
};
-static int __init ipmmu_init(void)
-{
- int ret;
-
- ret = platform_driver_register(&ipmmu_driver);
- if (ret < 0)
- return ret;
-
- if (!iommu_present(&platform_bus_type))
- bus_set_iommu(&platform_bus_type, &ipmmu_ops);
-
- return 0;
-}
-
-static void __exit ipmmu_exit(void)
-{
- return platform_driver_unregister(&ipmmu_driver);
-}
-
-subsys_initcall(ipmmu_init);
-module_exit(ipmmu_exit);
+module_platform_driver(ipmmu_driver);
MODULE_DESCRIPTION("IOMMU API for Renesas VMSA-compatible IPMMU");
MODULE_AUTHOR("Laurent Pinchart <laurent.pinchart@ideasonboard.com>");
--
2.14.1
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web