From d3d5a4d165222306946b4b44bfb1d0d742f4fbe0 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Tue, 2 May 2023 15:15:17 +0800 Subject: [PATCH 1/3] TEST: dump_stack in __pm_runtime_set_status To know who is requesting runtime pm active. Signed-off-by: Bard Liao --- drivers/base/power/runtime.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 4545669cb9735a..5879487c520d65 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -92,6 +92,8 @@ static void update_pm_runtime_accounting(struct device *dev) static void __update_runtime_status(struct device *dev, enum rpm_status status) { + dev_info(dev, "%s status %d\n", __func__, status); + dump_stack(); update_pm_runtime_accounting(dev); dev->power.runtime_status = status; } @@ -1307,6 +1309,9 @@ int __pm_runtime_set_status(struct device *dev, unsigned int status) dev_err(dev, "runtime PM trying to activate child device %s but parent (%s) is not active\n", dev_name(dev), dev_name(parent)); + dev_err(dev, " status %d, parent runtime_status %d\n", + status, parent->power.runtime_status); + dump_stack(); error = -EBUSY; } else if (dev->power.runtime_status == RPM_SUSPENDED) { atomic_inc(&parent->power.child_count); From d52327f399bd0c12eb3bc7099880a01e85fe3ac7 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Thu, 4 May 2023 10:07:50 +0800 Subject: [PATCH 2/3] TEST: ASoC: rt711: add debug trace To double confirm rt711->first_hw_init is false when the error happens. Signed-off-by: Bard Liao --- sound/soc/codecs/rt711.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/soc/codecs/rt711.c b/sound/soc/codecs/rt711.c index af53cbcc7bf2dd..602442d3c0156d 100644 --- a/sound/soc/codecs/rt711.c +++ b/sound/soc/codecs/rt711.c @@ -1213,9 +1213,12 @@ int rt711_init(struct device *dev, struct regmap *sdw_regmap, int rt711_io_init(struct device *dev, struct sdw_slave *slave) { struct rt711_priv *rt711 = dev_get_drvdata(dev); + struct device *parent = dev->parent; rt711->disable_irq = false; + dev_info(dev, "bard: %s start hw_init %d first_hw_init %d parent %s rumtime_status %d\n", + __func__, rt711->hw_init, rt711->first_hw_init, dev_name(parent), parent->power.runtime_status); if (rt711->hw_init) return 0; @@ -1228,6 +1231,7 @@ int rt711_io_init(struct device *dev, struct sdw_slave *slave) * PM runtime is only enabled when a Slave reports as Attached */ if (!rt711->first_hw_init) { + /* set autosuspend parameters */ pm_runtime_set_autosuspend_delay(&slave->dev, 3000); pm_runtime_use_autosuspend(&slave->dev); From f6258724eb5baf61053af73c4d03036385538eff Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Thu, 4 May 2023 15:16:07 +0800 Subject: [PATCH 3/3] TEST: ASoC: soc-component: add a delay to reproduce the rpm issue snd_soc_pcm_component_pm_runtime_get will firstly resume sdw link which will make rt711 be attached and rt711_io_init will be called. Then, resume sdw-master-0 and rt711. Adding trace to make sure rt711 is resumed by snd_soc_pcm_component_pm_runtime_get. Signed-off-by: Bard Liao --- sound/soc/soc-component.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index ff25718ff2e887..d8387111f3407a 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -1234,6 +1234,8 @@ int snd_soc_pcm_component_pm_runtime_get(struct snd_soc_pcm_runtime *rtd, for_each_rtd_components(rtd, i, component) { int ret = pm_runtime_get_sync(component->dev); + dev_info(component->dev, "bard: %s i %d called pm_runtime_get_sync ret %d\n", + __func__, i, ret); if (ret < 0 && ret != -EACCES) { pm_runtime_put_noidle(component->dev); return soc_component_ret(component, ret);