[Spice-commits] 3 commits - display/driver.c display/qxldd.h display/res.c display/res.h

Yonit Halperin yhalperi at kemper.freedesktop.org
Mon Jul 19 00:47:54 PDT 2010


 display/driver.c |   11 ++---------
 display/qxldd.h  |    4 +---
 display/res.c    |   23 ++++++++++++++++++++++-
 display/res.h    |    2 ++
 4 files changed, 27 insertions(+), 13 deletions(-)

New commits:
commit 3f1b5fffa0474e1c31950bfd5dbbed02c78dc380
Author: Yonit Halperin <yhalperi at redhat.com>
Date:   Mon Jul 12 16:37:03 2010 +0300

    Fix corrupted ram data (e.g., release_ring), and unsynchronized worker, after driver is disabled and re-enabled.
    
    On logoff, in Win7 guest, and on switch user and login into a Winxp guest, the driver is disabled and re-enabled (while the miniport in not reset).
    However, before the fix, all the draw objects, e.g., surfaces, were still alive in the worker and the release ring still contained objects, while all the driver's data was initialized. This caused blue screens, and panics in the worker.

diff --git a/display/driver.c b/display/driver.c
index 7dce00e..4eaedc4 100644
--- a/display/driver.c
+++ b/display/driver.c
@@ -256,6 +256,7 @@ BOOL DrvEnableDriver(ULONG engine_version, ULONG enable_data_size, PDRVENABLEDAT
 VOID DrvDisableDriver(VOID)
 {
     DEBUG_PRINT((NULL, 1, "%s\n", __FUNCTION__));
+    ResetAllDevices();
     ResDestroyGlobals();
     CleanGlobalRes();
 }
diff --git a/display/qxldd.h b/display/qxldd.h
index ffa8b8c..b90aaad 100644
--- a/display/qxldd.h
+++ b/display/qxldd.h
@@ -168,6 +168,7 @@ typedef struct DevRes {
 
     UINT8 *surfaces_used;
 
+    HANDLE driver;
 #ifdef DBG
     int num_free_pages;
     int num_outputs;
diff --git a/display/res.c b/display/res.c
index c769aeb..a8357f7 100644
--- a/display/res.c
+++ b/display/res.c
@@ -28,6 +28,8 @@
 #include "surface.h"
 #include "dd.h"
 #include "rop.h"
+#include "devioctl.h"
+#include "ntddvdeo.h"
 
 #if (WINVER < 0x0501)
 #define WAIT_FOR_EVENT(pdev, event, timeout) (pdev)->WaitForEvent(event, timeout)
@@ -397,6 +399,8 @@ static void InitRes(PDev *pdev)
     RtlZeroMemory(pdev->Res.palette_cache, sizeof(pdev->Res.palette_cache));
     RingInit(&pdev->Res.dynamic->palette_lru);
     pdev->Res.num_palettes = 0;
+    
+    pdev->Res.driver = pdev->driver;
 
     ONDBG(pdev->Res.num_outputs = 0);
     ONDBG(pdev->Res.num_path_pages = 0);
@@ -3156,5 +3160,22 @@ void CheckAndSetSSE2()
     }
 }
 
+void ResetAllDevices()
+{
+    UINT32 i;
+    EngAcquireSemaphore(res_sem);
 
+    for (i = 0; i < num_global_res; i++) {
+        if (global_res[i].driver) {
+            DWORD length;
+            if (EngDeviceIoControl(global_res[i].driver, IOCTL_VIDEO_RESET_DEVICE,
+                                   NULL, 0, NULL, 0, &length)) {
+                DEBUG_PRINT((NULL, 0, "%s: reset to device failed 0x%lx\n",
+                            __FUNCTION__, global_res[i].driver));
+                
+            }
+        }
+    }
 
+    EngReleaseSemaphore(res_sem);
+}
diff --git a/display/res.h b/display/res.h
index 3bfb0c7..7a10035 100644
--- a/display/res.h
+++ b/display/res.h
@@ -63,4 +63,6 @@ void ResDestroy(PDev *pdev);
 void ResInitGlobals();
 void ResDestroyGlobals();
 void CheckAndSetSSE2();
+void ResetAllDevices();
+
 #endif
commit f55b4857ed8a828f75c2034e6d1bbec60d56abc1
Author: Yonit Halperin <yhalperi at redhat.com>
Date:   Mon Jul 12 10:20:12 2010 +0300

    Fix memory leak: deleting primary surface device bitmap when it is disabled.
    
    The bug caused BSOD: SESSION_HAS_VALID_POOL_ON_EXIT on switching users/log off
    (after the driver is disabled and enabled back again, while the miniport is not restarted).

diff --git a/display/driver.c b/display/driver.c
index 39d0aa9..7dce00e 100644
--- a/display/driver.c
+++ b/display/driver.c
@@ -929,23 +929,15 @@ VOID DrvDisableSurface(DHPDEV in_pdev)
     DEBUG_PRINT((NULL, 1, "%s: 0x%lx\n", __FUNCTION__, pdev));
 
     DisableQXLPrimarySurface(pdev);
-    //DisableQXLAllSurfaces(pdev);
 
     UnmapFB(pdev);
 
     if (pdev->surf) {
         DeleteDeviceBitmap(pdev, 0, DEVICE_BITMAP_ALLOCATION_TYPE_SURF0);
+        EngDeleteSurface(pdev->surf);
         pdev->surf = NULL;
     }
 
-    if (pdev->draw_surf) {
-        drawarea.bitmap = pdev->draw_bitmap;
-        drawarea.surf_obj = pdev->draw_surf;
-        FreeDrawArea(&drawarea);
-        pdev->draw_surf = NULL;
-        pdev->draw_bitmap = NULL;
-    }
-
     if (pdev->surfaces_info) {
         EngFreeMem(pdev->surfaces_info);
         pdev->surfaces_info = NULL;
diff --git a/display/qxldd.h b/display/qxldd.h
index 86438fe..ffa8b8c 100644
--- a/display/qxldd.h
+++ b/display/qxldd.h
@@ -242,9 +242,6 @@ typedef struct PDev {
     PEVENT cursor_event;
     PEVENT sleep_event;
 
-    HSURF draw_bitmap;
-    SURFOBJ *draw_surf;
-
     UINT32 log_port;
     UINT8 *log_buf;
     UINT32 *log_level;
commit 43512da5e50b3ae434f5df89ed91d53fd12867cb
Author: Yonit Halperin <yhalperi at redhat.com>
Date:   Mon Jul 12 10:15:14 2010 +0300

    Fix global resources cleanup

diff --git a/display/res.c b/display/res.c
index 05bc9e6..c769aeb 100644
--- a/display/res.c
+++ b/display/res.c
@@ -322,7 +322,7 @@ void CleanGlobalRes()
 {
     UINT32 i;
 
-    if (!global_res) {
+    if (global_res) {
         for (i = 0; i < num_global_res; ++i) {
             if (global_res[i].dynamic) {
                 EngFreeMem(global_res[i].dynamic);


More information about the Spice-commits mailing list