Skip to contentSkip to conversation

drm/amd/display: check fb of primary plane

PATCH Applied Sefa Eyeoglu 5 participants 5 messages Mar 16, 2021 – Mar 17, 2021

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

PATCH 1/1 drm/amd/display: check fb of primary plane

Sometimes the primary plane might not be initialized (yet), which causes dm_check_crtc_cursor to divide by zero.
Apparently a weird state before a S3-suspend causes the aforementioned divide-by-zero error when resuming from S3. This was explained in bug 212293 on Bugzilla.

To avoid this divide-by-zero error we check if the primary plane's fb isn't NULL. If it's NULL the src_w and src_h attributes will be 0, which would cause a divide-by-zero.

This fixes Bugzilla report 212293
https://bugzilla.kernel.org/show_bug.cgi?id=212293

Fixes 12f4849a1cfd69f3 ("drm/amd/display: check cursor scaling")
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -1
index 573cf17262da4e11..fbb1ac223ccbb62a 100644
@@ -9267,7 +9267,8 @@ static int dm_check_crtc_cursor(struct drm_atomic_state *state,
 
 	new_cursor_state = drm_atomic_get_new_plane_state(state, crtc->cursor);
 	new_primary_state = drm_atomic_get_new_plane_state(state, crtc->primary);
-	if (!new_cursor_state || !new_primary_state || !new_cursor_state->fb) {
+	if (!new_cursor_state || !new_primary_state ||
+		!new_cursor_state->fb || !new_primary_state->fb) {
 		return 0;
 	}
 
Signature · 6 lines
2.31.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Sefa Eyeoglu

Sometimes the primary plane might not be initialized (yet), which causes dm_check_crtc_cursor to divide by zero.
Apparently a weird state before a S3-suspend causes the aforementioned divide-by-zero error when resuming from S3. This was explained in bug 212293 on Bugzilla.

To avoid this divide-by-zero error we check if the primary plane's fb isn't NULL. If it's NULL the src_w and src_h attributes will be 0, which would cause a divide-by-zero.

Quoted 5 lines

This fixes Bugzilla report 212293
https://bugzilla.kernel.org/show_bug.cgi?id=212293

Fixes 12f4849a1cfd69f3 ("drm/amd/display: check cursor scaling")

Thanks for the fix! In theory we should return -EINVAL here, because we can't enable the cursor plane without the primary plane. But that would break the legacy API translation layer in DRM core, which expects that planes can always be disabled individually.

So this is:

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

#2 lore raw
Quoted 15 lines · Simon Ser
Quoted 13 lines · Sefa Eyeoglu

Sometimes the primary plane might not be initialized (yet), which causes dm_check_crtc_cursor to divide by zero.
Apparently a weird state before a S3-suspend causes the aforementioned divide-by-zero error when resuming from S3. This was explained in bug 212293 on Bugzilla.

To avoid this divide-by-zero error we check if the primary plane's fb isn't NULL. If it's NULL the src_w and src_h attributes will be 0, which would cause a divide-by-zero.

This fixes Bugzilla report 212293
https://bugzilla.kernel.org/show_bug.cgi?id=212293

Quoted 7 lines
Quoted 2 lines
Fixes 12f4849a1cfd69f3 ("drm/amd/display: check cursor scaling")

Thanks for the fix! In theory we should return -EINVAL here, because we can't enable the cursor plane without the primary plane. But that would break the legacy API translation layer in DRM core, which expects that planes can always be disabled individually.

The core DRM code can deal with being unable to enable the CRTC while the primary plane is disabled. If you have evidence to the contrary, I'd like to see it.

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 Reviewed-by on v1 1/1
#3 lore raw
In reply to Sefa Eyeoglu
Quoted 6 lines · Sefa Eyeoglu

Sometimes the primary plane might not be initialized (yet), which causes dm_check_crtc_cursor to divide by zero.
Apparently a weird state before a S3-suspend causes the aforementioned divide-by-zero error when resuming from S3. This was explained in bug 212293 on Bugzilla.

Quoted 7 lines

To avoid this divide-by-zero error we check if the primary plane's fb isn't NULL. If it's NULL the src_w and src_h attributes will be 0, which would cause a divide-by-zero.

This fixes Bugzilla report 212293
https://bugzilla.kernel.org/show_bug.cgi?id=212293>> Fixes: 12f4849a1cfd69f3 ("drm/amd/display: check cursor scaling")

Thanks for your patch.

It is

Harry

Quoted 10 lines
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index 573cf17262da4e11..fbb1ac223ccbb62a 100644

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_check_crtc_cursor(struct drm_atomic_state *state, · line 9274

Quoted 9 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -1
@@ -9267,7 +9267,8 @@ static int dm_check_crtc_cursor(struct drm_atomic_state *state,
 
  	new_cursor_state = drm_atomic_get_new_plane_state(state, crtc->cursor);
  	new_primary_state = drm_atomic_get_new_plane_state(state, crtc->primary);
-	if (!new_cursor_state || !new_primary_state || !new_cursor_state->fb) {
+	if (!new_cursor_state || !new_primary_state ||
+		!new_cursor_state->fb || !new_primary_state->fb) {
  		return 0;
  	}
 

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

Applied
#4 lore raw
Quoted 19 lines · Harry Wentland
Quoted 6 lines · Sefa Eyeoglu

Sometimes the primary plane might not be initialized (yet), which causes dm_check_crtc_cursor to divide by zero.
Apparently a weird state before a S3-suspend causes the aforementioned divide-by-zero error when resuming from S3. This was explained in bug 212293 on Bugzilla.

Quoted 8 lines

To avoid this divide-by-zero error we check if the primary plane's fb isn't NULL. If it's NULL the src_w and src_h attributes will be 0, which would cause a divide-by-zero.

This fixes Bugzilla report 212293
https://bugzilla.kernel.org/show_bug.cgi?id=212293>>

Fixes 12f4849a1cfd69f3 ("drm/amd/display: check cursor scaling")
Quoted 4 lines

Thanks for your patch.

It is

Applied. Thanks!

Alex

Quoted 13 lines

Harry

Quoted 10 lines
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index 573cf17262da4e11..fbb1ac223ccbb62a 100644
@@ -9267,7 +9267,8 @@ static int dm_check_crtc_cursor(struct drm_atomic_state *state,
 
Quoted 14 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_check_crtc_cursor(struct drm_atomic_state *state, · line 9274

Quoted 9 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -1
      new_cursor_state = drm_atomic_get_new_plane_state(state, crtc->cursor);
      new_primary_state = drm_atomic_get_new_plane_state(state, crtc->primary);
-     if (!new_cursor_state || !new_primary_state || !new_cursor_state->fb) {
+     if (!new_cursor_state || !new_primary_state ||
+             !new_cursor_state->fb || !new_primary_state->fb) {
              return 0;
      }
 

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

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