[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[win-pv-devel] [PATCH] Fix WHQL induced BSODs



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@xxxxxxxxxx>
---
 src/xenvif/fdo.c | 20 ++++++++++++++++++--
 src/xenvif/pdo.c |  8 ++++++++
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/xenvif/fdo.c b/src/xenvif/fdo.c
index d2ce513..6b1aeff 100644
--- a/src/xenvif/fdo.c
+++ b/src/xenvif/fdo.c
@@ -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
diff --git a/src/xenvif/pdo.c b/src/xenvif/pdo.c
index a7755d2..5ce6c50 100644
--- a/src/xenvif/pdo.c
+++ b/src/xenvif/pdo.c
@@ -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
-- 
2.1.1


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.