xf86-video-amdgpu: Branch 'master' - 15 commits

Michel Dänzer daenzer at kemper.freedesktop.org
Tue Mar 7 08:19:48 UTC 2017


 configure.ac          |    6 +++++
 src/amdgpu_drv.h      |   20 ++++++++++++++++
 src/amdgpu_kms.c      |   59 ++++++++++++++++++++++++++++++++------------------
 src/amdgpu_present.c  |   15 +++++++++++-
 src/amdgpu_probe.c    |   18 +++++++++++----
 src/amdgpu_probe.h    |    2 +
 src/drmmode_display.c |   11 +--------
 7 files changed, 95 insertions(+), 36 deletions(-)

New commits:
commit 7884e38e94c2cbd6c205f556f2b31ad59b4089b4
Author: Hans De Goede <hdegoede at redhat.com>
Date:   Tue Oct 18 16:48:40 2016 +0200

    amdgpu_probe: Do not close server managed drm fds
    
    This fixes the xserver only seeing AMD/ATI devices supported by the amdgpu
    driver, as by the time xf86-video-ati gets a chance to probe them, the
    fd has been closed.
    
    This fixes e.g. Xorg not seeing the dGPU on a Lenovo Thinkpad E465 laptop
    with a CARRIZO iGPU and a HAINAN dGPU.
    
    Signed-off-by: Hans de Goede <hdegoede at redhat.com>
    
    v2: Rebased on top of new patch 1.
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/amdgpu_probe.c b/src/amdgpu_probe.c
index fc93ac6..fb62cb8 100644
--- a/src/amdgpu_probe.c
+++ b/src/amdgpu_probe.c
@@ -166,7 +166,7 @@ static Bool amdgpu_open_drm_master(ScrnInfoPtr pScrn, AMDGPUEntPtr pAMDGPUEnt,
 	if (err != 0) {
 		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 			   "[drm] failed to set drm interface version.\n");
-		drmClose(pAMDGPUEnt->fd);
+		amdgpu_kernel_close_fd(pAMDGPUEnt);
 		return FALSE;
 	}
 
@@ -254,7 +254,7 @@ static Bool amdgpu_get_scrninfo(int entity_num, struct pci_device *pci_dev)
 	return TRUE;
 
 error_amdgpu:
-	drmClose(pAMDGPUEnt->fd);
+	amdgpu_kernel_close_fd(pAMDGPUEnt);
 error_fd:
 	free(pPriv->ptr);
 error:
