[PATCH mach64] Don't play wrapping games

Mark Kettenis kettenis at openbsd.org
Sun Aug 29 09:13:18 PDT 2010


The driver calls the wrapped CloseScreen function in the middle of messing
with the hardware state.  On multi-card setups this may cause the VGA
arbiter to switch to a different card while we're in the middle of things,
with obvious disastrous effects.  This fixes things by making sure we
only call the wrapped CloseScreen function at the very end of the driver's
CloseScreen function.

Signed-off-by: Mark Kettenis <kettenis at openbsd.org>
---
 src/aticonsole.c |    9 +--------
 src/atiscreen.c  |   14 +++-----------
 2 files changed, 4 insertions(+), 19 deletions(-)

diff --git a/src/aticonsole.c b/src/aticonsole.c
index 8efe897..1be147e 100644
--- a/src/aticonsole.c
+++ b/src/aticonsole.c
@@ -784,17 +784,10 @@ ATIFreeScreen
     int flags
 )
 {
-    ScreenPtr   pScreen     = screenInfo.screens[iScreen];
     ScrnInfoPtr pScreenInfo = xf86Screens[iScreen];
     ATIPtr      pATI        = ATIPTR(pScreenInfo);
 
-    if (pATI->Closeable || (serverGeneration > 1))
-        ATII2CFreeScreen(iScreen);
-
-    if (pATI->Closeable)
-        (void)(*pScreen->CloseScreen)(iScreen, pScreen);
-
-    ATILeaveGraphics(pScreenInfo, pATI);
+    ATII2CFreeScreen(iScreen);
 
 #ifndef AVOID_CPIO
 
diff --git a/src/atiscreen.c b/src/atiscreen.c
index bc57934..cf79c37 100644
--- a/src/atiscreen.c
+++ b/src/atiscreen.c
@@ -628,7 +628,6 @@ ATICloseScreen
 {
     ScrnInfoPtr pScreenInfo = xf86Screens[iScreen];
     ATIPtr      pATI        = ATIPTR(pScreenInfo);
-    Bool        Closed      = TRUE;
 
 #ifdef XF86DRI_DEVEL
 
@@ -658,21 +657,13 @@ ATICloseScreen
         pATI->pXAAInfo = NULL;
     }
 #endif
-
-    if ((pScreen->CloseScreen = pATI->CloseScreen))
-    {
-        pATI->CloseScreen = NULL;
-        Closed = (*pScreen->CloseScreen)(iScreen, pScreen);
-    }
-
-    pATI->Closeable = FALSE;
-
     if (pATI->pCursorInfo)
     {
         xf86DestroyCursorInfoRec(pATI->pCursorInfo);
         pATI->pCursorInfo = NULL;
     }
 
+    pATI->Closeable = FALSE;
     ATILeaveGraphics(pScreenInfo, pATI);
 
 #ifdef USE_XAA
@@ -688,5 +679,6 @@ ATICloseScreen
     pATI->pShadow = NULL;
     pScreenInfo->pScreen = NULL;
 
-    return Closed;
+    pScreen->CloseScreen = pATI->CloseScreen;
+    return (*pScreen->CloseScreen)(iScreen, pScreen);
 }
-- 
1.7.1



More information about the xorg-devel mailing list