Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH v2 1/2] ASoC: rockchip: rockchip_sai: Fix unbalanced clock reference count when CONFIG_PM=n
@ 2026-07-22 11:52 phucduc.bui
  2026-07-22 11:52 ` [PATCH v2 2/2] ASoC: rockchip: rockchip_sai: Fix runtime PM state after manual resume phucduc.bui
  0 siblings, 1 reply; 2+ messages in thread
From: phucduc.bui @ 2026-07-22 11:52 UTC (permalink / raw)
  To: Nicolas Frattaroli, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Heiko Stuebner
  Cc: linux-rockchip, linux-sound, linux-arm-kernel, linux-kernel,
	bui duc phuc

From: bui duc phuc <phucduc.bui@gmail.com>

When CONFIG_PM is disabled, Runtime PM callbacks are stubbed out. Using
devm_clk_get_enabled() causes an unbalanced clk_disable_unprepare() upon
driver unbind, as devm cleanup attempts to disable the clock a second
time after manual disabling, triggering clock framework warnings.
Replace devm_clk_get_enabled() with devm_clk_get() and manually manage
hclk enablement around probe register accesses to keep clock reference
counts balanced regardless of CONFIG_PM.

Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---

Link v1: 
https://lore.kernel.org/all/20260622005613.21870-1-phucduc.bui@gmail.com/

Changes in v2:
 - Update the commit message.

 sound/soc/rockchip/rockchip_sai.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/sound/soc/rockchip/rockchip_sai.c b/sound/soc/rockchip/rockchip_sai.c
index 585e89f61f0d..9a80e120dbda 100644
--- a/sound/soc/rockchip/rockchip_sai.c
+++ b/sound/soc/rockchip/rockchip_sai.c
@@ -1443,20 +1443,30 @@ static int rockchip_sai_probe(struct platform_device *pdev)
 		return dev_err_probe(&pdev->dev, PTR_ERR(sai->mclk),
 				     "Failed to get mclk\n");
 
-	sai->hclk = devm_clk_get_enabled(&pdev->dev, "hclk");
+	sai->hclk = devm_clk_get(&pdev->dev, "hclk");
 	if (IS_ERR(sai->hclk))
 		return dev_err_probe(&pdev->dev, PTR_ERR(sai->hclk),
 				     "Failed to get hclk\n");
 
+	ret = clk_prepare_enable(sai->hclk);
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "Failed to enable hclk\n");
+
 	regmap_read(sai->regmap, SAI_VERSION, &sai->version);
 
 	ret = rockchip_sai_init_dai(sai, res, &dai);
-	if (ret)
-		return dev_err_probe(&pdev->dev, ret, "Failed to initialize DAI\n");
+	if (ret) {
+		ret = dev_err_probe(&pdev->dev, ret, "Failed to initialize DAI\n");
+		goto err_disable_hclk;
+	}
 
 	ret = rockchip_sai_parse_paths(sai, node);
-	if (ret)
-		return dev_err_probe(&pdev->dev, ret, "Failed to parse paths\n");
+	if (ret) {
+		ret = dev_err_probe(&pdev->dev, ret, "Failed to parse paths\n");
+		goto err_disable_hclk;
+	}
+
+	clk_disable_unprepare(sai->hclk);
 
 	/*
 	 * From here on, all register accesses need to be wrapped in
@@ -1487,8 +1497,6 @@ static int rockchip_sai_probe(struct platform_device *pdev)
 	pm_runtime_use_autosuspend(&pdev->dev);
 	pm_runtime_put(&pdev->dev);
 
-	clk_disable_unprepare(sai->hclk);
-
 	return 0;
 
 err_runtime_suspend:
@@ -1498,6 +1506,11 @@ static int rockchip_sai_probe(struct platform_device *pdev)
 		rockchip_sai_runtime_suspend(&pdev->dev);
 
 	return ret;
+
+err_disable_hclk:
+	clk_disable_unprepare(sai->hclk);
+
+	return ret;
 }
 
 static void rockchip_sai_remove(struct platform_device *pdev)
-- 
2.43.0


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

end of thread, other threads:[~2026-07-22 11:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-22 11:52 [PATCH v2 1/2] ASoC: rockchip: rockchip_sai: Fix unbalanced clock reference count when CONFIG_PM=n phucduc.bui
2026-07-22 11:52 ` [PATCH v2 2/2] ASoC: rockchip: rockchip_sai: Fix runtime PM state after manual resume phucduc.bui

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