]> xenbits.xensource.com Git - pvdrivers/win/xenvif.git/commitdiff
Fix WHQL induced BSODs
authorPaul Durrant <paul.durrant@citrix.com>
Wed, 4 Mar 2015 10:04:58 +0000 (10:04 +0000)
committerPaul Durrant <paul.durrant@citrix.com>
Wed, 4 Mar 2015 10:04:58 +0000 (10:04 +0000)
The PNP Rebalance Fail Restart Device test causes BSODs due to incorrect
PnP state assumptions about the FDO. This patch fixes these problems
allowing the test to pass.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
src/xenvif/fdo.c
src/xenvif/pdo.c

index d2ce51335792f136e13f4e77e3b76d4e2215840f..6b1aeff0a379c94c865f920d6fb4cfa42731f02d 100644 (file)
@@ -158,6 +158,16 @@ __FdoGetDevicePnpState(
     return Dx->DevicePnpState;
 }
 
+static FORCEINLINE DEVICE_PNP_STATE
+__FdoGetPreviousDevicePnpState(
+    IN  PXENVIF_FDO Fdo
+    )
+{
+    PXENVIF_DX      Dx = Fdo->Dx;
+
+    return Dx->PreviousDevicePnpState;
+}
+
 static FORCEINLINE VOID
 __FdoSetDevicePowerState(
     IN  PXENVIF_FDO         Fdo,
@@ -621,7 +631,8 @@ FdoAddPhysicalDeviceObject(
     ASSERT3U(Fdo->References, !=, 0);
     Fdo->References++;
 
-    PdoResume(Pdo);
+    if (__FdoGetDevicePowerState(Fdo) == PowerDeviceD0)
+        PdoResume(Pdo);
 }
 
 VOID
@@ -637,7 +648,8 @@ FdoRemovePhysicalDeviceObject(
     Dx = (PXENVIF_DX)DeviceObject->DeviceExtension;
     ASSERT3U(Dx->Type, ==, PHYSICAL_DEVICE_OBJECT);
 
-    PdoSuspend(Pdo);
+    if (__FdoGetDevicePowerState(Fdo) == PowerDeviceD0)
+        PdoSuspend(Pdo);
 
     RemoveEntryList(&Dx->ListEntry);
     ASSERT3U(Fdo->References, !=, 0);
@@ -1485,6 +1497,9 @@ FdoRemoveDevice(
 
     ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
 
+    if (__FdoGetPreviousDevicePnpState(Fdo) != Started)
+        goto done;
+
     KeClearEvent(&Fdo->ScanEvent);
     ThreadWake(Fdo->ScanThread);
 
@@ -1531,6 +1546,7 @@ FdoRemoveDevice(
 
     RtlZeroMemory(&Fdo->Resource, sizeof (FDO_RESOURCE) * RESOURCE_COUNT);
 
+done:
     __FdoSetDevicePnpState(Fdo, Deleted);
 
     // We must release our reference before the PDO is destroyed
index a7755d2929e66c78c0aa3fc14c76441e75d1e213..5ce6c502642854d304b0b3d092570c7d7dc8effe 100644 (file)
@@ -2533,7 +2533,11 @@ PdoResume(
     IN  PXENVIF_PDO     Pdo
     )
 {
+    Trace("====>\n");
+
     FrontendResume(__PdoGetFrontend(Pdo));
+
+    Trace("<====\n");
 }
 
 VOID
@@ -2541,7 +2545,11 @@ PdoSuspend(
     IN  PXENVIF_PDO     Pdo
     )
 {
+    Trace("====>\n");
+
     FrontendSuspend(__PdoGetFrontend(Pdo));
+
+    Trace("<====\n");
 }
 
 NTSTATUS