Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH] iommu/exynos: Disable runtime PM on registration failure
@ 2026-11-26  4:52 ` Zhiqi Zhang
  2026-11-26  7:52   ` Marek Szyprowski
                     ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Zhiqi Zhang @ 2026-11-26  4:52 UTC (permalink / raw)
  To: Marek Szyprowski, Joerg Roedel, Will Deacon
  Cc: Robin Murphy, Krzysztof Kozlowski, Peter Griffin, Alim Akhtar,
	Sam Protsenko, iommu, linux-arm-kernel, linux-samsung-soc,
	Zhiqi Zhang, stable

exynos_sysmmu_probe() enables runtime PM and then registers the SysMMU
with the IOMMU core. If iommu_device_register() fails, the error path
currently only removes the sysfs entry before returning.

That leaves runtime PM enabled for a device whose probe failed. The same
path can also leave dma_dev pointing at this SysMMU when it was the first
one to initialize the global DMA helper device, so later domain allocation
may use a device that never finished probing.

Add an unwind label for iommu_device_register() failures. Disable runtime
PM there, clear dma_dev if this probe set it, and then remove the sysfs
entry as before.

Found during static probe error-path review with help from OpenAI Codex.
The fix was build-tested with ARCH=arm exynos_defconfig and W=1 using an
arm-linux-gnueabihf GCC cross-compiler.

Fixes: bbc4d205d93f ("iommu/exynos: Fix driver initialization sequence")
Cc: stable@vger.kernel.org # 6.2+
Signed-off-by: Zhiqi Zhang <zhiqizhangg@gmail.com>
---
 drivers/iommu/exynos-iommu.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index 7c337ba96..18a536008 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -844,10 +844,14 @@ static int exynos_sysmmu_probe(struct platform_device *pdev)
 
 	ret = iommu_device_register(&data->iommu, &exynos_iommu_ops, dev);
 	if (ret)
-		goto err_dma_set_mask;
+		goto err_iommu_register;
 
 	return 0;
 
+err_iommu_register:
+	pm_runtime_disable(dev);
+	if (dma_dev == &pdev->dev)
+		dma_dev = NULL;
 err_dma_set_mask:
 	iommu_device_sysfs_remove(&data->iommu);
 	return ret;

base-commit: ebb7a8dc1e74c705daffe11c2faf38ec2628f838
-- 
2.54.0 (Apple Git-157)


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] iommu/exynos: Disable runtime PM on registration failure
  2026-11-26  4:52 ` [PATCH] iommu/exynos: Disable runtime PM on registration failure Zhiqi Zhang
@ 2026-11-26  7:52   ` Marek Szyprowski
  2026-11-27 13:50   ` Robin Murphy
  2026-11-30  9:45   ` Joerg Roedel
  2 siblings, 0 replies; 4+ messages in thread
From: Marek Szyprowski @ 2026-11-26  7:52 UTC (permalink / raw)
  To: Zhiqi Zhang, Joerg Roedel, Will Deacon
  Cc: Robin Murphy, Krzysztof Kozlowski, Peter Griffin, Alim Akhtar,
	Sam Protsenko, iommu, linux-arm-kernel, linux-samsung-soc, stable

On 26.11.2026 05:52, Zhiqi Zhang wrote:
> exynos_sysmmu_probe() enables runtime PM and then registers the SysMMU
> with the IOMMU core. If iommu_device_register() fails, the error path
> currently only removes the sysfs entry before returning.
>
> That leaves runtime PM enabled for a device whose probe failed. The same
> path can also leave dma_dev pointing at this SysMMU when it was the first
> one to initialize the global DMA helper device, so later domain allocation
> may use a device that never finished probing.
>
> Add an unwind label for iommu_device_register() failures. Disable runtime
> PM there, clear dma_dev if this probe set it, and then remove the sysfs
> entry as before.
>
> Found during static probe error-path review with help from OpenAI Codex.
> The fix was build-tested with ARCH=arm exynos_defconfig and W=1 using an
> arm-linux-gnueabihf GCC cross-compiler.
>
> Fixes: bbc4d205d93f ("iommu/exynos: Fix driver initialization sequence")
> Cc: stable@vger.kernel.org # 6.2+
> Signed-off-by: Zhiqi Zhang <zhiqizhangg@gmail.com>

In real world this doesn't happen, but anyway:

Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>


