From: Dillon Varone Dillon.Varone@amd.com
[ Upstream commit 6b34e7ed4ba583ee77032a4c850ff97ba16ad870 ]
[WHY&HOW] The sink max slice width limitation should be considered for DSC, but was removed in "refactor DSC cap calculations". This patch adds it back and takes the valid minimum between the sink and source.
Signed-off-by: Dillon Varone Dillon.Varone@amd.com Signed-off-by: Aurabindo Pillai aurabindo.pillai@amd.com Reviewed-by: Wenjing Liu Wenjing.Liu@amd.com Tested-by: Dan 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:
YES
- Fixes a real regression: The change restores enforcement of the sink’s maximum slice-width constraint when selecting the number of DSC slices, which was lost during a prior refactor. Without this, the driver can select too few slices and later fail the final width check, incorrectly concluding “DSC not possible” or programming an invalid configuration that can cause display failures for affected sinks.
- Precise change and rationale: The patch adds an explicit lower bound on the horizontal slice count based on the sink’s maximum slice width: - New logic: `drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c:1161` - `min_slices_h = dc_fixpt_ceil(dc_fixpt_max(dc_fixpt_div_int(dc_fix pt_from_int(pic_width), dsc_common_caps.max_slice_width), dc_fixpt_from_int(min_slices_h)));` - This enforces `min_slices_h >= ceil(pic_width / max_slice_width)`, i.e., each slice width ≤ sink/source capability. - This is then snapped to a supported slice count: `drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c:1165` - `min_slices_h = fit_num_slices_up(dsc_common_caps.slice_caps, min_slices_h);` - Throughput and divisibility constraints are applied after this in existing code: `drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c:1168`, `drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c:1177`.
- Why it matters: The final validation still checks `slice_width <= dsc_common_caps.max_slice_width` at `drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c:1236`. Before this patch, `min_slices_h` could be too low (because width wasn’t considered), leading to late failure and no attempt to raise the slice count if `policy.use_min_slices_h` is active (set to true in policy defaults: `drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c:1373`). By raising `min_slices_h` early to meet the width constraint, the algorithm avoids that false “not possible” outcome and finds a valid configuration when one exists.
- Correct intersection of caps: The code uses `dsc_common_caps.max_slice_width`, which is already the minimum between sink and encoder capabilities (intersection): `drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c:753`. This matches the commit’s intent to “take the valid minimum between the sink and source.”
- Consistent with existing logic elsewhere: A similar max-slice-width constraint is already considered when computing ODM-related minimum slices (`get_min_dsc_slice_count_for_odm`) via a width-based term: `drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c:664`. This patch brings the main DSC setup path into alignment with that established reasoning.
- Scope and risk: - Small and contained (a few lines in one function, one file). - No API/ABI changes, no architectural shifts. - Targets a correctness issue in AMD DC DSC slice selection. - Low risk of regression: it only increases the minimum slices to satisfy an already-known sink limitation; subsequent throughput/divisibility checks remain unchanged.
- User impact: Prevents display failures or inability to enable DSC on sinks that enforce max slice width, especially for high resolutions/refresh rates where DSC is required.
Given it’s a targeted regression fix, minimal risk, and improves correctness for real hardware, this is a good candidate for stable backporting.
drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c b/drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c index 1f53a9f0c0ac3..e4144b2443324 100644 --- a/drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c +++ b/drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c @@ -1157,6 +1157,11 @@ static bool setup_dsc_config( if (!is_dsc_possible) goto done;
+ /* increase miniumum slice count to meet sink slice width limitations */ + min_slices_h = dc_fixpt_ceil(dc_fixpt_max( + dc_fixpt_div_int(dc_fixpt_from_int(pic_width), dsc_common_caps.max_slice_width), // sink min + dc_fixpt_from_int(min_slices_h))); // source min + min_slices_h = fit_num_slices_up(dsc_common_caps.slice_caps, min_slices_h);
/* increase minimum slice count to meet sink throughput limitations */