From: Shuming Fan shumingf@realtek.com
[ Upstream commit d914ec6f07548f7c13a231a4f526e043e736e82e ]
This patch adds settings to prevent the 'prepare clock stop failed' error.
Signed-off-by: Shuming Fan shumingf@realtek.com Link: https://patch.msgid.link/20251027103333.38353-1-shumingf@realtek.com Signed-off-by: Mark Brown broonie@kernel.org Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
## Backport Analysis Result
**Answer: YES**
### Analysis Summary
I performed comprehensive semantic code analysis of this commit using multiple tools. Here are my findings:
### 1. Semantic Code Analysis Tools Used
- **mcp__semcode__find_function**: Located the modified function `rt721_sdca_jack_preset()` and `rt721_sdca_jack_init()` - **mcp__semcode__find_callers**: Traced the call graph to understand impact scope - **mcp__semcode__diff_functions**: Analyzed the semantic nature of changes - **git history analysis**: Investigated driver history and related commits
### 2. Code Change Analysis
**Modified Function**: `rt721_sdca_jack_preset()` (sound/soc/codecs/rt721-sdca.c:211-284)
**Changes Made**: ```c + regmap_write(rt721->regmap, 0x2f51, 0x00); + rt_sdca_index_write(rt721->mbq_regmap, RT721_HDA_SDCA_FLOAT, + RT721_MISC_CTL, 0x0004); ```
The commit adds exactly **2 register writes** at the end of the hardware preset initialization function, plus 1 new constant definition (RT721_MISC_CTL = 0x07) in the header file.
### 3. Impact Scope Assessment
**Call Chain Analysis**: ``` SoundWire driver ops callback └─> rt721_sdca_update_status() [1 caller, no other callers found] └─> rt721_sdca_io_init() [1 caller] └─> rt721_sdca_jack_preset() [1 caller - modified function] ```
**Impact Scope**: - **Very Limited**: Only affects RT721 SDCA codec hardware - **Initialization path**: Changes occur during device initialization/preset configuration - **Not in critical data path**: This is setup code, not runtime audio processing - **User exposure**: Only users with RT721 hardware are affected
### 4. Root Cause Analysis
Using grep analysis of the SoundWire subsystem, I found the error message "prepare clock stop failed" originates from: - `drivers/soundwire/qcom.c:1742` - `drivers/soundwire/amd_manager.c:1099` - `drivers/soundwire/cadence_master.c:1733`
The error occurs when `sdw_bus_prep_clk_stop()` fails during **power management operations** (suspend/clock stop sequence). The fix adds missing vendor-specific register initialization to ensure the codec properly prepares for clock stop.
### 5. Driver Context
- **Driver age**: RT721 driver was added in **commit 86ce355c1f9ab on 2024-10-01** - **First appeared**: Kernel **v6.13-rc1** - **Present in tags**: v6.13, v6.13-rc1, p-6.15, p-6.16, p-6.17 - **Backport status**: Already backported as commit 20e9900b3c3fe (references upstream d914ec6f07548)
### 6. Backport Suitability Evaluation
✅ **POSITIVE INDICATORS**: 1. **Fixes real bug**: Prevents "prepare clock stop failed" errors affecting power management 2. **Small, contained change**: Only 2 register writes added 3. **Low regression risk**: Hardware-specific initialization, doesn't change logic flow 4. **Hardware errata style fix**: Vendor-recommended settings for proper operation 5. **Stable tree compliant**: Bug fix, not new feature, no architectural changes 6. **Already being backported**: Evidence shows autosel has picked this up
❌ **LIMITATIONS**: 1. **New driver**: Only relevant for kernels v6.13+ (where rt721 driver exists) 2. **No explicit stable tag**: Missing "Cc: stable@vger.kernel.org" in original commit 3. **Limited hardware exposure**: Only affects RT721 codec users (relatively new hardware)
### 7. Change Type Classification
Using semantic diff analysis, this is classified as: - ✅ **Bug fix**: YES - fixes initialization failure - ❌ **New feature**: NO - just completes existing initialization - ❌ **Architectural change**: NO - adds register writes to existing function - ❌ **Performance optimization**: NO - correctness fix
### 8. Risk Assessment
**Risk Level**: **LOW**
- Contained to single driver (rt721) - Hardware-specific register values (unlikely to affect other systems) - Added at end of preset function (won't disrupt existing init sequence) - No behavior change to existing functionality, only adds missing setup
### Recommendation
**YES - Backport to stable kernels 6.13+** where the RT721 driver is present. This is a legitimate bug fix that: - Resolves power management failures (clock stop preparation) - Has minimal regression risk - Follows stable kernel rules (obvious, small bug fix) - Improves user experience for RT721 hardware owners
For stable kernels **older than 6.13**, this commit is **NOT APPLICABLE** as the driver doesn't exist.
sound/soc/codecs/rt721-sdca.c | 4 ++++ sound/soc/codecs/rt721-sdca.h | 1 + 2 files changed, 5 insertions(+)
diff --git a/sound/soc/codecs/rt721-sdca.c b/sound/soc/codecs/rt721-sdca.c index a4bd29d7220b8..5f7b505d54147 100644 --- a/sound/soc/codecs/rt721-sdca.c +++ b/sound/soc/codecs/rt721-sdca.c @@ -281,6 +281,10 @@ static void rt721_sdca_jack_preset(struct rt721_sdca_priv *rt721) rt_sdca_index_write(rt721->mbq_regmap, RT721_BOOST_CTRL, RT721_BST_4CH_TOP_GATING_CTRL1, 0x002a); regmap_write(rt721->regmap, 0x2f58, 0x07); + + regmap_write(rt721->regmap, 0x2f51, 0x00); + rt_sdca_index_write(rt721->mbq_regmap, RT721_HDA_SDCA_FLOAT, + RT721_MISC_CTL, 0x0004); }
static void rt721_sdca_jack_init(struct rt721_sdca_priv *rt721) diff --git a/sound/soc/codecs/rt721-sdca.h b/sound/soc/codecs/rt721-sdca.h index 71fac9cd87394..24ce188562baf 100644 --- a/sound/soc/codecs/rt721-sdca.h +++ b/sound/soc/codecs/rt721-sdca.h @@ -137,6 +137,7 @@ struct rt721_sdca_dmic_kctrl_priv { #define RT721_HDA_LEGACY_UAJ_CTL 0x02 #define RT721_HDA_LEGACY_CTL1 0x05 #define RT721_HDA_LEGACY_RESET_CTL 0x06 +#define RT721_MISC_CTL 0x07 #define RT721_XU_REL_CTRL 0x0c #define RT721_GE_REL_CTRL1 0x0d #define RT721_HDA_LEGACY_GPIO_WAKE_EN_CTL 0x0e