From: Mario Limonciello mario.limonciello@amd.com
[ Upstream commit 7e40f64896e8e3dca471e287672db5ace12ea0be ]
[Why] If the dummy values in `populate_dummy_dml_surface_cfg()` aren't updated then they can lead to a divide by zero in downstream callers like CalculateVMAndRowBytes()
[How] Initialize dummy value to a value to avoid divide by zero.
Reviewed-by: Alex Hung alex.hung@amd.com Signed-off-by: Mario Limonciello mario.limonciello@amd.com Signed-off-by: Zaeem Mohamed zaeem.mohamed@amd.com Tested-by: Mark Broadworth mark.broadworth@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. **Analysis:** This is a classic divide-by-zero prevention fix that follows the exact same pattern as all the similar commits marked "YES" in the historical examples. The commit: 1. **Fixes a critical bug**: Prevents division by zero errors that could cause kernel crashes or undefined behavior 2. **Extremely minimal and safe change**: Only changes `out->PitchC[location] = 0;` to `out->PitchC[location] = 1;` on line 900 of `drivers/gpu/drm/amd/display/dc/dml2/dml2_translation_helper.c` 3. **Well-documented issue**: The commit message clearly explains that dummy values in `populate_dummy_dml_surface_cfg()` can lead to divide by zero in downstream callers like `CalculateVMAndRowBytes()` 4. **Follows established pattern**: The fix is identical to Similar Commits #1, #2, and #5 which were all marked "YES" for backporting The code change is in the `populate_dummy_dml_surface_cfg()` function where dummy/placeholder values are initialized. Setting `PitchC[location]` to 1 instead of 0 ensures that any downstream code performing calculations using this value as a denominator won't encounter division by zero errors. **Key evidence supporting backporting:** - **AMD Display subsystem**: This is a critical graphics subsystem where crashes can severely impact user experience - **Crash prevention**: Division by zero can cause kernel panics - **Zero risk of regression**: Changing a dummy value from 0 to 1 has no functional impact other than preventing crashes - **Small, contained fix**: Single line change in one function - **Clear precedent**: Multiple similar commits fixing divide-by-zero in AMD display code have been backported This fix directly addresses a potential stability issue with minimal risk, making it an ideal candidate for stable tree backporting under the kernel's stable tree rules.
drivers/gpu/drm/amd/display/dc/dml2/dml2_translation_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/display/dc/dml2/dml2_translation_helper.c b/drivers/gpu/drm/amd/display/dc/dml2/dml2_translation_helper.c index aeb9fae83cacc..ad16cfc5eaed6 100644 --- a/drivers/gpu/drm/amd/display/dc/dml2/dml2_translation_helper.c +++ b/drivers/gpu/drm/amd/display/dc/dml2/dml2_translation_helper.c @@ -892,7 +892,7 @@ static void populate_dummy_dml_surface_cfg(struct dml_surface_cfg_st *out, unsig out->SurfaceWidthC[location] = in->timing.h_addressable; out->SurfaceHeightC[location] = in->timing.v_addressable; out->PitchY[location] = ((out->SurfaceWidthY[location] + 127) / 128) * 128; - out->PitchC[location] = 0; + out->PitchC[location] = 1; out->DCCEnable[location] = false; out->DCCMetaPitchY[location] = 0; out->DCCMetaPitchC[location] = 0;