From 08f416da209fad3a103469b975a853f25eda25e0 Mon Sep 17 00:00:00 2001 From: Sugar Zhang Date: Fri, 11 Aug 2023 16:10:36 +0800 Subject: [PATCH] ASoC: rockchip: i2s: Fix register access in probe MUST: after pm_runtime_enable step, any register R/W should be wrapped with pm_runtime_get_sync/put. Another approach is to enable the regcache true to avoid access HW registers. Alternatively, performing the registers R/W before pm_runtime_enable is also a good option. Signed-off-by: Sugar Zhang Change-Id: I9c495361fcb7fb0a06fe1538d05b94617e332756 --- sound/soc/rockchip/rockchip_i2s.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c index aff6cbf7fc95..6a02002d020f 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -897,6 +897,20 @@ static int rockchip_i2s_probe(struct platform_device *pdev) return ret; } + ret = rockchip_i2s_init_dai(i2s, res, &dai); + if (ret) + goto err_clk; + + /* + * MUST: after pm_runtime_enable step, any register R/W + * should be wrapped with pm_runtime_get_sync/put. + * + * Another approach is to enable the regcache true to + * avoid access HW registers. + * + * Alternatively, performing the registers R/W before + * pm_runtime_enable is also a good option. + */ pm_runtime_enable(&pdev->dev); if (!pm_runtime_enabled(&pdev->dev)) { ret = i2s_runtime_resume(&pdev->dev); @@ -904,10 +918,6 @@ static int rockchip_i2s_probe(struct platform_device *pdev) goto err_pm_disable; } - ret = rockchip_i2s_init_dai(i2s, res, &dai); - if (ret) - goto err_pm_disable; - ret = devm_snd_soc_register_component(&pdev->dev, &rockchip_i2s_component, dai, 1); @@ -935,7 +945,7 @@ err_suspend: i2s_runtime_suspend(&pdev->dev); err_pm_disable: pm_runtime_disable(&pdev->dev); - +err_clk: clk_disable_unprepare(i2s->hclk); return ret;