st/xorg: Try hard to not touch hardware after dropping the master
authorJakob Bornecrantz <jakob@vmware.com>
Thu, 29 Apr 2010 12:05:49 +0000 (13:05 +0100)
committerJakob Bornecrantz <jakob@vmware.com>
Thu, 29 Apr 2010 13:27:35 +0000 (14:27 +0100)
src/gallium/state_trackers/xorg/xorg_driver.c
src/gallium/state_trackers/xorg/xorg_exa.c

index 459d0083ec4817b3b725f56c7cd1f07872ce6a79..44520b81b663a52d0d2f8583be254fc60bf1bfd7 100644 (file)
@@ -334,17 +334,9 @@ static Bool
 drv_close_resource_management(ScrnInfoPtr pScrn)
 {
     modesettingPtr ms = modesettingPTR(pScrn);
-    int i;
 
     if (ms->screen) {
        assert(ms->ctx == NULL);
-
-       for (i = 0; i < XORG_NR_FENCES; i++) {
-           if (ms->fence[i]) {
-               ms->screen->fence_finish(ms->screen, ms->fence[i], 0);
-               ms->screen->fence_reference(ms->screen, &ms->fence[i], NULL);
-           }
-       }
        ms->screen->destroy(ms->screen);
     }
     ms->screen = NULL;
@@ -357,6 +349,22 @@ drv_close_resource_management(ScrnInfoPtr pScrn)
     return TRUE;
 }
 
+static void
+drv_cleanup_fences(ScrnInfoPtr pScrn)
+{
+    modesettingPtr ms = modesettingPTR(pScrn);
+    int i;
+
+    assert(ms->screen);
+
+    for (i = 0; i < XORG_NR_FENCES; i++) {
+       if (ms->fence[i]) {
+           ms->screen->fence_finish(ms->screen, ms->fence[i], 0);
+           ms->screen->fence_reference(ms->screen, &ms->fence[i], NULL);
+       }
+    }
+}
+
 static Bool
 drv_pre_init(ScrnInfoPtr pScrn, int flags)
 {
@@ -824,6 +832,10 @@ drv_leave_vt(int scrnIndex, int flags)
     drmModeRmFB(ms->fd, ms->fb_id);
     ms->fb_id = -1;
 
+    /* idle hardware */
+    if (!ms->kms)
+       drv_cleanup_fences(pScrn);
+
     if (drmDropMaster(ms->fd))
        xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
                   "drmDropMaster failed: %s\n", strerror(errno));
@@ -882,10 +894,6 @@ drv_close_screen(int scrnIndex, ScreenPtr pScreen)
     modesettingPtr ms = modesettingPTR(pScrn);
     CustomizerPtr cust = ms->cust;
 
-    if (pScrn->vtSema) {
-       drv_leave_vt(scrnIndex, 0);
-    }
-
     if (ms->cursor) {
        FreeCursor(ms->cursor, None);
        ms->cursor = NULL;
@@ -917,6 +925,11 @@ drv_close_screen(int scrnIndex, ScreenPtr pScreen)
        xorg_exa_close(pScrn);
     ms->exa = NULL;
 
+    /* calls drop master make sure we don't talk to 3D HW after that */
+    if (pScrn->vtSema) {
+       drv_leave_vt(scrnIndex, 0);
+    }
+
     drv_close_resource_management(pScrn);
 
     drv_close_drm(pScrn);
index 65be8c332a5da8b4f3180562d1efaf0f524cfc8c..31140f13bb4d2a389f32aca5098d28054c64d72d 100644 (file)
@@ -981,6 +981,8 @@ xorg_exa_close(ScrnInfoPtr pScrn)
 
    renderer_destroy(exa->renderer);
 
+   xorg_exa_finish(exa);
+
    if (exa->pipe)
       exa->pipe->destroy(exa->pipe);
    exa->pipe = NULL;