Skip to contentSkip to conversation

sna: Also fix ZaphodHeads on Linux kernels older than 3.19

PATCH New Mario Kleiner 1 participant 1 message Dec 7, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sna: Also fix ZaphodHeads on Linux kernels older than 3.19

Only 3.19 will have O_NONBLOCK for drm_read(), so the current ddx will still "stutter" in ZaphodHead mode on current kernels. Fix the problem by adding a poll() on the drm fd before potentially blocking on read().

The logic is directly transplanted from the uxa backend intel_mode_read_drm_events() function.

Fixes fdo bug #84744 on older kernels.

---
 src/sna/sna_display.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
src/sna/sna_display.c +10 -1
index 1633333..a7ad6cc 100644
@@ -7390,7 +7390,16 @@ fixup_flip:
 void sna_mode_wakeup(struct sna *sna)
 {
 	char buffer[1024];
-	int len, i;
+	int len, i, r;
+	struct pollfd p = { .fd = sna->kgem.fd, .events = POLLIN };
+
+	/* DRM read is blocking on old kernels, so poll first to avoid it. */
+	do {
+		r = poll(&p, 1, 0);
+	} while (r == -1 && (errno == EINTR || errno == EAGAIN));
+
+	if (r <= 0)
+		return;
 
 	/* The DRM read semantics guarantees that we always get only
 	 * complete events.
Signature · 6 lines
1.9.1

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel