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] Use a timer for unreferencing the all-black FB
Date: Wed, 30 Aug 2017 17:24:31 +0900	[thread overview]
Message-ID: <20170830082431.20475-1-michel@daenzer.net> (raw)

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

The timer fires 1 second after LeaveVT. This gives the next DRM master
enough time to set up scanout of its own buffers.

Fixes prolonged intermittent black screen when switching from Xorg to
e.g. the GDM Wayland mode login VT.

Fixes: c16ff42f927d ("Make all active CRTCs scan out an all-black
                      framebuffer in LeaveVT")
(Ported from radeon commit 9d9c565c84601f4c6c73ad769f86491088683f7a)

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
 src/amdgpu_kms.c | 42 +++++++++++++++++++++++++++---------------
 1 file changed, 27 insertions(+), 15 deletions(-)

diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index c3613eb8d..d82ead2ac 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -1044,7 +1044,6 @@ static void AMDGPUBlockHandler_KMS(BLOCKHANDLER_ARGS_DECL)
 {
 	SCREEN_PTR(arg);
 	ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
-	AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(pScrn);
 	AMDGPUInfoPtr info = AMDGPUPTR(pScrn);
 	xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
 	int c;
@@ -1053,21 +1052,8 @@ static void AMDGPUBlockHandler_KMS(BLOCKHANDLER_ARGS_DECL)
 	(*pScreen->BlockHandler) (BLOCKHANDLER_ARGS);
 	pScreen->BlockHandler = AMDGPUBlockHandler_KMS;
 
-	if (!xf86ScreenToScrn(amdgpu_master_screen(pScreen))->vtSema) {
-		/* Unreference the all-black FB created by AMDGPULeaveVT_KMS. After
-		 * this, there should be no FB left created by this driver.
-		 */
-
-		for (c = 0; c < xf86_config->num_crtc; c++) {
-			drmmode_crtc_private_ptr drmmode_crtc =
-				xf86_config->crtc[c]->driver_private;
-
-			drmmode_fb_reference(pAMDGPUEnt->fd, &drmmode_crtc->fb,
-					     NULL);
-		}
-
+	if (!xf86ScreenToScrn(amdgpu_master_screen(pScreen))->vtSema)
 		return;
-	}
 
 	if (!amdgpu_is_gpu_screen(pScreen))
 	{
@@ -1629,6 +1615,30 @@ static void amdgpu_drop_drm_master(ScrnInfoPtr pScrn)
 }
 
 
+static
+CARD32 cleanup_black_fb(OsTimerPtr timer, CARD32 now, pointer data)
+{
+	ScreenPtr screen = data;
+	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+	AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(scrn);
+	xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+	int c;
+
+	if (xf86ScreenToScrn(amdgpu_master_screen(screen))->vtSema)
+		return 0;
+
+	/* Unreference the all-black FB created by AMDGPULeaveVT_KMS. After
+	 * this, there should be no FB left created by this driver.
+	 */
+	for (c = 0; c < xf86_config->num_crtc; c++) {
+		drmmode_crtc_private_ptr drmmode_crtc =
+			xf86_config->crtc[c]->driver_private;
+
+		drmmode_fb_reference(pAMDGPUEnt->fd, &drmmode_crtc->fb, NULL);
+	}
+
+	return 0;
+}
 
 static Bool AMDGPUSaveScreen_KMS(ScreenPtr pScreen, int mode)
 {
@@ -2061,6 +2071,8 @@ void AMDGPULeaveVT_KMS(VT_FUNC_ARGS_DECL)
 	}
 	pixmap_unref_fb(pScreen->GetScreenPixmap(pScreen), None, pAMDGPUEnt);
 
+	TimerSet(NULL, 0, 1000, cleanup_black_fb, pScreen);
+
 	xf86_hide_cursors(pScrn);
 
 	amdgpu_drop_drm_master(pScrn);
-- 
2.14.1

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

             reply	other threads:[~2017-08-30  8:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-30  8:24 Michel Dänzer [this message]
     [not found] ` <20170830082431.20475-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2017-08-30 15:14   ` [PATCH xf86-video-amdgpu] Use a timer for unreferencing the all-black FB Deucher, Alexander

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=20170830082431.20475-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.