[openchrome-devel] xf86-video-openchrome: 7 commits - configure.ac src/via_driver.c src/via_ums.c src/via_ums.h

Kevin Brace kevinbrace at kemper.freedesktop.org
Tue Mar 10 02:45:01 UTC 2020


 configure.ac     |    2 
 src/via_driver.c |   47 ++++++---
 src/via_ums.c    |  268 +++++++++++++++++++++++++++++++++++--------------------
 src/via_ums.h    |    3 
 4 files changed, 209 insertions(+), 111 deletions(-)

New commits:
commit 4be5703061b4657c715d53fa46e9030dc7094982
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Mon Mar 9 19:34:18 2020 -0700

    Version bumped to 0.6.217
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/configure.ac b/configure.ac
index 9705406..653ee03 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@
 # Initialize Autoconf
 AC_PREREQ([2.60])
 AC_INIT([xf86-video-openchrome],
-        [0.6.216],
+        [0.6.217],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=Driver/openchrome],
         [xf86-video-openchrome])
 
commit 5622df16bebeffa50442c5e566d37d71b658f910
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Mon Mar 9 19:31:16 2020 -0700

    Add viaUMSPreInitExit() for unmapping MMIOs
    
    This is for releasing MMIOs when exiting VIAPreInit() in UMS mode.
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_driver.c b/src/via_driver.c
index e40547f..8bc3c73 100644
--- a/src/via_driver.c
+++ b/src/via_driver.c
@@ -1212,12 +1212,17 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
      */
     pVia->Bpl = pScrn->virtualX * (pScrn->bitsPerPixel / 8);
 
+    if (!pVia->KMS) {
+        viaUMSPreInitExit(pScrn);
+    }
+
     status = TRUE;
     goto exit;
 fail:
     if (!pVia->KMS) {
-        viaUnmapMMIO(pScrn);
+        viaUMSPreInitExit(pScrn);
     }
+
 free_rec:
     VIAFreeRec(pScrn);
 exit:
diff --git a/src/via_ums.c b/src/via_ums.c
index e3979a9..6fad307 100644
--- a/src/via_ums.c
+++ b/src/via_ums.c
@@ -806,10 +806,19 @@ viaUMSCreate(ScrnInfoPtr pScrn)
     }
 #endif
 
+    /*
+     * Map MMIO PCI hardware resources to the memory map.
+     */
+    if (!viaMapMMIO(pScrn)) {
+        ret = FALSE;
+        goto exit;
+    }
+
     /*
      * Map FB PCI hardware resource to the memory map.
      */
     if (!viaMapFB(pScrn)) {
+        viaUnmapMMIO(pScrn);
         ret = FALSE;
         goto exit;
     }
@@ -1166,6 +1175,18 @@ viaUMSPreInit(ScrnInfoPtr pScrn)
     return TRUE;
 }
 
+void
+viaUMSPreInitExit(ScrnInfoPtr pScrn)
+{
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Entered %s.\n", __func__));
+
+    viaUnmapMMIO(pScrn);
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Exiting %s.\n", __func__));
+}
+
 Bool
 viaUMSCrtcInit(ScrnInfoPtr pScrn)
 {
diff --git a/src/via_ums.h b/src/via_ums.h
index e4822e2..9c58822 100644
--- a/src/via_ums.h
+++ b/src/via_ums.h
@@ -1556,12 +1556,12 @@ viaSetDisplayScaling(ScrnInfoPtr pScrn, Bool scalingState)
 
 
 /* via_ums.c */
-void viaUnmapMMIO(ScrnInfoPtr pScrn);
 void viaDisableVQ(ScrnInfoPtr pScrn);
 Bool viaUMSAccelInit(ScreenPtr pScreen);
 Bool viaUMSCreate(ScrnInfoPtr pScrn);
 void viaUMSDestroy(ScrnInfoPtr pScrn);
 Bool viaUMSPreInit(ScrnInfoPtr pScrn);
+void viaUMSPreInitExit(ScrnInfoPtr pScrn);
 Bool viaUMSCrtcInit(ScrnInfoPtr pScrn);
 
 /* via_i2c.c */
commit 69333bbad8de8ac63373e705f0103135a430fe37
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Mon Mar 9 19:28:47 2020 -0700

    Minor code tweaks to VIAPreInit()
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_driver.c b/src/via_driver.c
index 171eccd..e40547f 100644
--- a/src/via_driver.c
+++ b/src/via_driver.c
@@ -848,7 +848,7 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
     Bool status = FALSE;
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Entered VIAPreInit.\n"));
+                        "Entered %s.\n", __func__));
 
     pScrn->monitor = pScrn->confScreen->monitor;
 
