]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/amd/display: Skip inactive planes within ModeSupportAndSystemConfiguration
authorHersen Wu <hersenxs.wu@amd.com>
Fri, 26 Apr 2024 20:39:37 +0000 (16:39 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Apr 2025 12:31:01 +0000 (14:31 +0200)
commit a54f7e866cc73a4cb71b8b24bb568ba35c8969df upstream.

[Why]
Coverity reports Memory - illegal accesses.

[How]
Skip inactive planes.

Reviewed-by: Alex Hung <alex.hung@amd.com>
Acked-by: Tom Chung <chiahsuan.chung@amd.com>
Signed-off-by: Hersen Wu <hersenxs.wu@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
[get_pipe_idx() was introduced as a helper by
dda4fb85e433 ("drm/amd/display: DML changes for DCN32/321") in v6.0.
This patch backports it to make code clearer. And minor conflict is
resolved due to code context change.]
Signed-off-by: Jianqi Ren <jianqi.ren.cn@windriver.com>
Signed-off-by: He Zhe <zhe.he@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/amd/display/dc/dml/display_mode_vba.c

index 079fa52a737918c4b919d0ef60d0aebd6b29af6f..bfb0be4e60a6fe66d331eeae5fe288ec68d64706 100644 (file)
@@ -838,11 +838,30 @@ static unsigned int CursorBppEnumToBits(enum cursor_bpp ebpp)
        }
 }
 
+static unsigned int get_pipe_idx(struct display_mode_lib *mode_lib, unsigned int plane_idx)
+{
+       int pipe_idx = -1;
+       int i;
+
+       ASSERT(plane_idx < DC__NUM_DPP__MAX);
+
+       for (i = 0; i < DC__NUM_DPP__MAX ; i++) {
+               if (plane_idx == mode_lib->vba.pipe_plane[i]) {
+                       pipe_idx = i;
+                       break;
+               }
+       }
+       ASSERT(pipe_idx >= 0);
+
+       return pipe_idx;
+}
+
 void ModeSupportAndSystemConfiguration(struct display_mode_lib *mode_lib)
 {
        soc_bounding_box_st *soc = &mode_lib->vba.soc;
        unsigned int k;
        unsigned int total_pipes = 0;
+       unsigned int pipe_idx = 0;
 
        mode_lib->vba.VoltageLevel = mode_lib->vba.cache_pipes[0].clks_cfg.voltage;
        mode_lib->vba.ReturnBW = mode_lib->vba.ReturnBWPerState[mode_lib->vba.VoltageLevel][mode_lib->vba.maxMpcComb];
@@ -862,8 +881,14 @@ void ModeSupportAndSystemConfiguration(struct display_mode_lib *mode_lib)
                mode_lib->vba.DISPCLK = soc->clock_limits[mode_lib->vba.VoltageLevel].dispclk_mhz;
 
        // Total Available Pipes Support Check
-       for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k)
+       for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
+               pipe_idx = get_pipe_idx(mode_lib, k);
+               if (pipe_idx == -1) {
+                       ASSERT(0);
+                       continue; // skip inactive planes
+               }
                total_pipes += mode_lib->vba.DPPPerPlane[k];
+       }
        ASSERT(total_pipes <= DC__NUM_DPP__MAX);
 }