Skip to contentSkip to conversation

drm/amd/display: Reject non-zero src_y and src_x for video planes

PATCH Superseded Harry Wentland 2 participants 3 messages Apr 23, 2021

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Harry Wentland

author maintainer
#0 lore raw

PATCH v2 1/1 drm/amd/display: Reject non-zero src_y and src_x for video planes

[Why]
This hasn't been well tested and leads to complete system hangs on DCN1 based systems, possibly others.

The system hang can be reproduced by gesturing the video on the YouTube Android app on ChromeOS into full screen.

[How]
Reject atomic commits with non-zero drm_plane_state.src_x or src_y values.

v2:
- Add code comment describing the reason we're rejecting non-zero src_x and src_y
- Drop gerrit Change-Id
- Add stable CC
- Based on amd-staging-drm-next

---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c   | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +17 -0
index be1769d29742..b12469043e6b 100644
@@ -4089,6 +4089,23 @@ static int fill_dc_scaling_info(const struct drm_plane_state *state,
 	scaling_info->src_rect.x = state->src_x >> 16;
 	scaling_info->src_rect.y = state->src_y >> 16;
 
+	/*
+	 * For reasons we don't (yet) fully understand a non-zero
+	 * src_y coordinate into an NV12 buffer can cause a
+	 * system hang. To avoid hangs (and maybe be overly cautious)
+	 * let's reject both non-zero src_x and src_y.
+	 * 
+	 * We currently know of only one use-case to reproduce a
+	 * scenario with non-zero src_x and src_y for NV12, which
+	 * is to gesture the YouTube Android app into full screen
+	 * on ChromeOS.
+	 */
+	if (state->fb &&
+	    state->fb->format->format == DRM_FORMAT_NV12 &&
+	    (scaling_info->src_rect.x != 0 ||
+	     scaling_info->src_rect.y != 0))
+		return -EINVAL;
+
 	scaling_info->src_rect.width = state->src_w >> 16;
 	if (scaling_info->src_rect.width == 0)
 		return -EINVAL;
Signature · 1 line
2.31.1
#1 lore raw

Good that this has been found. Just a curious guess, but have you guys checked if the src_x and src_y are a multiple of 2?

Might cause problems to try to access a subsampled surface if the coordinates doesn't make much sense.

Anyway patch is Acked-by: Christian König <[email protected]>

Regards,
Christian.

Am 23.04.21 um 16:09 schrieb Harry Wentland:

Quoted 48 lines

[Why]
This hasn't been well tested and leads to complete system hangs on DCN1 based systems, possibly others.

The system hang can be reproduced by gesturing the video on the YouTube Android app on ChromeOS into full screen.

[How]
Reject atomic commits with non-zero drm_plane_state.src_x or src_y values.

v2:
- Add code comment describing the reason we're rejecting non-zero src_x and src_y
- Drop gerrit Change-Id
- Add stable CC
- Based on amd-staging-drm-next

---
  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c   | 17 +++++++++++++++++
  1 file changed, 17 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +10 -0
index be1769d29742..b12469043e6b 100644
@@ -4089,6 +4089,23 @@ static int fill_dc_scaling_info(const struct drm_plane_state *state,
  	scaling_info->src_rect.x = state->src_x >> 16;
  	scaling_info->src_rect.y = state->src_y >> 16;
 
+	/*
+	 * For reasons we don't (yet) fully understand a non-zero
+	 * src_y coordinate into an NV12 buffer can cause a
+	 * system hang. To avoid hangs (and maybe be overly cautious)
+	 * let's reject both non-zero src_x and src_y.
+	 *
+	 * We currently know of only one use-case to reproduce a
+	 * scenario with non-zero src_x and src_y for NV12, which
+	 * is to gesture the YouTube Android app into full screen
+	 * on ChromeOS.

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int fill_dc_scaling_info(const struct drm_plane_state *state, · line 4111

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +7 -0
+	 */
+	if (state->fb &&
+	    state->fb->format->format == DRM_FORMAT_NV12 &&
+	    (scaling_info->src_rect.x != 0 ||
+	     scaling_info->src_rect.y != 0))
+		return -EINVAL;
+
  	scaling_info->src_rect.width = state->src_w >> 16;
  	if (scaling_info->src_rect.width == 0)
  		return -EINVAL;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author maintainer
#2 lore raw
Quoted 2 lines · Christian König

Good that this has been found. Just a curious guess, but have you guys checked if the src_x and src_y are a multiple of 2?

That was one of my first guesses but I still observed the hang after forcing src_x and src_y to be multiples of 2.

Quoted 4 lines

Might cause problems to try to access a subsampled surface if the coordinates doesn't make much sense.

Anyway patch is Acked-by: Christian König <[email protected]>

Thanks,
Harry

Quoted 63 lines

Regards,
Christian.

Am 23.04.21 um 16:09 schrieb Harry Wentland:

Quoted 58 lines

[Why]
This hasn't been well tested and leads to complete system hangs on DCN1 based systems, possibly others.

The system hang can be reproduced by gesturing the video on the YouTube Android app on ChromeOS into full screen.

[How]
Reject atomic commits with non-zero drm_plane_state.src_x or src_y values.

v2:
  - Add code comment describing the reason we're rejecting non-zero src_x and src_y
  - Drop gerrit Change-Id
  - Add stable CC
  - Based on amd-staging-drm-next

---
  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c   | 17 +++++++++++++++++

  1 file changed, 17 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +17 -0
index be1769d29742..b12469043e6b 100644
@@ -4089,6 +4089,23 @@ static int fill_dc_scaling_info(const struct 
 drm_plane_state *state,
       scaling_info->src_rect.x = state->src_x >> 16;
       scaling_info->src_rect.y = state->src_y >> 16;
+    /*
+     * For reasons we don't (yet) fully understand a non-zero
+     * src_y coordinate into an NV12 buffer can cause a
+     * system hang. To avoid hangs (and maybe be overly cautious)
+     * let's reject both non-zero src_x and src_y.
+     *
+     * We currently know of only one use-case to reproduce a
+     * scenario with non-zero src_x and src_y for NV12, which
+     * is to gesture the YouTube Android app into full screen
+     * on ChromeOS.
+     */
+    if (state->fb &&
+        state->fb->format->format == DRM_FORMAT_NV12 &&
+        (scaling_info->src_rect.x != 0 ||
+         scaling_info->src_rect.y != 0))
+        return -EINVAL;
+
       scaling_info->src_rect.width = state->src_w >> 16;
       if (scaling_info->src_rect.width == 0)
           return -EINVAL;