Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 2/7] dmaengine: lpc18xx-dmamux: Use managed DMA router registration
       [not found] <20261204121630.1720746-1-202300460064@mail.sdu.edu.cn>
@ 2026-12-04 12:16 ` Tian Xuechen
  2026-12-04 12:16 ` [PATCH v3 3/7] dmaengine: lpc32xx-dmamux: " Tian Xuechen
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Tian Xuechen @ 2026-12-04 12:16 UTC (permalink / raw)
  To: vkoul; +Cc: Frank.Li, dmaengine, vz, manabian, linux-arm-kernel

The DMA router remains in the OF registry after its device-managed
data is released. Use managed registration to remove the routing
entry before the router data is freed.

This issue was found by our static analysis tool under development.

Fixes: e5f4ae84be74 ("dmaengine: add driver for lpc18xx dmamux")
Cc: stable+noautosel@kernel.org # relies on new API
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
---
 drivers/dma/lpc18xx-dmamux.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/lpc18xx-dmamux.c b/drivers/dma/lpc18xx-dmamux.c
index d3ff52195..0c6758c53 100644
--- a/drivers/dma/lpc18xx-dmamux.c
+++ b/drivers/dma/lpc18xx-dmamux.c
@@ -166,8 +166,9 @@ static int lpc18xx_dmamux_probe(struct platform_device *pdev)
 	dmamux->dmarouter.dev = &pdev->dev;
 	dmamux->dmarouter.route_free = lpc18xx_dmamux_free;
 
