From f8a6ea73884dd5aadd827127b35ab56015e1e704 Mon Sep 17 00:00:00 2001 From: Sugar Zhang Date: Fri, 11 Aug 2023 16:10:31 +0800 Subject: [PATCH] ASoC: rockchip: sai: 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: Ife9b1a0e6f75e714bfb6e7c0d472e4603fa8cd8f --- sound/soc/rockchip/rockchip_sai.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/sound/soc/rockchip/rockchip_sai.c b/sound/soc/rockchip/rockchip_sai.c index 8c43150dd151..0e0f3b78b366 100644 --- a/sound/soc/rockchip/rockchip_sai.c +++ b/sound/soc/rockchip/rockchip_sai.c @@ -1398,6 +1398,20 @@ static int rockchip_sai_probe(struct platform_device *pdev) if (ret) return ret; + ret = rockchip_sai_init_dai(sai, res, &dai); + if (ret) + return ret; + + /* + * 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 = rockchip_sai_runtime_resume(&pdev->dev); @@ -1405,10 +1419,6 @@ static int rockchip_sai_probe(struct platform_device *pdev) goto err_runtime_disable; } - ret = rockchip_sai_init_dai(sai, res, &dai); - if (ret) - goto err_runtime_suspend; - ret = devm_snd_soc_register_component(&pdev->dev, &rockchip_sai_component, dai, 1);