* [PATCH 0/2] ASoC: tas2552: Fix runtime PM and supply refcounting
@ 2026-12-01 19:24 Arina Kharlamova via B4 Relay
2026-12-01 19:24 ` [PATCH 1/2] ASoC: tas2552: Fix runtime PM usage count underflow in probe Arina Kharlamova via B4 Relay
2026-12-01 19:24 ` [PATCH 2/2] ASoC: tas2552: Disable supplies on component remove Arina Kharlamova via B4 Relay
0 siblings, 2 replies; 4+ messages in thread
From: Arina Kharlamova via B4 Relay @ 2026-12-01 19:24 UTC (permalink / raw)
To: Baojun Xu, Sen Wang, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Dinghao Liu, Shenghao Ding, Kevin Lu
Cc: linux-sound, Arina Kharlamova
Two refcounting fixes for tas2552. Patch 1 removes an unmatched runtime
PM put from the I2C probe, which warns about a usage count underflow on
every boot, and disables runtime PM when the probe fails. Patch 2
disables the supplies when the component is removed.
I found this with spec2patch. I model-checked the probe and remove paths
of the driver with CBMC against formal specifications of the kernel APIs
it calls. The specifications are checked against the kernel source, and
some of them are proved in Rocq against a transcription of the kernel
code. I also checked lock usage separately. With the help of an AI
coding assistant (Claude); I reviewed the analysis and the fix.
Compile-tested only, not tested on hardware.
I noticed the problem fixed in patch 2 while reviewing patch 1.
To: Shenghao Ding <shenghao-ding@ti.com>
To: Kevin Lu <kevin-lu@ti.com>
---
Arina Kharlamova (2):
ASoC: tas2552: Fix runtime PM usage count underflow in probe
ASoC: tas2552: Disable supplies on component remove
sound/soc/codecs/tas2552.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
---
base-commit: 20ee6031645dbed8ddf8f4833edf415f3760607f
change-id: 20261201-tas2552-rpm-4d19db003214
Best regards,
--
Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] ASoC: tas2552: Fix runtime PM usage count underflow in probe
2026-12-01 19:24 [PATCH 0/2] ASoC: tas2552: Fix runtime PM and supply refcounting Arina Kharlamova via B4 Relay
@ 2026-12-01 19:24 ` Arina Kharlamova via B4 Relay
2026-12-01 19:24 ` [PATCH 2/2] ASoC: tas2552: Disable supplies on component remove Arina Kharlamova via B4 Relay
1 sibling, 0 replies; 4+ messages in thread
From: Arina Kharlamova via B4 Relay @ 2026-12-01 19:24 UTC (permalink / raw)
To: Baojun Xu, Sen Wang, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Dinghao Liu, Shenghao Ding, Kevin Lu
Cc: linux-sound, Arina Kharlamova
From: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
tas2552_probe() calls pm_runtime_put_sync_autosuspend() right after
pm_runtime_enable(), but nothing took a usage count reference before
it. Neither the I2C core nor the driver core holds one on the client
during probe, so the count is 0 and the runtime PM core prints
"Runtime PM usage count underflow!" on every probe. Before that check
was added in v5.19 the count went to -1 instead.
Remove the put. The device is active after probe as before, and
tas2552_component_probe() takes the first reference.
The error path after devm_snd_soc_register_component() made up for
the put with pm_runtime_get_noresume() and left runtime PM enabled.
Disable runtime PM there instead.
Fixes: 5df7f71d5cdf ("ASoC: tas2552: Support TI TAS2552 Amplifier")
Fixes: 7b3f5b207da5 ("ASoC: codecs: Fix runtime PM imbalance in tas2552_probe")
Signed-off-by: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
---
sound/soc/codecs/tas2552.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/sound/soc/codecs/tas2552.c b/sound/soc/codecs/tas2552.c
index 7fda383043ed..0f0c6f1afde7 100644
--- a/sound/soc/codecs/tas2552.c
+++ b/sound/soc/codecs/tas2552.c
@@ -746,7 +746,6 @@ static int tas2552_probe(struct i2c_client *client)
pm_runtime_set_autosuspend_delay(&client->dev, 1000);
pm_runtime_use_autosuspend(&client->dev);
pm_runtime_enable(&client->dev);
- pm_runtime_put_sync_autosuspend(&client->dev);
dev_set_drvdata(&client->dev, data);
@@ -755,7 +754,7 @@ static int tas2552_probe(struct i2c_client *client)
tas2552_dai, ARRAY_SIZE(tas2552_dai));
if (ret < 0) {
dev_err(&client->dev, "Failed to register component: %d\n", ret);
- pm_runtime_get_noresume(&client->dev);
+ pm_runtime_disable(&client->dev);
}
return ret;
--
Git-157)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] ASoC: tas2552: Disable supplies on component remove
2026-12-01 19:24 [PATCH 0/2] ASoC: tas2552: Fix runtime PM and supply refcounting Arina Kharlamova via B4 Relay
2026-12-01 19:24 ` [PATCH 1/2] ASoC: tas2552: Fix runtime PM usage count underflow in probe Arina Kharlamova via B4 Relay
@ 2026-12-01 19:24 ` Arina Kharlamova via B4 Relay
2026-12-01 19:36 ` sashiko-bot
1 sibling, 1 reply; 4+ messages in thread
From: Arina Kharlamova via B4 Relay @ 2026-12-01 19:24 UTC (permalink / raw)
To: Baojun Xu, Sen Wang, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Dinghao Liu, Shenghao Ding, Kevin Lu
Cc: linux-sound, Arina Kharlamova
From: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
tas2552_component_probe() enables the supplies, but
tas2552_component_remove() never disables them. Each card unbind and
rebind raises the regulator enable count by one, the supplies stay on
after the card is gone, and unbinding the codec then hits the
WARN_ON() in _regulator_put().
Disable the supplies in tas2552_component_remove(), as the error path
of tas2552_component_probe() already does.
Fixes: 5df7f71d5cdf ("ASoC: tas2552: Support TI TAS2552 Amplifier")
Signed-off-by: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
---
sound/soc/codecs/tas2552.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sound/soc/codecs/tas2552.c b/sound/soc/codecs/tas2552.c
index 0f0c6f1afde7..88b40154530e 100644
--- a/sound/soc/codecs/tas2552.c
+++ b/sound/soc/codecs/tas2552.c
@@ -644,6 +644,9 @@ static void tas2552_component_remove(struct snd_soc_component *component)
pm_runtime_put(component->dev);
gpiod_set_value_cansleep(tas2552->enable_gpio, 0);
+
+ regulator_bulk_disable(ARRAY_SIZE(tas2552->supplies),
+ tas2552->supplies);
};
#ifdef CONFIG_PM
--
Git-157)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] ASoC: tas2552: Disable supplies on component remove
2026-12-01 19:24 ` [PATCH 2/2] ASoC: tas2552: Disable supplies on component remove Arina Kharlamova via B4 Relay
@ 2026-12-01 19:36 ` sashiko-bot
0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-12-01 19:36 UTC (permalink / raw)
To: Arina Kharlamova; +Cc: linux-sound
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] ASoC: tas2552: supplies disabled before suspend in
tas2552_component_remove()
--
commit e52927e0e6aa3bc7040718bcc4161bf26af6fdee
Author: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
ASoC: tas2552: Disable supplies on component remove
This commit disables the tas2552 regulator supplies in
tas2552_component_remove() to balance the regulator_bulk_enable() call in
tas2552_component_probe().
> diff --git a/sound/soc/codecs/tas2552.c b/sound/soc/codecs/tas2552.c
> index 0f0c6f1afde78..88b40154530ec 100644
> --- a/sound/soc/codecs/tas2552.c
> +++ b/sound/soc/codecs/tas2552.c
> @@ -644,6 +644,9 @@ static void tas2552_component_remove(struct snd_soc_component *component)
> pm_runtime_put(component->dev);
>
> gpiod_set_value_cansleep(tas2552->enable_gpio, 0);
> +
> + regulator_bulk_disable(ARRAY_SIZE(tas2552->supplies),
> + tas2552->supplies);
> };
[Severity: Medium]
Does disabling tas2552->supplies right after pm_runtime_put() cut power
to the chip before runtime suspend runs?
tas2552_probe() enables runtime PM autosuspend with a 1000 ms delay, so
pm_runtime_put() returns while the device is still active. When
tas2552_runtime_suspend() runs later, it calls tas2552_sw_shutdown() over
I2C before enabling regcache_cache_only(), writing to the unpowered chip.
Once autosuspend completes and marks the regcache dirty, unbinding the
codec calls __device_release_driver() -> pm_runtime_get_sync(), which
runs tas2552_runtime_resume() and regcache_sync() over I2C with the
supplies still disabled. Conversely, if the card is rebound before the
1000 ms autosuspend delay expires, the device stays RPM_ACTIVE across the
regulator power cycle, so pm_runtime_resume_and_get() in
tas2552_component_probe() skips tas2552_runtime_resume() and leaves the
reset hardware registers out of sync with the regcache.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-tas2552-rpm-v1-0-2bac34f9f68f@mbzuai.ac.ae?part=2
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-01 19:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 19:24 [PATCH 0/2] ASoC: tas2552: Fix runtime PM and supply refcounting Arina Kharlamova via B4 Relay
2026-12-01 19:24 ` [PATCH 1/2] ASoC: tas2552: Fix runtime PM usage count underflow in probe Arina Kharlamova via B4 Relay
2026-12-01 19:24 ` [PATCH 2/2] ASoC: tas2552: Disable supplies on component remove Arina Kharlamova via B4 Relay
2026-12-01 19:36 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox