From 1f237bb6db9724358eca0467362c03dc6a41dc4a Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 21 May 2014 23:02:52 +0100 Subject: [PATCH] sna/dri2: Apply a margin of error to the sequence wrap detection If we have a queue of events, we may set the msc from a recent vblank query only to then process an older vblank event and declare the counter wrapped. Signed-off-by: Chris Wilson --- src/sna/sna.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sna/sna.h b/src/sna/sna.h index 59e44725..c3eb248e 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -472,8 +472,12 @@ extern bool sna_wait_for_scanline(struct sna *sna, PixmapPtr pixmap, static inline uint64_t msc64(struct sna *sna, int pipe, uint32_t seq) { assert((unsigned)pipe < MAX_PIPES); - if (seq < sna->mode.msc[pipe].last) + if ((int32_t)(seq - sna->mode.msc[pipe].last) < -0x40000000) { sna->mode.msc[pipe].wraps++; + DBG(("%s: pipe=%d wrapped was %u, now %u, wraps=%u\n", + __FUNCTION__, pipe, sna->mode.msc[pipe].last, seq, + sna->mode.msc[pipe].wraps)); + } sna->mode.msc[pipe].last = seq; return (uint64_t)sna->mode.msc[pipe].wraps << 32 | seq; }