@@ -927,8 +927,7 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
 #ifndef HAVE_PCIACCESS
     if (pEnt->resources) {
         free(pEnt);
-        VIAFreeRec(pScrn);
-        return FALSE;
+        goto free_rec;
     }
 #endif
 
@@ -945,9 +944,9 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
             pVIAEnt = pPriv->ptr;
             if (pVIAEnt->BypassSecondary) {
                 free(pEnt);
-                VIAFreeRec(pScrn);
-                return FALSE;
+                goto free_rec;
             }
+
             pVIAEnt->pSecondaryScrn = pScrn;
             pVIAEnt->HasSecondary = TRUE;
             pVia1 = VIAPTR(pVIAEnt->pPrimaryScrn);
@@ -1016,6 +1015,7 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
 
     if (pEnt)
         free(pEnt);
+
     xf86DrvMsg(pScrn->scrnIndex, from, "Chipset revision: %d\n", pVia->ChipRev);
 
     pVia->directRenderingType = DRI_NONE;
@@ -1144,14 +1144,13 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
     VIAVidHWDiffInit(pScrn);
 
     /*
-     * After viaUMSPreInit() succeeds, PCI hardware resources are
-     * memory mapped.  If there is an error from this point on, they
-     * will need to be explicitly relinquished.
+     * After viaUMSPreInit() succeeds, MMIO PCI hardware resources
+     * are memory mapped.  If there is an error from this point on,
+     * they will need to be explicitly relinquished.
      */
     if (!pVia->KMS) {
         if (!viaUMSPreInit(pScrn)) {
-            VIAFreeRec(pScrn);
-            return FALSE;
+            goto free_rec;
         }
     }
 
@@ -1178,9 +1177,6 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
         goto fail;
     }
 
-    /* Set up screen parameters. */
-    pVia->Bpl = pScrn->virtualX * (pScrn->bitsPerPixel >> 3);
-
     /* Set the current mode to the first in the list */
     pScrn->currentMode = pScrn->modes;
 
@@ -1211,17 +1207,22 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
         }
     }
 
+    /*
+     * Set up screen parameters.
+     */
+    pVia->Bpl = pScrn->virtualX * (pScrn->bitsPerPixel / 8);
+
     status = TRUE;
     goto exit;
 fail:
     if (!pVia->KMS) {
         viaUnmapMMIO(pScrn);
     }
-
-	VIAFreeRec(pScrn);
+free_rec:
+    VIAFreeRec(pScrn);
 exit:
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Exiting VIAPreInit.\n"));
+                        "Exiting %s.\n", __func__));
     return status;
 }
 
commit 38145b14fa0a6f387d1338db6d99911cd11b4504
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Mon Mar 9 19:23:03 2020 -0700

    Add viaUMSDestroy() for tearing down UMS specific resources
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_driver.c b/src/via_driver.c
index 6920f67..171eccd 100644
--- a/src/via_driver.c
+++ b/src/via_driver.c
@@ -405,8 +405,7 @@ VIAFreeScreen(FREE_SCREEN_ARGS_DECL)
     }
 
     if (!pVia->KMS) {
-        viaUnmapFB(pScrn);
-        viaUnmapMMIO(pScrn);
+        viaUMSDestroy(pScrn);
     }
 
     VIAFreeRec(pScrn);
@@ -1404,8 +1403,7 @@ VIACloseScreen(CLOSE_SCREEN_ARGS_DECL)
 #endif
 
     if (!pVia->KMS) {
-        viaUnmapFB(pScrn);
-        viaUnmapMMIO(pScrn);
+        viaUMSDestroy(pScrn);
     }
 
     pScrn->vtSema = FALSE;