@@ -349,6 +349,7 @@ amdgpu_platform_probe(DriverPtr pDriver,
 
 		pPriv->ptr = xnfcalloc(sizeof(AMDGPUEntRec), 1);
 		pAMDGPUEnt = pPriv->ptr;
+		pAMDGPUEnt->platform_dev = dev;
 		pAMDGPUEnt->fd = amdgpu_kernel_open_fd(pScrn, busid, dev);
 		if (pAMDGPUEnt->fd < 0)
 			goto error_fd;
@@ -367,7 +368,6 @@ amdgpu_platform_probe(DriverPtr pDriver,
 		pAMDGPUEnt = pPriv->ptr;
 		pAMDGPUEnt->fd_ref++;
 	}
-	pAMDGPUEnt->platform_dev = dev;
 
 	xf86SetEntityInstanceForScreen(pScrn, pEnt->index,
 				       xf86GetNumEntityInstances(pEnt->
@@ -379,7 +379,7 @@ amdgpu_platform_probe(DriverPtr pDriver,
 	return TRUE;
 
 error_amdgpu:
-	drmClose(pAMDGPUEnt->fd);
+	amdgpu_kernel_close_fd(pAMDGPUEnt);
 error_fd:
 	free(pPriv->ptr);
 error:
commit a2c360fa1d33d6a5aa64c396197e119ff77d1379
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Mon Mar 6 18:59:23 2017 +0900

    Refactor amdgpu_kernel_close_fd helper
    
    Preparation for the following change.
    
    Assign pAMDGPUEnt->fd = -1 instead of 0 when we're not using the file
    descriptor anymore.
    
    Reviewed-by: Hans de Goede <hdegoede at redhat.com>
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index 31c2e86..92bf5fa 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -132,12 +132,7 @@ static void AMDGPUFreeRec(ScrnInfoPtr pScrn)
 		pAMDGPUEnt->fd_ref--;
 		if (!pAMDGPUEnt->fd_ref) {
 			amdgpu_device_deinitialize(pAMDGPUEnt->pDev);
-#ifdef XF86_PDEV_SERVER_FD
-			if (!(pAMDGPUEnt->platform_dev &&
-			      pAMDGPUEnt->platform_dev->flags & XF86_PDEV_SERVER_FD))
-#endif
-				drmClose(pAMDGPUEnt->fd);
-			pAMDGPUEnt->fd = 0;
+			amdgpu_kernel_close_fd(pAMDGPUEnt);
 		}
 	}
 
diff --git a/src/amdgpu_probe.c b/src/amdgpu_probe.c
index 94da7f6..fc93ac6 100644
--- a/src/amdgpu_probe.c
+++ b/src/amdgpu_probe.c
@@ -134,6 +134,16 @@ static int amdgpu_kernel_open_fd(ScrnInfoPtr pScrn, char *busid,
 	return fd;
 }
 
+void amdgpu_kernel_close_fd(AMDGPUEntPtr pAMDGPUEnt)
+{
+#ifdef XF86_PDEV_SERVER_FD
+	if (!(pAMDGPUEnt->platform_dev &&
+	      pAMDGPUEnt->platform_dev->flags & XF86_PDEV_SERVER_FD))
+#endif
+		drmClose(pAMDGPUEnt->fd);
+	pAMDGPUEnt->fd = -1;
+}
+
 static Bool amdgpu_open_drm_master(ScrnInfoPtr pScrn, AMDGPUEntPtr pAMDGPUEnt,
 				   char *busid)
 {
diff --git a/src/amdgpu_probe.h b/src/amdgpu_probe.h
index 0f43233..9e4a9a4 100644
--- a/src/amdgpu_probe.h
+++ b/src/amdgpu_probe.h
@@ -71,6 +71,8 @@ typedef struct {
 	char *render_node;
 } AMDGPUEntRec, *AMDGPUEntPtr;
 
+extern void amdgpu_kernel_close_fd(AMDGPUEntPtr pAMDGPUEnt);
+
 extern const OptionInfoRec *AMDGPUOptionsWeak(void);
 
 extern Bool AMDGPUPreInit_KMS(ScrnInfoPtr, int);
commit 947017194d07e32876a43ee0efc45fdc71385748
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Fri Mar 3 17:59:19 2017 +0900

    glamor: Don't flush in BlockHandler with Xorg >= 1.19
    
    This was only necessary with older versions for driving the FBO cache
    expiry mechanism.
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index d48ad48..31c2e86 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -1035,8 +1035,10 @@ static void AMDGPUBlockHandler_KMS(BLOCKHANDLER_ARGS_DECL)
 		}
 	}
 
+#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1,19,0,0,0)
 	if (info->use_glamor)
 		amdgpu_glamor_flush(pScrn);
+#endif
 
 #ifdef AMDGPU_PIXMAP_SHARING
 	amdgpu_dirty_update(pScrn);
commit 86907a5e4ce33154167b330570491f88218725d3
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Mon Mar 6 18:23:41 2017 +0900

    Only define transform_region for XF86_CRTC_VERSION >= 4
    
    Not used with older versions of Xorg. Fixes warning in that case:
    
    ../../src/amdgpu_kms.c:328:1: warning: ‘transform_region’ defined but not used [-Wunused-function]
     transform_region(RegionPtr region, struct pict_f_transform *transform,
     ^~~~~~~~~~~~~~~~
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index bfc3530..d48ad48 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -324,6 +324,8 @@ amdgpu_scanout_extents_intersect(xf86CrtcPtr xf86_crtc, BoxPtr extents)
 	return (extents->x1 < extents->x2 && extents->y1 < extents->y2);
 }
 
+#if XF86_CRTC_VERSION >= 4
+
 static RegionPtr
 transform_region(RegionPtr region, struct pict_f_transform *transform,
 		 int w, int h)
@@ -362,6 +364,8 @@ transform_region(RegionPtr region, struct pict_f_transform *transform,
 	return transformed;
 }
 
+#endif
+
 static void
 amdgpu_sync_scanout_pixmaps(xf86CrtcPtr xf86_crtc, RegionPtr new_region,
 							int scanout_id)
commit 8d2b7d1758e3fcac520a18a0684c073f0ac62389
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Mon Mar 6 18:09:58 2017 +0900

    Use local implementation of RegionDuplicate for older xserver
    
    It was only added in xserver 1.15. Fixes build against older xserver.
    
    Reported-by: Pali Rohár <pali.rohar at gmail.com>
    (Ported from radeon commit 80cc892ee1ce54fad3cb7dd11bd9df18c359136f)
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/configure.ac b/configure.ac
index 11dc285..00249a5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -152,6 +152,12 @@ else
 fi
 AM_CONDITIONAL(GLAMOR, test x$GLAMOR != xno)
 
+AC_CHECK_DECL(RegionDuplicate,
+	      [AC_DEFINE(HAVE_REGIONDUPLICATE, 1,
+	      [Have RegionDuplicate API])], [],
+	      [#include <xorg-server.h>
+	       #include <regionstr.h>])
+
 AC_CHECK_DECL(fbGlyphs,
 	      [AC_DEFINE(HAVE_FBGLYPHS, 1, [Have fbGlyphs API])], [],
 	      [#include <X11/Xmd.h>
diff --git a/src/amdgpu_drv.h b/src/amdgpu_drv.h
index ae5b6f9..0700dae 100644
--- a/src/amdgpu_drv.h
+++ b/src/amdgpu_drv.h
@@ -89,6 +89,25 @@
 
 struct _SyncFence;
 
+#ifndef HAVE_REGIONDUPLICATE
+
+static inline RegionPtr
+RegionDuplicate(RegionPtr pOld)
+{
+	RegionPtr pNew;
+
+	pNew = RegionCreate(&pOld->extents, 0);
+	if (!pNew)
+		return NULL;
+	if (!RegionCopy(pNew, pOld)) {
+		RegionDestroy(pNew);
+		return NULL;
+	}
+	return pNew;
+}
+
+#endif
+
 #ifndef MAX
 #define MAX(a,b) ((a)>(b)?(a):(b))
 #endif
commit cd73100114a18642d9c40f1df33cef8311e96a8b
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Mon Mar 6 18:07:19 2017 +0900

    Don't use pScrn->is_gpu in AMDGPUCreateScreenResources_KMS
    
    Looks like this snuck in accidentally.
    
    Brings us back in line with the radeon driver, and fixes the build
    against older versions of xserver which didn't have the is_gpu field
    yet.
    
    Fixes: 6bab8fabb37e ("Remove info->dri2.drm_fd and info->drmmode->fd")
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index c5205e2..bfc3530 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -248,7 +248,7 @@ static Bool AMDGPUCreateScreenResources_KMS(ScreenPtr pScreen)
 		}
 	}
 
-	if (!drmmode_set_desired_modes(pScrn, &info->drmmode, pScrn->is_gpu))
+	if (!drmmode_set_desired_modes(pScrn, &info->drmmode, FALSE))
 		return FALSE;
 
 	drmmode_uevent_init(pScrn, &info->drmmode);
commit 351baa89b9b0ecfb6c666af3a2d10c559a9224a9
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Fri Mar 3 16:44:15 2017 +0900

    Don't call amdgpu_glamor_flush in drmmode_copy_fb
    
    AMDGPUWindowExposures_oneshot takes care of it.
    
    (Ported from radeon commit d63881623f0686a66a2e3e3c1f84e496aa52ec6b)
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 406b5ee..2cdea90 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -429,8 +429,6 @@ void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
 
 	FreeScratchGC(gc);
 
-	amdgpu_glamor_finish(pScrn);
-
 	pScreen->canDoBGNoneRoot = TRUE;
 
 	if (info->fbcon_pixmap)
commit ad53635af150cda9b8da413be5a011d74f972ac7
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Fri Mar 3 16:41:49 2017 +0900

    Move DPMS check from amdgpu_scanout_do_update to amdgpu_scanout_flip
    
    When amdgpu_scanout_do_update is called from
    drmmode_crtc_scanout_update, drmmode_crtc->pending_dpms_mode may still
    be != DPMSModeOn, e.g. during server startup.
    
    Fixes intermittently showing garbage with TearFree enabled.
    
    (Ported from radeon commit cc9d6b7db9c2078be1e530a64af6d517c6a42024)
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index ce1ae43..c5205e2 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -787,7 +787,6 @@ amdgpu_scanout_do_update(xf86CrtcPtr xf86_crtc, int scanout_id)
 	BoxRec extents;
 
 	if (!xf86_crtc->enabled ||
-	    drmmode_crtc->pending_dpms_mode != DPMSModeOn ||
 	    !drmmode_crtc->scanout[scanout_id].pixmap)
 		return FALSE;
 
@@ -970,7 +969,8 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info,
 	uintptr_t drm_queue_seq;
 	unsigned scanout_id;
 
-	if (drmmode_crtc->scanout_update_pending)
+	if (drmmode_crtc->scanout_update_pending ||
+	    drmmode_crtc->pending_dpms_mode != DPMSModeOn)
 		return;
 
 	scanout_id = drmmode_crtc->scanout_id ^ 1;
commit 378bd05c849ad3092f138bdc8917d35d0b967389
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Fri Mar 3 16:36:24 2017 +0900

    Call drmmode_set_desired_modes from a WindowExposures hook
    
    This is the earliest opportunity where the root window contents are
    guaranteed to be initialized, and prevents drmmode_set_mode_major from
    getting called before drmmode_set_desired_modes via AMDGPUUnblank ->
    drmmode_crtc_dpms. Also, in contrast to the BlockHandler hook, this is
    called when running Xorg with -pogo.
    
    Fixes intermittently showing garbage on server startup or after server
    reset.
    
    As a bonus, this avoids trouble due to higher layers (e.g. the tigervnc
    Xorg module) calling AMDGPUBlockHandler_oneshot repeatedly even after
    we set pScreen->BlockHandler = AMDGPUBlockHandler_KMS.
    
    Bugzilla: https://bugs.freedesktop.org/99457
    (Ported from radeon commits 0a12bf1085505017068dfdfd31d23133e51b45b9 and
    f0e7948e1c0e984fc27f235f365639e9cf628291)
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/amdgpu_drv.h b/src/amdgpu_drv.h
index 2aaafe4..ae5b6f9 100644
--- a/src/amdgpu_drv.h
+++ b/src/amdgpu_drv.h
@@ -230,6 +230,7 @@ typedef struct {
 
 	CreateScreenResourcesProcPtr CreateScreenResources;
 	CreateWindowProcPtr CreateWindow;
+	WindowExposuresProcPtr WindowExposures;
 
 	Bool IsSecondary;
 
diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index bafcb9b..ce1ae43 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -1039,17 +1039,6 @@ static void AMDGPUBlockHandler_KMS(BLOCKHANDLER_ARGS_DECL)
 #endif
 }
 
-static void AMDGPUBlockHandler_oneshot(BLOCKHANDLER_ARGS_DECL)
-{
-	SCREEN_PTR(arg);
-	ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
-	AMDGPUInfoPtr info = AMDGPUPTR(pScrn);
-
-	AMDGPUBlockHandler_KMS(BLOCKHANDLER_ARGS);
-
-	drmmode_set_desired_modes(pScrn, &info->drmmode, TRUE);
-}
-
 /* This is called by AMDGPUPreInit to set up the default visual */
 static Bool AMDGPUPreInitVisual(ScrnInfoPtr pScrn)
 {
@@ -1266,6 +1255,31 @@ static Bool AMDGPUCreateWindow_oneshot(WindowPtr pWin)
 	return ret;
 }
 
+/* When the root window is mapped, set the initial modes */
+static void AMDGPUWindowExposures_oneshot(WindowPtr pWin, RegionPtr pRegion
+#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1,16,99,901,0)
+					  , RegionPtr pBSRegion
+#endif
+	)
+{
+	ScreenPtr pScreen = pWin->drawable.pScreen;
+	ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
+	AMDGPUInfoPtr info = AMDGPUPTR(pScrn);
+
+	if (pWin != pScreen->root)
+		ErrorF("%s called for non-root window %p\n", __func__, pWin);
+
+	pScreen->WindowExposures = info->WindowExposures;
+#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1,16,99,901,0)
+	pScreen->WindowExposures(pWin, pRegion, pBSRegion);
+#else
+	pScreen->WindowExposures(pWin, pRegion);
+#endif
+
+	amdgpu_glamor_finish(pScrn);
+	drmmode_set_desired_modes(pScrn, &info->drmmode, TRUE);
+}
+
 Bool AMDGPUPreInit_KMS(ScrnInfoPtr pScrn, int flags)
 {
 	AMDGPUInfoPtr info;
@@ -1824,6 +1838,8 @@ Bool AMDGPUScreenInit_KMS(SCREEN_INIT_ARGS_DECL)
 		info->CreateWindow = pScreen->CreateWindow;
 		pScreen->CreateWindow = AMDGPUCreateWindow_oneshot;
 	}
+	info->WindowExposures = pScreen->WindowExposures;
+	pScreen->WindowExposures = AMDGPUWindowExposures_oneshot;
 
 	/* Provide SaveScreen & wrap BlockHandler and CloseScreen */
 	/* Wrap CloseScreen */
@@ -1831,7 +1847,7 @@ Bool AMDGPUScreenInit_KMS(SCREEN_INIT_ARGS_DECL)
 	pScreen->CloseScreen = AMDGPUCloseScreen_KMS;
 	pScreen->SaveScreen = AMDGPUSaveScreen_KMS;
 	info->BlockHandler = pScreen->BlockHandler;
-	pScreen->BlockHandler = AMDGPUBlockHandler_oneshot;
+	pScreen->BlockHandler = AMDGPUBlockHandler_KMS;
 
 	info->CreateScreenResources = pScreen->CreateScreenResources;
 	pScreen->CreateScreenResources = AMDGPUCreateScreenResources_KMS;
commit 8d4d73e05ce34eb353daec7b2c0e7c844113c7de
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Fri Mar 3 16:34:16 2017 +0900

    present: Flush before flipping
    
    This isn't necessary for DRI clients, but the Present extension can also
    be used for presenting normal pixmaps rendered to via the X11 protocol.
    
    (Ported from radeon commit 9035b6abea557828e672ee455f0c84e43da0906f)
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/amdgpu_present.c b/src/amdgpu_present.c
index d381e15..3c4bc52 100644
--- a/src/amdgpu_present.c
+++ b/src/amdgpu_present.c
@@ -327,6 +327,8 @@ amdgpu_present_flip(RRCrtcPtr crtc, uint64_t event_id, uint64_t target_msc,
 
 	event->event_id = event_id;
 
+	amdgpu_glamor_flush(scrn);
+
 	ret = amdgpu_do_pageflip(scrn, AMDGPU_DRM_QUEUE_CLIENT_DEFAULT,
 				 pixmap, event_id, event, crtc_id,
 				 amdgpu_present_flip_event,
commit 88725b68cad92418c9bb03cb7f20526ce238d64e
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Fri Mar 3 16:30:27 2017 +0900

    present: Use async flip for unflip if possible
    
    In that case, unflip operations should finish faster in general.
    
    (Ported from radeon commit 0a4eb0e12f0c9c653cf4cea6fd62e1a507eb261c)
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/amdgpu_present.c b/src/amdgpu_present.c
index 4048f98..d381e15 100644
--- a/src/amdgpu_present.c
+++ b/src/amdgpu_present.c
@@ -48,6 +48,8 @@
 
 #include "present.h"
 
+static present_screen_info_rec amdgpu_present_screen_info;
+
 struct amdgpu_present_vblank_event {
 	uint64_t event_id;
 	Bool unflip;
@@ -351,6 +353,9 @@ amdgpu_present_unflip(ScreenPtr screen, uint64_t event_id)
 	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
 	struct amdgpu_present_vblank_event *event;
 	PixmapPtr pixmap = screen->GetScreenPixmap(screen);
+	enum drmmode_flip_sync flip_sync =
+		(amdgpu_present_screen_info.capabilities & PresentCapabilityAsync) ?
+		FLIP_ASYNC : FLIP_VSYNC;
 	int old_fb_id;
 	int i;
 
@@ -369,7 +374,7 @@ amdgpu_present_unflip(ScreenPtr screen, uint64_t event_id)
 	amdgpu_glamor_flush(scrn);
 	if (amdgpu_do_pageflip(scrn, AMDGPU_DRM_QUEUE_CLIENT_DEFAULT, pixmap,
 			       event_id, event, -1, amdgpu_present_flip_event,
-			       amdgpu_present_flip_abort, FLIP_VSYNC, 0))
+			       amdgpu_present_flip_abort, flip_sync, 0))
 		return;
 
 modeset:
commit b31489c086b4bc50c824e85fa26d97c0f43afb20
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Fri Mar 3 16:28:41 2017 +0900

    present: Also flush before using a flip to unflip
    
    Not doing so might result in intermittently scanning out stale contents
    of the screen pixmap.
    
    (Ported from radeon commit 9a951a3e551db58ba50e7a594521ceac54d90615)
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/amdgpu_present.c b/src/amdgpu_present.c
index cf6e36b..4048f98 100644
--- a/src/amdgpu_present.c
+++ b/src/amdgpu_present.c
@@ -366,6 +366,7 @@ amdgpu_present_unflip(ScreenPtr screen, uint64_t event_id)
 	event->event_id = event_id;
 	event->unflip = TRUE;
 
+	amdgpu_glamor_flush(scrn);
 	if (amdgpu_do_pageflip(scrn, AMDGPU_DRM_QUEUE_CLIENT_DEFAULT, pixmap,
 			       event_id, event, -1, amdgpu_present_flip_event,
 			       amdgpu_present_flip_abort, FLIP_VSYNC, 0))
commit f6a3c87c3097e8d5c1d2159bc90d6541a46ed8be
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Fri Mar 3 16:26:26 2017 +0900

    present: Wait for GPU idle before setting modes for unflip
    
    To make sure the screen pixmap contents are up to date when it starts
    being scanned out.
    
    (Ported from radeon commit 244d4bc7f8c8f6bc90f49556c0b9344c8aa40295)
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/amdgpu_present.c b/src/amdgpu_present.c
index 5a345cb..cf6e36b 100644
--- a/src/amdgpu_present.c
+++ b/src/amdgpu_present.c
@@ -378,6 +378,7 @@ modeset:
 	old_fb_id = info->drmmode.fb_id;
 	info->drmmode.fb_id = 0;
 
+	amdgpu_glamor_finish(scrn);
 	for (i = 0; i < config->num_crtc; i++) {
 		xf86CrtcPtr crtc = config->crtc[i];
 		drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
commit 012ffffb45119059f3610fb8fd6ae103186b3e3c
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Fri Mar 3 16:22:39 2017 +0900

    present: Only call drmModeRmFB after setting modes for unflip
    
    Fixes display intermittently blanking when a modeset is used for unflip.
    
    (Ported from radeon commit 3ff29e5a14451916bc66b4e0028e9a317f0723f8)
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/amdgpu_present.c b/src/amdgpu_present.c
index 3646190..5a345cb 100644
--- a/src/amdgpu_present.c
+++ b/src/amdgpu_present.c
@@ -351,6 +351,7 @@ amdgpu_present_unflip(ScreenPtr screen, uint64_t event_id)
 	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
 	struct amdgpu_present_vblank_event *event;
 	PixmapPtr pixmap = screen->GetScreenPixmap(screen);
+	int old_fb_id;
 	int i;
 
 	if (!amdgpu_present_check_unflip(scrn))
@@ -374,7 +375,7 @@ modeset:
 	/* info->drmmode.fb_id still points to the FB for the last flipped BO.
 	 * Clear it, drmmode_set_mode_major will re-create it
 	 */
-	drmModeRmFB(pAMDGPUEnt->fd, info->drmmode.fb_id);
+	old_fb_id = info->drmmode.fb_id;
 	info->drmmode.fb_id = 0;
 
 	for (i = 0; i < config->num_crtc; i++) {
@@ -391,6 +392,7 @@ modeset:
 			drmmode_crtc->need_modeset = TRUE;
 	}
 
+	drmModeRmFB(pAMDGPUEnt->fd, old_fb_id);
 	present_event_notify(event_id, 0, 0);
 	info->drmmode.present_flipping = FALSE;
 }
commit f4719bb473df897012f8830f46e99cb781d67b6f
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Fri Mar 3 16:19:11 2017 +0900

    Use drmmode_crtc_scanout_free in drmmode_fini
    
    We were leaking drmmode_crtc->scanout_damage, which caused trouble on
    server reset. Fixes server reset with active separate scanout pixmaps.
    
    (Cherry picked from radeon commit 0c29deb5a97d9a57e994cc0053c49ddf7aca6ecb)
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 40439dd..406b5ee 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -2415,13 +2415,8 @@ void drmmode_fini(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
 #endif
 	}
 
-	for (c = 0; c < config->num_crtc; c++) {
-		xf86CrtcPtr crtc = config->crtc[c];
-		drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-
-		drmmode_crtc_scanout_destroy(&info->drmmode, &drmmode_crtc->scanout[0]);
-		drmmode_crtc_scanout_destroy(&info->drmmode, &drmmode_crtc->scanout[1]);
-	}
+	for (c = 0; c < config->num_crtc; c++)
+		drmmode_crtc_scanout_free(config->crtc[c]->driver_private);
 }
 
 void drmmode_set_cursor(ScrnInfoPtr scrn, drmmode_ptr drmmode, int id,


More information about the xorg-commit mailing list