[PATCH xf86-video-amdgpu 7/9] Call drmmode_set_desired_modes from a WindowExposures hook

Michel Dänzer michel at daenzer.net
Fri Mar 3 09:07:43 UTC 2017


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

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 commit 0a12bf1085505017068dfdfd31d23133e51b45b9)

Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
 src/amdgpu_drv.h |  1 +
 src/amdgpu_kms.c | 40 ++++++++++++++++++++++++++++------------
 2 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/src/amdgpu_drv.h b/src/amdgpu_drv.h
index 2aaafe438..ae5b6f94c 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 bafcb9bbb..3420fd89a 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, RegionPtr 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;
-- 
2.11.0



More information about the amd-gfx mailing list