summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/amd/display/dc/dml2_0
diff options
context:
space:
mode:
authorAlex Hung <alex.hung@amd.com>2026-09-11 10:29:02 -0600
committerAlex Deucher <alexander.deucher@amd.com>2026-09-23 14:19:40 -0400
commit92dd8d3edf395efbe812d29dba763098885befbe (patch)
tree10aad9d972629872cb44f24674854940b8dd8c76 /drivers/gpu/drm/amd/display/dc/dml2_0
parent708d3e7aeec1cfd53fe6b9b048e92ac3eca6c59a (diff)
downloadlinux-next-92dd8d3edf395efbe812d29dba763098885befbe.tar.gz
linux-next-92dd8d3edf395efbe812d29dba763098885befbe.zip
drm/amd/display: Fix LSDMA divide by zero
[WHY] element_size_to_bytes_per_pixel() handled only element sizes 0 to 4 and returned 0 for every other value, and an unexpected element size caused a divide by zero. [HOW] Derive the size as 1 << element_size, which matches the existing encoding, and fall back to 1 for values of 8 or more to keep the result nonzero. Reviewed-by: Austin Zheng <austin.zheng@amd.com> Signed-off-by: Alex Hung <alex.hung@amd.com> Signed-off-by: George Zhang <george.zhang@amd.com> Tested-by: Dan Wheeler <daniel.wheeler@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/display/dc/dml2_0')
-rw-r--r--drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_standalone_libraries/alternate_pstate_shared_lib.c22
1 files changed, 1 insertions, 21 deletions
diff --git a/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_standalone_libraries/alternate_pstate_shared_lib.c b/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_standalone_libraries/alternate_pstate_shared_lib.c
index 53ead9f687ac..f082f058001e 100644
--- a/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_standalone_libraries/alternate_pstate_shared_lib.c
+++ b/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_standalone_libraries/alternate_pstate_shared_lib.c
@@ -884,27 +884,7 @@ static void populate_lsdma_start_end_lines(
static uint8_t element_size_to_bytes_per_pixel(uint8_t element_size)
{
- uint8_t bytes_per_pixel = 0;
-
- switch (element_size) { // 0: 8bpp, 1: 16bpp, 2: 32bpp, 3: 64bpp, 4: 128bpp - Values supported by LSDMA Controller
- case 0:
- bytes_per_pixel = 1;
- break;
- case 1:
- bytes_per_pixel = 2;
- break;
- case 2:
- bytes_per_pixel = 4;
- break;
- case 3:
- bytes_per_pixel = 8;
- break;
- case 4:
- bytes_per_pixel = 16;
- break;
- }
-
- return bytes_per_pixel;
+ return element_size < 8 ? (uint8_t)(1U << element_size) : 1;
}
static void populate_lsdma(