Skip to contentSkip to conversation

drm/amd/display: Fix overlay validation by considering cursors

PATCH In review Rodrigo Siqueira 7 participants 13 messages May 14, 2021 – Jun 8, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/display: Fix overlay validation by considering cursors

A few weeks ago, we saw a two cursor issue in a ChromeOS system. We fixed it in the commit:

drm/amd/display: Fix two cursor duplication when using overlay (read the commit message for more details)

After this change, we noticed that some IGT subtests related to kms_plane and kms_plane_scaling started to fail. After investigating this issue, we noticed that all subtests that fail have a primary plane covering the overlay plane, which is currently rejected by amdgpu dm. Fail those IGT tests highlight that our verification was too broad and compromises the overlay usage in our drive. This patch fixes this issue by ensuring that we only reject commits where the primary plane is not fully covered by the overlay when the cursor hardware is enabled. With this fix, all IGT tests start to pass again, which means our overlay support works as expected.

Cc Tianci.Yin <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Nicholas Choi <[email protected]>
Cc Bhawanpreet Lakha <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
Cc Mark Yacoub <[email protected]>
Cc Daniel Wheeler <[email protected]>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +9 -1
index ccd67003b120..9c2537a17a7b 100644
@@ -10067,7 +10067,7 @@ static int validate_overlay(struct drm_atomic_state *state)
 	int i;
 	struct drm_plane *plane;
 	struct drm_plane_state *old_plane_state, *new_plane_state;
