Skip to contentSkip to conversation

dmaengine: owl-dma: Handle clock enable failure in probe

PATCH In review Jiawen Liu 2 participants 2 messages Nov 29 – Nov 30

Subsystems (2)
lore
Share & tools
lore

Jiawen Liu

author
#0 lore raw

PATCH 1/1 dmaengine: owl-dma: Handle clock enable failure in probe

On S900, with firmware device links disabled, the CMU driver can unbind after owl_dma_probe() gets the DMA clock and before it prepares it. The clock framework can then return -ENXIO when preparing the retained clock.

Ignoring that error can expose DMA channels without the required clock. A later registration failure or device removal can also attempt an unmatched clock disable and unprepare, which can trigger clock warnings.

Check clk_prepare_enable() and return its error after freeing the descriptor pool. Keep clock teardown on the registration error paths, where clock setup has succeeded.

Verification covered
the probe and remove paths by source inspection, git diff --check, checkpatch, and an arm64 defconfig build of drivers/dma/owl-dma.o with CONFIG_OWL_DMA=y. Runtime and hardware reproduction were not performed.

Fixes 47e20577c24d ("dmaengine: Add Actions Semi Owl family S900 DMA driver")
---
 drivers/dma/owl-dma.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/dma/owl-dma.c +6 -3
index 31a6c6e01a750..c4032643c49ad 100644
@@ -1199,12 +1199,14 @@ static int owl_dma_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	clk_prepare_enable(od->clk);
+	ret = clk_prepare_enable(od->clk);
+	if (ret)
+		goto err_pool_free;
 
 	ret = dma_async_device_register(&od->dma);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to register DMA engine device\n");
-		goto err_pool_free;
+		goto err_clk_disable;
 	}
 
 	/* Device-tree DMA controller registration */
@@ -1219,8 +1221,9 @@ static int owl_dma_probe(struct platform_device *pdev)
 
 err_dma_unregister:
 	dma_async_device_unregister(&od->dma);
-err_pool_free:
+err_clk_disable:
 	clk_disable_unprepare(od->clk);
+err_pool_free:
 	dma_pool_destroy(od->lli_pool);
 
 	return ret;
Signature · 1 line
2.34.1
#1 lore raw
Quoted 17 lines · Jiawen Liu

On S900, with firmware device links disabled, the CMU driver can unbind after owl_dma_probe() gets the DMA clock and before it prepares it. The clock framework can then return -ENXIO when preparing the retained clock.

Ignoring that error can expose DMA channels without the required clock. A later registration failure or device removal can also attempt an unmatched clock disable and unprepare, which can trigger clock warnings.

Check clk_prepare_enable() and return its error after freeing the descriptor pool. Keep clock teardown on the registration error paths, where clock setup has succeeded.

Verification covered
the probe and remove paths by source inspection, git diff --check, checkpatch, and an arm64 defconfig build of drivers/dma/owl-dma.o with CONFIG_OWL_DMA=y. Runtime and hardware reproduction were not performed.

Quoted 6 lines
Fixes 47e20577c24d ("dmaengine: Add Actions Semi Owl family S900 DMA driver")
---
 drivers/dma/owl-dma.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

You sent multiple independent patches, to multiple independent subsystems. The amount of these patches clearly suggest this was AI generated and most likely not tested.

More importantly, you sent all this work without properly organizing relevant patches into patchsets. This makes reviewing difficult and might cause multiple reviewers to address the same issue. Replying to the entire set is impossible and requires handling each patch independently, instead of applying or discarding the set. Maintainers also won't see the bigger picture of your work. Quite worrying.

Please read kernel documentation BEFORE posting more work. It will explain you how to identify subsystems, how to organize your work per subsystem (so a patchset grouping multiple patches with a short cover letter), how to document the issue discovery method and what was or was not tested.

Best regards,
Krzysztof