diff --git a/src/via_ums.c b/src/via_ums.c
index f1c19ef..e3979a9 100644
--- a/src/via_ums.c
+++ b/src/via_ums.c
@@ -367,7 +367,7 @@ exit:
     return ret;
 }
 
-void
+static void
 viaUnmapFB(ScrnInfoPtr pScrn)
 {
     VIAPtr pVia = VIAPTR(pScrn);
@@ -846,6 +846,19 @@ exit:
     return ret;
 }
 
+void
+viaUMSDestroy(ScrnInfoPtr pScrn)
+{
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Entered %s.\n", __func__));
+
+    viaUnmapFB(pScrn);
+    viaUnmapMMIO(pScrn);
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Exiting %s.\n", __func__));
+}
+
 static Bool
 viaProbeVRAM(ScrnInfoPtr pScrn)
 {
diff --git a/src/via_ums.h b/src/via_ums.h
index 017c1ec..e4822e2 100644
--- a/src/via_ums.h
+++ b/src/via_ums.h
@@ -1557,10 +1557,10 @@ viaSetDisplayScaling(ScrnInfoPtr pScrn, Bool scalingState)
 
 /* via_ums.c */
 void viaUnmapMMIO(ScrnInfoPtr pScrn);
-void viaUnmapFB(ScrnInfoPtr pScrn);
 void viaDisableVQ(ScrnInfoPtr pScrn);
 Bool viaUMSAccelInit(ScreenPtr pScreen);
 Bool viaUMSCreate(ScrnInfoPtr pScrn);
+void viaUMSDestroy(ScrnInfoPtr pScrn);
 Bool viaUMSPreInit(ScrnInfoPtr pScrn);
 Bool viaUMSCrtcInit(ScrnInfoPtr pScrn);
 
commit a245948a455de13719ac6db13608b6cecad186de
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Mon Mar 9 19:01:04 2020 -0700

    Map FB during screen initialization rather than pre-initialization
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_driver.c b/src/via_driver.c
index e1a6b6e..6920f67 100644
--- a/src/via_driver.c
+++ b/src/via_driver.c
@@ -1216,7 +1216,6 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
     goto exit;
 fail:
     if (!pVia->KMS) {
-        viaUnmapFB(pScrn);
         viaUnmapMMIO(pScrn);
     }
 
diff --git a/src/via_ums.c b/src/via_ums.c
index 042979a..f1c19ef 100644
--- a/src/via_ums.c
+++ b/src/via_ums.c
@@ -806,6 +806,14 @@ viaUMSCreate(ScrnInfoPtr pScrn)
     }
 #endif
 
+    /*
+     * Map FB PCI hardware resource to the memory map.
+     */
+    if (!viaMapFB(pScrn)) {
+        ret = FALSE;
+        goto exit;
+    }
+
     if (pVia->directRenderingType == DRI_NONE) {
         if (!pVia->useEXA) {
             if (!viaInitFB(pScrn)) {
@@ -1142,11 +1150,6 @@ viaUMSPreInit(ScrnInfoPtr pScrn)
         return FALSE;
     }
 
-    if (!viaMapFB(pScrn)) {
-        viaUnmapMMIO(pScrn);
-        return FALSE;
-    }
-
     return TRUE;
 }
 
commit 105868a7f7db6f9d05ec49f2777d226dc12d42e6
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Fri Mar 6 15:39:09 2020 -0800

    Separate FB (un)mapping code from MMIO (un)mapping code
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_driver.c b/src/via_driver.c
index 152e9b6..e1a6b6e 100644
--- a/src/via_driver.c
+++ b/src/via_driver.c
@@ -405,6 +405,7 @@ VIAFreeScreen(FREE_SCREEN_ARGS_DECL)
     }
 
     if (!pVia->KMS) {
+        viaUnmapFB(pScrn);
         viaUnmapMMIO(pScrn);
     }
 
@@ -1215,6 +1216,7 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
     goto exit;
 fail:
     if (!pVia->KMS) {
+        viaUnmapFB(pScrn);
         viaUnmapMMIO(pScrn);
     }
 
@@ -1403,6 +1405,7 @@ VIACloseScreen(CLOSE_SCREEN_ARGS_DECL)
 #endif
 
     if (!pVia->KMS) {
+        viaUnmapFB(pScrn);
         viaUnmapMMIO(pScrn);
     }
 
