dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] dmaengine: lpc: Manage DMA router registration
@ 2026-11-27 11:03 Tian Xuechen
  2026-11-27 11:03 ` [PATCH v2 1/3] dmaengine: of: Add managed " Tian Xuechen
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Tian Xuechen @ 2026-11-27 11:03 UTC (permalink / raw)
  To: vkoul
  Cc: Frank.Li, Frank.li, dmaengine, linux-kernel, vz,
	piotr.wojtaszczyk, manabian, robh, saravanak, devicetree,
	linux-arm-kernel

Add a managed OF DMA router registration helper and use it in the
LPC18xx and LPC32xx DMA mux drivers.

Changes in v2:
  - Add devm_of_dma_router_register(), as requested by Frank Li.
  - Use the helper in both drivers instead of adding remove callbacks.

Tian Xuechen (3):
  dmaengine: of: Add managed DMA router registration
  dmaengine: lpc18xx-dmamux: Use managed DMA router registration
  dmaengine: lpc32xx-dmamux: Use managed DMA router registration

 drivers/dma/lpc18xx-dmamux.c |  5 +++--
 drivers/dma/lpc32xx-dmamux.c |  5 +++--
 include/linux/of_dma.h       | 24 ++++++++++++++++++++++++
 3 files changed, 30 insertions(+), 4 deletions(-)


base-commit: 2e02fb103be058cf8b2fb24112a74a2715e090f0
-- 
2.43.0


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

* [PATCH v2 1/3] dmaengine: of: Add managed DMA router registration
  2026-11-27 11:03 [PATCH v2 0/3] dmaengine: lpc: Manage DMA router registration Tian Xuechen
@ 2026-11-27 11:03 ` Tian Xuechen
  2026-11-27 15:21   ` Frank Li
  2026-11-27 11:03 ` [PATCH v2 2/3] dmaengine: lpc18xx-dmamux: Use " Tian Xuechen
  2026-11-27 11:04 ` [PATCH v2 3/3] dmaengine: lpc32xx-dmamux: " Tian Xuechen
  2 siblings, 1 reply; 7+ messages in thread
From: Tian Xuechen @ 2026-11-27 11:03 UTC (permalink / raw)
  To: vkoul
  Cc: Frank.Li, Frank.li, dmaengine, linux-kernel, vz,
	piotr.wojtaszczyk, manabian, robh, saravanak, devicetree,
	linux-arm-kernel

Add devm_of_dma_router_register() to unregister a router when its
device is detached. Reuse the controller cleanup action, since routers
share the same OF registry. If registering the cleanup action fails,
remove the newly registered router immediately.

Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
---
Changes in v2:
  - Add the reusable managed router helper.

 include/linux/of_dma.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/include/linux/of_dma.h b/include/linux/of_dma.h
index 16b08234d03b..7f9198ea9627 100644
--- a/include/linux/of_dma.h
+++ b/include/linux/of_dma.h
@@ -64,6 +64,21 @@ extern int of_dma_router_register(struct device_node *np,
 		struct dma_router *dma_router);
 #define of_dma_router_free of_dma_controller_free
 
+static inline int
+devm_of_dma_router_register(struct device *dev, struct device_node *np,
+			    void *(*of_dma_route_allocate)
+			    (struct of_phandle_args *, struct of_dma *),
+			    struct dma_router *dma_router)
+{
+	int ret;
+
+	ret = of_dma_router_register(np, of_dma_route_allocate, dma_router);
+	if (ret)
+		return ret;
+
+	return devm_add_action_or_reset(dev, __of_dma_controller_free, np);
+}
+
 extern struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
 						     const char *name);
 extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
@@ -103,6 +118,15 @@ static inline int of_dma_router_register(struct device_node *np,
 
 #define of_dma_router_free of_dma_controller_free
 
+static inline int
+devm_of_dma_router_register(struct device *dev, struct device_node *np,
+			    void *(*of_dma_route_allocate)
+			    (struct of_phandle_args *, struct of_dma *),
+			    struct dma_router *dma_router)
+{
+	return -ENODEV;
+}
+
 static inline struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
 						     const char *name)
 {
-- 
2.43.0


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

* [PATCH v2 2/3] dmaengine: lpc18xx-dmamux: Use managed DMA router registration
  2026-11-27 11:03 [PATCH v2 0/3] dmaengine: lpc: Manage DMA router registration Tian Xuechen
  2026-11-27 11:03 ` [PATCH v2 1/3] dmaengine: of: Add managed " Tian Xuechen
@ 2026-11-27 11:03 ` Tian Xuechen
  2026-11-27 15:22   ` Frank Li
  2026-11-27 11:04 ` [PATCH v2 3/3] dmaengine: lpc32xx-dmamux: " Tian Xuechen
  2 siblings, 1 reply; 7+ messages in thread
From: Tian Xuechen @ 2026-11-27 11:03 UTC (permalink / raw)
  To: vkoul
  Cc: Frank.Li, Frank.li, dmaengine, linux-kernel, vz,
	piotr.wojtaszczyk, manabian, robh, saravanak, devicetree,
	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")

Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
---
Changes in v2:
  - Use devm_of_dma_router_register() instead of a remove callback.

 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 d3ff521951b8..0c6758c53a72 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[] = {
-- 
2.43.0


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

* [PATCH v2 3/3] dmaengine: lpc32xx-dmamux: Use managed DMA router registration
  2026-11-27 11:03 [PATCH v2 0/3] dmaengine: lpc: Manage DMA router registration Tian Xuechen
  2026-11-27 11:03 ` [PATCH v2 1/3] dmaengine: of: Add managed " Tian Xuechen
  2026-11-27 11:03 ` [PATCH v2 2/3] dmaengine: lpc18xx-dmamux: Use " Tian Xuechen
@ 2026-11-27 11:04 ` Tian Xuechen
  2026-11-27 15:22   ` Frank Li
  2 siblings, 1 reply; 7+ messages in thread
From: Tian Xuechen @ 2026-11-27 11:04 UTC (permalink / raw)
  To: vkoul
  Cc: Frank.Li, Frank.li, dmaengine, linux-kernel, vz,
	piotr.wojtaszczyk, manabian, robh, saravanak, devicetree,
	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")

Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
---
Changes in v2:
  - Use devm_of_dma_router_register() instead of a remove callback.

 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 33be714740dd..3218be8e8eae 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[] = {
-- 
2.43.0


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

* Re: [PATCH v2 1/3] dmaengine: of: Add managed DMA router registration
  2026-11-27 11:03 ` [PATCH v2 1/3] dmaengine: of: Add managed " Tian Xuechen
