xserver: Branch 'master' - 2 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Dec 30 01:35:14 UTC 2022


 dix/main.c                          |   10 ++++------
 dix/pixmap.c                        |   36 +++++++++++-------------------------
 hw/xfree86/common/xf86Module.h      |    2 +-
 hw/xfree86/common/xf86platformBus.c |    2 +-
 include/pixmap.h                    |    4 +---
 include/scrnintstr.h                |    2 --
 6 files changed, 18 insertions(+), 38 deletions(-)

New commits:
commit 3cb3024fea187a1292049a0a33200dad53051149
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Wed Dec 21 22:14:01 2022 -0800

    dix: Remove pScratchPixmap and other associated ABI changes
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/dix/main.c b/dix/main.c
index bfc8addbe..5964120c6 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -195,8 +195,8 @@ dix_main(int argc, char *argv[], char *envp[])
 
         for (i = 0; i < screenInfo.numGPUScreens; i++) {
             ScreenPtr pScreen = screenInfo.gpuscreens[i];
-            if (!CreateScratchPixmapsForScreen(pScreen))
-                FatalError("failed to create scratch pixmaps");
+            if (!PixmapScreenInit(pScreen))
+                FatalError("failed to create screen pixmap properties");
             if (pScreen->CreateScreenResources &&
                 !(*pScreen->CreateScreenResources) (pScreen))
                 FatalError("failed to create screen resources");
@@ -205,8 +205,8 @@ dix_main(int argc, char *argv[], char *envp[])
         for (i = 0; i < screenInfo.numScreens; i++) {
             ScreenPtr pScreen = screenInfo.screens[i];
 
-            if (!CreateScratchPixmapsForScreen(pScreen))
-                FatalError("failed to create scratch pixmaps");
+            if (!PixmapScreenInit(pScreen))
+                FatalError("failed to create screen pixmap properties");
             if (pScreen->CreateScreenResources &&
                 !(*pScreen->CreateScreenResources) (pScreen))
                 FatalError("failed to create screen resources");
@@ -305,7 +305,6 @@ dix_main(int argc, char *argv[], char *envp[])
 
         for (i = screenInfo.numGPUScreens - 1; i >= 0; i--) {
             ScreenPtr pScreen = screenInfo.gpuscreens[i];
-            FreeScratchPixmapsForScreen(pScreen);
             dixFreeScreenSpecificPrivates(pScreen);
             (*pScreen->CloseScreen) (pScreen);
             dixFreePrivates(pScreen->devPrivates, PRIVATE_SCREEN);
@@ -314,7 +313,6 @@ dix_main(int argc, char *argv[], char *envp[])
         }
 
         for (i = screenInfo.numScreens - 1; i >= 0; i--) {
-            FreeScratchPixmapsForScreen(screenInfo.screens[i]);
             FreeGCperDepth(i);
             FreeDefaultStipple(i);
             dixFreeScreenSpecificPrivates(screenInfo.screens[i]);
diff --git a/dix/pixmap.c b/dix/pixmap.c
index b7411df65..a58795c78 100644
--- a/dix/pixmap.c
+++ b/dix/pixmap.c
@@ -80,7 +80,7 @@ FreeScratchPixmapHeader(PixmapPtr pPixmap)
 }
 
 Bool
-CreateScratchPixmapsForScreen(ScreenPtr pScreen)
+PixmapScreenInit(ScreenPtr pScreen)
 {
     unsigned int pixmap_size;
 
@@ -88,16 +88,9 @@ CreateScratchPixmapsForScreen(ScreenPtr pScreen)
     pScreen->totalPixmapSize =
         BitmapBytePad(pixmap_size * 8);
 
-    /* NULL this out as it is no longer used */
-    pScreen->pScratchPixmap = NULL;
     return TRUE;
 }
 
-void
-FreeScratchPixmapsForScreen(ScreenPtr pScreen)
-{
-}
-
 /* callable by ddx */
 PixmapPtr
 AllocatePixmap(ScreenPtr pScreen, int pixDataSize)
diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
index c59e53a55..d5e858fc8 100644
--- a/hw/xfree86/common/xf86Module.h
+++ b/hw/xfree86/common/xf86Module.h
@@ -74,7 +74,7 @@
  * mask is 0xFFFF0000.
  */
 #define ABI_ANSIC_VERSION	SET_ABI_VERSION(0, 4)
-#define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(25, 4)
+#define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(26, 0)
 #define ABI_XINPUT_VERSION	SET_ABI_VERSION(24, 4)
 #define ABI_EXTENSION_VERSION	SET_ABI_VERSION(10, 0)
 
diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
index 1d1f87c74..abd09054d 100644
--- a/hw/xfree86/common/xf86platformBus.c
+++ b/hw/xfree86/common/xf86platformBus.c
@@ -715,7 +715,7 @@ xf86platformAddDevice(const char *driver_name, int index)
    dixSetPrivate(&xf86GPUScreens[i]->pScreen->devPrivates,
                  xf86ScreenKey, xf86GPUScreens[i]);
 
-   CreateScratchPixmapsForScreen(xf86GPUScreens[i]->pScreen);
+   PixmapScreenInit(xf86GPUScreens[i]->pScreen);
 
    if (xf86GPUScreens[i]->pScreen->CreateScreenResources &&
        !(*xf86GPUScreens[i]->pScreen->CreateScreenResources) (xf86GPUScreens[i]->pScreen)) {
diff --git a/include/pixmap.h b/include/pixmap.h
index e251690d5..be6df9890 100644
--- a/include/pixmap.h
+++ b/include/pixmap.h
@@ -103,9 +103,7 @@ extern _X_EXPORT PixmapPtr GetScratchPixmapHeader(ScreenPtr pScreen,
 
 extern _X_EXPORT void FreeScratchPixmapHeader(PixmapPtr /*pPixmap */ );
 
-extern _X_EXPORT Bool CreateScratchPixmapsForScreen(ScreenPtr /*pScreen */ );
-
-extern _X_EXPORT void FreeScratchPixmapsForScreen(ScreenPtr /*pScreen */ );
+extern _X_EXPORT Bool PixmapScreenInit(ScreenPtr /*pScreen */ );
 
 extern _X_EXPORT PixmapPtr AllocatePixmap(ScreenPtr /*pScreen */ ,
                                           int /*pixDataSize */ );
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index 6d09e8019..98f47bf51 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -604,8 +604,6 @@ typedef struct _Screen {
     SetScreenPixmapProcPtr SetScreenPixmap;
     NameWindowPixmapProcPtr NameWindowPixmap;
 
-    PixmapPtr pScratchPixmap;   /* scratch pixmap "pool" (unused / NULL in modern servers) */
-
     unsigned int totalPixmapSize;
 
     MarkWindowProcPtr MarkWindow;
commit 6ee937b3be49a9d0cff2a84c7ea7d623e7cdf743
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Wed Dec 14 23:45:56 2022 -0800

    dix: Stop recycling scratch pixmaps
    
    The minimal performance wins we gain by recycling pixmaps at this layer are
    not worth the code complexity nor the interference with memory analysis
    tools like malloc history, ASan, etc.
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/dix/pixmap.c b/dix/pixmap.c
index 0b01c4ee0..b7411df65 100644
--- a/dix/pixmap.c
+++ b/dix/pixmap.c
@@ -44,8 +44,13 @@ from The Open Group.
 #include "picturestr.h"
 #include "randrstr.h"
 /*
- *  Scratch pixmap management and device independent pixmap allocation
- *  function.
+ * Scratch pixmap APIs are provided for source and binary compatability.  In
+ * older versions, DIX would store a freed scratch pixmap for future use.  This
+ * optimization is not really that impactful on modern systems with decent
+ * system heap management and modern CPUs, and it interferes with memory
+ * analysis tools such as ASan, malloc history, etc.
+ *
+ * Now, these entry points just allocte/free pixmaps.
  */
 
 /* callable by ddx */
@@ -53,14 +58,7 @@ PixmapPtr
 GetScratchPixmapHeader(ScreenPtr pScreen, int width, int height, int depth,
                        int bitsPerPixel, int devKind, void *pPixData)
 {
-    PixmapPtr pPixmap = pScreen->pScratchPixmap;
-
-    if (pPixmap)
-        pScreen->pScratchPixmap = NULL;
-    else
-        /* width and height of 0 means don't allocate any pixmap data */
-        pPixmap = (*pScreen->CreatePixmap) (pScreen, 0, 0, depth, 0);
-
+    PixmapPtr pPixmap = (*pScreen->CreatePixmap) (pScreen, 0, 0, depth, 0);
     if (pPixmap) {
         if ((*pScreen->ModifyPixmapHeader) (pPixmap, width, height, depth,
                                             bitsPerPixel, devKind, pPixData))
@@ -76,12 +74,8 @@ FreeScratchPixmapHeader(PixmapPtr pPixmap)
 {
     if (pPixmap) {
         ScreenPtr pScreen = pPixmap->drawable.pScreen;
-
-        pPixmap->devPrivate.ptr = NULL; /* lest ddx chases bad ptr */
-        if (pScreen->pScratchPixmap)
-            (*pScreen->DestroyPixmap) (pPixmap);
-        else
-            pScreen->pScratchPixmap = pPixmap;
+        pPixmap->devPrivate.ptr = NULL; /* help catch/avoid heap-use-after-free */
+        (*pScreen->DestroyPixmap)(pPixmap);
     }
 }
 
@@ -94,7 +88,7 @@ CreateScratchPixmapsForScreen(ScreenPtr pScreen)
     pScreen->totalPixmapSize =
         BitmapBytePad(pixmap_size * 8);
 
-    /* let it be created on first use */
+    /* NULL this out as it is no longer used */
     pScreen->pScratchPixmap = NULL;
     return TRUE;
 }
@@ -102,7 +96,6 @@ CreateScratchPixmapsForScreen(ScreenPtr pScreen)
 void
 FreeScratchPixmapsForScreen(ScreenPtr pScreen)
 {
-    FreeScratchPixmapHeader(pScreen->pScratchPixmap);
 }
 
 /* callable by ddx */
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index 24ca423f2..6d09e8019 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -604,7 +604,7 @@ typedef struct _Screen {
     SetScreenPixmapProcPtr SetScreenPixmap;
     NameWindowPixmapProcPtr NameWindowPixmap;
 
-    PixmapPtr pScratchPixmap;   /* scratch pixmap "pool" */
+    PixmapPtr pScratchPixmap;   /* scratch pixmap "pool" (unused / NULL in modern servers) */
 
     unsigned int totalPixmapSize;
 


More information about the xorg-commit mailing list