From 279c855bce8f842d8220d40f4887eb43f6365bfe Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Thu, 6 Jul 2023 15:05:27 +0800 Subject: [PATCH] ASoC: max98363: set first_hw_init = true before pm_runtime_get_noresume max98363_resume() will return 0 directly if max98363->first_hw_init is false. This test is to make sure max98363_resume won't do anything before the codec is attached. However, max98363_io_init called pm_runtime_get_noresume before setting max98363->first_hw_init = true, as a result, max98363_resume() will return directly and doesn't do regcache_sync(). regcache_sync() is required in a corner case when pcm starts before the codec is attached. Signed-off-by: Bard Liao --- sound/soc/codecs/max98363.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/max98363.c b/sound/soc/codecs/max98363.c index 9e3873e56e6d9c..a21f3637abc0ce 100644 --- a/sound/soc/codecs/max98363.c +++ b/sound/soc/codecs/max98363.c @@ -158,11 +158,14 @@ static int max98363_io_init(struct sdw_slave *slave) { struct device *dev = &slave->dev; struct max98363_priv *max98363 = dev_get_drvdata(dev); + bool cache_bypass = false; int ret, reg; regcache_cache_only(max98363->regmap, false); - if (max98363->first_hw_init) + if (max98363->first_hw_init) { regcache_cache_bypass(max98363->regmap, true); + cache_bypass = true; + } /* * PM runtime status is marked as 'active' only when a Slave reports as Attached @@ -171,6 +174,7 @@ static int max98363_io_init(struct sdw_slave *slave) /* update count of parent 'active' children */ pm_runtime_set_active(dev); + max98363->first_hw_init = true; pm_runtime_get_noresume(dev); ret = regmap_read(max98363->regmap, MAX98363_R21FF_REV_ID, ®); @@ -179,12 +183,11 @@ static int max98363_io_init(struct sdw_slave *slave) return ret; } - if (max98363->first_hw_init) { + if (cache_bypass) { regcache_cache_bypass(max98363->regmap, false); regcache_mark_dirty(max98363->regmap); } - max98363->first_hw_init = true; max98363->hw_init = true; pm_runtime_mark_last_busy(dev);