Skip to contentSkip to conversation

Call drmmode_set_desired_modes from a WindowExposures hook

PATCH Superseded Michel Dänzer 2 participants 3 messages Mar 1, 2017 1 message not in the archive

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Call drmmode_set_desired_modes from a WindowExposures hook

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

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 RADEONUnblank -> 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 RADEONBlockHandler_oneshot repeatedly even after we set pScreen->BlockHandler = RADEONBlockHandler_KMS.

Bugzilla: https://bugs.freedesktop.org/99457

---
 src/radeon.h     |  1 +
 src/radeon_kms.c | 40 ++++++++++++++++++++++++++++------------
 2 files changed, 29 insertions(+), 12 deletions(-)
src/radeon.h +1 -0
index bfff232c4..815c12a1d 100644
@@ -523,6 +523,7 @@ typedef struct {
 
     CreateScreenResourcesProcPtr CreateScreenResources;
     CreateWindowProcPtr CreateWindow;
+    WindowExposuresProcPtr WindowExposures;
 
     Bool              IsSecondary;
 
src/radeon_kms.c +28 -12
index 331f3f1c9..a0961199c 100644
@@ -1137,17 +1137,6 @@ static void RADEONBlockHandler_KMS(BLOCKHANDLER_ARGS_DECL)
 #endif
 }
 
-static void RADEONBlockHandler_oneshot(BLOCKHANDLER_ARGS_DECL)
-{
-    SCREEN_PTR(arg);
-    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
-    RADEONInfoPtr info = RADEONPTR(pScrn);
-
-    RADEONBlockHandler_KMS(BLOCKHANDLER_ARGS);
-
-    drmmode_set_desired_modes(pScrn, &info->drmmode, TRUE);
-}
-
 static Bool RADEONIsFastFBWorking(ScrnInfoPtr pScrn)
 {
     RADEONInfoPtr info = RADEONPTR(pScrn);
@@ -1636,6 +1625,31 @@ static Bool RADEONCreateWindow_oneshot(WindowPtr pWin)
     return ret;
 }
 
+/* When the root window is mapped, set the initial modes */
+static void RADEONWindowExposures_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);
+    RADEONInfoPtr info = RADEONPTR(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
+
+    radeon_cs_flush_indirect(pScrn);
+    drmmode_set_desired_modes(pScrn, &info->drmmode, TRUE);
+}
+
 Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn, int flags)
 {
     RADEONInfoPtr     info;
@@ -2330,6 +2344,8 @@ Bool RADEONScreenInit_KMS(SCREEN_INIT_ARGS_DECL)
 	info->CreateWindow = pScreen->CreateWindow;
 	pScreen->CreateWindow = RADEONCreateWindow_oneshot;
     }
+    info->WindowExposures = pScreen->WindowExposures;
+    pScreen->WindowExposures = RADEONWindowExposures_oneshot;
 
     /* Provide SaveScreen & wrap BlockHandler and CloseScreen */
     /* Wrap CloseScreen */
@@ -2337,7 +2353,7 @@ Bool RADEONScreenInit_KMS(SCREEN_INIT_ARGS_DECL)
     pScreen->CloseScreen = RADEONCloseScreen_KMS;
     pScreen->SaveScreen  = RADEONSaveScreen_KMS;
     info->BlockHandler = pScreen->BlockHandler;
-    pScreen->BlockHandler = RADEONBlockHandler_oneshot;
+    pScreen->BlockHandler = RADEONBlockHandler_KMS;
 
     info->CreateScreenResources = pScreen->CreateScreenResources;
     pScreen->CreateScreenResources = RADEONCreateScreenResources_KMS;
Signature · 6 lines
2.11.0

_______________________________________________
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): 20170301100242.19172-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org

#2 lore raw

PATCH 2/2 Move DPMS check from radeon_scanout_do_update to radeon_scanout_flip

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

When radeon_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.

---
 src/radeon_kms.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/radeon_kms.c +2 -2
index a0961199c..a9fc0676c 100644
@@ -882,7 +882,6 @@ radeon_scanout_do_update(xf86CrtcPtr xf86_crtc, int scanout_id)
     Bool force;
 
     if (!xf86_crtc->enabled ||
-	drmmode_crtc->pending_dpms_mode != DPMSModeOn ||
 	!drmmode_crtc->scanout[scanout_id].pixmap)
 	return FALSE;
 
@@ -1069,7 +1068,8 @@ radeon_scanout_flip(ScreenPtr pScreen, RADEONInfoPtr 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;
Signature · 6 lines
2.11.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by
#3 lore raw
In reply to a message not in the archive
Quoted 11 lines · Michel Dänzer

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

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 RADEONUnblank -> 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.

Quoted 6 lines

As a bonus, this avoids trouble due to higher layers (e.g. the tigervnc Xorg module) calling RADEONBlockHandler_oneshot repeatedly even after we set pScreen->BlockHandler = RADEONBlockHandler_KMS.

Bugzilla: https://bugs.freedesktop.org/99457

Series is:

Quoted 92 lines
---
 src/radeon.h     |  1 +
 src/radeon_kms.c | 40 ++++++++++++++++++++++++++++------------
 2 files changed, 29 insertions(+), 12 deletions(-)
src/radeon.h +1 -0
index bfff232c4..815c12a1d 100644
@@ -523,6 +523,7 @@ typedef struct {
 
     CreateScreenResourcesProcPtr CreateScreenResources;
     CreateWindowProcPtr CreateWindow;
+    WindowExposuresProcPtr WindowExposures;
 
     Bool              IsSecondary;
 
src/radeon_kms.c +28 -13
index 331f3f1c9..a0961199c 100644
@@ -1137,17 +1137,6 @@ static void RADEONBlockHandler_KMS(BLOCKHANDLER_ARGS_DECL)
 #endif
 }
 
-static void RADEONBlockHandler_oneshot(BLOCKHANDLER_ARGS_DECL)
-{
-    SCREEN_PTR(arg);
-    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
-    RADEONInfoPtr info = RADEONPTR(pScrn);
-
-    RADEONBlockHandler_KMS(BLOCKHANDLER_ARGS);
-
-    drmmode_set_desired_modes(pScrn, &info->drmmode, TRUE);
-}
-
 static Bool RADEONIsFastFBWorking(ScrnInfoPtr pScrn)
 {
     RADEONInfoPtr info = RADEONPTR(pScrn);
@@ -1636,6 +1625,31 @@ static Bool RADEONCreateWindow_oneshot(WindowPtr pWin)
     return ret;
 }
 
+/* When the root window is mapped, set the initial modes */
+static void RADEONWindowExposures_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);
+    RADEONInfoPtr info = RADEONPTR(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
+
+    radeon_cs_flush_indirect(pScrn);
+    drmmode_set_desired_modes(pScrn, &info->drmmode, TRUE);
+}
+
 Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn, int flags)
 {
     RADEONInfoPtr     info;
@@ -2330,6 +2344,8 @@ Bool RADEONScreenInit_KMS(SCREEN_INIT_ARGS_DECL)
        info->CreateWindow = pScreen->CreateWindow;
        pScreen->CreateWindow = RADEONCreateWindow_oneshot;
     }
+    info->WindowExposures = pScreen->WindowExposures;
+    pScreen->WindowExposures = RADEONWindowExposures_oneshot;
 
     /* Provide SaveScreen & wrap BlockHandler and CloseScreen */
     /* Wrap CloseScreen */
@@ -2337,7 +2353,7 @@ Bool RADEONScreenInit_KMS(SCREEN_INIT_ARGS_DECL)
     pScreen->CloseScreen = RADEONCloseScreen_KMS;
     pScreen->SaveScreen  = RADEONSaveScreen_KMS;
     info->BlockHandler = pScreen->BlockHandler;
-    pScreen->BlockHandler = RADEONBlockHandler_oneshot;
+    pScreen->BlockHandler = RADEONBlockHandler_KMS;
 
     info->CreateScreenResources = pScreen->CreateScreenResources;
     pScreen->CreateScreenResources = RADEONCreateScreenResources_KMS;
--

2.11.0

Quoted 4 lines

_______________________________________________
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