Skip to contentSkip to conversation

drm: Do not allow to set NOFB for active primary plane

PATCH In review Stanislav Lisovskiy 3 participants 4 messages Apr 15, 2019 – Apr 16, 2019

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

PATCH 1/1 drm: Do not allow to set NOFB for active primary plane

There was an issue reported from end users, confirmed also locally that when user executes xrandr --output <some DP> --rotate left/right, the other eDP screen gets blank after rotation.

Investigation showed that reason was that primary plane was for some reason disabled, while cursor plane was still enabled. After some effort it turns out that userspace might wrongly assign NOFB to active primary plane for some reason.

Then this gets detected in drm_atomic_helper_check_plane_state, called from ->plane_check and plane gets deactivated, leaving the screen blank and cursor visible. This can be cured by reboot or xrandr off/on sequence for that crtc.

This patch is proposal to fix the issue by forbiding fb removal from active primary plane. If one needs to remove fb plane must be disabled first.

Not sure if this is correct, however it fixes the issue at least.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110375

---
 drivers/gpu/drm/drm_atomic_uapi.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/gpu/drm/drm_atomic_uapi.c +9 -0
index ea797d4c82ee..e2f078b302f3 100644
@@ -229,6 +229,15 @@ drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state,
 {
 	struct drm_plane *plane = plane_state->plane;
 
+	if (!fb) {
+		if (plane->state->visible && plane->type == DRM_PLANE_TYPE_PRIMARY) {
+			DRM_DEBUG_ATOMIC("Not allowed to set [NOFB] for active"
+					" primary [PLANE:%d:%s] - disable first",
+					plane->base.id, plane->name);
+			return;
+		}
+	}
+
 	if (fb)
 		DRM_DEBUG_ATOMIC("Set [FB:%d] for [PLANE:%d:%s] state %p\n",
 				 fb->base.id, plane->base.id, plane->name,
Signature · 6 lines
2.17.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

Op 15-04-2019 om 10:00 schreef Stanislav Lisovskiy:

Quoted 36 lines

There was an issue reported from end users, confirmed also locally that when user executes xrandr --output <some DP> --rotate left/right, the other eDP screen gets blank after rotation.

Investigation showed that reason was that primary plane was for some reason disabled, while cursor plane was still enabled. After some effort it turns out that userspace might wrongly assign NOFB to active primary plane for some reason.

Then this gets detected in drm_atomic_helper_check_plane_state, called from ->plane_check and plane gets deactivated, leaving the screen blank and cursor visible. This can be cured by reboot or xrandr off/on sequence for that crtc.

This patch is proposal to fix the issue by forbiding fb removal from active primary plane. If one needs to remove fb plane must be disabled first.

Not sure if this is correct, however it fixes the issue at least.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110375

---
 drivers/gpu/drm/drm_atomic_uapi.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
index ea797d4c82ee..e2f078b302f3 100644
@@ -229,6 +229,15 @@ drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state,
 {
 	struct drm_plane *plane = plane_state->plane;
 
+	if (!fb) {
+		if (plane->state->visible && plane->type == DRM_PLANE_TYPE_PRIMARY) {

drivers/gpu/drm/drm_atomic_uapi.c drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state, · line 243

Quoted 10 lines
drivers/gpu/drm/drm_atomic_uapi.c +7 -0
+			DRM_DEBUG_ATOMIC("Not allowed to set [NOFB] for active"
+					" primary [PLANE:%d:%s] - disable first",
+					plane->base.id, plane->name);
+			return;
+		}
+	}
+
 	if (fb)
 		DRM_DEBUG_ATOMIC("Set [FB:%d] for [PLANE:%d:%s] state %p\n",
 				 fb->base.id, plane->base.id, plane->name,

If userspace asks to disable the primary plane, but not the crtc then that is not an atomic bug. The bug is in the userspace requesting this (Xorg).

If you want to include such a check, the correct place is at the end of drm_atomic_check_only(), after ->atomic_check(), return -EINVAL there.

But such a patch will not be accepted. It's perfectly acceptable to disable the primary plane for whatever reason, and some of our internal tests do so.

~Maarten

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

#2 lore raw
Quoted 60 lines · Maarten Lankhorst

Op 15-04-2019 om 10:00 schreef Stanislav Lisovskiy:

Quoted 51 lines

There was an issue reported from end users, confirmed also locally that when user executes xrandr --output <some DP> --rotate left/right, the other eDP screen gets blank after rotation.

Investigation showed that reason was that primary plane was for some reason disabled, while cursor plane was still enabled. After some effort it turns out that userspace might wrongly assign NOFB to active primary plane for some reason.

Then this gets detected in drm_atomic_helper_check_plane_state, called from ->plane_check and plane gets deactivated, leaving the screen blank and cursor visible. This can be cured by reboot or xrandr off/on sequence for that crtc.

This patch is proposal to fix the issue by forbiding fb removal from active primary plane. If one needs to remove fb plane must be disabled first.

Not sure if this is correct, however it fixes the issue at least.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110375

---
 drivers/gpu/drm/drm_atomic_uapi.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/gpu/drm/drm_atomic_uapi.c +3 -0
index ea797d4c82ee..e2f078b302f3 100644
@@ -229,6 +229,15 @@ drm_atomic_set_fb_for_plane(struct
 drm_plane_state *plane_state,
 {
 	struct drm_plane *plane = plane_state->plane;
 
+	if (!fb) {
+		if (plane->state->visible && plane->type ==
 DRM_PLANE_TYPE_PRIMARY) {
+			DRM_DEBUG_ATOMIC("Not allowed to set [NOFB] for

active"

drivers/gpu/drm/drm_atomic_uapi.c +1 -0
+					" primary [PLANE:%d:%s] -

disable first",

drivers/gpu/drm/drm_atomic_uapi.c +5 -0
+					plane->base.id, plane->name);
+			return;
+		}
+	}
+
 	if (fb)
 		DRM_DEBUG_ATOMIC("Set [FB:%d] for [PLANE:%d:%s] state
Quoted 3 lines

%p\n",
fb->base.id, plane->base.id, plane-

Quoted 1 line

name,

If userspace asks to disable the primary plane, but not the crtc then that is not an atomic bug. The bug is in the userspace requesting this (Xorg).

Quoted 7 lines

If you want to include such a check, the correct place is at the end of drm_atomic_check_only(), after ->atomic_check(), return -EINVAL there.

But such a patch will not be accepted. It's perfectly acceptable to disable the primary plane for whatever reason, and some of our internal tests do so.

Well, yeah that's why I was not quite sure, if this is correct. However to me the problem seems to be that userspace is disabling primary plane without realizing it. For example on my skl I see that drm_atomic_helper_check_plane_state complains that primary plane has no FB and then disables it.

Quoted 4 lines

~Maarten

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

#3 lore raw
Quoted 69 lines · Stanislav
Quoted 60 lines · Maarten Lankhorst

Op 15-04-2019 om 10:00 schreef Stanislav Lisovskiy:

Quoted 51 lines

There was an issue reported from end users, confirmed also locally that when user executes xrandr --output <some DP> --rotate left/right, the other eDP screen gets blank after rotation.

Investigation showed that reason was that primary plane was for some reason disabled, while cursor plane was still enabled. After some effort it turns out that userspace might wrongly assign NOFB to active primary plane for some reason.

Then this gets detected in drm_atomic_helper_check_plane_state, called from ->plane_check and plane gets deactivated, leaving the screen blank and cursor visible. This can be cured by reboot or xrandr off/on sequence for that crtc.

This patch is proposal to fix the issue by forbiding fb removal from active primary plane. If one needs to remove fb plane must be disabled first.

Not sure if this is correct, however it fixes the issue at least.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110375

---
 drivers/gpu/drm/drm_atomic_uapi.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/gpu/drm/drm_atomic_uapi.c +3 -0
index ea797d4c82ee..e2f078b302f3 100644
@@ -229,6 +229,15 @@ drm_atomic_set_fb_for_plane(struct
 drm_plane_state *plane_state,
 {
 	struct drm_plane *plane = plane_state->plane;
 
+	if (!fb) {
+		if (plane->state->visible && plane->type ==
 DRM_PLANE_TYPE_PRIMARY) {
+			DRM_DEBUG_ATOMIC("Not allowed to set [NOFB] for

active"

drivers/gpu/drm/drm_atomic_uapi.c +1 -0
+					" primary [PLANE:%d:%s] -

disable first",

drivers/gpu/drm/drm_atomic_uapi.c +5 -0
+					plane->base.id, plane->name);
+			return;
+		}
+	}
+
 	if (fb)
 		DRM_DEBUG_ATOMIC("Set [FB:%d] for [PLANE:%d:%s] state
Quoted 3 lines

%p\n",
fb->base.id, plane->base.id, plane-

Quoted 1 line

name,

If userspace asks to disable the primary plane, but not the crtc then that is not an atomic bug. The bug is in the userspace requesting this (Xorg).

Quoted 7 lines

If you want to include such a check, the correct place is at the end of drm_atomic_check_only(), after ->atomic_check(), return -EINVAL there.

But such a patch will not be accepted. It's perfectly acceptable to disable the primary plane for whatever reason, and some of our internal tests do so.

Quoted 5 lines

Well, yeah that's why I was not quite sure, if this is correct. However to me the problem seems to be that userspace is disabling primary plane without realizing it. For example on my skl I see that drm_atomic_helper_check_plane_state complains that primary plane has no FB and then disables it.

Yeah we need to figure out where this is coming from. Is this with sna or -modesetting or something else?
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel