summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-06-23 20:54:28 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2011-06-23 20:56:03 +0100
commite3b4c10f239f69e5282bde1d3b0c3685b24cf0aa (patch)
tree526428acf47bb7a55dbc324e852b3e66a3403574
parent33d3077266942b23c5bc05ef4a9a6cebe357272a (diff)
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@chris-wilson.co.uk>
-rw-r--r--src/sna/sna_driver.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c
index d791ee33..4ae6b5fc 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);