* [PATCH 1/3] dmaengine: stm32-dmamux: Unregister the DMA router on removal
2026-11-27 11:33 [PATCH 0/3] dmaengine: stm32: Pair DMA provider registration with cleanup Tian Xuechen
@ 2026-11-27 11:33 ` Tian Xuechen
2026-11-27 15:15 ` Frank Li
2026-11-27 11:33 ` [PATCH 2/3] dmaengine: stm32-dma: Unregister the OF controller and DMA device Tian Xuechen
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Tian Xuechen @ 2026-11-27 11:33 UTC (permalink / raw)
To: amelie.delaunay, vkoul, mcoquelin.stm32, alexandre.torgue,
cedric.madianga, pierre-yves.mordret
Cc: Frank.Li, dmaengine, linux-stm32, linux-arm-kernel
From: Tian Xuechen <202300460064@mail.sdu.edu.cn>
The DMA router remains in the OF registry after its device-managed
data is released. Remove the routing entry when the device is
unbound.
This issue was found by our static analysis tool under development.
Fixes: df7e762db5f6 ("dmaengine: Add STM32 DMAMUX driver")
Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
---
drivers/dma/stm32/stm32-dmamux.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/dma/stm32/stm32-dmamux.c b/drivers/dma/stm32/stm32-dmamux.c
index 57318715d9f3..6f49d78bfe3d 100644
--- a/drivers/dma/stm32/stm32-dmamux.c
+++ b/drivers/dma/stm32/stm32-dmamux.c
@@ -389,8 +389,14 @@ static const struct of_device_id stm32_dmamux_match[] = {
{},
};
+static void stm32_dmamux_remove(struct platform_device *pdev)
+{
+ of_dma_router_free(pdev->dev.of_node);
+}
+
static struct platform_driver stm32_dmamux_driver = {
.probe = stm32_dmamux_probe,
+ .remove = stm32_dmamux_remove,
.driver = {
.name = "stm32-dmamux",
.of_match_table = stm32_dmamux_match,
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 1/3] dmaengine: stm32-dmamux: Unregister the DMA router on removal
2026-11-27 11:33 ` [PATCH 1/3] dmaengine: stm32-dmamux: Unregister the DMA router on removal Tian Xuechen
@ 2026-11-27 15:15 ` Frank Li
0 siblings, 0 replies; 7+ messages in thread
From: Frank Li @ 2026-11-27 15:15 UTC (permalink / raw)
To: Tian Xuechen
Cc: amelie.delaunay, vkoul, mcoquelin.stm32, alexandre.torgue,
cedric.madianga, pierre-yves.mordret, Frank.Li, dmaengine,
linux-stm32, linux-arm-kernel
On Fri, Nov 27, 2026 at 07:33:30PM +0800, Tian Xuechen wrote:
> From: Tian Xuechen <202300460064@mail.sdu.edu.cn>
>
> The DMA router remains in the OF registry after its device-managed
> data is released. Remove the routing entry when the device is
> unbound.
>
> This issue was found by our static analysis tool under development.
>
> Fixes: df7e762db5f6 ("dmaengine: Add STM32 DMAMUX driver")
> Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
> ---
> drivers/dma/stm32/stm32-dmamux.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/dma/stm32/stm32-dmamux.c b/drivers/dma/stm32/stm32-dmamux.c
> index 57318715d9f3..6f49d78bfe3d 100644
> --- a/drivers/dma/stm32/stm32-dmamux.c
> +++ b/drivers/dma/stm32/stm32-dmamux.c
> @@ -389,8 +389,14 @@ static const struct of_device_id stm32_dmamux_match[] = {
> {},
> };
>
> +static void stm32_dmamux_remove(struct platform_device *pdev)
> +{
> + of_dma_router_free(pdev->dev.of_node);
> +}
> +
Add dev manage API for router_register()
Frank
> static struct platform_driver stm32_dmamux_driver = {
> .probe = stm32_dmamux_probe,
> + .remove = stm32_dmamux_remove,
> .driver = {
> .name = "stm32-dmamux",
> .of_match_table = stm32_dmamux_match,
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/3] dmaengine: stm32-dma: Unregister the OF controller and DMA device
2026-11-27 11:33 [PATCH 0/3] dmaengine: stm32: Pair DMA provider registration with cleanup Tian Xuechen
2026-11-27 11:33 ` [PATCH 1/3] dmaengine: stm32-dmamux: Unregister the DMA router on removal Tian Xuechen
@ 2026-11-27 11:33 ` Tian Xuechen
2026-11-27 15:14 ` Frank Li
2026-11-27 11:33 ` [PATCH 3/3] dmaengine: stm32-mdma: Use managed OF DMA controller registration Tian Xuechen
2026-11-27 14:48 ` [PATCH 0/3] dmaengine: stm32: Pair DMA provider registration with cleanup Amelie Delaunay
3 siblings, 1 reply; 7+ messages in thread
From: Tian Xuechen @ 2026-11-27 11:33 UTC (permalink / raw)
To: amelie.delaunay, vkoul, mcoquelin.stm32, alexandre.torgue,
cedric.madianga, pierre-yves.mordret
Cc: Frank.Li, dmaengine, linux-stm32, linux-arm-kernel
From: Tian Xuechen <202300460064@mail.sdu.edu.cn>
The OF controller and DMA engine remain registered after the driver
releases its channel data. Unregister both in reverse order when the
device is removed.
This issue was found by our static analysis tool under development.
Fixes: d8b468394fb7 ("dmaengine: Add STM32 DMA driver")
Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
---
drivers/dma/stm32/stm32-dma.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/dma/stm32/stm32-dma.c b/drivers/dma/stm32/stm32-dma.c
index ba8121d37f51..6392c15b4317 100644
--- a/drivers/dma/stm32/stm32-dma.c
+++ b/drivers/dma/stm32/stm32-dma.c
@@ -1761,6 +1761,14 @@ static const struct dev_pm_ops stm32_dma_pm_ops = {
stm32_dma_runtime_resume, NULL)
};
+static void stm32_dma_remove(struct platform_device *pdev)
+{
+ struct stm32_dma_device *dmadev = platform_get_drvdata(pdev);
+
+ of_dma_controller_free(pdev->dev.of_node);
+ dma_async_device_unregister(&dmadev->ddev);
+}
+
static struct platform_driver stm32_dma_driver = {
.driver = {
.name = "stm32-dma",
@@ -1768,6 +1776,7 @@ static struct platform_driver stm32_dma_driver = {
.pm = &stm32_dma_pm_ops,
},
.probe = stm32_dma_probe,
+ .remove = stm32_dma_remove,
};
static int __init stm32_dma_init(void)
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 2/3] dmaengine: stm32-dma: Unregister the OF controller and DMA device
2026-11-27 11:33 ` [PATCH 2/3] dmaengine: stm32-dma: Unregister the OF controller and DMA device Tian Xuechen
@ 2026-11-27 15:14 ` Frank Li
0 siblings, 0 replies; 7+ messages in thread
From: Frank Li @ 2026-11-27 15:14 UTC (permalink / raw)
To: Tian Xuechen
Cc: amelie.delaunay, vkoul, mcoquelin.stm32, alexandre.torgue,
cedric.madianga, pierre-yves.mordret, Frank.Li, dmaengine,
linux-stm32, linux-arm-kernel
On Fri, Nov 27, 2026 at 07:33:31PM +0800, Tian Xuechen wrote:
> From: Tian Xuechen <202300460064@mail.sdu.edu.cn>
>
> The OF controller and DMA engine remain registered after the driver
> releases its channel data. Unregister both in reverse order when the
> device is removed.
>
> This issue was found by our static analysis tool under development.
>
> Fixes: d8b468394fb7 ("dmaengine: Add STM32 DMA driver")
> Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
> ---
> drivers/dma/stm32/stm32-dma.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/dma/stm32/stm32-dma.c b/drivers/dma/stm32/stm32-dma.c
> index ba8121d37f51..6392c15b4317 100644
> --- a/drivers/dma/stm32/stm32-dma.c
> +++ b/drivers/dma/stm32/stm32-dma.c
> @@ -1761,6 +1761,14 @@ static const struct dev_pm_ops stm32_dma_pm_ops = {
> stm32_dma_runtime_resume, NULL)
> };
>
> +static void stm32_dma_remove(struct platform_device *pdev)
> +{
> + struct stm32_dma_device *dmadev = platform_get_drvdata(pdev);
> +
> + of_dma_controller_free(pdev->dev.of_node);
> + dma_async_device_unregister(&dmadev->ddev);
> +}
> +
Please use manange APIs to fix this problem
Frank
> static struct platform_driver stm32_dma_driver = {
> .driver = {
> .name = "stm32-dma",
> @@ -1768,6 +1776,7 @@ static struct platform_driver stm32_dma_driver = {
> .pm = &stm32_dma_pm_ops,
> },
> .probe = stm32_dma_probe,
> + .remove = stm32_dma_remove,
> };
>
> static int __init stm32_dma_init(void)
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/3] dmaengine: stm32-mdma: Use managed OF DMA controller registration
2026-11-27 11:33 [PATCH 0/3] dmaengine: stm32: Pair DMA provider registration with cleanup Tian Xuechen
2026-11-27 11:33 ` [PATCH 1/3] dmaengine: stm32-dmamux: Unregister the DMA router on removal Tian Xuechen
2026-11-27 11:33 ` [PATCH 2/3] dmaengine: stm32-dma: Unregister the OF controller and DMA device Tian Xuechen
@ 2026-11-27 11:33 ` Tian Xuechen
2026-11-27 14:48 ` [PATCH 0/3] dmaengine: stm32: Pair DMA provider registration with cleanup Amelie Delaunay
3 siblings, 0 replies; 7+ messages in thread
From: Tian Xuechen @ 2026-11-27 11:33 UTC (permalink / raw)
To: amelie.delaunay, vkoul, mcoquelin.stm32, alexandre.torgue,
cedric.madianga, pierre-yves.mordret
Cc: Frank.Li, dmaengine, linux-stm32, linux-arm-kernel
From: Tian Xuechen <202300460064@mail.sdu.edu.cn>
The OF controller outlives the managed DMA engine and its channel
data on removal. Use the managed registration helper to withdraw the
OF controller first.
This issue was found by our static analysis tool under development.
Fixes: a4ffb13c8946 ("dmaengine: Add STM32 MDMA driver")
Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
---
drivers/dma/stm32/stm32-mdma.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/stm32/stm32-mdma.c b/drivers/dma/stm32/stm32-mdma.c
index 4851c1c7ce0c..c95a9bb1171b 100644
--- a/drivers/dma/stm32/stm32-mdma.c
+++ b/drivers/dma/stm32/stm32-mdma.c
@@ -1714,7 +1714,8 @@ static int stm32_mdma_probe(struct platform_device *pdev)
if (ret)
goto err_clk;
- ret = of_dma_controller_register(of_node, stm32_mdma_of_xlate, dmadev);
+ ret = devm_of_dma_controller_register(&pdev->dev, of_node,
+ stm32_mdma_of_xlate, dmadev);
if (ret < 0) {
dev_err(&pdev->dev,
"STM32 MDMA DMA OF registration failed %d\n", ret);
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 0/3] dmaengine: stm32: Pair DMA provider registration with cleanup
2026-11-27 11:33 [PATCH 0/3] dmaengine: stm32: Pair DMA provider registration with cleanup Tian Xuechen
` (2 preceding siblings ...)
2026-11-27 11:33 ` [PATCH 3/3] dmaengine: stm32-mdma: Use managed OF DMA controller registration Tian Xuechen
@ 2026-11-27 14:48 ` Amelie Delaunay
3 siblings, 0 replies; 7+ messages in thread
From: Amelie Delaunay @ 2026-11-27 14:48 UTC (permalink / raw)
To: Tian Xuechen, vkoul, mcoquelin.stm32, alexandre.torgue,
cedric.madianga, pierre-yves.mordret
Cc: Frank.Li, dmaengine, linux-stm32, linux-arm-kernel
Hi,
On 11/27/26 12:33, Tian Xuechen wrote:
> From: Tian Xuechen <202300460064@mail.sdu.edu.cn>
>
> Unregister the STM32 DMA mux, DMA and MDMA providers when their devices
> are removed.
>
> Tian Xuechen (3):
> dmaengine: stm32-dmamux: Unregister the DMA router on removal
> dmaengine: stm32-dma: Unregister the OF controller and DMA device
> dmaengine: stm32-mdma: Use managed OF DMA controller registration
>
> base-commit: 4dce97c6c265544342e716e62fd24bbb232590c5
These built-in drivers are not intended to be unbound at runtime.
STM32 DMAMUX routes peripherals DMA requests to STM32 DMA, and STM32 DMA
and MDMA channels may also be chained.
Rather than adding partial removal support, I think we should set
".suppress_bind_attrs = true" for stm32_dmamux_driver, stm32_dma_driver
and stm32_mdma_driver to prevent manual bind/unbind through sysfs.
Regards,
Amelie
^ permalink raw reply [flat|nested] 7+ messages in thread