drm/amd/display: Avoid divide by zero by initializing dummy pitch to 1
authorMario Limonciello <mario.limonciello@amd.com>
Tue, 21 Jan 2025 22:03:52 +0000 (16:03 -0600)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 21 Apr 2025 15:27:29 +0000 (11:27 -0400)
[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>
drivers/gpu/drm/amd/display/dc/dml2/dml2_translation_helper.c

index 2061d43b92e1b99467cd68700a4f1280f5c778e3..857ce1695fd557691c08b6fa6f4179f2da8ee1cd 100644 (file)
@@ -896,7 +896,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;