All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michel Dänzer" <michel-otUistvHUpPR7s880joybQ@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: [PATCH xf86-video-amdgpu v2 7/9] Call drmmode_set_desired_modes from a WindowExposures hook
Date: Mon,  6 Mar 2017 10:47:59 +0900	[thread overview]
Message-ID: <20170306014759.9030-1-michel@daenzer.net> (raw)
In-Reply-To: <20170303090745.2254-7-michel-otUistvHUpPR7s880joybQ@public.gmane.org>

From: Michel Dänzer <michel.daenzer@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 commits 0a12bf1085505017068dfdfd31d23133e51b45b9 and
f0e7948e1c0e984fc27f235f365639e9cf628291)

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---

v2: Squash radeon commit f0e7948e1c0e984fc27f235f365639e9cf628291 to fix
    compile error against xserver < 1.16.99.901

Any volunteers for reviewing this series?

 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..ce1ae43a4 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;
-- 
2.11.0

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2017-03-06  1:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-03  9:07 [PATCH xf86-video-amdgpu 1/9] Use drmmode_crtc_scanout_free in drmmode_fini Michel Dänzer
     [not found] ` <20170303090745.2254-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2017-03-03  9:07   ` [PATCH xf86-video-amdgpu 2/9] present: Only call drmModeRmFB after setting modes for unflip Michel Dänzer
2017-03-03  9:07   ` [PATCH xf86-video-amdgpu 3/9] present: Wait for GPU idle before " Michel Dänzer
2017-03-03  9:07   ` [PATCH xf86-video-amdgpu 4/9] present: Also flush before using a flip to unflip Michel Dänzer
2017-03-03  9:07   ` [PATCH xf86-video-amdgpu 5/9] present: Use async flip for unflip if possible Michel Dänzer
2017-03-03  9:07   ` [PATCH xf86-video-amdgpu 6/9] present: Flush before flipping Michel Dänzer
2017-03-03  9:07   ` [PATCH xf86-video-amdgpu 7/9] Call drmmode_set_desired_modes from a WindowExposures hook Michel Dänzer
     [not found]     ` <20170303090745.2254-7-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2017-03-06  1:47       ` Michel Dänzer [this message]
     [not found]         ` <20170306014759.9030-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2017-03-06 15:23           ` [PATCH xf86-video-amdgpu v2 " Alex Deucher
2017-03-03  9:07   ` [PATCH xf86-video-amdgpu 8/9] Move DPMS check from amdgpu_scanout_do_update to amdgpu_scanout_flip Michel Dänzer
2017-03-03  9:07   ` [PATCH xf86-video-amdgpu 9/9] Don't call amdgpu_glamor_flush in drmmode_copy_fb Michel Dänzer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170306014759.9030-1-michel@daenzer.net \
    --to=michel-otuistvhuppr7s880joybq@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.