[PATCH] sna: Also fix ZaphodHeads on Linux kernels older than 3.19

Mario Kleiner mario.kleiner.de at gmail.com
Sat Dec 6 21:11:06 PST 2014


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.

Signed-off-by: Mario Kleiner <mario.kleiner.de at gmail.com>
---
 src/sna/sna_display.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index 1633333..a7ad6cc 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -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.
-- 
1.9.1



More information about the xorg-devel mailing list