diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2014-06-01 08:44:13 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2014-06-02 08:32:11 +0100 |
commit | c95a4002d1d27937731c59e84254ccb3b1246ccd (patch) | |
tree | 252915e3e71106aed959ea66bf6e829a2d03f4fb /src | |
parent | b1c07c20a371795a8dc4102f83fe542d62d8a4e6 (diff) |
sna/dri2: Hide MSC reported as going backwards
OML_sync_control mandates that MSC must be monotonic, so if the kernel
reports that they go backwards, lie.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r-- | src/sna/sna_display.c | 16 | ||||
-rw-r--r-- | src/sna/sna_dri2.c | 40 |
2 files changed, 27 insertions, 29 deletions
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index 1761be60..2a887176 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -233,11 +233,17 @@ int sna_crtc_is_on(xf86CrtcPtr crtc) static inline uint64_t msc64(struct sna_crtc *sna_crtc, uint32_t seq) { - if ((int32_t)(seq - sna_crtc->last_seq) < -0x40000000) { - sna_crtc->wrap_seq++; - DBG(("%s: pipe=%d wrapped was %u, now %u, wraps=%u\n", - __FUNCTION__, sna_crtc->pipe, - sna_crtc->last_seq, seq, sna_crtc->wrap_seq)); + if (seq < sna_crtc->last_seq) { + if (sna_crtc->last_seq - seq > 0x40000000) { + sna_crtc->wrap_seq++; + DBG(("%s: pipe=%d wrapped; was %u, now %u, wraps=%u\n", + __FUNCTION__, sna_crtc->pipe, + sna_crtc->last_seq, seq, sna_crtc->wrap_seq)); + } else { + ERR(("%s: pipe=%d msc went backwards; was %u, now %u\n", + __FUNCTION__, sna_crtc->pipe, sna_crtc->last_seq, seq)); + seq = sna_crtc->last_seq; + } } sna_crtc->last_seq = seq; return (uint64_t)sna_crtc->wrap_seq << 32 | seq; diff --git a/src/sna/sna_dri2.c b/src/sna/sna_dri2.c index 117f8795..f6d2fea0 100644 --- a/src/sna/sna_dri2.c +++ b/src/sna/sna_dri2.c @@ -2410,37 +2410,29 @@ static int sna_dri2_get_msc(DrawablePtr draw, CARD64 *ust, CARD64 *msc) { struct sna *sna = to_sna_from_drawable(draw); - union drm_wait_vblank vbl; xf86CrtcPtr crtc = sna_dri2_get_crtc(draw); + const struct ust_msc *swap; DBG(("%s(draw=%ld, pipe=%d)\n", __FUNCTION__, draw->id, crtc ? sna_crtc_to_pipe(crtc) : -1)); - if (crtc == NULL) { - const struct ust_msc *swap; - crtc = sna_mode_first_crtc(sna); -fail: - /* Drawable not displayed, make up a *monotonic* value */ - swap = sna_crtc_last_swap(crtc); - *msc = draw_current_msc(draw, crtc, swap->msc); - *ust = ust64(swap->tv_sec, swap->tv_usec); - return TRUE; - } + if (crtc != NULL) { + union drm_wait_vblank vbl; - VG_CLEAR(vbl); - vbl.request.type = _DRM_VBLANK_RELATIVE; - vbl.request.sequence = 0; - if (sna_wait_vblank(sna, &vbl, sna_crtc_to_pipe(crtc)) == 0) { - *ust = ust64(vbl.reply.tval_sec, vbl.reply.tval_usec); - *msc = draw_current_msc(draw, crtc, sna_crtc_record_vblank(crtc, &vbl)); - DBG(("%s: msc=%llu, ust=%llu\n", __FUNCTION__, - (long long)*msc, (long long)*ust)); - } else { - DBG(("%s: query failed on pipe %d, ret=%d\n", - __FUNCTION__, sna_crtc_to_pipe(crtc), errno)); - goto fail; - } + VG_CLEAR(vbl); + vbl.request.type = _DRM_VBLANK_RELATIVE; + vbl.request.sequence = 0; + if (sna_wait_vblank(sna, &vbl, sna_crtc_to_pipe(crtc)) == 0) + sna_crtc_record_vblank(crtc, &vbl); + } else + /* Drawable not displayed, make up a *monotonic* value */ + crtc = sna_mode_first_crtc(sna); + swap = sna_crtc_last_swap(crtc); + *msc = draw_current_msc(draw, crtc, swap->msc); + *ust = ust64(swap->tv_sec, swap->tv_usec); + DBG(("%s: msc=%llu, ust=%llu\n", __FUNCTION__, + (long long)*msc, (long long)*ust)); return TRUE; } |