diff --git a/src/via_ums.c b/src/via_ums.c
index 47b5678..042979a 100644
--- a/src/via_ums.c
+++ b/src/via_ums.c
@@ -166,77 +166,6 @@ viaMapMMIO(ScrnInfoPtr pScrn)
     }
 #endif
 
-    if (!(pVia->videoRambytes)) {
-        goto fail;
-    }
-
-#ifdef HAVE_PCIACCESS
-    if (pVia->Chipset == VIA_VX900) {
-        pVia->FrameBufferBase = pVia->PciInfo->regions[2].base_addr;
-    } else {
-        pVia->FrameBufferBase = pVia->PciInfo->regions[0].base_addr;
-    }
-#else
-    if (pVia->Chipset == VIA_VX900) {
-        pVia->FrameBufferBase = pVia->PciInfo->memBase[2];
-    } else {
-        pVia->FrameBufferBase = pVia->PciInfo->memBase[0];
-    }
-#endif
-
-    xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
-               "Mapping the frame buffer at address 0x%lx with "
-               "size %lu KB.\n",
-               pVia->FrameBufferBase, pVia->videoRambytes / 1024);
-
-#ifdef HAVE_PCIACCESS
-    err = pci_device_map_range(pVia->PciInfo, pVia->FrameBufferBase,
-                               pVia->videoRambytes,
-                               (PCI_DEV_MAP_FLAG_WRITABLE |
-                                PCI_DEV_MAP_FLAG_WRITE_COMBINE),
-                               (void **)&pVia->FBBase);
-    if (err) {
-        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-                    "Unable to map the frame buffer.\n"
-                    "Error: %s (%u)\n",
-                    strerror(err), err);
-        goto fail;
-    }
-#else
-    /*
-     * FIXME: This is a hack to get rid of offending wrongly sized
-     * MTRR regions set up by the VIA BIOS. Should be taken care of
-     * in the OS support layer.
-     */
-    tmp = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, pVia->PciTag,
-                        pVia->FrameBufferBase, pVia->videoRambytes);
-    xf86UnMapVidMem(pScrn->scrnIndex, (pointer) tmp, pVia->videoRambytes);
-
-    /*
-     * And, as if this wasn't enough, 2.6 series kernels don't
-     * remove MTRR regions on the first attempt. So try again.
-     */
-    tmp = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, pVia->PciTag,
-                        pVia->FrameBufferBase, pVia->videoRambytes);
-    xf86UnMapVidMem(pScrn->scrnIndex, (pointer) tmp, pVia->videoRambytes);
-    /*
-     * End of hack.
-     */
-
-    pVia->FBBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER,
-                                 pVia->PciTag, pVia->FrameBufferBase,
-                                 pVia->videoRambytes);
-
-    if (!pVia->FBBase) {
-        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-                   "Unable to map the frame buffer.\n");
-        goto fail;
-    }
-#endif
-
-    pVia->FBFreeStart = 0;
-    pVia->FBFreeEnd = pVia->videoRambytes;
-
     /* MMIO for MPEG engine. */
     pVia->MpegMapBase = pVia->MapBase + 0xc00;
 
@@ -263,11 +192,6 @@ viaMapMMIO(ScrnInfoPtr pScrn)
 fail:
 
 #ifdef HAVE_PCIACCESS
-    if (pVia->FBBase) {
-        pci_device_unmap_range(pVia->PciInfo, (pointer) pVia->FBBase,
-                                pVia->videoRambytes);
-    }
-
     if (pVia->BltBase) {
         pci_device_unmap_range(pVia->PciInfo, (pointer) pVia->BltBase,
                                VIA_MMIO_BLTSIZE);
@@ -278,11 +202,6 @@ fail:
                                VIA_MMIO_REGSIZE);
     }
 #else
-    if (pVia->FBBase) {
-        xf86UnMapVidMem(pScrn->scrnIndex, (pointer) pVia->FBBase,
-                        pVia->videoRambytes);
-    }
-
     if (pVia->BltBase) {
         xf86UnMapVidMem(pScrn->scrnIndex, (pointer) pVia->BltBase,
                         VIA_MMIO_BLTSIZE);
@@ -294,7 +213,6 @@ fail:
     }
 #endif
 
