diff mbox

[1/2] iommu/msm: Claim bus ops on probe

Message ID f1a506337bf602c54f4d6d417c14ca556a5f3674.1515436860.git.robin.murphy@arm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Robin Murphy Jan. 8, 2018, 6:42 p.m. UTC
Since the MSM IOMMU driver now probes via DT exclusively rather than
platform data, dependent masters should be deferred until the IOMMU
itself is ready. Thus we can do away with the early initialisation
hook to unconditionally claim the bus ops, and instead do that only
once an IOMMU is actually probed. Furthermore, this should also make
the driver safe for multiplatform kernels on non-MSM SoCs.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---
 drivers/iommu/msm_iommu.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

Comments

Sricharan Ramabadhran Jan. 9, 2018, 6:04 a.m. UTC | #1
On 1/9/2018 12:12 AM, Robin Murphy wrote:
> Since the MSM IOMMU driver now probes via DT exclusively rather than
> platform data, dependent masters should be deferred until the IOMMU
> itself is ready. Thus we can do away with the early initialisation
> hook to unconditionally claim the bus ops, and instead do that only
> once an IOMMU is actually probed. Furthermore, this should also make
> the driver safe for multiplatform kernels on non-MSM SoCs.
> 
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
>  drivers/iommu/msm_iommu.c | 16 +++-------------
>  1 file changed, 3 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c
> index 04f4d51ffacb..dda1ce87a070 100644
> --- a/drivers/iommu/msm_iommu.c
> +++ b/drivers/iommu/msm_iommu.c
> @@ -823,6 +823,8 @@ static int msm_iommu_probe(struct platform_device *pdev)
>  		goto fail;
>  	}
>  
> +	bus_set_iommu(&platform_bus_type, &msm_iommu_ops);
> +
>  	pr_info("device mapped at %p, irq %d with %d ctx banks\n",
>  		iommu->base, iommu->irq, iommu->ncb);
>  
> @@ -875,19 +877,7 @@ static void __exit msm_iommu_driver_exit(void)
>  subsys_initcall(msm_iommu_driver_init);
>  module_exit(msm_iommu_driver_exit);
>  
> -static int __init msm_iommu_init(void)
> -{
> -	bus_set_iommu(&platform_bus_type, &msm_iommu_ops);
> -	return 0;
> -}
> -
> -static int __init msm_iommu_of_setup(struct device_node *np)
> -{
> -	msm_iommu_init();
> -	return 0;
> -}
> -
> -IOMMU_OF_DECLARE(msm_iommu_of, "qcom,apq8064-iommu", msm_iommu_of_setup);
> +IOMMU_OF_DECLARE(msm_iommu_of, "qcom,apq8064-iommu", NULL);
>  
>  MODULE_LICENSE("GPL v2");
>  MODULE_AUTHOR("Stepan Moskovchenko <stepanm@codeaurora.org>");
> 

Reviewed-by: Sricharan R <sricharan@codeaurora.org>

Regards,
 Sricharan
Joerg Roedel Jan. 17, 2018, 1:33 p.m. UTC | #2
On Mon, Jan 08, 2018 at 06:42:30PM +0000, Robin Murphy wrote:
> Since the MSM IOMMU driver now probes via DT exclusively rather than
> platform data, dependent masters should be deferred until the IOMMU
> itself is ready. Thus we can do away with the early initialisation
> hook to unconditionally claim the bus ops, and instead do that only
> once an IOMMU is actually probed. Furthermore, this should also make
> the driver safe for multiplatform kernels on non-MSM SoCs.
> 
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>

Applied both, thanks Robin.
Robin Murphy Jan. 17, 2018, 1:39 p.m. UTC | #3
On 17/01/18 13:33, Joerg Roedel wrote:
> On Mon, Jan 08, 2018 at 06:42:30PM +0000, Robin Murphy wrote:
>> Since the MSM IOMMU driver now probes via DT exclusively rather than
>> platform data, dependent masters should be deferred until the IOMMU
>> itself is ready. Thus we can do away with the early initialisation
>> hook to unconditionally claim the bus ops, and instead do that only
>> once an IOMMU is actually probed. Furthermore, this should also make
>> the driver safe for multiplatform kernels on non-MSM SoCs.
>>
>> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> 
> Applied both, thanks Robin.

Oops, patch #2 of this series will break the build, as it was 
accidentally based on an older branch missing the Renesas IPMMU updates. 
Please see v2 [1] - I'm still hoping for confirmation from the Renesas 
folks, but it *should* be fine...

Incidentally, per your other mail, these changes also makes Jeffy's 
"Only do IOMMU lookup for available ones" patch obsolete.

