From: Charlene Liu Charlene.Liu@amd.com
[ Upstream commit d5a7fdc88a2d64242d959942cbd0e1499ebb9806 ]
[why] the guard of is_apu not in sync, caused no watermark_c output.
Reviewed-by: Ovidiu Bunea ovidiu.bunea@amd.com Signed-off-by: Charlene Liu Charlene.Liu@amd.com Signed-off-by: Aurabindo Pillai aurabindo.pillai@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 ---
**YES** This commit should be backported to stable kernel trees. Here's my extensive analysis: ## Bug Analysis The commit fixes a critical bug in AMD display driver's watermark handling for APU (Accelerated Processing Unit) systems. The issue is in the `dml2_validate_and_build_resource` function where watermark_c was being incorrectly populated for APU systems. ## Problem Description **Before the fix:** ```c memcpy(&context->bw_ctx.bw.dcn.watermarks.c, &dml2->v20.g6_temp_read_watermark_set, sizeof(context->bw_ctx.bw.dcn.watermarks.c)); ``` **After the fix:** ```c if (context->streams[0]->sink->link->dc->caps.is_apu) dml2_extract_watermark_set(&context->bw_ctx.bw.dcn.watermarks.c, &dml2->v20.dml_core_ctx); else memcpy(&context->bw_ctx.bw.dcn.watermarks.c, &dml2->v20.g6_temp_read_watermark_set, sizeof(context->bw_ctx.bw.dcn.watermarks.c)); ``` ## Why This is a Good Backport Candidate 1. **Clear Bug Fix**: The commit message explicitly states "the guard of is_apu not in sync, caused no watermark_c output" - this indicates a bug where APU systems were getting incorrect (likely zero) watermark values. 2. **Consistent Pattern**: Looking at the same file (line 546, 561, 569), there are already multiple `is_apu` checks that differentiate behavior between APU and discrete GPU systems. The original code at line 666 was inconsistent with this pattern. 3. **Small and Contained**: The fix is minimal - just adding a conditional check around an existing operation. It doesn't introduce new functionality or architectural changes. 4. **Critical Subsystem**: Display watermarks are critical for preventing display artifacts, screen corruption, underflow issues, and power management problems. Incorrect watermarks can cause visible display problems for users. 5. **APU-Specific Impact**: APUs (integrated GPU+CPU) are very common in laptops and budget systems. A watermark bug affecting these systems would impact a large user base. 6. **Comparison with Similar Commits**: Looking at the similar commits provided: - Commits #2 and #4 with "YES" status fix watermark values to prevent "flickering and OTC underflow" - This commit follows the same pattern of fixing watermark-related display issues ## Risk Assessment **Low Risk:** - The change only affects APU systems (`is_apu` check) - For non-APU systems, behavior remains exactly the same - The fix aligns the watermark_c handling with how watermarks a, b, and d are already handled - Uses existing, well-tested `dml2_extract_watermark_set()` function instead of raw memcpy ## Context from Kernel Investigation The git blame shows the original problematic code was introduced in commit 7966f319c66d9 (July 2023) when DML2 was first introduced. This suggests the bug has existed since DML2 was added, affecting APU users for potentially over a year. The fix ensures APU systems get proper watermark calculations via `dml2_extract_watermark_set()` instead of using potentially incorrect temporary values from `g6_temp_read_watermark_set`. **Conclusion**: This is a clear, low-risk bug fix that addresses display functionality issues on a common class of hardware (APUs) and follows stable tree criteria perfectly.
drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c b/drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c index e89571874185e..525b7d04bf84c 100644 --- a/drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c +++ b/drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c @@ -663,7 +663,10 @@ static bool dml2_validate_and_build_resource(const struct dc *in_dc, struct dc_s dml2_copy_clocks_to_dc_state(&out_clks, context); dml2_extract_watermark_set(&context->bw_ctx.bw.dcn.watermarks.a, &dml2->v20.dml_core_ctx); dml2_extract_watermark_set(&context->bw_ctx.bw.dcn.watermarks.b, &dml2->v20.dml_core_ctx); - memcpy(&context->bw_ctx.bw.dcn.watermarks.c, &dml2->v20.g6_temp_read_watermark_set, sizeof(context->bw_ctx.bw.dcn.watermarks.c)); + if (context->streams[0]->sink->link->dc->caps.is_apu) + dml2_extract_watermark_set(&context->bw_ctx.bw.dcn.watermarks.c, &dml2->v20.dml_core_ctx); + else + memcpy(&context->bw_ctx.bw.dcn.watermarks.c, &dml2->v20.g6_temp_read_watermark_set, sizeof(context->bw_ctx.bw.dcn.watermarks.c)); dml2_extract_watermark_set(&context->bw_ctx.bw.dcn.watermarks.d, &dml2->v20.dml_core_ctx); dml2_extract_writeback_wm(context, &dml2->v20.dml_core_ctx); //copy for deciding zstate use