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

[win-pv-devel] [PATCH 4/6] Rework Wmi setup/cleanup to always Resume/Suspend sessions



Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 src/xeniface/fdo.c | 47 ++++++++++++++++-------------------------------
 src/xeniface/wmi.c |  3 +++
 2 files changed, 19 insertions(+), 31 deletions(-)

diff --git a/src/xeniface/fdo.c b/src/xeniface/fdo.c
index 10ead15..2b3e44d 100644
--- a/src/xeniface/fdo.c
+++ b/src/xeniface/fdo.c
@@ -741,20 +741,6 @@ __FdoD0ToD3(
     Trace("<====\n");
 }
 
-static DECLSPEC_NOINLINE VOID
-FdoSuspendCallbackLate(
-    IN  PVOID   Argument
-    )
-{
-    PXENIFACE_FDO Fdo = (PXENIFACE_FDO) Argument;
-    NTSTATUS    status;
-
-    __FdoD0ToD3(Fdo);
-
-    status = __FdoD3ToD0(Fdo);
-    ASSERT(NT_SUCCESS(status));
-}
-
 static DECLSPEC_NOINLINE NTSTATUS
 FdoD3ToD0(
     IN  PXENIFACE_FDO Fdo
@@ -791,6 +777,8 @@ FdoD3ToD0(
     Fdo->InterfacesAcquired = TRUE;
     KeLowerIrql(Irql);
 
+    WmiSessionsResumeAll(Fdo);
+
     return STATUS_SUCCESS;
 
 fail4:
@@ -824,8 +812,11 @@ FdoD0ToD3(
     KIRQL           Irql;
 
     ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
-    Fdo->InterfacesAcquired = FALSE;
+
+    WmiSessionsSuspendAll(Fdo);
+
     KeRaiseIrql(DISPATCH_LEVEL, &Irql);
+    Fdo->InterfacesAcquired = FALSE;
 
     XENBUS_SUSPEND(Deregister,
                    &Fdo->SuspendInterface,
@@ -886,24 +877,20 @@ FdoStartDevice(
      FdoS4ToS3(Fdo);
     __FdoSetSystemPowerState(Fdo, PowerSystemWorking);
 
-    status = FdoD3ToD0(Fdo);
+    status = WmiRegister(Fdo);
     if (!NT_SUCCESS(status))
         goto fail3;
 
-    status =  IoSetDeviceInterfaceState(&Fdo->InterfaceName, TRUE);
+    status = FdoD3ToD0(Fdo);
     if (!NT_SUCCESS(status))
         goto fail4;
 
-
-    if (__FdoGetDevicePnpState(Fdo) != Stopped) {
-        status = WmiRegister(Fdo);
-        if (!NT_SUCCESS(status))
-            goto fail5;
-    }
+    status =  IoSetDeviceInterfaceState(&Fdo->InterfaceName, TRUE);
+    if (!NT_SUCCESS(status))
+        goto fail5;
 
     __FdoSetDevicePnpState(Fdo, Started);
 
-
     status = Irp->IoStatus.Status;
     IoCompleteRequest(Irp, IO_NO_INCREMENT);
 
@@ -911,12 +898,12 @@ FdoStartDevice(
 
 fail5:
     Error("fail5\n");
-#pragma warning(suppress : 6031)
-    IoSetDeviceInterfaceState(&Fdo->InterfaceName, FALSE);
+    FdoD0ToD3(Fdo);
 
 fail4:
     Error("fail4\n");
-    FdoD0ToD3(Fdo);
+
+    WmiDeregister(Fdo);
 
 fail3:
     Error("fail3\n");
@@ -981,6 +968,7 @@ FdoStopDevice(
     NTSTATUS        status;
 
     FdoD0ToD3(Fdo);
+    WmiDeregister(Fdo);
 
     __FdoSetSystemPowerState(Fdo, PowerSystemSleeping3);
     FdoS3ToS4(Fdo);
@@ -1335,7 +1323,6 @@ __FdoSetDevicePowerUp(
 
     ASSERT3U(DeviceState, ==, PowerDeviceD0);
     status = FdoD3ToD0(Fdo);
-    WmiSessionsResumeAll(Fdo);
     ASSERT(NT_SUCCESS(status));
 
 done:
@@ -1367,10 +1354,8 @@ __FdoSetDevicePowerDown(
 
     ASSERT3U(DeviceState, ==, PowerDeviceD3);
 
-    if (__FdoGetDevicePowerState(Fdo) == PowerDeviceD0){
-        WmiSessionsSuspendAll(Fdo);
+    if (__FdoGetDevicePowerState(Fdo) == PowerDeviceD0)
         FdoD0ToD3(Fdo);
-    }
 
     IoSkipCurrentIrpStackLocation(Irp);
     status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
diff --git a/src/xeniface/wmi.c b/src/xeniface/wmi.c
index 1ae84e1..0f63ef5 100644
--- a/src/xeniface/wmi.c
+++ b/src/xeniface/wmi.c
@@ -1327,6 +1327,9 @@ WmiRegister(
 {
     NTSTATUS            status;
 
+    if (Fdo->WmiReady)
+        return STATUS_SUCCESS;
+
     XenIfaceDebugPrint(TRACE,"%s\n",__FUNCTION__);
     XenIfaceDebugPrint(INFO,"DRV: XenIface WMI Initialisation\n");
 
-- 
1.9.4.msysgit.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®.