[PATCH xf86-video-ati 05/13] Explicitly keep track of whether a DRM event is for a flip or not

Michel Dänzer michel at daenzer.net
Fri Dec 21 17:48:59 UTC 2018


From: Michel Dänzer <michel.daenzer at amd.com>

When an async flip is performed, and TearFree is enabled on the CRTC
used for timing, we schedule a vblank event for completing the page
flip. The DRM event queuing code treated this event like a vblank event,
but it needs to be treated like a page flip event.

(Ported from amdgpu commit e2c7369cae65069aa93eed1c0b678f975ce5c274)

Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
 src/drmmode_display.c  |  3 ++-
 src/radeon_dri2.c      |  4 ++--
 src/radeon_drm_queue.c | 39 +++++++++++----------------------------
 src/radeon_drm_queue.h |  3 ++-
 src/radeon_kms.c       | 10 ++++++----
 src/radeon_present.c   |  3 ++-
 6 files changed, 25 insertions(+), 37 deletions(-)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 831394d4c..134b0f72b 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -3397,7 +3397,8 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
 		drm_queue_seq = radeon_drm_queue_alloc(crtc, client, id,
 						       flipdata,
 						       drmmode_flip_handler,
-						       drmmode_flip_abort);
+						       drmmode_flip_abort,
+						       TRUE);
 		if (drm_queue_seq == RADEON_DRM_QUEUE_ERROR) {
 			xf86DrvMsg(scrn->scrnIndex, X_WARNING,
 				   "Allocating DRM queue event entry failed.\n");
diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index 4d12fc09a..922ed4fb6 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -1076,7 +1076,7 @@ static int radeon_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw,
 
     drm_queue_seq = radeon_drm_queue_alloc(crtc, client, RADEON_DRM_QUEUE_ID_DEFAULT,
 					   wait_info, radeon_dri2_frame_event_handler,
-					   radeon_dri2_frame_event_abort);
+					   radeon_dri2_frame_event_abort, FALSE);
     if (drm_queue_seq == RADEON_DRM_QUEUE_ERROR) {
         xf86DrvMsg(scrn->scrnIndex, X_WARNING,
 		   "Allocating DRM queue event entry failed.\n");
@@ -1215,7 +1215,7 @@ static int radeon_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,
 
     drm_queue_seq = radeon_drm_queue_alloc(crtc, client, RADEON_DRM_QUEUE_ID_DEFAULT,
 					   swap_info, radeon_dri2_frame_event_handler,
-					   radeon_dri2_frame_event_abort);
+					   radeon_dri2_frame_event_abort, FALSE);
     if (drm_queue_seq == RADEON_DRM_QUEUE_ERROR) {
         xf86DrvMsg(scrn->scrnIndex, X_WARNING,
 		   "Allocating DRM queue entry failed.\n");
diff --git a/src/radeon_drm_queue.c b/src/radeon_drm_queue.c
index ebc6a5b64..acfea3daf 100644
--- a/src/radeon_drm_queue.c
+++ b/src/radeon_drm_queue.c
@@ -48,6 +48,7 @@ struct radeon_drm_queue_entry {
     xf86CrtcPtr crtc;
     radeon_drm_handler_proc handler;
     radeon_drm_abort_proc abort;
+    Bool is_flip;
     unsigned int frame;
 };
 
@@ -86,8 +87,8 @@ radeon_drm_abort_one(struct radeon_drm_queue_entry *e)
 }
 
 static void
-radeon_drm_queue_handler(struct xorg_list *signalled, unsigned int frame,
-			 unsigned int sec, unsigned int usec, void *user_ptr)
+radeon_drm_queue_handler(int fd, unsigned int frame, unsigned int sec,
+			 unsigned int usec, void *user_ptr)
 {
     uintptr_t seq = (uintptr_t)user_ptr;
     struct radeon_drm_queue_entry *e, *tmp;
@@ -102,34 +103,14 @@ radeon_drm_queue_handler(struct xorg_list *signalled, unsigned int frame,
 	    xorg_list_del(&e->list);
 	    e->usec = (uint64_t)sec * 1000000 + usec;
 	    e->frame = frame;
-	    xorg_list_append(&e->list, signalled);
+	    xorg_list_append(&e->list, e->is_flip ?
+			     &radeon_drm_flip_signalled :
+			     &radeon_drm_vblank_signalled);
 	    break;
 	}
     }
 }
 
