Skip to contentSkip to conversation

igt/kms_atomic: Match CRTC harder for special planes

PATCH In review Daniel Stone 2 participants 3 messages Dec 13, 2016 – Dec 14, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 igt/kms_atomic: Match CRTC harder for special planes

Our heuristic for finding planes was previously matching the type, and ensuring that the plane was valid for that CRTC. However, VC4 now has primary/cursor planes which can wander multiple CRTCs, so we could pick a PRIMARY plane which was not the kernel's idea of crtc->primary, causing plane_primary_legacy to fail; ditto for cursor.

Make find_plane try harder, by preferring to return planes which are already on the requested CRTC.

---
 tests/kms_atomic.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
tests/kms_atomic.c +11 -2
index 1441fdf..e6d71c3 100644
@@ -451,6 +451,7 @@ static struct kms_atomic_plane_state *
 find_plane(struct kms_atomic_state *state, enum plane_type type,
 	   struct kms_atomic_crtc_state *crtc)
 {
+	struct kms_atomic_plane_state *ret = NULL;
 	int i;
 
 	for (i = 0; i < state->num_planes; i++) {
@@ -464,10 +465,18 @@ find_plane(struct kms_atomic_state *state, enum plane_type type,
 			continue;
 
 		plane_get_current_state(plane);
-		return plane;
+
+		/* Try to find a plane that's already on this CRTC. In
+		 * particular, this ensures that for special (primary/cursor)
+		 * planes that can be on multiple CRTCs, we find the same
+		 * one that the legacy ioctls will. */
+		if (!crtc || plane->crtc_id == crtc->obj)
+			return plane;
+
+		ret = plane;
 	}
 
-	return NULL;
+	return ret;
 }
 
 static void crtc_populate_req(struct kms_atomic_crtc_state *crtc,
Signature · 6 lines
2.10.2

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

Hey Daniel,

This patch looks good to me.

Quoted 40 lines · Daniel Stone

Our heuristic for finding planes was previously matching the type, and ensuring that the plane was valid for that CRTC. However, VC4 now has primary/cursor planes which can wander multiple CRTCs, so we could pick a PRIMARY plane which was not the kernel's idea of crtc->primary, causing plane_primary_legacy to fail; ditto for cursor.

Make find_plane try harder, by preferring to return planes which are already on the requested CRTC.

---
 tests/kms_atomic.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
tests/kms_atomic.c +7 -1
index 1441fdf..e6d71c3 100644
@@ -451,6 +451,7 @@ static struct kms_atomic_plane_state *
 find_plane(struct kms_atomic_state *state, enum plane_type type,
 	   struct kms_atomic_crtc_state *crtc)
 {
+	struct kms_atomic_plane_state *ret = NULL;
 	int i;
 
 	for (i = 0; i < state->num_planes; i++) {
@@ -464,10 +465,18 @@ find_plane(struct kms_atomic_state *state, enum plane_type type,
 			continue;
 
 		plane_get_current_state(plane);
-		return plane;
+
+		/* Try to find a plane that's already on this CRTC. In
+		 * particular, this ensures that for special (primary/cursor)
+		 * planes that can be on multiple CRTCs, we find the same
+		 * one that the legacy ioctls will. */
+		if (!crtc || plane->crtc_id == crtc->obj)

tests/kms_atomic.c find_plane(struct kms_atomic_state *state, enum plane_type type, · line 482

Quoted 10 lines
tests/kms_atomic.c +4 -1
+			return plane;
+
+		ret = plane;
 	}
 
-	return NULL;
+	return ret;
 }
 
 static void crtc_populate_req(struct kms_atomic_crtc_state *crtc,

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

#2 lore raw
In reply to Daniel Stone

Pushed, thanks.

Rob.

Quoted 40 lines · Daniel Stone

Our heuristic for finding planes was previously matching the type, and ensuring that the plane was valid for that CRTC. However, VC4 now has primary/cursor planes which can wander multiple CRTCs, so we could pick a PRIMARY plane which was not the kernel's idea of crtc->primary, causing plane_primary_legacy to fail; ditto for cursor.

Make find_plane try harder, by preferring to return planes which are already on the requested CRTC.

---
 tests/kms_atomic.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
tests/kms_atomic.c +7 -1
index 1441fdf..e6d71c3 100644
@@ -451,6 +451,7 @@ static struct kms_atomic_plane_state *
 find_plane(struct kms_atomic_state *state, enum plane_type type,
 	   struct kms_atomic_crtc_state *crtc)
 {
+	struct kms_atomic_plane_state *ret = NULL;
 	int i;
 
 	for (i = 0; i < state->num_planes; i++) {
@@ -464,10 +465,18 @@ find_plane(struct kms_atomic_state *state, enum plane_type type,
 			continue;
 
 		plane_get_current_state(plane);
-		return plane;
+
+		/* Try to find a plane that's already on this CRTC. In
+		 * particular, this ensures that for special (primary/cursor)
+		 * planes that can be on multiple CRTCs, we find the same
+		 * one that the legacy ioctls will. */
+		if (!crtc || plane->crtc_id == crtc->obj)

tests/kms_atomic.c find_plane(struct kms_atomic_state *state, enum plane_type type, · line 482

Quoted 10 lines
tests/kms_atomic.c +4 -1
+			return plane;
+
+		ret = plane;
 	}
 
-	return NULL;
+	return ret;
 }
 
 static void crtc_populate_req(struct kms_atomic_crtc_state *crtc,

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