From 39ba4821fafb41eb0e3a198a410518c466a89497 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 26 Mar 2018 21:36:41 +0100 Subject: [PATCH xf86-video-intel] sna: Ratelimit per-CRTC updates using the pageflip event In order to coordinate the per-CRTC pixmap updates to the vblank and to avoid repeated rendering to the scanout, after rendering trigger a flip to itself. This should be a no-op in terms of the HW, but should then trigger a flip completion event on the vblank following the rendering. If we then service that event promptly, the next render pass will then occur within the vblank period. Signed-off-by: Chris Wilson --- src/sna/sna_display.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index e7bf6ca..7fccb50 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -9270,8 +9270,35 @@ disable1: DBG(("%s: recording flip on CRTC:%d handle=%d, active_scanout=%d, serial=%d\n", __FUNCTION__, __sna_crtc_id(sna_crtc), sna_crtc->flip_bo->handle, sna_crtc->flip_bo->active_scanout, sna_crtc->flip_serial)); } else { + struct drm_mode_crtc_page_flip arg; + sna_crtc_redisplay(crtc, &damage, sna_crtc->bo); kgem_scanout_flush(&sna->kgem, sna_crtc->bo); + + /* flip to itself for ratelimiting */ + assert_crtc_fb(sna, sna_crtc); + arg.crtc_id = __sna_crtc_id(sna_crtc); + arg.fb_id = get_fb(sna, sna_crtc->bo, + crtc->mode.HDisplay, + crtc->mode.VDisplay); + assert(arg.fb_id); + + arg.user_data = (uintptr_t)sna_crtc; + arg.flags = DRM_MODE_PAGE_FLIP_EVENT; + arg.reserved = 0; + + assert(sna_crtc->flip_bo == NULL); + if (drmIoctl(sna->kgem.fd, DRM_IOCTL_MODE_PAGE_FLIP, &arg) == 0) { + sna->mode.flip_active++; + + sna_crtc->flip_handler = shadow_flip_handler; + sna_crtc->flip_data = sna; + sna_crtc->flip_bo = + kgem_bo_reference(sna_crtc->bo); + sna_crtc->flip_bo->active_scanout++; + sna_crtc->flip_serial = sna_crtc->mode_serial; + sna_crtc->flip_pending = true; + } } } RegionUninit(&damage); -- 2.7.4