-/*
- * Signal a DRM page flip event
- */
-static void
-radeon_drm_page_flip_handler(int fd, unsigned int frame, unsigned int sec,
-			     unsigned int usec, void *user_ptr)
-{
-    radeon_drm_queue_handler(&radeon_drm_flip_signalled, frame, sec, usec,
-			     user_ptr);
-}
-
-/*
- * Signal a DRM vblank event
- */
-static void
-radeon_drm_vblank_handler(int fd, unsigned int frame, unsigned int sec,
-			  unsigned int usec, void *user_ptr)
-{
-    radeon_drm_queue_handler(&radeon_drm_vblank_signalled, frame, sec, usec,
-			     user_ptr);
-}
-
 /*
  * Handle deferred DRM vblank events
  *
@@ -162,7 +143,8 @@ uintptr_t
 radeon_drm_queue_alloc(xf86CrtcPtr crtc, ClientPtr client,
 		       uint64_t id, void *data,
 		       radeon_drm_handler_proc handler,
-		       radeon_drm_abort_proc abort)
+		       radeon_drm_abort_proc abort,
+		       Bool is_flip)
 {
     struct radeon_drm_queue_entry *e;
 
@@ -180,6 +162,7 @@ radeon_drm_queue_alloc(xf86CrtcPtr crtc, ClientPtr client,
     e->data = data;
     e->handler = handler;
     e->abort = abort;
+    e->is_flip = is_flip;
 
     xorg_list_append(&e->list, &radeon_drm_queue);
 
@@ -306,8 +289,8 @@ radeon_drm_queue_init(ScrnInfoPtr scrn)
     drmmode_ptr drmmode = &info->drmmode;
 
     drmmode->event_context.version = 2;
-    drmmode->event_context.vblank_handler = radeon_drm_vblank_handler;
-    drmmode->event_context.page_flip_handler = radeon_drm_page_flip_handler;
+    drmmode->event_context.vblank_handler = radeon_drm_queue_handler;
+    drmmode->event_context.page_flip_handler = radeon_drm_queue_handler;
 
     if (radeon_drm_queue_refcnt++)
 	return;
diff --git a/src/radeon_drm_queue.h b/src/radeon_drm_queue.h
index 334c4ca63..19d42e930 100644
--- a/src/radeon_drm_queue.h
+++ b/src/radeon_drm_queue.h
@@ -44,7 +44,8 @@ void radeon_drm_queue_handle_deferred(xf86CrtcPtr crtc);
 uintptr_t radeon_drm_queue_alloc(xf86CrtcPtr crtc, ClientPtr client,
 				 uint64_t id, void *data,
 				 radeon_drm_handler_proc handler,
-				 radeon_drm_abort_proc abort);
+				 radeon_drm_abort_proc abort,
+				 Bool is_flip);
 void radeon_drm_abort_client(ClientPtr client);
 void radeon_drm_abort_entry(uintptr_t seq);
 void radeon_drm_abort_id(uint64_t id);
diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index cd5efd530..a7aade702 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -769,7 +769,8 @@ radeon_prime_scanout_update(PixmapDirtyUpdatePtr dirty)
 					   RADEON_DRM_QUEUE_CLIENT_DEFAULT,
 					   RADEON_DRM_QUEUE_ID_DEFAULT, NULL,
 					   radeon_prime_scanout_update_handler,
-					   radeon_prime_scanout_update_abort);
+					   radeon_prime_scanout_update_abort,
+					   FALSE);
     if (drm_queue_seq == RADEON_DRM_QUEUE_ERROR) {
 	xf86DrvMsg(scrn->scrnIndex, X_WARNING,
 		   "radeon_drm_queue_alloc failed for PRIME update\n");
@@ -817,7 +818,7 @@ radeon_prime_scanout_flip(PixmapDirtyUpdatePtr ent)
 					   RADEON_DRM_QUEUE_ID_DEFAULT,
 					   NULL,
 					   radeon_scanout_flip_handler,
-					   radeon_scanout_flip_abort);
+					   radeon_scanout_flip_abort, TRUE);
     if (drm_queue_seq == RADEON_DRM_QUEUE_ERROR) {
 	xf86DrvMsg(scrn->scrnIndex, X_WARNING,
 		   "Allocating DRM event queue entry failed for PRIME flip.\n");
@@ -1053,7 +1054,8 @@ radeon_scanout_update(xf86CrtcPtr xf86_crtc)
 					   RADEON_DRM_QUEUE_ID_DEFAULT,
 					   drmmode_crtc,
 					   radeon_scanout_update_handler,
-					   radeon_scanout_update_abort);
+					   radeon_scanout_update_abort,
+					   FALSE);
     if (drm_queue_seq == RADEON_DRM_QUEUE_ERROR) {
 	xf86DrvMsg(scrn->scrnIndex, X_WARNING,
 		   "radeon_drm_queue_alloc failed for scanout update\n");
@@ -1102,7 +1104,7 @@ radeon_scanout_flip(ScreenPtr pScreen, RADEONInfoPtr info,
 					   RADEON_DRM_QUEUE_ID_DEFAULT,
 					   NULL,
 					   radeon_scanout_flip_handler,
-					   radeon_scanout_flip_abort);
+					   radeon_scanout_flip_abort, TRUE);
     if (drm_queue_seq == RADEON_DRM_QUEUE_ERROR) {
 	xf86DrvMsg(scrn->scrnIndex, X_WARNING,
 		   "Allocating DRM event queue entry failed.\n");
diff --git a/src/radeon_present.c b/src/radeon_present.c
index d0a0c68ca..0b55117eb 100644
--- a/src/radeon_present.c
+++ b/src/radeon_present.c
@@ -157,7 +157,8 @@ radeon_present_queue_vblank(RRCrtcPtr crtc, uint64_t event_id, uint64_t msc)
 					   RADEON_DRM_QUEUE_CLIENT_DEFAULT,
 					   event_id, event,
 					   radeon_present_vblank_handler,
-					   radeon_present_vblank_abort);
+					   radeon_present_vblank_abort,
+					   FALSE);
     if (drm_queue_seq == RADEON_DRM_QUEUE_ERROR) {
 	free(event);
 	return BadAlloc;
-- 
2.20.1



More information about the amd-gfx mailing list