[Spice-devel] [PATCH spice-win-qxl] qxl: support device "surprise removal"

Arnon Gilboa agilboa at redhat.com
Thu Feb 3 02:38:28 PST 2011


Part of the WHQL generic device qualification tests is the "Surprise Removal",
a case which is unrealistic for the qxl display device in the real world.
However, in surprise removal the cursor and display events are not set, so we
need to wait with a timeout in order not to wait forever.
---
 display/res.c |   60 ++++++++++++++++++++++++++------------------------------
 1 files changed, 28 insertions(+), 32 deletions(-)

diff --git a/display/res.c b/display/res.c
index ccbb110..2d8e996 100644
--- a/display/res.c
+++ b/display/res.c
@@ -157,11 +157,22 @@ static _inline void CursorCmdAddRes(PDev *pdev, QXLCursorCmd *cmd, Resource *res
     AddRes(pdev, output, res);
 }
 
+/* Required for passing WHQL generic device "Surprise Removal" test, a case which is unrealistic
+   for the qxl display device in the real world. However, in surprise removal the cursor and display
+   events are not set, so we need to wait with a timeout in order not to wait forever.*/
+#define SUPPORT_SURPRISE_REMOVE
+
 /* Called with cursor_sem held */
 static void WaitForCursorRing(PDev* pdev)
 {
     int wait;
+    PLARGE_INTEGER ptimeout = NULL;
+#ifdef SUPPORT_SURPRISE_REMOVE
+    LARGE_INTEGER timeout; // 1 => 100 nanoseconds
 
+    timeout.QuadPart = -1 * (1000 * 1000 * 10); //negative  => relative // 1s
+    ptimeout = &timeout;
+#endif
     DEBUG_PRINT((pdev, 9, "%s: 0x%lx\n", __FUNCTION__, pdev));
 
     for (;;) {
@@ -170,26 +181,15 @@ static void WaitForCursorRing(PDev* pdev)
         if (!wait) {
             break;
         }
-#ifdef DBG
-        {
-            LARGE_INTEGER timeout; // 1 => 100 nanoseconds
-            timeout.QuadPart = -1 * (1000 * 1000 * 10); //negative  => relative // 1s
 #if (WINVER < 0x0501)
-            pdev->WaitForEvent(pdev->cursor_event, &timeout);
+        pdev->WaitForEvent(pdev->cursor_event, ptimeout);
 #else
-            EngWaitForSingleObject(pdev->cursor_event, &timeout);
+        EngWaitForSingleObject(pdev->cursor_event, ptimeout);
 #endif // (WINVER < 0x0501)
-
-            if (SPICE_RING_IS_FULL(pdev->cursor_ring)) {
-                DEBUG_PRINT((pdev, 0, "%s: 0x%lx: timeout\n", __FUNCTION__, pdev));
-            }
+#ifdef DBG
+        if (SPICE_RING_IS_FULL(pdev->cursor_ring)) {
+            DEBUG_PRINT((pdev, 0, "%s: 0x%lx: timeout\n", __FUNCTION__, pdev));
         }
-#else
-#if (WINVER < 0x0501)
-        pdev->WaitForEvent(pdev->cursor_event, NULL);
-#else
-        EngWaitForSingleObject(pdev->cursor_event, NULL);
-#endif // (WINVER < 0x0501)
 #endif //DBG
     }
 }
@@ -198,6 +198,13 @@ static void WaitForCursorRing(PDev* pdev)
 static void WaitForCmdRing(PDev* pdev)
 {
     int wait;
+    PLARGE_INTEGER ptimeout = NULL;
+#ifdef SUPPORT_SURPRISE_REMOVE
+    LARGE_INTEGER timeout; // 1 => 100 nanoseconds
+
+    timeout.QuadPart = -1 * (1000 * 1000 * 10); //negative  => relative // 1s
+    ptimeout = &timeout;
+#endif
 
     DEBUG_PRINT((pdev, 9, "%s: 0x%lx\n", __FUNCTION__, pdev));
 
@@ -207,26 +214,15 @@ static void WaitForCmdRing(PDev* pdev)
         if (!wait) {
             break;
         }
-#ifdef DBG
-        {
-            LARGE_INTEGER timeout; // 1 => 100 nanoseconds
-            timeout.QuadPart = -1 * (1000 * 1000 * 10); //negative  => relative // 1s
 #if (WINVER < 0x0501)
-            pdev->WaitForEvent(pdev->display_event, &timeout);
+        pdev->WaitForEvent(pdev->display_event, ptimeout);
 #else
-            EngWaitForSingleObject(pdev->display_event, &timeout);
+        EngWaitForSingleObject(pdev->display_event, ptimeout);
 #endif // (WINVER < 0x0501)
-
-            if (SPICE_RING_IS_FULL(pdev->cmd_ring)) {
-                DEBUG_PRINT((pdev, 0, "%s: 0x%lx: timeout\n", __FUNCTION__, pdev));
-            }
+#ifdef DBG
+        if (SPICE_RING_IS_FULL(pdev->cmd_ring)) {
+            DEBUG_PRINT((pdev, 0, "%s: 0x%lx: timeout\n", __FUNCTION__, pdev));
         }
-#else
-#if (WINVER < 0x0501)
-        pdev->WaitForEvent(pdev->display_event, NULL);
-#else
-        EngWaitForSingleObject(pdev->display_event, NULL);
-#endif // (WINVER < 0x0501)
 #endif //DBG
     }
 }
-- 
1.5.5.6



More information about the Spice-devel mailing list