Skip to contentSkip to conversation

ASoC: tas2783-sdw: ensure PM runtime active to fix no sound issue

PATCH In review Baojun Xu 3 participants 3 messages Nov 30

Subsystems (3)
lore
Share & tools
lore

Baojun Xu

author maintainer
#0 lore raw

PATCH 1/1 ASoC: tas2783-sdw: ensure PM runtime active to fix no sound issue

Fix an issue where sound output fails after multiple reboots. The driver now explicitly ensures the device is in PM runtime active state during initialization/resume to prevent the codec from remaining in a low-power state..

---
 sound/soc/codecs/tas2783-sdw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/tas2783-sdw.c +1 -1
index 08b37e7b3a9e..86c1fb153abd 100644
@@ -1105,7 +1105,7 @@ static s32 tas_init(struct tas2783_prv *tas_dev)
 	pm_runtime_set_autosuspend_delay(tas_dev->dev, 3000);
 	pm_runtime_use_autosuspend(tas_dev->dev);
 	/* make sure the device does not suspend immediately */
-	pm_runtime_mark_last_busy(tas_dev->dev);
+	pm_runtime_set_active(tas_dev->dev);
 	pm_runtime_enable(tas_dev->dev);
 
 	return ret;
Signature · 1 line
2.25.1
#1 lore raw
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] ASoC: tas2783-sdw: removing pm_runtime_mark_last_busy() in tas_init() bypasses autosuspend…

Thank you for your contribution! Sashiko AI review found 3 potential issues to consider:
- [Medium] ASoC: tas2783-sdw: removing pm_runtime_mark_last_busy() in tas_init() bypasses autosuspend
- [Medium] ASoC: tas2783-sdw: premature pm_runtime_set_active() in tas_init() bypasses init wait
- [Low] ASoC: tas2783-sdw: missing Fixes trailer for commit 4cc9bd8d7b32 --

commit bb8b101e025b2a336b69d877adfc8440c8b588c0
Author: Baojun Xu <[email protected]>

Quoted 8 lines

ASoC: tas2783-sdw: ensure PM runtime active to fix no sound issue

Fix an issue where sound output fails after multiple reboots. The driver now explicitly ensures the device is in PM runtime active state during initialization/resume to prevent the codec from remaining in a low-power state..

[Severity: Low]
This fixes a bug introduced with the driver. Should the commit message include:

Fixes 4cc9bd8d7b32 ("ASoc: tas2783A: Add soundwire based codec driver")

sound/soc/codecs/tas2783-sdw.c static s32 tas_init(struct tas2783_prv *tas_dev) · line 1111

Quoted 13 lines
sound/soc/codecs/tas2783-sdw.c +1 -1
index 08b37e7b3a9e4..86c1fb153abd3 100644
@@ -1105,7 +1105,7 @@ static s32 tas_init(struct tas2783_prv *tas_dev)
 	pm_runtime_set_autosuspend_delay(tas_dev->dev, 3000);
 	pm_runtime_use_autosuspend(tas_dev->dev);
 	/* make sure the device does not suspend immediately */
-	pm_runtime_mark_last_busy(tas_dev->dev);
+	pm_runtime_set_active(tas_dev->dev);
 	pm_runtime_enable(tas_dev->dev);
 
 	return ret;

[Severity: Medium]
Does removing pm_runtime_mark_last_busy(tas_dev->dev) instead of keeping it alongside pm_runtime_set_active(tas_dev->dev) cause the device to suspend immediately after probe?

Neither pm_runtime_set_active() nor the _no_pm SoundWire register helpers update dev->power.last_busy, leaving it at 0. When the driver core calls pm_request_idle() after probe returns (on any probe finishing at least 3 seconds after boot), pm_runtime_autosuspend_expiration() sees an already expired timestamp and triggers tas2783_sdca_dev_suspend() immediately rather than waiting for the 3000 ms autosuspend delay.

[Severity: Medium]
Can setting tas_dev->dev to RPM_ACTIVE unconditionally in tas_init() cause pm_runtime_get_sync() to skip waiting for SoundWire initialization and firmware download?

tas_sdw_probe() calls tas_init() while regmap is still cache-only and before tas_update_status() -> tas_io_init() has attached the peripheral and loaded firmware. When the device is already marked RPM_ACTIVE, a PCM open calling pm_runtime_get_sync() returns immediately without running tas2783_sdca_dev_resume() -> sdw_slave_wait_for_init(), so a concurrent tas_sdw_hw_params() sees !tas_dev->fw_dl_success and fails with -EINVAL.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to Baojun Xu
Quoted 15 lines · Baojun Xu

Fix an issue where sound output fails after multiple reboots. The driver now explicitly ensures the device is in PM runtime active state during initialization/resume to prevent the codec from remaining in a low-power state..

---
 sound/soc/codecs/tas2783-sdw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/tas2783-sdw.c +0 -0
index 08b37e7b3a9e..86c1fb153abd 100644

sound/soc/codecs/tas2783-sdw.c static s32 tas_init(struct tas2783_prv *tas_dev) · line 1109

Quoted 6 lines
sound/soc/codecs/tas2783-sdw.c +1 -1
@@ -1105,7 +1105,7 @@ static s32 tas_init(struct tas2783_prv *tas_dev)
 	pm_runtime_set_autosuspend_delay(tas_dev->dev, 3000);
 	pm_runtime_use_autosuspend(tas_dev->dev);
 	/* make sure the device does not suspend immediately */
-	pm_runtime_mark_last_busy(tas_dev->dev);
+	pm_runtime_set_active(tas_dev->dev);
 	pm_runtime_enable(tas_dev->dev);

There are two issues with this change I am afraid:
- first why would you keep a comment related to mark_last_busy() but remove that call?
- and then the set_active() is typically done when the device becomes attached, not when the driver/component is probed. See other drivers for reference, e.g. rt711

/*
* PM runtime status is marked as 'active' only when a Slave reports as
Attached
*/
if (!rt711->first_hw_init)

	/* update count of parent 'active' children */
	pm_runtime_set_active(&slave->dev);

It does look like your driver is indeed missing the set_active() call, but you added it in the wrong location.