Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [PATCH] dmaengine: jz4780: handle clock enable failures
@ 2026-11-29 12:53 Jiawen Liu
  2026-11-29 14:50 ` H. Nikolaus Schaller
  2026-11-29 19:10 ` Markus Elfring
  0 siblings, 2 replies; 3+ messages in thread
From: Jiawen Liu @ 2026-11-29 12:53 UTC (permalink / raw)
  To: Paul Cercueil, Vinod Koul; +Cc: Frank Li, linux-mips, dmaengine, linux-kernel

jz4780_dma_probe() ignores the result of clk_prepare_enable() and
continues to configure controller registers, request resources, and
register the DMA controller. A parent-clock failure can therefore publish
a controller without a successful clock activation. Later probe cleanup
can also attempt to disable a clock that was never enabled.

Propagate the activation error before touching the controller.

Fixes: d894fc6046fe ("dmaengine: jz4780: add driver for the Ingenic JZ4780 DMA controller")
Signed-off-by: Jiawen Liu <1298662399@qq.com>
---
 drivers/dma/dma-jz4780.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/dma-jz4780.c b/drivers/dma/dma-jz4780.c
index e610aba094188..c1438bf3336b0 100644
--- a/drivers/dma/dma-jz4780.c
+++ b/drivers/dma/dma-jz4780.c
@@ -902,7 +902,9 @@ static int jz4780_dma_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	clk_prepare_enable(jzdma->clk);
+	ret = clk_prepare_enable(jzdma->clk);
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to enable clock\n");
 
 	/* Property is optional, if it doesn't exist the value will remain 0. */
 	of_property_read_u32_index(dev->of_node, "ingenic,reserved-channels",
-- 
2.34.1


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

* Re: [PATCH] dmaengine: jz4780: handle clock enable failures
  2026-11-29 12:53 [PATCH] dmaengine: jz4780: handle clock enable failures Jiawen Liu
@ 2026-11-29 14:50 ` H. Nikolaus Schaller
  2026-11-29 19:10 ` Markus Elfring
  1 sibling, 0 replies; 3+ messages in thread
From: H. Nikolaus Schaller @ 2026-11-29 14:50 UTC (permalink / raw)
  To: Jiawen Liu
  Cc: Paul Cercueil, Vinod Koul, Frank Li, linux-mips, dmaengine,
	linux-kernel

Hi,

> Am 29.11.2026 um 13:53 schrieb Jiawen Liu <1298662399@qq.com>:
> 
> jz4780_dma_probe() ignores the result of clk_prepare_enable() and
> continues to configure controller registers, request resources, and
> register the DMA controller. A parent-clock failure can therefore publish
> a controller without a successful clock activation. Later probe cleanup
> can also attempt to disable a clock that was never enabled.
> 
> Propagate the activation error before touching the controller.
> 
> Fixes: d894fc6046fe ("dmaengine: jz4780: add driver for the Ingenic JZ4780 DMA controller")
> Signed-off-by: Jiawen Liu <1298662399@qq.com>
> ---
> drivers/dma/dma-jz4780.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/dma-jz4780.c b/drivers/dma/dma-jz4780.c
> index e610aba094188..c1438bf3336b0 100644
> --- a/drivers/dma/dma-jz4780.c
> +++ b/drivers/dma/dma-jz4780.c
> @@ -902,7 +902,9 @@ static int jz4780_dma_probe(struct platform_device *pdev)
> return ret;
> }
> 
> - clk_prepare_enable(jzdma->clk);
> + ret = clk_prepare_enable(jzdma->clk);
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to enable clock\n");
> 
> /* Property is optional, if it doesn't exist the value will remain 0. */
> of_property_read_u32_index(dev->of_node, "ingenic,reserved-channels",
> -- 
> 2.34.1
> 
> 

there seems to be a patch for a related problem from 2025:

https://linuxtesting.org/pipermail/lvc-project/2025-January/003978.html

It was acked by Paul but I could not find it upstream.

BR,
Nikolaus

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

* Re: [PATCH] dmaengine: jz4780: handle clock enable failures
  2026-11-29 12:53 [PATCH] dmaengine: jz4780: handle clock enable failures Jiawen Liu
  2026-11-29 14:50 ` H. Nikolaus Schaller
@ 2026-11-29 19:10 ` Markus Elfring
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2026-11-29 19:10 UTC (permalink / raw)
  To: Jiawen Liu, dmaengine, linux-mips, Paul Cercueil, Vinod Koul
  Cc: LKML, kernel-janitors, Andy Shevchenko, Christophe Jaillet,
	Fabio Estevam, Florian Fainelli, Frank Li, H. Nikolaus Schaller

> jz4780_dma_probe() ignores the result of clk_prepare_enable() and
> continues to configure controller registers, request resources, and
> register the DMA controller. A parent-clock failure can therefore publish
> a controller without a successful clock activation. Later probe cleanup
> can also attempt to disable a clock that was never enabled.
> 
> Propagate the activation error before touching the controller.

How do you think about to reuse the function “devm_clk_get_enabled”?
https://elixir.bootlin.com/linux/v7.4-rc2/source/include/linux/clk.h#L615-L632
https://elixir.bootlin.com/linux/v7.4-rc2/source/drivers/dma/dma-jz4780.c#L898-L905

Regards,
Markus

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

end of thread, other threads:[~2026-11-29 19:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 12:53 [PATCH] dmaengine: jz4780: handle clock enable failures Jiawen Liu
2026-11-29 14:50 ` H. Nikolaus Schaller
2026-11-29 19:10 ` Markus Elfring

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