@ 2026-11-27 15:21   ` Frank Li
  0 siblings, 0 replies; 7+ messages in thread
From: Frank Li @ 2026-11-27 15:21 UTC (permalink / raw)
  To: Tian Xuechen
  Cc: vkoul, Frank.Li, dmaengine, linux-kernel, vz, piotr.wojtaszczyk,
	manabian, robh, saravanak, devicetree, linux-arm-kernel

On Fri, Nov 27, 2026 at 07:03:58PM +0800, Tian Xuechen wrote:
> Add devm_of_dma_router_register() to unregister a router when its
> device is detached. Reuse the controller cleanup action, since routers
> share the same OF registry. If registering the cleanup action fails,
> remove the newly registered router immediately.
>
> Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
> ---

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

> Changes in v2:
>   - Add the reusable managed router helper.
>
>  include/linux/of_dma.h | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>
> diff --git a/include/linux/of_dma.h b/include/linux/of_dma.h
> index 16b08234d03b..7f9198ea9627 100644
> --- a/include/linux/of_dma.h
> +++ b/include/linux/of_dma.h
> @@ -64,6 +64,21 @@ extern int of_dma_router_register(struct device_node *np,
>  		struct dma_router *dma_router);
>  #define of_dma_router_free of_dma_controller_free
>
> +static inline int
> +devm_of_dma_router_register(struct device *dev, struct device_node *np,
> +			    void *(*of_dma_route_allocate)
> +			    (struct of_phandle_args *, struct of_dma *),
> +			    struct dma_router *dma_router)
> +{
> +	int ret;
> +
> +	ret = of_dma_router_register(np, of_dma_route_allocate, dma_router);
> +	if (ret)
> +		return ret;
> +
> +	return devm_add_action_or_reset(dev, __of_dma_controller_free, np);
> +}
> +
>  extern struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
>  						     const char *name);
>  extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
> @@ -103,6 +118,15 @@ static inline int of_dma_router_register(struct device_node *np,
>
>  #define of_dma_router_free of_dma_controller_free
>
> +static inline int
> +devm_of_dma_router_register(struct device *dev, struct device_node *np,
> +			    void *(*of_dma_route_allocate)
> +			    (struct of_phandle_args *, struct of_dma *),
> +			    struct dma_router *dma_router)
> +{
> +	return -ENODEV;
> +}
> +
>  static inline struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
>  						     const char *name)
>  {
> --
> 2.43.0
>

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

* Re: [PATCH v2 2/3] dmaengine: lpc18xx-dmamux: Use managed DMA router registration
  2026-11-27 11:03 ` [PATCH v2 2/3] dmaengine: lpc18xx-dmamux: Use " Tian Xuechen
@ 2026-11-27 15:22   ` Frank Li
  0 siblings, 0 replies; 7+ messages in thread
From: Frank Li @ 2026-11-27 15:22 UTC (permalink / raw)
  To: Tian Xuechen
  Cc: vkoul, Frank.Li, dmaengine, linux-kernel, vz, piotr.wojtaszczyk,
	manabian, robh, saravanak, devicetree, linux-arm-kernel

On Fri, Nov 27, 2026 at 07:03:59PM +0800, Tian Xuechen wrote:
> 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")
>
> Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
> ---

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

> Changes in v2:
>   - Use devm_of_dma_router_register() instead of a remove callback.
>
>  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 d3ff521951b8..0c6758c53a72 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[] = {
> --
> 2.43.0
>

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

* Re: [PATCH v2 3/3] dmaengine: lpc32xx-dmamux: Use managed DMA router registration
  2026-11-27 11:04 ` [PATCH v2 3/3] dmaengine: lpc32xx-dmamux: " Tian Xuechen
@ 2026-11-27 15:22   ` Frank Li
  0 siblings, 0 replies; 7+ messages in thread
From: Frank Li @ 2026-11-27 15:22 UTC (permalink / raw)
  To: Tian Xuechen
  Cc: vkoul, Frank.Li, dmaengine, linux-kernel, vz, piotr.wojtaszczyk,
	manabian, robh, saravanak, devicetree, linux-arm-kernel

On Fri, Nov 27, 2026 at 07:04:00PM +0800, Tian Xuechen wrote:
> 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")
>
> Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
> ---

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

> Changes in v2:
>   - Use devm_of_dma_router_register() instead of a remove callback.
>
>  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 33be714740dd..3218be8e8eae 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[] = {
> --
> 2.43.0
>

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

end of thread, other threads:[~2026-11-27 15:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 11:03 [PATCH v2 0/3] dmaengine: lpc: Manage DMA router registration Tian Xuechen
2026-11-27 11:03 ` [PATCH v2 1/3] dmaengine: of: Add managed " Tian Xuechen
2026-11-27 15:21   ` Frank Li
2026-11-27 11:03 ` [PATCH v2 2/3] dmaengine: lpc18xx-dmamux: Use " Tian Xuechen
2026-11-27 15:22   ` Frank Li
2026-11-27 11:04 ` [PATCH v2 3/3] dmaengine: lpc32xx-dmamux: " Tian Xuechen
2026-11-27 15:22   ` Frank Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).