From 4d1953728e52bb1da0a7d0cb66efa651cd01e88b Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 30 Sep 2024 17:58:50 +0200 Subject: [PATCH] xfree86: use dixDestroyPixmap() instead of direct driver call Direct calls to ScreenRec->DestroyPixmap() blocks cleaning up the wrapping jungle, so use the proper dix function instead. See: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1754 Signed-off-by: Enrico Weigelt, metux IT consult Part-of: --- hw/xfree86/common/xf86DGA.c | 4 ++-- hw/xfree86/dri2/dri2.c | 14 +++++++------- hw/xfree86/drivers/modesetting/dri2.c | 7 +++---- hw/xfree86/drivers/modesetting/drmmode_display.c | 9 +++------ 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c index 41b58d9e3..2482530a1 100644 --- a/hw/xfree86/common/xf86DGA.c +++ b/hw/xfree86/common/xf86DGA.c @@ -370,7 +370,7 @@ xf86SetDGAMode(ScrnInfoPtr pScrn, int num, DGADevicePtr devRet) if (oldPix->drawable.id) FreeResource(oldPix->drawable.id, X11_RESTYPE_NONE); else - (*pScreen->DestroyPixmap) (oldPix); + dixDestroyPixmap(oldPix, 0); } free(pScreenPriv->current); pScreenPriv->current = NULL; @@ -432,7 +432,7 @@ xf86SetDGAMode(ScrnInfoPtr pScrn, int num, DGADevicePtr devRet) if (oldPix->drawable.id) FreeResource(oldPix->drawable.id, X11_RESTYPE_NONE); else - (*pScreen->DestroyPixmap) (oldPix); + dixDestroyPixmap(oldPix, 0); } free(pScreenPriv->current); pScreenPriv->current = NULL; diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c index 1325f1f9f..6eb846187 100644 --- a/hw/xfree86/dri2/dri2.c +++ b/hw/xfree86/dri2/dri2.c @@ -428,8 +428,8 @@ DRI2DrawableGone(void *p, XID id) } if (pPriv->prime_secondary_pixmap) { - (*pPriv->prime_secondary_pixmap->primary_pixmap->drawable.pScreen->DestroyPixmap)(pPriv->prime_secondary_pixmap->primary_pixmap); - (*pPriv->prime_secondary_pixmap->drawable.pScreen->DestroyPixmap)(pPriv->prime_secondary_pixmap); + dixDestroyPixmap(pPriv->prime_secondary_pixmap->primary_pixmap, 0); + dixDestroyPixmap(pPriv->prime_secondary_pixmap, 0); } if (pPriv->buffers != NULL) { @@ -441,7 +441,7 @@ DRI2DrawableGone(void *p, XID id) if (pPriv->redirectpixmap) { (*pDraw->pScreen->ReplaceScanoutPixmap)(pDraw, pPriv->redirectpixmap, FALSE); - (*pDraw->pScreen->DestroyPixmap)(pPriv->redirectpixmap); + dixDestroyPixmap(pPriv->redirectpixmap, 0); } dri2WakeAll(CLIENT_SIGNAL_ANY, pPriv, WAKE_SWAP); @@ -839,7 +839,7 @@ DrawablePtr DRI2UpdatePrime(DrawablePtr pDraw, DRI2BufferPtr pDest) ret = (*primary->ReplaceScanoutPixmap)(pDraw, mpix, TRUE); if (ret == FALSE) { - (*primary->DestroyPixmap)(mpix); + dixDestroyPixmap(mpix, 0); return NULL; } pPriv->redirectpixmap = mpix; @@ -848,7 +848,7 @@ DrawablePtr DRI2UpdatePrime(DrawablePtr pDraw, DRI2BufferPtr pDest) } } else if (pPriv->redirectpixmap) { (*primary->ReplaceScanoutPixmap)(pDraw, pPriv->redirectpixmap, FALSE); - (*primary->DestroyPixmap)(pPriv->redirectpixmap); + dixDestroyPixmap(pPriv->redirectpixmap, 0); pPriv->redirectpixmap = NULL; } } @@ -861,8 +861,8 @@ DrawablePtr DRI2UpdatePrime(DrawablePtr pDraw, DRI2BufferPtr pDest) return &pPriv->prime_secondary_pixmap->drawable; else { PixmapUnshareSecondaryPixmap(pPriv->prime_secondary_pixmap); - (*pPriv->prime_secondary_pixmap->primary_pixmap->drawable.pScreen->DestroyPixmap)(pPriv->prime_secondary_pixmap->primary_pixmap); - (*secondary->DestroyPixmap)(pPriv->prime_secondary_pixmap); + dixDestroyPixmap(pPriv->prime_secondary_pixmap->primary_pixmap, 0); + dixDestroyPixmap(pPriv->prime_secondary_pixmap, 0); pPriv->prime_secondary_pixmap = NULL; } } diff --git a/hw/xfree86/drivers/modesetting/dri2.c b/hw/xfree86/drivers/modesetting/dri2.c index af7db7ddc..68765cad8 100644 --- a/hw/xfree86/drivers/modesetting/dri2.c +++ b/hw/xfree86/drivers/modesetting/dri2.c @@ -208,7 +208,7 @@ ms_dri2_create_buffer2(ScreenPtr screen, DrawablePtr drawable, if (buffer->name == -1) { xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to get DRI2 name for pixmap\n"); - screen->DestroyPixmap(pixmap); + dixDestroyPixmap(pixmap, 0); free(private); free(buffer); return NULL; @@ -247,8 +247,7 @@ static void ms_dri2_destroy_buffer2(ScreenPtr unused, DrawablePtr unused2, if (buffer->driverPrivate) { ms_dri2_buffer_private_ptr private = buffer->driverPrivate; if (--private->refcnt == 0) { - ScreenPtr screen = private->pixmap->drawable.pScreen; - screen->DestroyPixmap(private->pixmap); + dixDestroyPixmap(private->pixmap, 0); free(private); free(buffer); } @@ -523,7 +522,7 @@ update_front(DrawablePtr draw, DRI2BufferPtr front) front->name = name; - (*screen->DestroyPixmap) (priv->pixmap); + dixDestroyPixmap(priv->pixmap, 0); front->pitch = pixmap->devKind; front->cpp = pixmap->drawable.bitsPerPixel / 8; priv->pixmap = pixmap; diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c index 6d0b4453b..2072ce0c5 100644 --- a/hw/xfree86/drivers/modesetting/drmmode_display.c +++ b/hw/xfree86/drivers/modesetting/drmmode_display.c @@ -1570,8 +1570,7 @@ drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode) pScreen->canDoBGNoneRoot = TRUE; - if (drmmode->fbcon_pixmap) - pScrn->pScreen->DestroyPixmap(drmmode->fbcon_pixmap); + dixDestroyPixmap(drmmode->fbcon_pixmap, 0); drmmode->fbcon_pixmap = NULL; #endif } @@ -2151,7 +2150,7 @@ drmmode_create_pixmap_header(ScreenPtr pScreen, int width, int height, if ((*pScreen->ModifyPixmapHeader)(pixmap, width, height, depth, bitsPerPixel, devKind, pPixData)) return pixmap; - (*pScreen->DestroyPixmap)(pixmap); + dixDestroyPixmap(pixmap, 0); } return NullPixmap; } @@ -2223,9 +2222,7 @@ drmmode_shadow_fb_destroy(xf86CrtcPtr crtc, PixmapPtr pixmap, drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; drmmode_ptr drmmode = drmmode_crtc->drmmode; - if (pixmap) { - pixmap->drawable.pScreen->DestroyPixmap(pixmap); - } + dixDestroyPixmap(pixmap, 0); if (data) { drmModeRmFB(drmmode->fd, *fb_id);