Skip to contentSkip to conversation

Take current scanout_id into account everywhere involved with TearFree

PATCH In review Michel Dänzer 2 participants 5 messages Nov 29, 2016 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 Take current scanout_id into account everywhere involved with TearFree

From: Michel Dänzer <[email protected]>

Fixes various potential issues with TearFree enabled, e.g. outputs freezing after display configuration changes.

---
 src/drmmode_display.c | 22 +++++++++++-----------
 src/radeon.h          |  3 +--
 src/radeon_kms.c      |  6 +++---
 3 files changed, 15 insertions(+), 16 deletions(-)
src/drmmode_display.c +11 -11
index 95e3acd..e02a6f5 100644
@@ -722,6 +722,7 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 	RADEONInfoPtr info = RADEONPTR(pScrn);
 	xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+	unsigned scanout_id = drmmode_crtc->scanout_id ^ info->tear_free;
 	drmmode_ptr drmmode = drmmode_crtc->drmmode;
 	int saved_x, saved_y;
 	Rotation saved_rotation;
@@ -771,7 +772,7 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 		fb_id = drmmode->fb_id;
 #ifdef RADEON_PIXMAP_SHARING
 		if (crtc->randr_crtc && crtc->randr_crtc->scanout_pixmap) {
-			fb_id = drmmode_crtc->scanout[0].fb_id;
+			fb_id = drmmode_crtc->scanout[scanout_id].fb_id;
 			x = y = 0;
 		} else
 #endif
@@ -815,12 +816,11 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 				pBox->x2 = max(pBox->x2, pScrn->virtualX);
 				pBox->y2 = max(pBox->y2, pScrn->virtualY);
 
-				drmmode_crtc->scanout_id = 0;
-				fb_id = drmmode_crtc->scanout[0].fb_id;
+				fb_id = drmmode_crtc->scanout[scanout_id].fb_id;
 				x = y = 0;
 
-				radeon_scanout_update_handler(crtc, 0, 0, drmmode_crtc);
-				radeon_bo_wait(drmmode_crtc->scanout[0].bo);
+				radeon_scanout_do_update(crtc, scanout_id);
+				radeon_bo_wait(drmmode_crtc->scanout[scanout_id].bo);
 			}
 		}
 
@@ -897,7 +897,7 @@ done:
 	} else {
 		crtc->active = TRUE;
 
-		if (fb_id != drmmode_crtc->scanout[0].fb_id)
+		if (fb_id != drmmode_crtc->scanout[scanout_id].fb_id)
 			drmmode_crtc_scanout_free(drmmode_crtc);
 	}
 
@@ -1134,13 +1134,13 @@ static Bool
 drmmode_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix)
 {
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+	unsigned scanout_id = drmmode_crtc->scanout_id;
 	RADEONInfoPtr info = RADEONPTR(crtc->scrn);
 	ScreenPtr screen = crtc->scrn->pScreen;
 	PixmapDirtyUpdatePtr dirty;
 
 	xorg_list_for_each_entry(dirty, &screen->pixmap_dirty_list, ent) {
-		if (dirty->slave_dst !=
-		    drmmode_crtc->scanout[drmmode_crtc->scanout_id].pixmap)
+		if (dirty->slave_dst != drmmode_crtc->scanout[scanout_id].pixmap)
 			continue;
 
 		PixmapStopDirtyTracking(dirty->src, dirty->slave_dst);
@@ -1165,13 +1165,13 @@ drmmode_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix)
 	}
 
 #ifdef HAS_DIRTYTRACKING_ROTATION
-	PixmapStartDirtyTracking(ppix, drmmode_crtc->scanout[0].pixmap,
+	PixmapStartDirtyTracking(ppix, drmmode_crtc->scanout[scanout_id].pixmap,
 				 0, 0, 0, 0, RR_Rotate_0);
 #elif defined(HAS_DIRTYTRACKING2)
-	PixmapStartDirtyTracking2(ppix, drmmode_crtc->scanout[0].pixmap,
+	PixmapStartDirtyTracking2(ppix, drmmode_crtc->scanout[scanout_id].pixmap,
 				  0, 0, 0, 0);
 #else
-	PixmapStartDirtyTracking(ppix, drmmode_crtc->scanout[0].pixmap, 0, 0);
+	PixmapStartDirtyTracking(ppix, drmmode_crtc->scanout[scanout_id].pixmap, 0, 0);
 #endif
 	return TRUE;
 }
src/radeon.h +1 -2
index 8ca8d31..5797bed 100644
@@ -630,8 +630,7 @@ extern Bool RADEONGetPixmapOffsetPitch(PixmapPtr pPix,
 Bool radeon_dri3_screen_init(ScreenPtr screen);
 
 /* radeon_kms.c */
-void radeon_scanout_update_handler(xf86CrtcPtr crtc, uint32_t frame,
-				   uint64_t usec, void *event_data);
+Bool radeon_scanout_do_update(xf86CrtcPtr xf86_crtc, int scanout_id);
 
 /* radeon_present.c */
 Bool radeon_present_screen_init(ScreenPtr screen);
src/radeon_kms.c +3 -3
index 6281fa5..090ea3f 100644
@@ -676,7 +676,7 @@ radeon_prime_scanout_do_update(xf86CrtcPtr crtc, unsigned scanout_id)
     return ret;
 }
 
-void
+static void
 radeon_prime_scanout_update_handler(xf86CrtcPtr crtc, uint32_t frame, uint64_t usec,
 				    void *event_data)
 {
@@ -850,7 +850,7 @@ radeon_dirty_update(ScrnInfoPtr scrn)
 }
 #endif
 
-static Bool
+Bool
 radeon_scanout_do_update(xf86CrtcPtr xf86_crtc, int scanout_id)
 {
     drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private;
@@ -963,7 +963,7 @@ radeon_scanout_update_abort(xf86CrtcPtr crtc, void *event_data)
     drmmode_crtc->scanout_update_pending = FALSE;
 }
 
-void
+static void
 radeon_scanout_update_handler(xf86CrtcPtr crtc, uint32_t frame, uint64_t usec,
 			      void *event_data)
 {
Signature · 6 lines
2.10.2

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20161129093608.27260-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org

#2 lore raw

PATCH 2/4 Fix radeon_scanout_extents_intersect for GPU screens

From: Michel Dänzer <[email protected]>

Fixes incorrect screen updates with TearFree enabled on PRIME slave outputs which are not located at (0, 0).

---
 src/radeon_kms.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
src/radeon_kms.c +15 -5
index 090ea3f..8bb261e 100644
@@ -383,11 +383,21 @@ static Bool RADEONCreateScreenResources_KMS(ScreenPtr pScreen)
 static Bool
 radeon_scanout_extents_intersect(xf86CrtcPtr xf86_crtc, BoxPtr extents)
 {
-    extents->x1 -= xf86_crtc->filter_width >> 1;
-    extents->x2 += xf86_crtc->filter_width >> 1;
-    extents->y1 -= xf86_crtc->filter_height >> 1;
-    extents->y2 += xf86_crtc->filter_height >> 1;
-    pixman_f_transform_bounds(&xf86_crtc->f_framebuffer_to_crtc, extents);
+#ifdef RADEON_PIXMAP_SHARING
+    if (xf86_crtc->scrn->is_gpu) {
+	extents->x1 -= xf86_crtc->x;
+	extents->y1 -= xf86_crtc->y;
+	extents->x2 -= xf86_crtc->x;
+	extents->y2 -= xf86_crtc->y;
+    } else
+#endif
+    {
+	extents->x1 -= xf86_crtc->filter_width >> 1;
+	extents->x2 += xf86_crtc->filter_width >> 1;
+	extents->y1 -= xf86_crtc->filter_height >> 1;
+	extents->y2 += xf86_crtc->filter_height >> 1;
+	pixman_f_transform_bounds(&xf86_crtc->f_framebuffer_to_crtc, extents);
+    }
 
     extents->x1 = max(extents->x1, 0);
     extents->y1 = max(extents->y1, 0);
Signature · 6 lines
2.10.2

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#3 lore raw

PATCH 3/4 Call ValidateGC after ChangeClip in radeon_sync_scanout_pixmaps

In reply to a message not in the archive

From: Michel Dänzer <[email protected]>

The wrong order meant that the clipping region wasn't actually applied, so it always copied the full contents from the other scanout pixmap.

---
 src/radeon_kms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/radeon_kms.c +1 -1
index 8bb261e..5764c20 100644
@@ -495,8 +495,8 @@ radeon_sync_scanout_pixmaps(xf86CrtcPtr xf86_crtc, RegionPtr new_region,
 
     gc = GetScratchGC(dst->depth, pScreen);
     if (gc) {
-	ValidateGC(dst, gc);
 	gc->funcs->ChangeClip(gc, CT_REGION, sync_region, 0);
+	ValidateGC(dst, gc);
 	sync_region = NULL;
 	gc->ops->CopyArea(src, dst, gc, 0, 0, dst->width, dst->height, 0, 0);
 	FreeScratchGC(gc);
Signature · 6 lines
2.10.2

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#4 lore raw

PATCH 4/4 Call radeon_drm_abort_entry on failure to flip to a scanout pixmap

In reply to a message not in the archive

From: Michel Dänzer <[email protected]>

Fixes leaking the corresponding struct radeon_drm_queue list entry in that case.

---
 src/radeon_kms.c | 2 ++
 1 file changed, 2 insertions(+)
src/radeon_kms.c +2 -0
index 5764c20..48dec96 100644
@@ -807,6 +807,7 @@ radeon_prime_scanout_flip(PixmapDirtyUpdatePtr ent)
 					  0, drm_queue_seq, 0) != 0) {
 	xf86DrvMsg(scrn->scrnIndex, X_WARNING, "flip queue failed in %s: %s\n",
 		   __func__, strerror(errno));
+	radeon_drm_abort_entry(drm_queue_seq);
 	return;
     }
 
@@ -1083,6 +1084,7 @@ radeon_scanout_flip(ScreenPtr pScreen, RADEONInfoPtr info,
 					  0, drm_queue_seq, 0) != 0) {
 	xf86DrvMsg(scrn->scrnIndex, X_WARNING, "flip queue failed in %s: %s\n",
 		   __func__, strerror(errno));
+	radeon_drm_abort_entry(drm_queue_seq);
 	return;
     }
 
Signature · 6 lines
2.10.2

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20161129093608.27260-4-michel-otUistvHUpPR7s880joybQ@public.gmane.org

Reviewed-by Alex Deucher
#6 lore raw

RE: [PATCH xf86-video-ati 4/4] Call radeon_drm_abort_entry on failure to flip to a scanout pixmap

Quoted 8 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Michel Dänzer
Sent: Tuesday, November 29, 2016 4:36 AM
To: [email protected]
Subject: [PATCH xf86-video-ati 4/4] Call radeon_drm_abort_entry on failure to flip to a scanout pixmap

Quoted 6 lines

From: Michel Dänzer <[email protected]>

Fixes leaking the corresponding struct radeon_drm_queue list entry in that case.

Series is:

Quoted 28 lines
---
 src/radeon_kms.c | 2 ++
 1 file changed, 2 insertions(+)
src/radeon_kms.c +1 -0
index 5764c20..48dec96 100644
@@ -807,6 +807,7 @@ radeon_prime_scanout_flip(PixmapDirtyUpdatePtr
 ent)
 					  0, drm_queue_seq, 0) != 0) {
 	xf86DrvMsg(scrn->scrnIndex, X_WARNING, "flip queue failed in %s:
 %s\n",
 		   __func__, strerror(errno));
+	radeon_drm_abort_entry(drm_queue_seq);
 	return;
     }
src/radeon_kms.c +1 -0
@@ -1083,6 +1084,7 @@ radeon_scanout_flip(ScreenPtr pScreen,
 RADEONInfoPtr info,
 					  0, drm_queue_seq, 0) != 0) {
 	xf86DrvMsg(scrn->scrnIndex, X_WARNING, "flip queue failed in %s:
 %s\n",
 		   __func__, strerror(errno));
+	radeon_drm_abort_entry(drm_queue_seq);
 	return;
     }
Quoted 7 lines

--
2.10.2

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx