Hi! AFAIU, the driver is defining two different max number of surfaces: MAX_SURFACES (dc.h) and MAX_SURFACE_NUM (dc_types.h) Many years ago, MAX_SURFACES was set 3 just to prevent a stack size warning as in 091a97e542cf ("drm/amd/display: Fix warning. Set MAX_SURFACES to 3")[1]. But according to commit 3cfd03b79425 ("update max streams per surface")[2], from 2023, six is the real max number of surfaces supported by any asics and the warning that motivated [1] seems not valid anymore. This mismatch looks a bit problematic per se, and I wonder if we should start using only one definition (MAX_SURFACES or MAX_SURFACE_NUM) in the whole driver. Also, with MAX_PLANES and MAX_STREAMS both set as 6, there are some driver with `max_slave_planes = 2` and so the maximum of 3 surfaces can cause an array-index-out-of-bonds, as reported by [3] and pointed out in the second patch of this series (MAX_SURFACES < plane_count). I suppose that this blew up after 1d0c9ded4519 ("Introduce overlay cursor mode") [4], since it uses one more DCN plane for cursor overlay mode. So, the first patch just update MAX_SURFACES to 6 and the second add some debug prints to warn when changes on these values might cause array-index-out-of-bounds. Let me know your thoughts. Thanks, Melissa [1] https://gitlab.freedesktop.org/agd5f/linux/-/commit/091a97e542cf [2] https://gitlab.freedesktop.org/agd5f/linux/-/commit/3cfd03b79425 [3] https://gitlab.freedesktop.org/drm/amd/-/issues/3594 [4] https://lore.kernel.org/amd-gfx/20240315170959.165505-2-sunpeng.li@xxxxxxx/ Melissa Wen (2): drm/amd/display: increase max surfaces in line with planes and streams drm/amd/display: add warnings for MAX_SURFACES mismatch .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 20 +++++++++++++++++++ drivers/gpu/drm/amd/display/dc/dc.h | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) -- 2.45.2