From: Vijendar Mukunda Vijendar.Mukunda@amd.com
[ Upstream commit 03837341790039d6f1cbf7a1ae7dfa2cb77ef0a4 ]
During pm_prepare callback, pm_request_resume() delays SoundWire manager D0 entry sequence. Synchronize runtime resume sequence for amd_manager instance prior to invoking child devices resume sequence for both the amd power modes(ClockStop Mode and Power off mode). Change the power_mode_mask check and use pm_runtime_resume() in amd_pm_prepare() callback.
Signed-off-by: Vijendar Mukunda Vijendar.Mukunda@amd.com Link: https://lore.kernel.org/r/20250530054447.1645807-3-Vijendar.Mukunda@amd.com Signed-off-by: Vinod Koul vkoul@kernel.org Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
**Backport Status: YES**
This commit should be backported to stable kernel trees for the following reasons:
## Bug Fix Nature The commit fixes a critical synchronization issue in the AMD SoundWire driver's power management sequence. The original code used `pm_request_resume()` which is asynchronous, leading to race conditions where the manager device might not be fully resumed before child devices start their resume sequence. This causes: 1. Missing device alerts on AMD platforms 2. Race conditions during system resume 3. Potential communication failures between the SoundWire manager and peripheral devices
## Code Analysis
1. **Critical Fix**: The change from `pm_request_resume()` to `pm_runtime_resume()` ensures synchronous resume operation, eliminating race conditions. This is similar to Intel's fix (commit 6f4867fa5760) which addressed the same class of issue.
2. **Expanded Scope**: The condition change from `(power_mode_mask & AMD_SDW_CLK_STOP_MODE)` to just `(power_mode_mask)` ensures the fix applies to both power modes: - AMD_SDW_CLK_STOP_MODE (value 1): Clock stop mode - AMD_SDW_POWER_OFF_MODE (value 2): Power off mode
This ensures proper synchronization for all power management scenarios, not just clock stop mode.
3. **Small and Contained**: The fix is minimal (3 lines changed) and localized to the `amd_pm_prepare()` function, reducing regression risk.
4. **Clear Bug Symptoms**: The commit message explicitly states the observed bug: "device alerts are missing without pm_prepare on AMD platforms" - a user-visible problem affecting SoundWire functionality.
5. **No Architectural Changes**: This is purely a bug fix that corrects the synchronization mechanism without introducing new features or changing the driver architecture.
6. **Subsystem Pattern**: This follows an established pattern in the SoundWire subsystem where Intel had a similar issue and fix, indicating this is a known class of bugs that should be addressed in stable kernels.
The commit meets all stable kernel criteria: it fixes a real bug affecting users, is minimal in scope, has low regression risk, and doesn't introduce new functionality.
drivers/soundwire/amd_manager.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/soundwire/amd_manager.c b/drivers/soundwire/amd_manager.c index 7a671a786197..3b335d6eaa94 100644 --- a/drivers/soundwire/amd_manager.c +++ b/drivers/soundwire/amd_manager.c @@ -1178,10 +1178,10 @@ static int __maybe_unused amd_pm_prepare(struct device *dev) * device is not in runtime suspend state, observed that device alerts are missing * without pm_prepare on AMD platforms in clockstop mode0. */ - if (amd_manager->power_mode_mask & AMD_SDW_CLK_STOP_MODE) { - ret = pm_request_resume(dev); + if (amd_manager->power_mode_mask) { + ret = pm_runtime_resume(dev); if (ret < 0) { - dev_err(bus->dev, "pm_request_resume failed: %d\n", ret); + dev_err(bus->dev, "pm_runtime_resume failed: %d\n", ret); return 0; } }