xf86-video-ati: Branch 'master' - 2 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Sep 25 07:32:56 UTC 2019


 src/radeon_kms.c |   37 ++++++++++++++++++++++++++-----------
 1 file changed, 26 insertions(+), 11 deletions(-)

New commits:
commit 2faaecc69b127248718e759c6c98c84d56dd1b6b
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Fri Sep 20 17:24:19 2019 +0200

    Don't unreference FBs of pixmaps from different screens in LeaveVT
    
    FindClientResourcesByType finds pixmaps from all screens, but trying to
    process ones from other screens here makes no sense and likely results
    in a crash or memory corruption.
    
    Fixes: 06a465484101 ("Make all active CRTCs scan out an all-black
                          framebuffer in LeaveVT")

diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index 107c1ce7..b3db7c41 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -2602,16 +2602,25 @@ CARD32 cleanup_black_fb(OsTimerPtr timer, CARD32 now, pointer data)
 }
 
 static void
-pixmap_unref_fb(void *value, XID id, void *cdata)
+pixmap_unref_fb(PixmapPtr pixmap)
 {
-    PixmapPtr pixmap = value;
-    RADEONEntPtr pRADEONEnt = cdata;
+    ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
     struct drmmode_fb **fb_ptr = radeon_pixmap_get_fb_ptr(pixmap);
+    RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
 
     if (fb_ptr)
 	drmmode_fb_reference(pRADEONEnt->fd, fb_ptr, NULL);
 }
 
+static void
+client_pixmap_unref_fb(void *value, XID id, void *pScreen)
+{
+    PixmapPtr pixmap = value;
+
+    if (pixmap->drawable.pScreen == pScreen)
+	pixmap_unref_fb(pixmap);
+}
+
 void RADEONLeaveVT_KMS(ScrnInfoPtr pScrn)
 {
     RADEONInfoPtr  info  = RADEONPTR(pScrn);
@@ -2673,11 +2682,9 @@ void RADEONLeaveVT_KMS(ScrnInfoPtr pScrn)
 
 			if (pScrn->is_gpu) {
 			    if (drmmode_crtc->scanout[0].pixmap)
-				pixmap_unref_fb(drmmode_crtc->scanout[0].pixmap,
-						None, pRADEONEnt);
+				pixmap_unref_fb(drmmode_crtc->scanout[0].pixmap);
 			    if (drmmode_crtc->scanout[1].pixmap)
-				pixmap_unref_fb(drmmode_crtc->scanout[1].pixmap,
-						None, pRADEONEnt);
+				pixmap_unref_fb(drmmode_crtc->scanout[1].pixmap);
 			} else {
 			    drmmode_crtc_scanout_free(crtc);
 			}
@@ -2697,11 +2704,11 @@ void RADEONLeaveVT_KMS(ScrnInfoPtr pScrn)
 		(!clients[i] || clients[i]->clientState != ClientStateRunning))
 		continue;
 
-	    FindClientResourcesByType(clients[i], RT_PIXMAP, pixmap_unref_fb,
-				      pRADEONEnt);
+	    FindClientResourcesByType(clients[i], RT_PIXMAP,
+				      client_pixmap_unref_fb, pScreen);
 	}
 
-	pixmap_unref_fb(pScreen->GetScreenPixmap(pScreen), None, pRADEONEnt);
+	pixmap_unref_fb(pScreen->GetScreenPixmap(pScreen));
     } else {
 	memset(info->front_buffer->bo.radeon->ptr, 0,
 	       pScrn->displayWidth * info->pixel_bytes * pScrn->virtualY);
commit 2cbbd8648cdd27db8076565943b932ef81337053
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Fri Sep 20 18:47:02 2019 +0200

    Don't set up black scanout buffer if LeaveVT is called from CloseScreen
    
    Avoids a crash described in
    https://gitlab.freedesktop.org/xorg/driver/xf86-video-amdgpu/merge_requests/43#note_223718
    
    (Ported from amdgpu commit 5b8bc9fc505c551dcd9b0ed5ab835a49fa4f9fda)
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index 777fc14e..107c1ce7 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -2629,6 +2629,12 @@ void RADEONLeaveVT_KMS(ScrnInfoPtr pScrn)
 	unsigned w = 0, h = 0;
 	int i;
 
+	/* If we're called from CloseScreen, trying to clear the black
+	 * scanout BO will likely crash and burn
+	 */
+	if (!pScreen->GCperDepth[0])
+	    goto hide_cursors;
+
 	/* Compute maximum scanout dimensions of active CRTCs */
 	for (i = 0; i < xf86_config->num_crtc; i++) {
 	    crtc = xf86_config->crtc[i];
@@ -2701,8 +2707,10 @@ void RADEONLeaveVT_KMS(ScrnInfoPtr pScrn)
 	       pScrn->displayWidth * info->pixel_bytes * pScrn->virtualY);
     }
 
-    TimerSet(NULL, 0, 1000, cleanup_black_fb, pScreen);
+    if (pScreen->GCperDepth[0])
+	TimerSet(NULL, 0, 1000, cleanup_black_fb, pScreen);
 
+ hide_cursors:
     xf86_hide_cursors (pScrn);
 
     radeon_drop_drm_master(pScrn);


More information about the xorg-commit mailing list