From: Owen Smith Date: Fri, 2 Mar 2018 13:15:29 +0000 (+0000) Subject: Ensure D0 <-> D3 transitions occur only from the correct state X-Git-Tag: 9.0.0-rc1~17 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=82822de96690bbd054701b6afc045fc000f151cd;p=pvdrivers%2Fwin%2Fxencons.git Ensure D0 <-> D3 transitions occur only from the correct state Attempting to set D0 when already at D0 will trigger an ASSERT and overwrite several variables. Signed-off-by: Owen Smith --- diff --git a/src/xencons/pdo.c b/src/xencons/pdo.c index 66ab033..3b483a5 100644 --- a/src/xencons/pdo.c +++ b/src/xencons/pdo.c @@ -457,6 +457,9 @@ PdoD3ToD0( ASSERT3U(KeGetCurrentIrql(), == , PASSIVE_LEVEL); + if (__PdoGetDevicePowerState(Pdo) == PowerDeviceD0) + goto done; + KeRaiseIrql(DISPATCH_LEVEL, &Irql); status = XENBUS_SUSPEND(Acquire, &Pdo->SuspendInterface); @@ -482,6 +485,7 @@ PdoD3ToD0( if (!NT_SUCCESS(status)) goto fail4; +done: #pragma prefast(suppress:28123) (VOID) IoSetDeviceInterfaceState(&Pdo->Dx->Link, TRUE); @@ -532,6 +536,9 @@ PdoD0ToD3( #pragma prefast(suppress:28123) (VOID) IoSetDeviceInterfaceState(&Pdo->Dx->Link, FALSE); + if (__PdoGetDevicePowerState(Pdo) == PowerDeviceD3) + goto done; + XENCONS_CONSOLE_ABI(D0ToD3, &Pdo->Abi); KeRaiseIrql(DISPATCH_LEVEL, &Irql); @@ -547,6 +554,7 @@ PdoD0ToD3( KeLowerIrql(Irql); +done: Trace("(%s) <====\n", __PdoGetName(Pdo)); }