From 5adc20179e9818d51e1cd79bfc8a8271786c3949 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 27 Oct 2014 15:28:14 -0700 Subject: [PATCH] modesetting: Skip kernel work-around on error in crtc to kernel msc ms_crtc_msc_to_kernel_msc attempts to work around kernel inconsistencies in reporting msc values by comparing the expected value with the reported value. If the kernel fails to actually provide its current values, then just skip the work around steps as there's really nothing better we can do. Signed-off-by: Keith Packard --- hw/xfree86/drivers/modesetting/vblank.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/hw/xfree86/drivers/modesetting/vblank.c b/hw/xfree86/drivers/modesetting/vblank.c index 35cadb222..5031ef8ff 100644 --- a/hw/xfree86/drivers/modesetting/vblank.c +++ b/hw/xfree86/drivers/modesetting/vblank.c @@ -228,17 +228,18 @@ ms_crtc_msc_to_kernel_msc(xf86CrtcPtr crtc, uint64_t expect) uint64_t ust; int64_t diff; - ms_get_crtc_ust_msc(crtc, &ust, &msc); - diff = expect - msc; + if (ms_get_crtc_ust_msc(crtc, &ust, &msc) == Success) { + diff = expect - msc; - /* We're way off here, assume that the kernel has lost its mind - * and smack the vblank back to something sensible - */ - if (diff < -MAX_VBLANK_OFFSET || MAX_VBLANK_OFFSET < diff) { - drmmode_crtc->vblank_offset += (int32_t) diff; - if (drmmode_crtc->vblank_offset > -MAX_VBLANK_OFFSET && - drmmode_crtc->vblank_offset < MAX_VBLANK_OFFSET) - drmmode_crtc->vblank_offset = 0; + /* We're way off here, assume that the kernel has lost its mind + * and smack the vblank back to something sensible + */ + if (diff < -MAX_VBLANK_OFFSET || MAX_VBLANK_OFFSET < diff) { + drmmode_crtc->vblank_offset += (int32_t) diff; + if (drmmode_crtc->vblank_offset > -MAX_VBLANK_OFFSET && + drmmode_crtc->vblank_offset < MAX_VBLANK_OFFSET) + drmmode_crtc->vblank_offset = 0; + } } return (uint32_t) (expect - drmmode_crtc->vblank_offset); }