-	struct drm_plane_state *primary_state, *overlay_state = NULL;
+	struct drm_plane_state *primary_state, *cursor_state, *overlay_state = NULL;
 
 	/* Check if primary plane is contained inside overlay */
 	for_each_oldnew_plane_in_state_reverse(state, plane, old_plane_state, new_plane_state, i) {
@@ -10097,6 +10097,14 @@ static int validate_overlay(struct drm_atomic_state *state)
 	if (!primary_state->crtc)
 		return 0;
 
+	/* check if cursor plane is enabled */
+	cursor_state = drm_atomic_get_plane_state(state, overlay_state->crtc->cursor);
+	if (IS_ERR(cursor_state))
+		return PTR_ERR(cursor_state);
+
+	if (drm_atomic_plane_disabling(plane->state, cursor_state))
+		return 0;
+
 	/* Perform the bounds check to ensure the overlay plane covers the primary */
 	if (primary_state->crtc_x < overlay_state->crtc_x ||
 	    primary_state->crtc_y < overlay_state->crtc_y ||
Signature · 6 lines
2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Tested-by on v1 1/1
#1 lore raw

[AMD Public Use]

The tests that failed previously for me were:
amdgpu/amd_plane -> mpo-swizzle-toggle kms_atomic -> plane-overlay-legacy kms_plane -> plane-position-covered-pipe-a-planes kms_plane -> plane-position-covered-pipe-c-planes kms_plane -> plane-position-hole-dpms-pipe-a-planes kms_plane -> plane-position-hole-dpms-pipe-c-planes kms_plane -> plane-position-hole-pipe-a-planes kms_plane -> plane-position-hole-pipe-c-planes kms_plane_scaling -> pipe-a-plane-scaling kms_plane_scaling -> pipe-c-plane-scaling

After testing this patch on a HP Envy 360, with Ryzen 5 4500u, a Sapphire Pulse RX5700XT, and an AMD Reference RX6800, these tests all now pass.

Thank you,

Dan Wheeler
Technologist | AMD
SW Display
------------------------------------------------------------------------------------------------------------------
1 Commerce Valley Dr E, Thornhill, ON L3T 7X6
Facebook | Twitter | amd.com

Thank you,

Dan Wheeler
Technologist  |  AMD
SW Display
O +(1) 905-882-2600 ext. 74665
------------------------------------------------------------------------------------------------------------------
1 Commerce Valley Dr E, Thornhill, ON L3T 7X6
Facebook |  Twitter |  amd.com

-----Original Message-----
From: Siqueira, Rodrigo <[email protected]>
Sent: May 14, 2021 7:48 AM
To: [email protected]
Cc: Yin, Tianci (Rico) <[email protected]>; Wentland, Harry <[email protected]>; Choi, Nicholas <[email protected]>; Lakha, Bhawanpreet <[email protected]>; Kazlauskas, Nicholas <[email protected]>; Mark Yacoub <[email protected]>; Wheeler, Daniel <[email protected]>
Subject: [PATCH] drm/amd/display: Fix overlay validation by considering cursors

A few weeks ago, we saw a two cursor issue in a ChromeOS system. We fixed it in the commit:

drm/amd/display: Fix two cursor duplication when using overlay (read the commit message for more details)

After this change, we noticed that some IGT subtests related to kms_plane and kms_plane_scaling started to fail. After investigating this issue, we noticed that all subtests that fail have a primary plane covering the overlay plane, which is currently rejected by amdgpu dm.
Fail those IGT tests highlight that our verification was too broad and compromises the overlay usage in our drive. This patch fixes this issue by ensuring that we only reject commits where the primary plane is not fully covered by the overlay when the cursor hardware is enabled. With this fix, all IGT tests start to pass again, which means our overlay support works as expected.

Cc Tianci.Yin <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Nicholas Choi <[email protected]>
Cc Bhawanpreet Lakha <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
Cc Mark Yacoub <[email protected]>
Cc Daniel Wheeler <[email protected]>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -1
index ccd67003b120..9c2537a17a7b 100644
@@ -10067,7 +10067,7 @@ static int validate_overlay(struct drm_atomic_state *state)
 	int i;
 	struct drm_plane *plane;
 	struct drm_plane_state *old_plane_state, *new_plane_state;
-	struct drm_plane_state *primary_state, *overlay_state = NULL;
+	struct drm_plane_state *primary_state, *cursor_state, *overlay_state = 
+NULL;
 
 	/* Check if primary plane is contained inside overlay */

for_each_oldnew_plane_in_state_reverse(state, plane, old_plane_state, new_plane_state, i) { @@ -10097,6 +10097,14 @@ static int validate_overlay(struct drm_atomic_state *state) if (!primary_state->crtc)
return 0;

+ /* check if cursor plane is enabled */
+ cursor_state = drm_atomic_get_plane_state(state, overlay_state->crtc->cursor);
+ if (IS_ERR(cursor_state))
+ return PTR_ERR(cursor_state);
+
+ if (drm_atomic_plane_disabling(plane->state, cursor_state))
+ return 0;
+
/* Perform the bounds check to ensure the overlay plane covers the primary */

 	if (primary_state->crtc_x < overlay_state->crtc_x ||
 	    primary_state->crtc_y < overlay_state->crtc_y ||

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

maintainer
#2 lore raw
In reply to Rodrigo Siqueira
Quoted 45 lines · Rodrigo Siqueira

A few weeks ago, we saw a two cursor issue in a ChromeOS system. We fixed it in the commit:

drm/amd/display: Fix two cursor duplication when using overlay (read the commit message for more details)

After this change, we noticed that some IGT subtests related to kms_plane and kms_plane_scaling started to fail. After investigating this issue, we noticed that all subtests that fail have a primary plane covering the overlay plane, which is currently rejected by amdgpu dm. Fail those IGT tests highlight that our verification was too broad and compromises the overlay usage in our drive. This patch fixes this issue by ensuring that we only reject commits where the primary plane is not fully covered by the overlay when the cursor hardware is enabled. With this fix, all IGT tests start to pass again, which means our overlay support works as expected.

Cc Tianci.Yin <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Nicholas Choi <[email protected]>
Cc Bhawanpreet Lakha <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
Cc Mark Yacoub <[email protected]>
Cc Daniel Wheeler <[email protected]>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
index ccd67003b120..9c2537a17a7b 100644
@@ -10067,7 +10067,7 @@ static int validate_overlay(struct drm_atomic_state *state)
 	int i;
 	struct drm_plane *plane;
 	struct drm_plane_state *old_plane_state, *new_plane_state;
-	struct drm_plane_state *primary_state, *overlay_state = NULL;
+	struct drm_plane_state *primary_state, *cursor_state, *overlay_state = NULL;
 
 	/* Check if primary plane is contained inside overlay */
 	for_each_oldnew_plane_in_state_reverse(state, plane, old_plane_state, new_plane_state, i) {
@@ -10097,6 +10097,14 @@ static int validate_overlay(struct drm_atomic_state *state)
 	if (!primary_state->crtc)

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int validate_overlay(struct drm_atomic_state *state) · line 10107

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +8 -0
 		return 0;
 
+	/* check if cursor plane is enabled */
+	cursor_state = drm_atomic_get_plane_state(state, overlay_state->crtc->cursor);
+	if (IS_ERR(cursor_state))
+		return PTR_ERR(cursor_state);
+
+	if (drm_atomic_plane_disabling(plane->state, cursor_state))
+		return 0;
+

I thought this breaks Chrome's compositor since it can't handle an atomic commit rejection based solely on whether a cursor is enabled or not.

Harry

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int validate_overlay(struct drm_atomic_state *state) · line 10110

Quoted 4 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
 	/* Perform the bounds check to ensure the overlay plane covers the primary */
 	if (primary_state->crtc_x < overlay_state->crtc_x ||
 	    primary_state->crtc_y < overlay_state->crtc_y ||

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

#3 lore raw
Quoted 61 lines · Harry Wentland
Quoted 45 lines · Rodrigo Siqueira

A few weeks ago, we saw a two cursor issue in a ChromeOS system. We fixed it in the commit:

drm/amd/display: Fix two cursor duplication when using overlay (read the commit message for more details)

After this change, we noticed that some IGT subtests related to kms_plane and kms_plane_scaling started to fail. After investigating this issue, we noticed that all subtests that fail have a primary plane covering the overlay plane, which is currently rejected by amdgpu dm. Fail those IGT tests highlight that our verification was too broad and compromises the overlay usage in our drive. This patch fixes this issue by ensuring that we only reject commits where the primary plane is not fully covered by the overlay when the cursor hardware is enabled. With this fix, all IGT tests start to pass again, which means our overlay support works as expected.

Cc Tianci.Yin <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Nicholas Choi <[email protected]>
Cc Bhawanpreet Lakha <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
Cc Mark Yacoub <[email protected]>
Cc Daniel Wheeler <[email protected]>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
index ccd67003b120..9c2537a17a7b 100644
@@ -10067,7 +10067,7 @@ static int validate_overlay(struct drm_atomic_state *state)
      int i;
      struct drm_plane *plane;
      struct drm_plane_state *old_plane_state, *new_plane_state;
-     struct drm_plane_state *primary_state, *overlay_state = NULL;
+     struct drm_plane_state *primary_state, *cursor_state, *overlay_state = NULL;
 
      /* Check if primary plane is contained inside overlay */
      for_each_oldnew_plane_in_state_reverse(state, plane, old_plane_state, new_plane_state, i) {
@@ -10097,6 +10097,14 @@ static int validate_overlay(struct drm_atomic_state *state)
      if (!primary_state->crtc)

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int validate_overlay(struct drm_atomic_state *state) · line 10107

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +8 -0
              return 0;
 
+     /* check if cursor plane is enabled */
+     cursor_state = drm_atomic_get_plane_state(state, overlay_state->crtc->cursor);
+     if (IS_ERR(cursor_state))
+             return PTR_ERR(cursor_state);
+
+     if (drm_atomic_plane_disabling(plane->state, cursor_state))
+             return 0;
+

I thought this breaks Chrome's compositor since it can't handle an atomic commit rejection based solely on whether a cursor is enabled or not.

Quoted 7 lines

Harry

Quoted 4 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
      /* Perform the bounds check to ensure the overlay plane covers the primary */
      if (primary_state->crtc_x < overlay_state->crtc_x ||
          primary_state->crtc_y < overlay_state->crtc_y ||

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

#4 lore raw
Quoted 10 lines · Mark Yacoub
Quoted 8 lines · Harry Wentland
Quoted 6 lines · Rodrigo Siqueira

A few weeks ago, we saw a two cursor issue in a ChromeOS system. We fixed it in the commit:

drm/amd/display: Fix two cursor duplication when using overlay (read the commit message for more details)

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

After this change, we noticed that some IGT subtests related to kms_plane and kms_plane_scaling started to fail. After investigating this issue, we noticed that all subtests that fail have a primary plane covering the overlay plane, which is currently rejected by amdgpu dm. Fail those IGT tests highlight that our verification was too broad and compromises the overlay usage in our drive. This patch fixes this issue

nit: s/drive/driver?

Quoted 35 lines
Quoted 35 lines
Quoted 35 lines

by ensuring that we only reject commits where the primary plane is not fully covered by the overlay when the cursor hardware is enabled. With this fix, all IGT tests start to pass again, which means our overlay support works as expected.

Cc Tianci.Yin <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Nicholas Choi <[email protected]>
Cc Bhawanpreet Lakha <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
Cc Mark Yacoub <[email protected]>
Cc Daniel Wheeler <[email protected]>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
index ccd67003b120..9c2537a17a7b 100644
@@ -10067,7 +10067,7 @@ static int validate_overlay(struct drm_atomic_state *state)
      int i;
      struct drm_plane *plane;
      struct drm_plane_state *old_plane_state, *new_plane_state;
-     struct drm_plane_state *primary_state, *overlay_state = NULL;
+     struct drm_plane_state *primary_state, *cursor_state, *overlay_state = NULL;
 
      /* Check if primary plane is contained inside overlay */
      for_each_oldnew_plane_in_state_reverse(state, plane, old_plane_state, new_plane_state, i) {
@@ -10097,6 +10097,14 @@ static int validate_overlay(struct drm_atomic_state *state)
      if (!primary_state->crtc)
              return 0;
 
Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int validate_overlay(struct drm_atomic_state *state) · line 10107

Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +8 -0
+     /* check if cursor plane is enabled */
+     cursor_state = drm_atomic_get_plane_state(state, overlay_state->crtc->cursor);
+     if (IS_ERR(cursor_state))
+             return PTR_ERR(cursor_state);
+
+     if (drm_atomic_plane_disabling(plane->state, cursor_state))
+             return 0;
+

I thought this breaks Chrome's compositor since it can't handle an atomic commit rejection based solely on whether a cursor is enabled or not.

For context: To use overlays (the old/current async way), Chrome tests if an overlay strategy will work by doing an atomic commit with a TEST flag to check if the combination would work. If it works, it flags this planes configuration as valid. As it's valid, it performs an atomic page flip (which could also include the cursor).
So to Harry's point, you would pass an atomic test but fail on an atomic page flip with the exact same configuration that's been flagged as valid. Failing a pageflip causes Chrome to crash (Reset the GPU process cause something went horribly wrong when it shouldn't).

Quoted 8 lines
Quoted 8 lines

Harry

Quoted 4 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
      /* Perform the bounds check to ensure the overlay plane covers the primary */
      if (primary_state->crtc_x < overlay_state->crtc_x ||
          primary_state->crtc_y < overlay_state->crtc_y ||

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

#5 lore raw
Quoted 64 lines · Mark Yacoub
Quoted 10 lines · Mark Yacoub
Quoted 8 lines · Harry Wentland
Quoted 6 lines · Rodrigo Siqueira

A few weeks ago, we saw a two cursor issue in a ChromeOS system. We fixed it in the commit:

drm/amd/display: Fix two cursor duplication when using overlay (read the commit message for more details)

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

After this change, we noticed that some IGT subtests related to kms_plane and kms_plane_scaling started to fail. After investigating this issue, we noticed that all subtests that fail have a primary plane covering the overlay plane, which is currently rejected by amdgpu dm. Fail those IGT tests highlight that our verification was too broad and compromises the overlay usage in our drive. This patch fixes this issue

nit: s/drive/driver?

Quoted 35 lines
Quoted 35 lines
Quoted 35 lines

by ensuring that we only reject commits where the primary plane is not fully covered by the overlay when the cursor hardware is enabled. With this fix, all IGT tests start to pass again, which means our overlay support works as expected.

Cc Tianci.Yin <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Nicholas Choi <[email protected]>
Cc Bhawanpreet Lakha <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
Cc Mark Yacoub <[email protected]>
Cc Daniel Wheeler <[email protected]>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
index ccd67003b120..9c2537a17a7b 100644
@@ -10067,7 +10067,7 @@ static int validate_overlay(struct drm_atomic_state *state)
      int i;
      struct drm_plane *plane;
      struct drm_plane_state *old_plane_state, *new_plane_state;
-     struct drm_plane_state *primary_state, *overlay_state = NULL;
+     struct drm_plane_state *primary_state, *cursor_state, *overlay_state = NULL;
 
      /* Check if primary plane is contained inside overlay */
      for_each_oldnew_plane_in_state_reverse(state, plane, old_plane_state, new_plane_state, i) {
@@ -10097,6 +10097,14 @@ static int validate_overlay(struct drm_atomic_state *state)
      if (!primary_state->crtc)
              return 0;
 
Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int validate_overlay(struct drm_atomic_state *state) · line 10107

Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +8 -0
+     /* check if cursor plane is enabled */
+     cursor_state = drm_atomic_get_plane_state(state, overlay_state->crtc->cursor);
+     if (IS_ERR(cursor_state))
+             return PTR_ERR(cursor_state);
+
+     if (drm_atomic_plane_disabling(plane->state, cursor_state))
+             return 0;
+

I thought this breaks Chrome's compositor since it can't handle an atomic commit rejection based solely on whether a cursor is enabled or not.

Quoted 9 lines

For context: To use overlays (the old/current async way), Chrome tests if an overlay strategy will work by doing an atomic commit with a TEST flag to check if the combination would work. If it works, it flags this planes configuration as valid. As it's valid, it performs an atomic page flip (which could also include the cursor).
So to Harry's point, you would pass an atomic test but fail on an atomic page flip with the exact same configuration that's been flagged as valid. Failing a pageflip causes Chrome to crash (Reset the GPU process cause something went horribly wrong when it shouldn't).

Hi Mark and Sean,

I don't know if I fully comprehended the scenario which in my patch might cause a ChromeOS crash, but this is what I understood:

There is a chance that we pass the atomic check (DRM_MODE_ATOMIC_TEST_ONLY - TEST) but fails in the atomic page flip because, after use TEST, the compositor might slightly change the commit config by adding the cursor. The reason behind that came from the assumption that adds the cursor in the atomic commit config after the test is harmless. Is my understand correct? Please, correct me if I'm wrong.

If the above reasoning is correct, I think the compositor should not assume anything extra from what it got from the atomic check.

Best Regards,
Siqueira

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Harry

Quoted 4 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
      /* Perform the bounds check to ensure the overlay plane covers the primary */
      if (primary_state->crtc_x < overlay_state->crtc_x ||
          primary_state->crtc_y < overlay_state->crtc_y ||
Signature · 2 lines
Rodrigo Siqueira
https://siqueira.tech

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

#6 lore raw
Quoted 76 lines · Rodrigo Siqueira
Quoted 64 lines · Mark Yacoub
Quoted 10 lines · Mark Yacoub
Quoted 8 lines · Harry Wentland
Quoted 6 lines · Rodrigo Siqueira

A few weeks ago, we saw a two cursor issue in a ChromeOS system. We fixed it in the commit:

drm/amd/display: Fix two cursor duplication when using overlay (read the commit message for more details)

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

After this change, we noticed that some IGT subtests related to kms_plane and kms_plane_scaling started to fail. After investigating this issue, we noticed that all subtests that fail have a primary plane covering the overlay plane, which is currently rejected by amdgpu dm. Fail those IGT tests highlight that our verification was too broad and compromises the overlay usage in our drive. This patch fixes this issue

nit: s/drive/driver?

Quoted 35 lines
Quoted 35 lines
Quoted 35 lines

by ensuring that we only reject commits where the primary plane is not fully covered by the overlay when the cursor hardware is enabled. With this fix, all IGT tests start to pass again, which means our overlay support works as expected.

Cc Tianci.Yin <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Nicholas Choi <[email protected]>
Cc Bhawanpreet Lakha <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
Cc Mark Yacoub <[email protected]>
Cc Daniel Wheeler <[email protected]>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
index ccd67003b120..9c2537a17a7b 100644
@@ -10067,7 +10067,7 @@ static int validate_overlay(struct drm_atomic_state *state)
      int i;
      struct drm_plane *plane;
      struct drm_plane_state *old_plane_state, *new_plane_state;
-     struct drm_plane_state *primary_state, *overlay_state = NULL;
+     struct drm_plane_state *primary_state, *cursor_state, *overlay_state = NULL;
 
      /* Check if primary plane is contained inside overlay */
      for_each_oldnew_plane_in_state_reverse(state, plane, old_plane_state, new_plane_state, i) {
@@ -10097,6 +10097,14 @@ static int validate_overlay(struct drm_atomic_state *state)
      if (!primary_state->crtc)
              return 0;
 
Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int validate_overlay(struct drm_atomic_state *state) · line 10107

Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +8 -0
+     /* check if cursor plane is enabled */
+     cursor_state = drm_atomic_get_plane_state(state, overlay_state->crtc->cursor);
+     if (IS_ERR(cursor_state))
+             return PTR_ERR(cursor_state);
+
+     if (drm_atomic_plane_disabling(plane->state, cursor_state))
+             return 0;
+

I thought this breaks Chrome's compositor since it can't handle an atomic commit rejection based solely on whether a cursor is enabled or not.

Quoted 9 lines

For context: To use overlays (the old/current async way), Chrome tests if an overlay strategy will work by doing an atomic commit with a TEST flag to check if the combination would work. If it works, it flags this planes configuration as valid. As it's valid, it performs an atomic page flip (which could also include the cursor).
So to Harry's point, you would pass an atomic test but fail on an atomic page flip with the exact same configuration that's been flagged as valid. Failing a pageflip causes Chrome to crash (Reset the GPU process cause something went horribly wrong when it shouldn't).

Quoted 5 lines

Hi Mark and Sean,

I don't know if I fully comprehended the scenario which in my patch might cause a ChromeOS crash, but this is what I understood:

Chrome compositor only does an atomic test when the layout geometry changes (ie: plane is added/removed/resized/moved). This does not take into consideration the cursor. Once the atomic test has been validated for a given layout geometry (set of planes/fbs along with their sizes and locations), Chrome assumes this will continue to be valid.

So the situation I'm envisioning is if the cursor is hidden, an overlay-based strategy will pass in the kernel. If at any time the cursor becomes visible, the kernel will start failing commits which causes Chrome's GPU process to crash.

In general I'm uneasy with using the cursor in the atomic check since it feels like it could be racy independent of the issue above. I haven't dove into the helper code enough to prove it, just a spidey-sense.

Sean

Quoted 23 lines

There is a chance that we pass the atomic check (DRM_MODE_ATOMIC_TEST_ONLY - TEST) but fails in the atomic page flip because, after use TEST, the compositor might slightly change the commit config by adding the cursor. The reason behind that came from the assumption that adds the cursor in the atomic commit config after the test is harmless. Is my understand correct? Please, correct me if I'm wrong.

If the above reasoning is correct, I think the compositor should not assume anything extra from what it got from the atomic check.

Best Regards,
Siqueira

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Harry

Quoted 4 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
      /* Perform the bounds check to ensure the overlay plane covers the primary */
      if (primary_state->crtc_x < overlay_state->crtc_x ||
          primary_state->crtc_y < overlay_state->crtc_y ||
Quoted 3 lines

--
Rodrigo Siqueira
https://siqueira.tech

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

maintainer
#7 lore raw
Quoted 95 lines · Sean Paul
Quoted 76 lines · Rodrigo Siqueira
Quoted 64 lines · Mark Yacoub
Quoted 10 lines · Mark Yacoub
Quoted 8 lines · Harry Wentland
Quoted 6 lines · Rodrigo Siqueira

A few weeks ago, we saw a two cursor issue in a ChromeOS system. We fixed it in the commit:

drm/amd/display: Fix two cursor duplication when using overlay (read the commit message for more details)

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

After this change, we noticed that some IGT subtests related to kms_plane and kms_plane_scaling started to fail. After investigating this issue, we noticed that all subtests that fail have a primary plane covering the overlay plane, which is currently rejected by amdgpu dm. Fail those IGT tests highlight that our verification was too broad and compromises the overlay usage in our drive. This patch fixes this issue

nit: s/drive/driver?

Quoted 35 lines
Quoted 35 lines
Quoted 35 lines

by ensuring that we only reject commits where the primary plane is not fully covered by the overlay when the cursor hardware is enabled. With this fix, all IGT tests start to pass again, which means our overlay support works as expected.

Cc Tianci.Yin <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Nicholas Choi <[email protected]>
Cc Bhawanpreet Lakha <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
Cc Mark Yacoub <[email protected]>
Cc Daniel Wheeler <[email protected]>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
index ccd67003b120..9c2537a17a7b 100644
@@ -10067,7 +10067,7 @@ static int validate_overlay(struct drm_atomic_state *state)
      int i;
      struct drm_plane *plane;
      struct drm_plane_state *old_plane_state, *new_plane_state;
-     struct drm_plane_state *primary_state, *overlay_state = NULL;
+     struct drm_plane_state *primary_state, *cursor_state, *overlay_state = NULL;
 
      /* Check if primary plane is contained inside overlay */
      for_each_oldnew_plane_in_state_reverse(state, plane, old_plane_state, new_plane_state, i) {
@@ -10097,6 +10097,14 @@ static int validate_overlay(struct drm_atomic_state *state)
      if (!primary_state->crtc)
              return 0;
 
Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int validate_overlay(struct drm_atomic_state *state) · line 10107

Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +8 -0
+     /* check if cursor plane is enabled */
+     cursor_state = drm_atomic_get_plane_state(state, overlay_state->crtc->cursor);
+     if (IS_ERR(cursor_state))
+             return PTR_ERR(cursor_state);
+
+     if (drm_atomic_plane_disabling(plane->state, cursor_state))
+             return 0;
+

I thought this breaks Chrome's compositor since it can't handle an atomic commit rejection based solely on whether a cursor is enabled or not.

Quoted 9 lines

For context: To use overlays (the old/current async way), Chrome tests if an overlay strategy will work by doing an atomic commit with a TEST flag to check if the combination would work. If it works, it flags this planes configuration as valid. As it's valid, it performs an atomic page flip (which could also include the cursor).
So to Harry's point, you would pass an atomic test but fail on an atomic page flip with the exact same configuration that's been flagged as valid. Failing a pageflip causes Chrome to crash (Reset the GPU process cause something went horribly wrong when it shouldn't).

Quoted 5 lines

Hi Mark and Sean,

I don't know if I fully comprehended the scenario which in my patch might cause a ChromeOS crash, but this is what I understood:

Chrome compositor only does an atomic test when the layout geometry changes (ie: plane is added/removed/resized/moved). This does not take into consideration the cursor. Once the atomic test has been validated for a given layout geometry (set of planes/fbs along with their sizes and locations), Chrome assumes this will continue to be valid.

So the situation I'm envisioning is if the cursor is hidden, an overlay-based strategy will pass in the kernel. If at any time the cursor becomes visible, the kernel will start failing commits which causes Chrome's GPU process to crash.

Quoted 5 lines

In general I'm uneasy with using the cursor in the atomic check since it feels like it could be racy independent of the issue above. I haven't dove into the helper code enough to prove it, just a spidey-sense.

Isn't the cursor supposed to be just another plane? If so, shouldn't adding/removing the cursor trigger an atomic test?

Is Chrome's compositor doing cursor update through legacy IOCTLs or through the ATOMIC IOCTL?

Thanks,
Harry

Quoted 28 lines

Sean

Quoted 26 lines

There is a chance that we pass the atomic check (DRM_MODE_ATOMIC_TEST_ONLY - TEST) but fails in the atomic page flip because, after use TEST, the compositor might slightly change the commit config by adding the cursor. The reason behind that came from the assumption that adds the cursor in the atomic commit config after the test is harmless. Is my understand correct? Please, correct me if I'm wrong.

If the above reasoning is correct, I think the compositor should not assume anything extra from what it got from the atomic check.

Best Regards,
Siqueira

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Harry

Quoted 4 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
      /* Perform the bounds check to ensure the overlay plane covers the primary */
      if (primary_state->crtc_x < overlay_state->crtc_x ||
          primary_state->crtc_y < overlay_state->crtc_y ||

--
Rodrigo Siqueira
https://siqueira.tech/>

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

#8 lore raw
Quoted 111 lines · Harry Wentland
Quoted 5 lines · Sean Paul
Quoted 3 lines · Rodrigo Siqueira
Quoted 1 line · Mark Yacoub

On Fri, May 14, 2021 at 12:31 PM Mark Yacoub <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On Fri, May 14, 2021 at 11:28 AM Harry Wentland <

Quoted 11 lines · [email protected]> wrote:
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines · Rodrigo Siqueira
Quoted 9 lines

A few weeks ago, we saw a two cursor issue in a ChromeOS system. We fixed it in the commit:

drm/amd/display: Fix two cursor duplication when using overlay (read the commit message for more details)

After this change, we noticed that some IGT subtests related to kms_plane and kms_plane_scaling started to fail. After investigating this issue, we noticed that all subtests that fail have a primary

plane

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

covering the overlay plane, which is currently rejected by amdgpu

dm.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Fail those IGT tests highlight that our verification was too broad

and

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

compromises the overlay usage in our drive. This patch fixes this

issue

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

nit: s/drive/driver?

Quoted 1 line
Quoted 1 line
Quoted 1 line

by ensuring that we only reject commits where the primary plane is

not

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

fully covered by the overlay when the cursor hardware is enabled.

With

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

this fix, all IGT tests start to pass again, which means our overlay support works as expected.

Cc Tianci.Yin <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Nicholas Choi <[email protected]>
Cc Bhawanpreet Lakha <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
Cc Mark Yacoub <[email protected]>
Cc Daniel Wheeler <[email protected]>
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Review

Quoted 6 lines
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int validate_overlay(struct

Quoted 4 lines

index ccd67003b120..9c2537a17a7b 100644

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
@@ -10067,7 +10067,7 @@ static int validate_overlay(struct

drm_atomic_state *state)

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int validate_overlay(struct · line 10070

Quoted 5 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
      int i;
      struct drm_plane *plane;
      struct drm_plane_state *old_plane_state, *new_plane_state;
-     struct drm_plane_state *primary_state, *overlay_state = NULL;
+     struct drm_plane_state *primary_state, *cursor_state,

*overlay_state = NULL;

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int validate_overlay(struct · line 10072

Quoted 3 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
      /* Check if primary plane is contained inside overlay */
      for_each_oldnew_plane_in_state_reverse(state, plane,

old_plane_state, new_plane_state, i) {

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int validate_overlay(struct

Quoted 1 line
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
@@ -10097,6 +10097,14 @@ static int validate_overlay(struct

drm_atomic_state *state)

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int validate_overlay(struct · line 10101

Quoted 5 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -0
      if (!primary_state->crtc)
              return 0;
 
+     /* check if cursor plane is enabled */
+     cursor_state = drm_atomic_get_plane_state(state,

overlay_state->crtc->cursor);

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int validate_overlay(struct · line 10107

Quoted 6 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +6 -0
+     if (IS_ERR(cursor_state))
+             return PTR_ERR(cursor_state);
+
+     if (drm_atomic_plane_disabling(plane->state, cursor_state))
+             return 0;
+

I thought this breaks Chrome's compositor since it can't handle an

atomic commit rejection

Quoted 28 lines
Quoted 11 lines
Quoted 10 lines
Quoted 1 line
Quoted 1 line

based solely on whether a cursor is enabled or not.

For context: To use overlays (the old/current async way), Chrome tests if an overlay strategy will work by doing an atomic commit with a TEST flag to check if the combination would work. If it works, it flags this planes configuration as valid. As it's valid, it performs an atomic page flip (which could also include the cursor).
So to Harry's point, you would pass an atomic test but fail on an atomic page flip with the exact same configuration that's been flagged as valid. Failing a pageflip causes Chrome to crash (Reset the GPU process cause something went horribly wrong when it shouldn't).

Quoted 5 lines

Hi Mark and Sean,

I don't know if I fully comprehended the scenario which in my patch might cause a ChromeOS crash, but this is what I understood:

Chrome compositor only does an atomic test when the layout geometry changes (ie: plane is added/removed/resized/moved). This does not take into consideration the cursor. Once the atomic test has been validated for a given layout geometry (set of planes/fbs along with their sizes and locations), Chrome assumes this will continue to be valid.

So the situation I'm envisioning is if the cursor is hidden, an overlay-based strategy will pass in the kernel. If at any time the cursor becomes visible, the kernel will start failing commits which causes Chrome's GPU process to crash.

Quoted 10 lines
Quoted 5 lines

In general I'm uneasy with using the cursor in the atomic check since it feels like it could be racy independent of the issue above. I haven't dove into the helper code enough to prove it, just a spidey-sense.

Isn't the cursor supposed to be just another plane? If so, shouldn't adding/removing the cursor trigger an atomic test?

Chrome is using legacy cursor.

Yes it will trigger an atomic test in the kernel, and that atomic test will fail. Unfortunately Chrome does not expect a failure so it will crash.

Sean

Is Chrome's compositor doing cursor update through legacy IOCTLs or

Quoted 18 lines

through the ATOMIC IOCTL?

Thanks,
Harry

Quoted 13 lines

Sean

Quoted 11 lines

There is a chance that we pass the atomic check (DRM_MODE_ATOMIC_TEST_ONLY - TEST) but fails in the atomic page flip because, after use TEST, the compositor might slightly change the commit config by adding the cursor. The reason behind that came from the assumption that adds the cursor in the atomic commit config after the test is harmless. Is my understand correct? Please, correct me if I'm wrong.

If the above reasoning is correct, I think the compositor should not assume anything extra from what it got from the atomic check.

Quoted 17 lines
Quoted 7 lines
Quoted 7 lines

Best Regards,
Siqueira

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Harry

Quoted 1 line
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
      /* Perform the bounds check to ensure the overlay plane

covers the primary */

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int validate_overlay(struct · line 10110

Quoted 3 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
      if (primary_state->crtc_x < overlay_state->crtc_x ||
          primary_state->crtc_y < overlay_state->crtc_y ||

--
Rodrigo Siqueira
https://siqueira.tech/>

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

#9 lore raw
Quoted 106 lines · Sean Paul

On Mon, Jun 7, 2021 at 2:37 PM Harry Wentland <[email protected] <mailto:[email protected]>> wrote:

On 2021-06-07 2:19 p.m., Sean Paul wrote:
> On Tue, May 18, 2021 at 2:58 PM Rodrigo Siqueira
> <[email protected] <mailto:[email protected]>> wrote:
>>
>> On 05/14, Mark Yacoub wrote:
>>> On Fri, May 14, 2021 at 12:31 PM Mark Yacoub <[email protected] <mailto:[email protected]>> wrote:
>>>>
>>>> On Fri, May 14, 2021 at 11:28 AM Harry Wentland <[email protected] <mailto:[email protected]>> wrote:
>>>>>
>>>>> On 2021-05-14 7:47 a.m., Rodrigo Siqueira wrote:
>>>>>> A few weeks ago, we saw a two cursor issue in a ChromeOS system. We
>>>>>> fixed it in the commit:
>>>>>>
>>>>>>  drm/amd/display: Fix two cursor duplication when using overlay
>>>>>>  (read the commit message for more details)
>>>>>>
>>>>>> After this change, we noticed that some IGT subtests related to
>>>>>> kms_plane and kms_plane_scaling started to fail. After investigating
>>>>>> this issue, we noticed that all subtests that fail have a primary plane
>>>>>> covering the overlay plane, which is currently rejected by amdgpu dm.
>>>>>> Fail those IGT tests highlight that our verification was too broad and
>>>>>> compromises the overlay usage in our drive. This patch fixes this issue
>>> nit: s/drive/driver?
>>>>>> by ensuring that we only reject commits where the primary plane is not
>>>>>> fully covered by the overlay when the cursor hardware is enabled. With
>>>>>> this fix, all IGT tests start to pass again, which means our overlay
>>>>>> support works as expected.
>>>>>>
>>>>>> Cc: Tianci.Yin <[email protected] <mailto:[email protected]>>
>>>>>> Cc: Harry Wentland <[email protected] <mailto:[email protected]>>
>>>>>> Cc: Nicholas Choi <[email protected] <mailto:[email protected]>>
>>>>>> Cc: Bhawanpreet Lakha <[email protected] <mailto:[email protected]>>
>>>>>> Cc: Nicholas Kazlauskas <[email protected] <mailto:[email protected]>> >>>>>> Cc: Mark Yacoub <[email protected] <mailto:[email protected]>>
>>>>>> Cc: Daniel Wheeler <[email protected] <mailto:[email protected]>>
>>>>>>
>>>>>> Signed-off-by: Rodrigo Siqueira <[email protected] <mailto:[email protected]>> >>>>>> ---
>>>>>>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 +++++++++-
>>>>>>  1 file changed, 9 insertions(+), 1 deletion(-)
>>>>>>
>>>>>> 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 ccd67003b120..9c2537a17a7b 100644
>>>>>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>>>>>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>>>>>> @@ -10067,7 +10067,7 @@ static int validate_overlay(struct drm_atomic_state *state)
>>>>>>       int i;
>>>>>>       struct drm_plane *plane;
>>>>>>       struct drm_plane_state *old_plane_state, *new_plane_state;
>>>>>> -     struct drm_plane_state *primary_state, *overlay_state = NULL;
>>>>>> +     struct drm_plane_state *primary_state, *cursor_state, *overlay_state = NULL;
>>>>>>
>>>>>>       /* Check if primary plane is contained inside overlay */
>>>>>>       for_each_oldnew_plane_in_state_reverse(state, plane, old_plane_state, new_plane_state, i) { >>>>>> @@ -10097,6 +10097,14 @@ static int validate_overlay(struct drm_atomic_state *state)
>>>>>>       if (!primary_state->crtc)
>>>>>>               return 0;
>>>>>>
>>>>>> +     /* check if cursor plane is enabled */
>>>>>> +     cursor_state = drm_atomic_get_plane_state(state, overlay_state->crtc->cursor);
>>>>>> +     if (IS_ERR(cursor_state))
>>>>>> +             return PTR_ERR(cursor_state);
>>>>>> +
>>>>>> +     if (drm_atomic_plane_disabling(plane->state, cursor_state))
>>>>>> +             return 0;
>>>>>> +
>>>>>
>>>>> I thought this breaks Chrome's compositor since it can't handle an atomic commit rejection >>>>> based solely on whether a cursor is enabled or not.
>>> For context: To use overlays (the old/current async way), Chrome tests
>>> if an overlay strategy will work by doing an atomic commit with a TEST
>>> flag to check if the combination would work. If it works, it flags
>>> this planes configuration as valid. As it's valid, it performs an
>>> atomic page flip (which could also include the cursor).
>>> So to Harry's point, you would pass an atomic test but fail on an
>>> atomic page flip with the exact same configuration that's been flagged
>>> as valid. Failing a pageflip causes Chrome to crash (Reset the GPU
>>> process cause something went horribly wrong when it shouldn't).
>>
>> Hi Mark and Sean,
>>
>> I don't know if I fully comprehended the scenario which in my patch
>> might cause a ChromeOS crash, but this is what I understood:
>>
>
> Chrome compositor only does an atomic test when the layout geometry
> changes (ie: plane is added/removed/resized/moved). This does not take
> into consideration the cursor. Once the atomic test has been validated
> for a given layout geometry (set of planes/fbs along with their sizes
> and locations), Chrome assumes this will continue to be valid.
>
> So the situation I'm envisioning is if the cursor is hidden, an
> overlay-based strategy will pass in the kernel. If at any time the
> cursor becomes visible, the kernel will start failing commits which
> causes Chrome's GPU process to crash.
>
> In general I'm uneasy with using the cursor in the atomic check since
> it feels like it could be racy independent of the issue above. I
> haven't dove into the helper code enough to prove it, just a
> spidey-sense.
>

Quoted 7 lines

Isn't the cursor supposed to be just another plane? If so, shouldn't adding/removing the cursor trigger an atomic test?

Chrome is using legacy cursor.

Yes it will trigger an atomic test in the kernel, and that atomic test will fail. Unfortunately Chrome does not expect a failure so it will crash.

The solution is probably indeed for atomic check to reject state which couldn't work if the cursor was enabled, even if the cursor is currently disabled. Otherwise one can hit various surprising errors via legacy APIs, as described in b836a274b797 "drm/amdgpu/dc: Require primary plane to be enabled whenever the CRTC is".

Signature · 6 lines
Earthling Michel Dänzer               |               https://redhat.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
maintainer
#10 lore raw
Quoted 9 lines · Michel Dänzer
Quoted 8 lines · Sean Paul

On Mon, Jun 7, 2021 at 2:37 PM Harry Wentland <[email protected] <mailto:[email protected]>> wrote:

    On 2021-06-07 2:19 p.m., Sean Paul wrote:
    > On Tue, May 18, 2021 at 2:58 PM Rodrigo Siqueira
    > <[email protected] <mailto:[email protected]>> wrote:
    >>

<snip>

Quoted 27 lines
Quoted 27 lines
Quoted 17 lines
Quoted 5 lines

Hi Mark and Sean,

I don't know if I fully comprehended the scenario which in my patch might cause a ChromeOS crash, but this is what I understood:

Chrome compositor only does an atomic test when the layout geometry changes (ie: plane is added/removed/resized/moved). This does not take into consideration the cursor. Once the atomic test has been validated for a given layout geometry (set of planes/fbs along with their sizes and locations), Chrome assumes this will continue to be valid.

So the situation I'm envisioning is if the cursor is hidden, an overlay-based strategy will pass in the kernel. If at any time the cursor becomes visible, the kernel will start failing commits which causes Chrome's GPU process to crash.

Quoted 5 lines

In general I'm uneasy with using the cursor in the atomic check since it feels like it could be racy independent of the issue above. I haven't dove into the helper code enough to prove it, just a spidey-sense.

Isn't the cursor supposed to be just another plane? If so, shouldn't adding/removing the cursor trigger an atomic test?

Quoted 6 lines
Quoted 3 lines

Chrome is using legacy cursor.

Yes it will trigger an atomic test in the kernel, and that atomic test will fail. Unfortunately Chrome does not expect a failure so it will crash.

The solution is probably indeed for atomic check to reject state which couldn't work if the cursor was enabled, even if the cursor is currently disabled. Otherwise one can hit various surprising errors via legacy APIs, as described in b836a274b797 "drm/amdgpu/dc: Require primary plane to be enabled whenever the CRTC is".

Agreed.

It's a bit unfortunate but the only way to deal with this better is if we had some way for DRM master to tell us whether it will only use the atomic IOCTL or use legacy IOCTLs (including a combination of atomic and legacy).

Harry

Quoted 1 line

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

#11 lore raw
Quoted 45 lines · Harry Wentland
Quoted 9 lines · Michel Dänzer
Quoted 8 lines · Sean Paul

On Mon, Jun 7, 2021 at 2:37 PM Harry Wentland <[email protected] <mailto:[email protected]>> wrote:

    On 2021-06-07 2:19 p.m., Sean Paul wrote:
    > On Tue, May 18, 2021 at 2:58 PM Rodrigo Siqueira
    > <[email protected] <mailto:[email protected]>> wrote:
    >>

<snip>

Quoted 29 lines
Quoted 29 lines
Quoted 17 lines
Quoted 5 lines

Hi Mark and Sean,

I don't know if I fully comprehended the scenario which in my patch might cause a ChromeOS crash, but this is what I understood:

Chrome compositor only does an atomic test when the layout geometry changes (ie: plane is added/removed/resized/moved). This does not take into consideration the cursor. Once the atomic test has been validated for a given layout geometry (set of planes/fbs along with their sizes and locations), Chrome assumes this will continue to be valid.

So the situation I'm envisioning is if the cursor is hidden, an overlay-based strategy will pass in the kernel. If at any time the cursor becomes visible, the kernel will start failing commits which causes Chrome's GPU process to crash.

Quoted 5 lines

In general I'm uneasy with using the cursor in the atomic check since it feels like it could be racy independent of the issue above. I haven't dove into the helper code enough to prove it, just a spidey-sense.

Isn't the cursor supposed to be just another plane? If so, shouldn't adding/removing the cursor trigger an atomic test?

Chrome is using legacy cursor.

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

Yes it will trigger an atomic test in the kernel, and that atomic test will fail. Unfortunately Chrome does not expect a failure so it will crash.

The solution is probably indeed for atomic check to reject state which couldn't work if the cursor was enabled, even if the cursor is currently disabled. Otherwise one can hit various surprising errors via legacy APIs, as described in b836a274b797 "drm/amdgpu/dc: Require primary plane to be enabled whenever the CRTC is".

Agreed.

It's a bit unfortunate but the only way to deal with this better is if we had some way for DRM master to tell us whether it will only use the atomic IOCTL or use legacy IOCTLs (including a combination of atomic and legacy).

I think even with this information we wouldn't want to depend on cursor for atomic test. IMO kernel should not back the compositor into re-rendering the scene based on cursor visibility. Given that cursor is usually handled independently and asynchronously from composition, it makes things extremely complex and most compositors would probably just enable cursor all the time to work around this.

Sean

Quoted 4 lines

Harry

Quoted 1 line

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

#12 lore raw
In reply to Rodrigo Siqueira
Quoted 7 lines · Rodrigo Siqueira

A few weeks ago, we saw a two cursor issue in a ChromeOS system. We fixed it in the commit:

drm/amd/display: Fix two cursor duplication when using overlay (read the commit message for more details)

Quoted 6 lines

After this change, we noticed that some IGT subtests related to kms_plane and kms_plane_scaling started to fail. After investigating this issue, we noticed that all subtests that fail have a primary plane covering the overlay plane, which is currently rejected by amdgpu dm. Fail those IGT tests highlight that our verification was too broad and compromises the overlay usage in our drive. This patch fixes this issue

nit: driver*

Quoted 47 lines

by ensuring that we only reject commits where the primary plane is not fully covered by the overlay when the cursor hardware is enabled. With this fix, all IGT tests start to pass again, which means our overlay support works as expected.

Cc Tianci.Yin <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Nicholas Choi <[email protected]>
Cc Bhawanpreet Lakha <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
Cc Mark Yacoub <[email protected]>
Cc Daniel Wheeler <[email protected]>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +9 -2
index ccd67003b120..9c2537a17a7b 100644
@@ -10067,7 +10067,7 @@ static int validate_overlay(struct drm_atomic_state *state)
        int i;
        struct drm_plane *plane;
        struct drm_plane_state *old_plane_state, *new_plane_state;
-       struct drm_plane_state *primary_state, *overlay_state = NULL;
+       struct drm_plane_state *primary_state, *cursor_state, *overlay_state = NULL;
 
        /* Check if primary plane is contained inside overlay */
        for_each_oldnew_plane_in_state_reverse(state, plane, old_plane_state, new_plane_state, i) {
@@ -10097,6 +10097,14 @@ static int validate_overlay(struct drm_atomic_state *state)
        if (!primary_state->crtc)
                return 0;
 
+       /* check if cursor plane is enabled */
+       cursor_state = drm_atomic_get_plane_state(state, overlay_state->crtc->cursor);
+       if (IS_ERR(cursor_state))
+               return PTR_ERR(cursor_state);
+
+       if (drm_atomic_plane_disabling(plane->state, cursor_state))
+               return 0;
+
        /* Perform the bounds check to ensure the overlay plane covers the primary */
        if (primary_state->crtc_x < overlay_state->crtc_x ||
            primary_state->crtc_y < overlay_state->crtc_y ||
--
Quoted 2 lines

2.25.1

Happy this was caught earlier. Would not have been fun debugging it on Chrome haha.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx