[PATCH 2/2] drm/amd/display: add warnings for MAX_SURFACES mismatch
Melissa Wen
mwen at igalia.com
Wed Sep 25 15:37:19 UTC 2024
So that, in the future, when the max number of planes and streams
increases, they might be synced with the number of surfaces to prevent
array-index-out-of-bounds issues.
Signed-off-by: Melissa Wen <mwen at igalia.com>
---
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 20 +++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 6d12def3e8b3..95db2b1cc91a 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3098,6 +3098,13 @@ static void dm_gpureset_commit_state(struct dc_state *dc_state,
for (k = 0; k < dc_state->stream_count; k++) {
bundle->stream_update.stream = dc_state->streams[k];
+ if (MAX_SURFACES < dc_state->stream_status->plane_count) {
+ drm_warn(dm->ddev, "Not enough dc_surface_update for the "
+ "number of planes. Please increase "
+ "MAX_SURFACES inline to MAX_PLANES.\n");
+ continue;
+ }
+
for (m = 0; m < dc_state->stream_status->plane_count; m++) {
bundle->surface_updates[m].surface =
dc_state->stream_status->plane_states[m];
@@ -8923,6 +8930,13 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
if (!dc_plane)
continue;
+ if (MAX_SURFACES < planes_count) {
+ drm_warn(dev, "Not enough dc_surface_update for the "
+ "number of planes. Please increase "
+ "MAX_SURFACES inline to MAX_PLANES.\n");
+ continue;
+ }
+
bundle->surface_updates[planes_count].surface = dc_plane;
if (new_pcrtc_state->color_mgmt_changed) {
bundle->surface_updates[planes_count].gamma = &dc_plane->gamma_correction;
@@ -9874,6 +9888,12 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
WARN_ON(!status->plane_count);
+ if (MAX_SURFACES < status->plane_count) {
+ drm_warn(dev, "Not enough dc_surface_update for the "
+ "number of planes. Please increase "
+ "MAX_SURFACES inline to MAX_PLANES.\n");
+ continue;
+ }
/*
* TODO: DC refuses to perform stream updates without a dc_surface_update.
* Here we create an empty update on each plane.
--
2.45.2
More information about the dri-devel
mailing list