From aa439ffee4ea0926b382c0f0fb5d41feae9d0f8f Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 4 Oct 2013 09:07:30 +0100 Subject: [PATCH] sna: The device fd is marked as non-blocking so beware the busy-wait During redisplay we wait for the pageflip result. If the fd is marked as non-blocking this results in a busy-wait, so insert a poll first to remove the busy-wait. Signed-off-by: Chris Wilson --- 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 13796051..95ce1b09 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -155,6 +155,14 @@ static bool sna_mode_has_pending_events(struct sna *sna) return poll(&pfd, 1, 0) == 1; } +static bool sna_mode_wait_for_event(struct sna *sna) +{ + struct pollfd pfd; + pfd.fd = sna->kgem.fd; + pfd.events = POLLIN; + return poll(&pfd, 1, -1) == 1; +} + #define BACKLIGHT_CLASS "/sys/class/backlight" /* Enough for 10 digits of backlight + '\n' + '\0' */ @@ -4228,7 +4236,8 @@ disable: } if (sna->mode.shadow) { - while (sna->mode.shadow_flip) + while (sna->mode.shadow_flip && + sna_mode_wait_for_event(sna)) sna_mode_wakeup(sna); (void)sna->render.copy_boxes(sna, GXcopy, sna->front, new, 0, 0,