Sorry for the mess,
Robin.

[1] 
https://lists.linuxfoundation.org/pipermail/iommu/2018-January/025395.html
Joerg Roedel Jan. 17, 2018, 1:53 p.m. UTC | #4
Hi Robin,

On Wed, Jan 17, 2018 at 01:39:18PM +0000, Robin Murphy wrote:
> Oops, patch #2 of this series will break the build, as it was accidentally
> based on an older branch missing the Renesas IPMMU updates. 

So patch #2 needs the ipmmu-patch from your v2 post to build? I am a bit
confused...

> Please see v2 [1] - I'm still hoping for confirmation from the Renesas
> folks, but it *should* be fine...

I can apply the patches again from your v2 post, thats fine, I just want
to understand the dependencies first.


> Incidentally, per your other mail, these changes also makes Jeffy's "Only do
> IOMMU lookup for available ones" patch obsolete.

Okay, thanks for letting me know.


Thanks,

	Joerg
Robin Murphy Jan. 17, 2018, 2:05 p.m. UTC | #5
On 17/01/18 13:53, Joerg Roedel wrote:
> Hi Robin,
> 
> On Wed, Jan 17, 2018 at 01:39:18PM +0000, Robin Murphy wrote:
>> Oops, patch #2 of this series will break the build, as it was accidentally
>> based on an older branch missing the Renesas IPMMU updates.
> 
> So patch #2 needs the ipmmu-patch from your v2 post to build? I am a bit
> confused...
> 
>> Please see v2 [1] - I'm still hoping for confirmation from the Renesas
>> folks, but it *should* be fine...
> 
> I can apply the patches again from your v2 post, thats fine, I just want
> to understand the dependencies first.

The IOMMU_OF_DECLARE() in ipmmu-vmsa.c added in 4.15 is missed by the 
prototype change in (4.14-based) v1 2/2 - by applying v2 2/3 on top of 
the two v1 patches you will end up with an extra NULL argument there 
which will then fail to compile. v2 3/3 supersedes v1 2/2 by removing 
that one as well. This is entirely my fault for hacking out some quick 
patches on top of unrelated development work instead of creating a fresh 
branch...

>> Incidentally, per your other mail, these changes also makes Jeffy's "Only do
>> IOMMU lookup for available ones" patch obsolete.
> 
> Okay, thanks for letting me know.

Cheers,
Robin.
Joerg Roedel Jan. 17, 2018, 2:27 p.m. UTC | #6
On Wed, Jan 17, 2018 at 02:05:21PM +0000, Robin Murphy wrote:
> The IOMMU_OF_DECLARE() in ipmmu-vmsa.c added in 4.15 is missed by the
> prototype change in (4.14-based) v1 2/2 - by applying v2 2/3 on top of the
> two v1 patches you will end up with an extra NULL argument there which will
> then fail to compile. v2 3/3 supersedes v1 2/2 by removing that one as well.
> This is entirely my fault for hacking out some quick patches on top of
> unrelated development work instead of creating a fresh branch...

Okay, I see. So I removed the two patches from arm/msm and the one patch
from arm/renesas and applied all 3 patches from v2 to the core branch
instead.

Thanks,

	Joerg
diff mbox

Patch

diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c
index 04f4d51ffacb..dda1ce87a070 100644
--- a/drivers/iommu/msm_iommu.c
+++ b/drivers/iommu/msm_iommu.c
@@ -823,6 +823,8 @@  static int msm_iommu_probe(struct platform_device *pdev)
 		goto fail;
 	}
 
+	bus_set_iommu(&platform_bus_type, &msm_iommu_ops);
+
 	pr_info("device mapped at %p, irq %d with %d ctx banks\n",
 		iommu->base, iommu->irq, iommu->ncb);
 
@@ -875,19 +877,7 @@  static void __exit msm_iommu_driver_exit(void)
 subsys_initcall(msm_iommu_driver_init);
 module_exit(msm_iommu_driver_exit);
 
-static int __init msm_iommu_init(void)
-{
-	bus_set_iommu(&platform_bus_type, &msm_iommu_ops);
-	return 0;
-}
-
-static int __init msm_iommu_of_setup(struct device_node *np)
-{
-	msm_iommu_init();
-	return 0;
-}
-
-IOMMU_OF_DECLARE(msm_iommu_of, "qcom,apq8064-iommu", msm_iommu_of_setup);
+IOMMU_OF_DECLARE(msm_iommu_of, "qcom,apq8064-iommu", NULL);
 
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Stepan Moskovchenko <stepanm@codeaurora.org>");