From: Mario Limonciello mario.limonciello@amd.com
[ Upstream commit a5ce8695d6d1b40d6960d2d298b579042c158f25 ]
[Why] If PSR-SU is disabled on the link, then configuring su_y granularity in mod_power_calc_psr_configs() can lead to assertions in psr_su_set_dsc_slice_height().
[How] Check the PSR version in amdgpu_dm_link_setup_psr() to determine whether or not to configure granularity.
Reviewed-by: Sun peng (Leo) Li sunpeng.li@amd.com Signed-off-by: Mario Limonciello mario.limonciello@amd.com Signed-off-by: Ivan Lipski ivan.lipski@amd.com Tested-by: Daniel Wheeler daniel.wheeler@amd.com Signed-off-by: Alex Deucher alexander.deucher@amd.com Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
Now I have a clear understanding of the issue. Let me analyze the commit:
## Analysis Summary
**Backport Status: YES**
## Extensive Explanation
This commit fixes a bug that can cause assertions (kernel warnings/panics) in AMD display driver code when PSR (Panel Self Refresh) is enabled on systems that don't support PSR-SU (Selective Update).
### The Bug Being Fixed:
1. **Root Cause**: In `amdgpu_dm_link_setup_psr()`, the function `mod_power_calc_psr_configs()` is called for any PSR version (line 113), which sets `psr_config->su_y_granularity` from DPCD capabilities (line 926 in power_helpers.c).
2. **The Problem**: Even when PSR-SU is not supported (PSR version 1), `psr_su_set_dsc_slice_height()` was being called unconditionally (line 122). This function contains an assertion check at lines 968-970 that validates: ```c if (config->su_y_granularity && (slice_height % config->su_y_granularity)) { ASSERT(0); return false; } ```
3. **Impact**: When PSR version 1 (non-SU) is active but `su_y_granularity` is non-zero from DPCD caps, the assertion triggers, potentially causing system instability or crashes.
### The Fix:
The commit adds a simple version check to only call `psr_su_set_dsc_slice_height()` when PSR-SU (DC_PSR_VERSION_SU_1) is actually supported:
```c if (link->psr_settings.psr_version == DC_PSR_VERSION_SU_1) { if (!psr_su_set_dsc_slice_height(dc, link, stream, &psr_config)) return false; } ```
### Why This Should Be Backported:
1. **Bug Fix**: This fixes a real bug that causes assertions/warnings in production systems 2. **Small and Contained**: The fix is minimal - just adding a version check around an existing function call 3. **No Architectural Changes**: This doesn't introduce new features or change architecture 4. **Prevents System Instability**: Assertions in kernel code can lead to panics or unstable behavior 5. **Clear Regression Prevention**: Systems with PSR version 1 that have non-zero su_y_granularity values from their panel DPCD would hit this assertion 6. **Limited Scope**: Only affects AMD GPU display driver PSR functionality 7. **Safe Fix**: The change only adds a guard to prevent calling PSR-SU specific code when PSR-SU is not supported - this is clearly the correct behavior
The commit follows stable kernel rules perfectly - it's a targeted bug fix that prevents potential system crashes without introducing new functionality or risks.
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c index f984cb0cb889..ff7b867ae98b 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c @@ -119,8 +119,10 @@ bool amdgpu_dm_link_setup_psr(struct dc_stream_state *stream) psr_config.allow_multi_disp_optimizations = (amdgpu_dc_feature_mask & DC_PSR_ALLOW_MULTI_DISP_OPT);
- if (!psr_su_set_dsc_slice_height(dc, link, stream, &psr_config)) - return false; + if (link->psr_settings.psr_version == DC_PSR_VERSION_SU_1) { + if (!psr_su_set_dsc_slice_height(dc, link, stream, &psr_config)) + return false; + }
ret = dc_link_setup_psr(link, stream, &psr_config, &psr_context);