-    pVia->FBBase = NULL;
     pVia->BltBase = NULL;
     pVia->MapBase = NULL;
 
@@ -314,11 +232,6 @@ viaUnmapMMIO(ScrnInfoPtr pScrn)
     viaMMIODisable(pScrn);
 
 #ifdef HAVE_PCIACCESS
-    if (pVia->FBBase) {
-        pci_device_unmap_range(pVia->PciInfo, (pointer) pVia->FBBase,
-                               pVia->videoRambytes);
-    }
-
     if (pVia->BltBase) {
         pci_device_unmap_range(pVia->PciInfo, (pointer) pVia->BltBase,
                                VIA_MMIO_BLTSIZE);
@@ -329,11 +242,6 @@ viaUnmapMMIO(ScrnInfoPtr pScrn)
                                VIA_MMIO_REGSIZE);
     }
 #else
-    if (pVia->FBBase) {
-        xf86UnMapVidMem(pScrn->scrnIndex, (pointer) pVia->FBBase,
-                        pVia->videoRambytes);
-    }
-
     if (pVia->BltBase) {
         xf86UnMapVidMem(pScrn->scrnIndex, (pointer) pVia->BltBase,
                         VIA_MMIO_BLTSIZE);
@@ -345,7 +253,6 @@ viaUnmapMMIO(ScrnInfoPtr pScrn)
     }
 #endif
 
-    pVia->FBBase = NULL;
     pVia->BltBase = NULL;
     pVia->MapBase = NULL;
 
@@ -353,6 +260,139 @@ viaUnmapMMIO(ScrnInfoPtr pScrn)
                         "Exiting viaUnmapMMIO.\n"));
 }
 
+static Bool
+viaMapFB(ScrnInfoPtr pScrn)
+{
+    VIAPtr pVia = VIAPTR(pScrn);
+#ifdef HAVE_PCIACCESS
+    int err;
+#else
+    unsigned char *tmp;
+#endif
+    Bool ret = FALSE;
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Entered %s.\n", __func__));
+
+    if (!pVia->videoRambytes) {
+        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                    "Unable to map the frame buffer!\n");
+        goto exit;
+    }
+
+#ifdef HAVE_PCIACCESS
+    if (pVia->Chipset == VIA_VX900) {
+        pVia->FrameBufferBase = pVia->PciInfo->regions[2].base_addr;
+    } else {
+        pVia->FrameBufferBase = pVia->PciInfo->regions[0].base_addr;
+    }
+#else
+    if (pVia->Chipset == VIA_VX900) {
+        pVia->FrameBufferBase = pVia->PciInfo->memBase[2];
+    } else {
+        pVia->FrameBufferBase = pVia->PciInfo->memBase[0];
+    }
+#endif
+
+#ifdef HAVE_PCIACCESS
+    err = pci_device_map_range(pVia->PciInfo, pVia->FrameBufferBase,
+                                pVia->videoRambytes,
+                                PCI_DEV_MAP_FLAG_WRITABLE |
+                                PCI_DEV_MAP_FLAG_WRITE_COMBINE,
+                                (void **)&pVia->FBBase);
+    if (err) {
+        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                    "Unable to map the frame buffer!\n"
+                    "Error: %s (%u)\n",
+                    strerror(err), err);
+        goto exit;
+    }
+#else
+    /*
+     * FIXME: This is a hack to get rid of offending wrongly sized
+     * MTRR regions set up by the VIA BIOS. Should be taken care of
+     * in the OS support layer.
+     */
+    tmp = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, pVia->PciTag,
+                        pVia->FrameBufferBase, pVia->videoRambytes);
+    if (!tmp) {
+        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                    "Unable to map the frame buffer!\n");
+        goto exit;
+    }
+
+    xf86UnMapVidMem(pScrn->scrnIndex,
+                    (pointer) tmp, pVia->videoRambytes);
+
+    /*
+     * And, as if this wasn't enough, 2.6 series kernels don't
+     * remove MTRR regions on the first attempt. So try again.
+     */
+    tmp = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, pVia->PciTag,
+                        pVia->FrameBufferBase, pVia->videoRambytes);
+    if (!tmp) {
+        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                    "Unable to map the frame buffer!\n");
+        goto exit;
+    }
+
+    xf86UnMapVidMem(pScrn->scrnIndex,
+                    (pointer) tmp, pVia->videoRambytes);
+    /*
+     * End of hack.
+     */
+
+    pVia->FBBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER,
+                                 pVia->PciTag, pVia->FrameBufferBase,
+                                 pVia->videoRambytes);
+    if (!pVia->FBBase) {
+        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                    "Unable to map the frame buffer!\n");
+        goto exit;
+    }
+#endif
+
+    xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+                "Mapping the frame buffer at address 0x%lx with "
+                "size %lu KB.\n",
+                pVia->FrameBufferBase, pVia->videoRambytes / 1024);
+
+    pVia->FBFreeStart = 0;
+    pVia->FBFreeEnd = pVia->videoRambytes;
+
+    ret = TRUE;
+exit:
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Exiting %s.\n", __func__));
+    return ret;
+}
+
+void
+viaUnmapFB(ScrnInfoPtr pScrn)
+{
+    VIAPtr pVia = VIAPTR(pScrn);
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Entered %s.\n", __func__));
+
+#ifdef HAVE_PCIACCESS
+    if (pVia->FBBase) {
+        pci_device_unmap_range(pVia->PciInfo, (pointer) pVia->FBBase,
+                               pVia->videoRambytes);
+    }
+#else
+    if (pVia->FBBase) {
+        xf86UnMapVidMem(pScrn->scrnIndex, (pointer) pVia->FBBase,
+                        pVia->videoRambytes);
+    }
+#endif
+
+    pVia->FBBase = NULL;
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Exiting %s.\n", __func__));
+}
+
 /*
  * Leftover from VIA's code.
  */
