* [PATCH v2] iommu/exynos: Fix driver initialization sequence
[not found] <CGME20221110154412eucas1p26182a3d691584b577ddced9a1287df60@eucas1p2.samsung.com>
@ 2022-11-10 15:44 ` Marek Szyprowski
2022-11-11 12:48 ` Sam Protsenko
2022-11-19 9:34 ` Joerg Roedel
0 siblings, 2 replies; 3+ messages in thread
From: Marek Szyprowski @ 2022-11-10 15:44 UTC (permalink / raw)
To: iommu, linux-samsung-soc
Cc: Marek Szyprowski, Joerg Roedel, Will Deacon, Krzysztof Kozlowski,
Alim Akhtar, Sam Protsenko
Registering a SYSMMU platform driver might directly trigger initializing
IOMMU domains and performing the initial mappings. Also the IOMMU core
might use the IOMMU hardware once it has been registered with
iommu_device_register() function. Ensure that all driver resources are
allocated and initialized before the driver advertise its presence to the
platform bus and the IOMMU subsystem.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
drivers/iommu/exynos-iommu.c | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index 45fd4850bacb..b0cde2211987 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -708,10 +708,6 @@ static int exynos_sysmmu_probe(struct platform_device *pdev)
if (ret)
return ret;
- ret = iommu_device_register(&data->iommu, &exynos_iommu_ops, dev);
- if (ret)
- goto err_iommu_register;
-
platform_set_drvdata(pdev, data);
if (PG_ENT_SHIFT < 0) {
@@ -743,11 +739,13 @@ static int exynos_sysmmu_probe(struct platform_device *pdev)
pm_runtime_enable(dev);
+ ret = iommu_device_register(&data->iommu, &exynos_iommu_ops, dev);
+ if (ret)
+ goto err_dma_set_mask;
+
return 0;
err_dma_set_mask:
- iommu_device_unregister(&data->iommu);
-err_iommu_register:
iommu_device_sysfs_remove(&data->iommu);
return ret;
}
@@ -1432,12 +1430,6 @@ static int __init exynos_iommu_init(void)
return -ENOMEM;
}
- ret = platform_driver_register(&exynos_sysmmu_driver);
- if (ret) {
- pr_err("%s: Failed to register driver\n", __func__);
- goto err_reg_driver;
- }
-
zero_lv2_table = kmem_cache_zalloc(lv2table_kmem_cache, GFP_KERNEL);
if (zero_lv2_table == NULL) {
pr_err("%s: Failed to allocate zero level2 page table\n",
@@ -1446,10 +1438,16 @@ static int __init exynos_iommu_init(void)
goto err_zero_lv2;
}
+ ret = platform_driver_register(&exynos_sysmmu_driver);
+ if (ret) {
+ pr_err("%s: Failed to register driver\n", __func__);
+ goto err_reg_driver;
+ }
+
return 0;
-err_zero_lv2:
- platform_driver_unregister(&exynos_sysmmu_driver);
err_reg_driver:
+ platform_driver_unregister(&exynos_sysmmu_driver);
+err_zero_lv2:
kmem_cache_destroy(lv2table_kmem_cache);
return ret;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] iommu/exynos: Fix driver initialization sequence
2022-11-10 15:44 ` [PATCH v2] iommu/exynos: Fix driver initialization sequence Marek Szyprowski
@ 2022-11-11 12:48 ` Sam Protsenko
2022-11-19 9:34 ` Joerg Roedel
1 sibling, 0 replies; 3+ messages in thread
From: Sam Protsenko @ 2022-11-11 12:48 UTC (permalink / raw)
To: Marek Szyprowski
Cc: iommu, linux-samsung-soc, Joerg Roedel, Will Deacon,
Krzysztof Kozlowski, Alim Akhtar
On Thu, 10 Nov 2022 at 16:44, Marek Szyprowski <m.szyprowski@samsung.com> wrote:
>
> Registering a SYSMMU platform driver might directly trigger initializing
> IOMMU domains and performing the initial mappings. Also the IOMMU core
> might use the IOMMU hardware once it has been registered with
> iommu_device_register() function. Ensure that all driver resources are
> allocated and initialized before the driver advertise its presence to the
> platform bus and the IOMMU subsystem.
>
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
> drivers/iommu/exynos-iommu.c | 26 ++++++++++++--------------
> 1 file changed, 12 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
> index 45fd4850bacb..b0cde2211987 100644
> --- a/drivers/iommu/exynos-iommu.c
> +++ b/drivers/iommu/exynos-iommu.c
> @@ -708,10 +708,6 @@ static int exynos_sysmmu_probe(struct platform_device *pdev)
> if (ret)
> return ret;
>
> - ret = iommu_device_register(&data->iommu, &exynos_iommu_ops, dev);
> - if (ret)
> - goto err_iommu_register;
> -
> platform_set_drvdata(pdev, data);
>
> if (PG_ENT_SHIFT < 0) {
> @@ -743,11 +739,13 @@ static int exynos_sysmmu_probe(struct platform_device *pdev)
>
> pm_runtime_enable(dev);
>
> + ret = iommu_device_register(&data->iommu, &exynos_iommu_ops, dev);
> + if (ret)
> + goto err_dma_set_mask;
> +
> return 0;
>
> err_dma_set_mask:
> - iommu_device_unregister(&data->iommu);
> -err_iommu_register:
> iommu_device_sysfs_remove(&data->iommu);
> return ret;
> }
> @@ -1432,12 +1430,6 @@ static int __init exynos_iommu_init(void)
> return -ENOMEM;
> }
>
> - ret = platform_driver_register(&exynos_sysmmu_driver);
> - if (ret) {
> - pr_err("%s: Failed to register driver\n", __func__);
> - goto err_reg_driver;
> - }
> -
> zero_lv2_table = kmem_cache_zalloc(lv2table_kmem_cache, GFP_KERNEL);
> if (zero_lv2_table == NULL) {
> pr_err("%s: Failed to allocate zero level2 page table\n",
> @@ -1446,10 +1438,16 @@ static int __init exynos_iommu_init(void)
> goto err_zero_lv2;
> }
>
> + ret = platform_driver_register(&exynos_sysmmu_driver);
> + if (ret) {
> + pr_err("%s: Failed to register driver\n", __func__);
> + goto err_reg_driver;
> + }
> +
> return 0;
> -err_zero_lv2:
> - platform_driver_unregister(&exynos_sysmmu_driver);
> err_reg_driver:
> + platform_driver_unregister(&exynos_sysmmu_driver);
> +err_zero_lv2:
> kmem_cache_destroy(lv2table_kmem_cache);
> return ret;
> }
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] iommu/exynos: Fix driver initialization sequence
2022-11-10 15:44 ` [PATCH v2] iommu/exynos: Fix driver initialization sequence Marek Szyprowski
2022-11-11 12:48 ` Sam Protsenko
@ 2022-11-19 9:34 ` Joerg Roedel
1 sibling, 0 replies; 3+ messages in thread
From: Joerg Roedel @ 2022-11-19 9:34 UTC (permalink / raw)
To: Marek Szyprowski
Cc: iommu, linux-samsung-soc, Will Deacon, Krzysztof Kozlowski,
Alim Akhtar, Sam Protsenko
On Thu, Nov 10, 2022 at 04:44:07PM +0100, Marek Szyprowski wrote:
> Registering a SYSMMU platform driver might directly trigger initializing
> IOMMU domains and performing the initial mappings. Also the IOMMU core
> might use the IOMMU hardware once it has been registered with
> iommu_device_register() function. Ensure that all driver resources are
> allocated and initialized before the driver advertise its presence to the
> platform bus and the IOMMU subsystem.
>
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
> drivers/iommu/exynos-iommu.c | 26 ++++++++++++--------------
> 1 file changed, 12 insertions(+), 14 deletions(-)
Removed v1 and applied this instead, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-11-19 9:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20221110154412eucas1p26182a3d691584b577ddced9a1287df60@eucas1p2.samsung.com>
2022-11-10 15:44 ` [PATCH v2] iommu/exynos: Fix driver initialization sequence Marek Szyprowski
2022-11-11 12:48 ` Sam Protsenko
2022-11-19 9:34 ` Joerg Roedel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.