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

[win-pv-devel] [PATCH 2/3] Make sure the NICS unplug count does not run away



In a tight loop of network attach/detach it's possible for a mismatch in
the number of unplug requests and revocations to occur, leading to a
run-away unplug count.

This patch adjusts the location of the requests and revocations to make
sure this does not happen.

Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
 src/xenvif/pdo.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/xenvif/pdo.c b/src/xenvif/pdo.c
index 28f9eb0..6c4c9bd 100644
--- a/src/xenvif/pdo.c
+++ b/src/xenvif/pdo.c
@@ -91,6 +91,7 @@ struct _XENVIF_PDO {
     PXENBUS_SUSPEND_CALLBACK    SuspendCallbackLate;
 
     XENBUS_UNPLUG_INTERFACE     UnplugInterface;
+    BOOLEAN                     UnplugRequested;
 
     PXENVIF_FRONTEND            Frontend;
 
@@ -1174,6 +1175,9 @@ PdoUnplugRequest(
 {
     NTSTATUS        status;
 
+    ASSERT3U(Pdo->UnplugRequested, !=, Make);
+    Pdo->UnplugRequested = Make;
+
     status = XENBUS_UNPLUG(Acquire, &Pdo->UnplugInterface);
     if (!NT_SUCCESS(status))
         return;
@@ -1204,8 +1208,6 @@ PdoStartDevice(
     if (Pdo->HasAlias)
         goto fail1;
 
-    PdoUnplugRequest(Pdo, TRUE);
-
     if (DriverSafeMode())
         goto fail2;
 
@@ -1268,6 +1270,8 @@ PdoStartDevice(
 
         Pdo->HasAlias = TRUE;
 
+        PdoUnplugRequest(Pdo, TRUE);
+
         status = STATUS_UNSUCCESSFUL;
         goto fail9;
     }
@@ -1278,6 +1282,8 @@ PdoStartDevice(
     if (!NT_SUCCESS(status))
         goto fail10;
 
+    PdoUnplugRequest(Pdo, TRUE);
+
     __PdoSetDevicePnpState(Pdo, Started);
 
     Irp->IoStatus.Status = STATUS_SUCCESS;
@@ -1479,10 +1485,10 @@ PdoRemoveDevice(
     if (__PdoGetDevicePowerState(Pdo) != PowerDeviceD0)
         goto done;
 
-    PdoD0ToD3(Pdo);
-
     PdoUnplugRequest(Pdo, FALSE);
 
+    PdoD0ToD3(Pdo);
+
 done:
     RtlZeroMemory(&Pdo->CurrentAddress, sizeof (ETHERNET_ADDRESS));
 
@@ -2777,6 +2783,7 @@ PdoDestroy(
     PDEVICE_OBJECT  PhysicalDeviceObject = Dx->DeviceObject;
     PXENVIF_FDO     Fdo = __PdoGetFdo(Pdo);
 
+    ASSERT(!Pdo->UnplugRequested);
     ASSERT3U(__PdoGetDevicePnpState(Pdo), ==, Deleted);
 
     Pdo->HasAlias = FALSE;
-- 
2.1.1


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
https://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®.