@@ -1102,6 +1142,11 @@ viaUMSPreInit(ScrnInfoPtr pScrn)
         return FALSE;
     }
 
+    if (!viaMapFB(pScrn)) {
+        viaUnmapMMIO(pScrn);
+        return FALSE;
+    }
+
     return TRUE;
 }
 
diff --git a/src/via_ums.h b/src/via_ums.h
index 570da1a..017c1ec 100644
--- a/src/via_ums.h
+++ b/src/via_ums.h
@@ -1557,6 +1557,7 @@ viaSetDisplayScaling(ScrnInfoPtr pScrn, Bool scalingState)
 
 /* via_ums.c */
 void viaUnmapMMIO(ScrnInfoPtr pScrn);
+void viaUnmapFB(ScrnInfoPtr pScrn);
 void viaDisableVQ(ScrnInfoPtr pScrn);
 Bool viaUMSAccelInit(ScreenPtr pScreen);
 Bool viaUMSCreate(ScrnInfoPtr pScrn);
commit 90f1c9d2fcc8d8a60999884f76be4d97387f4b91
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Fri Mar 6 15:37:07 2020 -0800

    Unmap MMIO and FB when tearing down the DDX
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_driver.c b/src/via_driver.c
index 4733c04..152e9b6 100644
--- a/src/via_driver.c
+++ b/src/via_driver.c
@@ -396,6 +396,7 @@ static void
 VIAFreeScreen(FREE_SCREEN_ARGS_DECL)
 {
     SCRN_INFO_PTR(arg);
+    VIAPtr pVia = VIAPTR(pScrn);
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIAFreeScreen\n"));
 
@@ -403,6 +404,10 @@ VIAFreeScreen(FREE_SCREEN_ARGS_DECL)
         vgaHWFreeHWRec(pScrn);
     }
 
+    if (!pVia->KMS) {
+        viaUnmapMMIO(pScrn);
+    }
+
     VIAFreeRec(pScrn);
 }
 
@@ -1397,6 +1402,10 @@ VIACloseScreen(CLOSE_SCREEN_ARGS_DECL)
     }
 #endif
 
+    if (!pVia->KMS) {
+        viaUnmapMMIO(pScrn);
+    }
+
     pScrn->vtSema = FALSE;
     pScreen->CloseScreen = pVia->CloseScreen;
     return (*pScreen->CloseScreen) (CLOSE_SCREEN_ARGS);


More information about the openchrome-devel mailing list