-	return of_dma_router_register(np, lpc18xx_dmamux_reserve,
-				      &dmamux->dmarouter);
+	return devm_of_dma_router_register(&pdev->dev, np,
+					   lpc18xx_dmamux_reserve,
+					   &dmamux->dmarouter);
 }
 
 static const struct of_device_id lpc18xx_dmamux_match[] = {


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

* [PATCH v3 3/7] dmaengine: lpc32xx-dmamux: Use managed DMA router registration
       [not found] <20261204121630.1720746-1-202300460064@mail.sdu.edu.cn>
  2026-12-04 12:16 ` [PATCH v3 2/7] dmaengine: lpc18xx-dmamux: Use managed DMA router registration Tian Xuechen
@ 2026-12-04 12:16 ` Tian Xuechen
  2026-12-04 12:16 ` [PATCH v3 5/7] dmaengine: stm32: Disable manual bind and unbind Tian Xuechen
  2026-12-04 12:16 ` [PATCH v3 6/7] dmaengine: stm32-dmamux: Use managed DMA router registration Tian Xuechen
  3 siblings, 0 replies; 6+ messages in thread
From: Tian Xuechen @ 2026-12-04 12:16 UTC (permalink / raw)
  To: vkoul; +Cc: Frank.Li, dmaengine, vz, piotr.wojtaszczyk, linux-arm-kernel

The DMA router remains in the OF registry after its device-managed
data is released. Use managed registration to remove the routing
entry before the router data is freed.

This issue was found by our static analysis tool under development.

Fixes: 5d318b595982 ("dmaengine: Add dma router for pl08x in LPC32XX SoC")
Cc: stable+noautosel@kernel.org # relies on new API
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
---
 drivers/dma/lpc32xx-dmamux.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/lpc32xx-dmamux.c b/drivers/dma/lpc32xx-dmamux.c
index 33be71474..3218be8e8 100644
--- a/drivers/dma/lpc32xx-dmamux.c
+++ b/drivers/dma/lpc32xx-dmamux.c
@@ -180,8 +180,9 @@ static int lpc32xx_dmamux_probe(struct platform_device *pdev)
 	dmamux->dmarouter.dev = &pdev->dev;
 	dmamux->dmarouter.route_free = lpc32xx_dmamux_release;
 
-	return of_dma_router_register(np, lpc32xx_dmamux_reserve,
-				      &dmamux->dmarouter);
+	return devm_of_dma_router_register(&pdev->dev, np,
+					   lpc32xx_dmamux_reserve,
+					   &dmamux->dmarouter);
 }
 
 static const struct of_device_id lpc32xx_dmamux_match[] = {


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

* [PATCH v3 5/7] dmaengine: stm32: Disable manual bind and unbind
       [not found] <20261204121630.1720746-1-202300460064@mail.sdu.edu.cn>
  2026-12-04 12:16 ` [PATCH v3 2/7] dmaengine: lpc18xx-dmamux: Use managed DMA router registration Tian Xuechen
  2026-12-04 12:16 ` [PATCH v3 3/7] dmaengine: lpc32xx-dmamux: " Tian Xuechen
@ 2026-12-04 12:16 ` Tian Xuechen
  2026-12-04 17:56   ` Frank Li
  2026-12-04 12:16 ` [PATCH v3 6/7] dmaengine: stm32-dmamux: Use managed DMA router registration Tian Xuechen
  3 siblings, 1 reply; 6+ messages in thread
From: Tian Xuechen @ 2026-12-04 12:16 UTC (permalink / raw)
  To: vkoul
  Cc: Frank.Li, dmaengine, amelie.delaunay, mcoquelin.stm32,
	alexandre.torgue, cedric.madianga, pierre-yves.mordret,
	linux-stm32, linux-arm-kernel

STM32 DMAMUX routes peripheral requests to the STM32 DMA controller,
and STM32 DMA and MDMA channels can be chained. The three built-in
drivers are not designed to be unbound while those paths are in use.

Set suppress_bind_attrs on all three platform drivers to disable
manual bind and unbind through sysfs.

Suggested-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Link: https://lore.kernel.org/r/f2a156ee-55d4-4a00-ac75-bb51f1785a9d@foss.st.com
Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
---
 drivers/dma/stm32/stm32-dma.c    | 1 +
 drivers/dma/stm32/stm32-dmamux.c | 1 +
 drivers/dma/stm32/stm32-mdma.c   | 1 +
 3 files changed, 3 insertions(+)

diff --git a/drivers/dma/stm32/stm32-dma.c b/drivers/dma/stm32/stm32-dma.c
index 4688cebaf..f34e5e36f 100644
--- a/drivers/dma/stm32/stm32-dma.c
+++ b/drivers/dma/stm32/stm32-dma.c
@@ -1764,6 +1764,7 @@ static const struct dev_pm_ops stm32_dma_pm_ops = {
 static struct platform_driver stm32_dma_driver = {
 	.driver = {
 		.name = "stm32-dma",
+		.suppress_bind_attrs = true,
 		.of_match_table = stm32_dma_of_match,
 		.pm = &stm32_dma_pm_ops,
 	},
diff --git a/drivers/dma/stm32/stm32-dmamux.c b/drivers/dma/stm32/stm32-dmamux.c
index 57318715d..b3cacd57b 100644
--- a/drivers/dma/stm32/stm32-dmamux.c
+++ b/drivers/dma/stm32/stm32-dmamux.c
@@ -393,6 +393,7 @@ static struct platform_driver stm32_dmamux_driver = {
 	.probe	= stm32_dmamux_probe,
 	.driver = {
 		.name = "stm32-dmamux",
+		.suppress_bind_attrs = true,
 		.of_match_table = stm32_dmamux_match,
 		.pm = &stm32_dmamux_pm_ops,
 	},
diff --git a/drivers/dma/stm32/stm32-mdma.c b/drivers/dma/stm32/stm32-mdma.c
index 04639e4b5..e2e638a1f 100644
--- a/drivers/dma/stm32/stm32-mdma.c
+++ b/drivers/dma/stm32/stm32-mdma.c
@@ -1806,6 +1806,7 @@ static struct platform_driver stm32_mdma_driver = {
 	.probe = stm32_mdma_probe,
 	.driver = {
 		.name = "stm32-mdma",
+		.suppress_bind_attrs = true,
 		.of_match_table = stm32_mdma_of_match,
 		.pm = &stm32_mdma_pm_ops,
 	},


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

* [PATCH v3 6/7] dmaengine: stm32-dmamux: Use managed DMA router registration
       [not found] <20261204121630.1720746-1-202300460064@mail.sdu.edu.cn>
                   ` (2 preceding siblings ...)
  2026-12-04 12:16 ` [PATCH v3 5/7] dmaengine: stm32: Disable manual bind and unbind Tian Xuechen
@ 2026-12-04 12:16 ` Tian Xuechen
  2026-12-04 17:57   ` Frank Li
  3 siblings, 1 reply; 6+ messages in thread
From: Tian Xuechen @ 2026-12-04 12:16 UTC (permalink / raw)
  To: vkoul
  Cc: Frank.Li, dmaengine, amelie.delaunay, mcoquelin.stm32,
	alexandre.torgue, cedric.madianga, pierre-yves.mordret,
	linux-stm32, linux-arm-kernel

The STM32 DMAMUX registers an OF DMA router backed by managed driver
data. The router entry can outlive that data when the device is
detached.

Use devm_of_dma_router_register() to remove the entry before devres
releases the router data. Keep the probe error unwind for runtime PM
and clocks when registration fails.

Fixes: df7e762db5f6 ("dmaengine: Add STM32 DMAMUX driver")
Cc: stable+noautosel@kernel.org # relies on new API
Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
---
 drivers/dma/stm32/stm32-dmamux.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/stm32/stm32-dmamux.c b/drivers/dma/stm32/stm32-dmamux.c
index b3cacd57b..3cb9d4051 100644
--- a/drivers/dma/stm32/stm32-dmamux.c
+++ b/drivers/dma/stm32/stm32-dmamux.c
@@ -290,8 +290,9 @@ static int stm32_dmamux_probe(struct platform_device *pdev)
 
 	pm_runtime_put(&pdev->dev);
 
-	ret = of_dma_router_register(node, stm32_dmamux_route_allocate,
-				     &stm32_dmamux->dmarouter);
+	ret = devm_of_dma_router_register(&pdev->dev, node,
+					  stm32_dmamux_route_allocate,
+					  &stm32_dmamux->dmarouter);
 	if (ret)
 		goto pm_disable;
 


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

* Re: [PATCH v3 5/7] dmaengine: stm32: Disable manual bind and unbind
  2026-12-04 12:16 ` [PATCH v3 5/7] dmaengine: stm32: Disable manual bind and unbind Tian Xuechen
@ 2026-12-04 17:56   ` Frank Li
  0 siblings, 0 replies; 6+ messages in thread
From: Frank Li @ 2026-12-04 17:56 UTC (permalink / raw)
  To: Tian Xuechen
  Cc: vkoul, Frank.Li, dmaengine, amelie.delaunay, mcoquelin.stm32,
	alexandre.torgue, cedric.madianga, pierre-yves.mordret,
	linux-stm32, linux-arm-kernel

On Fri, Dec 04, 2026 at 08:16:28PM +0800, Tian Xuechen wrote:
> STM32 DMAMUX routes peripheral requests to the STM32 DMA controller,
> and STM32 DMA and MDMA channels can be chained. The three built-in
> drivers are not designed to be unbound while those paths are in use.
>
> Set suppress_bind_attrs on all three platform drivers to disable
> manual bind and unbind through sysfs.
>
> Suggested-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
> Link: https://lore.kernel.org/r/f2a156ee-55d4-4a00-ac75-bb51f1785a9d@foss.st.com
> Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
> ---

This difference purpose patch. You'd better send seperately.

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>  drivers/dma/stm32/stm32-dma.c    | 1 +
>  drivers/dma/stm32/stm32-dmamux.c | 1 +
>  drivers/dma/stm32/stm32-mdma.c   | 1 +
>  3 files changed, 3 insertions(+)
>
> diff --git a/drivers/dma/stm32/stm32-dma.c b/drivers/dma/stm32/stm32-dma.c
> index 4688cebaf..f34e5e36f 100644
> --- a/drivers/dma/stm32/stm32-dma.c
> +++ b/drivers/dma/stm32/stm32-dma.c
> @@ -1764,6 +1764,7 @@ static const struct dev_pm_ops stm32_dma_pm_ops = {
>  static struct platform_driver stm32_dma_driver = {
>  	.driver = {
>  		.name = "stm32-dma",
> +		.suppress_bind_attrs = true,
>  		.of_match_table = stm32_dma_of_match,
>  		.pm = &stm32_dma_pm_ops,
>  	},
> diff --git a/drivers/dma/stm32/stm32-dmamux.c b/drivers/dma/stm32/stm32-dmamux.c
> index 57318715d..b3cacd57b 100644
> --- a/drivers/dma/stm32/stm32-dmamux.c
> +++ b/drivers/dma/stm32/stm32-dmamux.c
> @@ -393,6 +393,7 @@ static struct platform_driver stm32_dmamux_driver = {
>  	.probe	= stm32_dmamux_probe,
>  	.driver = {
>  		.name = "stm32-dmamux",
> +		.suppress_bind_attrs = true,
>  		.of_match_table = stm32_dmamux_match,
>  		.pm = &stm32_dmamux_pm_ops,
>  	},
> diff --git a/drivers/dma/stm32/stm32-mdma.c b/drivers/dma/stm32/stm32-mdma.c
> index 04639e4b5..e2e638a1f 100644
> --- a/drivers/dma/stm32/stm32-mdma.c
> +++ b/drivers/dma/stm32/stm32-mdma.c
> @@ -1806,6 +1806,7 @@ static struct platform_driver stm32_mdma_driver = {
>  	.probe = stm32_mdma_probe,
>  	.driver = {
>  		.name = "stm32-mdma",
> +		.suppress_bind_attrs = true,
>  		.of_match_table = stm32_mdma_of_match,
>  		.pm = &stm32_mdma_pm_ops,
>  	},


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

* Re: [PATCH v3 6/7] dmaengine: stm32-dmamux: Use managed DMA router registration
  2026-12-04 12:16 ` [PATCH v3 6/7] dmaengine: stm32-dmamux: Use managed DMA router registration Tian Xuechen
@ 2026-12-04 17:57   ` Frank Li
  0 siblings, 0 replies; 6+ messages in thread
From: Frank Li @ 2026-12-04 17:57 UTC (permalink / raw)
  To: Tian Xuechen
  Cc: vkoul, Frank.Li, dmaengine, amelie.delaunay, mcoquelin.stm32,
	alexandre.torgue, cedric.madianga, pierre-yves.mordret,
	linux-stm32, linux-arm-kernel

On Fri, Dec 04, 2026 at 08:16:29PM +0800, Tian Xuechen wrote:
> The STM32 DMAMUX registers an OF DMA router backed by managed driver
> data. The router entry can outlive that data when the device is
> detached.
>
> Use devm_of_dma_router_register() to remove the entry before devres
> releases the router data. Keep the probe error unwind for runtime PM
> and clocks when registration fails.
>
> Fixes: df7e762db5f6 ("dmaengine: Add STM32 DMAMUX driver")
> Cc: stable+noautosel@kernel.org # relies on new API
> Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>  drivers/dma/stm32/stm32-dmamux.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma/stm32/stm32-dmamux.c b/drivers/dma/stm32/stm32-dmamux.c
> index b3cacd57b..3cb9d4051 100644
> --- a/drivers/dma/stm32/stm32-dmamux.c
> +++ b/drivers/dma/stm32/stm32-dmamux.c
> @@ -290,8 +290,9 @@ static int stm32_dmamux_probe(struct platform_device *pdev)
>
>  	pm_runtime_put(&pdev->dev);
>
> -	ret = of_dma_router_register(node, stm32_dmamux_route_allocate,
> -				     &stm32_dmamux->dmarouter);
> +	ret = devm_of_dma_router_register(&pdev->dev, node,
> +					  stm32_dmamux_route_allocate,
> +					  &stm32_dmamux->dmarouter);
>  	if (ret)
>  		goto pm_disable;
>


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

end of thread, other threads:[~2026-12-04 17:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20261204121630.1720746-1-202300460064@mail.sdu.edu.cn>
2026-12-04 12:16 ` [PATCH v3 2/7] dmaengine: lpc18xx-dmamux: Use managed DMA router registration Tian Xuechen
2026-12-04 12:16 ` [PATCH v3 3/7] dmaengine: lpc32xx-dmamux: " Tian Xuechen
2026-12-04 12:16 ` [PATCH v3 5/7] dmaengine: stm32: Disable manual bind and unbind Tian Xuechen
2026-12-04 17:56   ` Frank Li
2026-12-04 12:16 ` [PATCH v3 6/7] dmaengine: stm32-dmamux: Use managed DMA router registration Tian Xuechen
2026-12-04 17:57   ` Frank Li

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