diff options
author | Michel Dänzer <michel.daenzer@amd.com> | 2019-01-22 18:36:56 +0100 |
---|---|---|
committer | Michel Dänzer <michel@daenzer.net> | 2019-01-25 17:49:52 +0100 |
commit | 3ff2cc225f6bc08364ee007fa54e9d0150adaf11 (patch) | |
tree | 1d06801d5a60836fa0a19e014823ae8d4f38395e | |
parent | e72a02ba1d35743fefd939458b9d8cddce86e7f5 (diff) |
Call drmHandleEvent again if it was interrupted by a signal
drmHandleEvent can be interrupted by a signal in read(), in which case
it doesn't process any events but returns -1, which
drm_handle_event propagated to its callers. This could cause the
following failure cascade:
1. drm_wait_pending_flip stopped waiting for a pending flip.
2. Its caller cleared drmmode_crtc->flip_pending before the flip
completed.
3. Another flip was attempted but got an unexpected EBUSY error because
the previous flip was still pending.
4. TearFree was disabled due to the error.
The solution is to call drmHandleEvent if it was interrupted by a
signal. We can do that in drm_handle_event, because when that is called,
either it is known that there are events ready to be processed, or the
caller has to wait for events to arrive anyway.
v2:
* Use ErrorF instead of xf86DrvMsg with hard-coded screen 0.
Bugzilla: https://bugs.freedesktop.org/109364
Reviewed-by: Alex Deucher <alexander.deucher@amd.com> # v1
-rw-r--r-- | src/amdgpu_drm_queue.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/amdgpu_drm_queue.c b/src/amdgpu_drm_queue.c index 56d593d..534ad32 100644 --- a/src/amdgpu_drm_queue.c +++ b/src/amdgpu_drm_queue.c @@ -30,6 +30,8 @@ #include "config.h" #endif +#include <errno.h> + #include <xorg-server.h> #include <X11/Xdefs.h> #include <list.h> @@ -277,7 +279,20 @@ amdgpu_drm_handle_event(int fd, drmEventContext *event_context) struct amdgpu_drm_queue_entry *e; int r; - r = drmHandleEvent(fd, event_context); + /* Retry drmHandleEvent if it was interrupted by a signal in read() */ + do { + r = drmHandleEvent(fd, event_context); + } while (r < 0 && (errno == EINTR || errno == EAGAIN)); + + if (r < 0) { + static Bool printed; + + if (!printed) { + ErrorF("%s: drmHandleEvent returned %d, errno=%d (%s)\n", + __func__, r, errno, strerror(errno)); + printed = TRUE; + } + } while (!xorg_list_is_empty(&amdgpu_drm_flip_signalled)) { e = xorg_list_first_entry(&amdgpu_drm_flip_signalled, |