From 266d9868ca1cf77b7d315d607b515f081a9f45c3 Mon Sep 17 00:00:00 2001 From: Alex Goins Date: Thu, 19 Oct 2017 20:02:30 -0700 Subject: [PATCH] xf86-video-modesetting: Fix ms_queue_vblank(flags = MS_QUEUE_RELATIVE) Change 677c32bc refactored all usages of drmWaitVBlank() into a helper function, ms_queue_vblank(). ms_queue_vblank() takes in an MS_QUEUE_RELATIVE flag to indicate that the sequence number is relative rather than absolute, but still treats the actual sequence number as absolute, passing it through ms_crtc_msc_to_kernel_msc() unconditionally before calling drmWaitVBlank(). ms_crtc_msc_to_kernel_msc() works by subtracting a vblank offset from the provided sequence number, which only makes sense for absolute sequence numbers. In the case of PRIME Sync, drmmode_SharedPixmapPrsentOnVBlank() passes in 1, which results in a large negative vblank offset. After subtracting, we're left with a relative sequence number of 100,000+, i.e. wait for 100,000+ vblanks... In the relative case we want to pass in the sequence number unmodified. Simply add a check to do this. Signed-off-by: Alex Goins Reviewed-by: Keith Packard --- hw/xfree86/drivers/modesetting/vblank.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/xfree86/drivers/modesetting/vblank.c b/hw/xfree86/drivers/modesetting/vblank.c index 31cf0bd70..fe046e48b 100644 --- a/hw/xfree86/drivers/modesetting/vblank.c +++ b/hw/xfree86/drivers/modesetting/vblank.c @@ -219,7 +219,8 @@ ms_queue_vblank(xf86CrtcPtr crtc, ms_queue_flag flags, if (flags & MS_QUEUE_NEXT_ON_MISS) vbl.request.type |= DRM_VBLANK_NEXTONMISS; - vbl.request.sequence = ms_crtc_msc_to_kernel_msc(crtc, msc); + vbl.request.sequence = (flags & MS_QUEUE_RELATIVE) ? + msc : ms_crtc_msc_to_kernel_msc(crtc, msc); vbl.request.signal = seq; ret = drmWaitVBlank(ms->fd, &vbl); if (ret == 0) {