> ---
>  drivers/iommu/exynos-iommu.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
> index 7c337ba96..18a536008 100644
> --- a/drivers/iommu/exynos-iommu.c
> +++ b/drivers/iommu/exynos-iommu.c
> @@ -844,10 +844,14 @@ static int exynos_sysmmu_probe(struct platform_device *pdev)
>  
>  	ret = iommu_device_register(&data->iommu, &exynos_iommu_ops, dev);
>  	if (ret)
> -		goto err_dma_set_mask;
> +		goto err_iommu_register;
>  
>  	return 0;
>  
> +err_iommu_register:
> +	pm_runtime_disable(dev);
> +	if (dma_dev == &pdev->dev)
> +		dma_dev = NULL;
>  err_dma_set_mask:
>  	iommu_device_sysfs_remove(&data->iommu);
>  	return ret;
>
> base-commit: ebb7a8dc1e74c705daffe11c2faf38ec2628f838

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iommu/exynos: Disable runtime PM on registration failure
  2026-11-26  4:52 ` [PATCH] iommu/exynos: Disable runtime PM on registration failure Zhiqi Zhang
  2026-11-26  7:52   ` Marek Szyprowski
@ 2026-11-27 13:50   ` Robin Murphy
  2026-11-30  9:45   ` Joerg Roedel
  2 siblings, 0 replies; 4+ messages in thread
From: Robin Murphy @ 2026-11-27 13:50 UTC (permalink / raw)
  To: Zhiqi Zhang, Marek Szyprowski, Joerg Roedel, Will Deacon
  Cc: Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, Sam Protsenko,
	iommu, linux-arm-kernel, linux-samsung-soc, stable

On 26/11/2026 4:52 am, Zhiqi Zhang wrote:
> exynos_sysmmu_probe() enables runtime PM and then registers the SysMMU
> with the IOMMU core. If iommu_device_register() fails, the error path
> currently only removes the sysfs entry before returning.
> 
> That leaves runtime PM enabled for a device whose probe failed.

If that matters, then wouldn't the same theoretical reasoning also still 
apply to module removal after a successful probe?

> The same
> path can also leave dma_dev pointing at this SysMMU when it was the first
> one to initialize the global DMA helper device, so later domain allocation
> may use a device that never finished probing.
> 
> Add an unwind label for iommu_device_register() failures. Disable runtime
> PM there, clear dma_dev if this probe set it, and then remove the sysfs
> entry as before.
> 
> Found during static probe error-path review with help from OpenAI Codex.
> The fix was build-tested with ARCH=arm exynos_defconfig and W=1 using an
> arm-linux-gnueabihf GCC cross-compiler.
> 
> Fixes: bbc4d205d93f ("iommu/exynos: Fix driver initialization sequence")
> Cc: stable@vger.kernel.org # 6.2+
> Signed-off-by: Zhiqi Zhang <zhiqizhangg@gmail.com>
> ---
>   drivers/iommu/exynos-iommu.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
> index 7c337ba96..18a536008 100644
> --- a/drivers/iommu/exynos-iommu.c
> +++ b/drivers/iommu/exynos-iommu.c
> @@ -844,10 +844,14 @@ static int exynos_sysmmu_probe(struct platform_device *pdev)
>   
>   	ret = iommu_device_register(&data->iommu, &exynos_iommu_ops, dev);
>   	if (ret)
> -		goto err_dma_set_mask;
> +		goto err_iommu_register;
>   
>   	return 0;
>   
> +err_iommu_register:
> +	pm_runtime_disable(dev);
> +	if (dma_dev == &pdev->dev)
> +		dma_dev = NULL;

But what about other IOMMU instances that could have probed in parallel 
and already observed dma_dev to be set? Sure the existing code is not 
perfectly race-free to begin with, but this only makes the issue much 
more obviously worse.

Thanks,
Robin.

>   err_dma_set_mask:
>   	iommu_device_sysfs_remove(&data->iommu);
>   	return ret;
> 
> base-commit: ebb7a8dc1e74c705daffe11c2faf38ec2628f838


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iommu/exynos: Disable runtime PM on registration failure
  2026-11-26  4:52 ` [PATCH] iommu/exynos: Disable runtime PM on registration failure Zhiqi Zhang
  2026-11-26  7:52   ` Marek Szyprowski
  2026-11-27 13:50   ` Robin Murphy
@ 2026-11-30  9:45   ` Joerg Roedel
  2 siblings, 0 replies; 4+ messages in thread
From: Joerg Roedel @ 2026-11-30  9:45 UTC (permalink / raw)
  To: Zhiqi Zhang
  Cc: Marek Szyprowski, Will Deacon, Robin Murphy, Krzysztof Kozlowski,
	Peter Griffin, Alim Akhtar, Sam Protsenko, iommu,
	linux-arm-kernel, linux-samsung-soc, stable

Applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-30  9:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20261126045219eucas1p11712605a6aec839075da6ff9bc9dfe15@eucas1p1.samsung.com>
2026-11-26  4:52 ` [PATCH] iommu/exynos: Disable runtime PM on registration failure Zhiqi Zhang
2026-11-26  7:52   ` Marek Szyprowski
2026-11-27 13:50   ` Robin Murphy
2026-11-30  9:45   ` Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox