xf86-video-intel: src/sna/sna_driver.c

Chris Wilson ickle at kemper.freedesktop.org
Thu Jun 23 12:56:29 PDT 2011


 src/sna/sna_driver.c |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

New commits:
commit e3b4c10f239f69e5282bde1d3b0c3685b24cf0aa
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jun 23 20:54:28 2011 +0100

    sna: Relent and workaround the lack of O_NONBLOCK on /dev/dri/card0
    
    So in order not to block server shutdown, check that the fd is readable
    before attempting to read from it.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c
index d791ee3..4ae6b5f 100644
--- a/src/sna/sna_driver.c
+++ b/src/sna/sna_driver.c
@@ -68,6 +68,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include <sys/ioctl.h>
 #include <sys/fcntl.h>
+#include <sys/poll.h>
 #include "i915_drm.h"
 
 #if DEBUG_DRIVER
@@ -707,6 +708,17 @@ static void sna_leave_vt(int scrnIndex, int flags)
 			   "drmDropMaster failed: %s\n", strerror(errno));
 }
 
+/* In order to workaround a kernel bug in not honouring O_NONBLOCK,
+ * check that the fd is readable before attempting to read the next
+ * event from drm.
+ */
+static Bool sna_dri_has_pending_events(struct sna *sna)
+{
+	struct pollfd pfd;
+	pfd.fd = sna->kgem.fd;
+	pfd.events = POLLIN;
+	return poll(&pfd, 1, 0) == 1;
+}
 
 static Bool sna_close_screen(int scrnIndex, ScreenPtr screen)
 {
@@ -721,7 +733,8 @@ static Bool sna_close_screen(int scrnIndex, ScreenPtr screen)
 
 	/* drain the event queues */
 	sna_accel_wakeup_handler(sna);
-	sna_dri_wakeup(sna);
+	if (sna_dri_has_pending_events(sna))
+		sna_dri_wakeup(sna);
 
 	if (scrn->vtSema == TRUE)
 		sna_leave_vt(scrnIndex, 0);


More information about the xorg-commit mailing list