Re: [PATCH v2 05/13] iommu/rockchip: Fix error handling in init

2018-01-17 Thread JeffyChen

Hi Robin,

Thanks for your reply.

On 01/17/2018 07:36 PM, Robin Murphy wrote:

On 17/01/18 05:26, Tomasz Figa wrote:

On Tue, Jan 16, 2018 at 10:25 PM, Jeffy Chen
 wrote:

It's hard to undo bus_set_iommu() in the error path, so move it to the
end of rk_iommu_probe().


Does this work fine now? I remember we used to need this called in an
early initcall for all the ARM/ARM64 DMA stuff to work.


It will do once we get to patch #11 (where the IOMMU_OF_DECLARE ensures
that masters defer until iommu_register() has set ops with a non-NULL
.of_xlate callback); in the meantime you might end up depending on DT
probe order as to whether the master uses the IOMMU or not. I'd say it's
up to you guys whether you consider that a bisection-breaker or not.


hmmm, maybe i can just place this patch after the patch #11 ;)

Robin.






___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [PATCH v2 05/13] iommu/rockchip: Fix error handling in init

2018-01-17 Thread Robin Murphy

On 17/01/18 05:26, Tomasz Figa wrote:

On Tue, Jan 16, 2018 at 10:25 PM, Jeffy Chen  wrote:

It's hard to undo bus_set_iommu() in the error path, so move it to the
end of rk_iommu_probe().


Does this work fine now? I remember we used to need this called in an
early initcall for all the ARM/ARM64 DMA stuff to work.


It will do once we get to patch #11 (where the IOMMU_OF_DECLARE ensures 
that masters defer until iommu_register() has set ops with a non-NULL 
.of_xlate callback); in the meantime you might end up depending on DT 
probe order as to whether the master uses the IOMMU or not. I'd say it's 
up to you guys whether you consider that a bisection-breaker or not.


Robin.
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [PATCH v2 05/13] iommu/rockchip: Fix error handling in init

2018-01-16 Thread JeffyChen

Hi Tomasz,

On 01/17/2018 01:26 PM, Tomasz Figa wrote:

On Tue, Jan 16, 2018 at 10:25 PM, Jeffy Chen  wrote:

It's hard to undo bus_set_iommu() in the error path, so move it to the
end of rk_iommu_probe().


Does this work fine now? I remember we used to need this called in an
early initcall for all the ARM/ARM64 DMA stuff to work.

yes, i think it works now, i saw there are some other iommu drivers also 
do this(arm-smmu-v3, mtk_iommu) :)



Best regards,
Tomasz






___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [PATCH v2 05/13] iommu/rockchip: Fix error handling in init

2018-01-16 Thread Tomasz Figa
On Tue, Jan 16, 2018 at 10:25 PM, Jeffy Chen  wrote:
> It's hard to undo bus_set_iommu() in the error path, so move it to the
> end of rk_iommu_probe().

Does this work fine now? I remember we used to need this called in an
early initcall for all the ARM/ARM64 DMA stuff to work.

Best regards,
Tomasz
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


[PATCH v2 05/13] iommu/rockchip: Fix error handling in init

2018-01-16 Thread Jeffy Chen
It's hard to undo bus_set_iommu() in the error path, so move it to the
end of rk_iommu_probe().

Signed-off-by: Jeffy Chen 
---

Changes in v2:
Move bus_set_iommu() to rk_iommu_probe().

 drivers/iommu/rockchip-iommu.c | 20 +++-
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
index bd8b32dc0db6..d2a0b0daf40d 100644
--- a/drivers/iommu/rockchip-iommu.c
+++ b/drivers/iommu/rockchip-iommu.c
@@ -1187,6 +1187,8 @@ static int rk_iommu_probe(struct platform_device *pdev)
return err;
}
 
+   bus_set_iommu(_bus_type, _iommu_ops);
+
return 0;
 }
 
@@ -1218,27 +1220,19 @@ static struct platform_driver rk_iommu_driver = {
 
 static int __init rk_iommu_init(void)
 {
-   struct device_node *np;
int ret;
 
-   np = of_find_matching_node(NULL, rk_iommu_dt_ids);
-   if (!np)
-   return 0;
-
-   of_node_put(np);
-
-   ret = bus_set_iommu(_bus_type, _iommu_ops);
-   if (ret)
-   return ret;
-
ret = platform_driver_register(_iommu_domain_driver);
if (ret)
return ret;
 
ret = platform_driver_register(_iommu_driver);
-   if (ret)
+   if (ret) {
platform_driver_unregister(_iommu_domain_driver);
-   return ret;
+   return ret;
+   }
+
+   return 0;
 }
 static void __exit rk_iommu_exit(void)
 {
-- 
2.11.0


___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu