WdfDeviceStopIdle function

[Applies to KMDF and UMDF]

The WdfDeviceStopIdle method informs the framework that the specified device must be placed in its working (D0) power state.


NTSTATUS WdfDeviceStopIdle(
  _In_ WDFDEVICE Device,
  _In_ BOOLEAN   WaitForD0



A handle to a framework device object.


A Boolean value that indicates when WdfDeviceStopIdle will return. If TRUE, it returns only after the specified device has entered the D0 device power state. If FALSE, the method returns immediately.

Return Value



If your device can enter a low-power state when it becomes idle, your driver might have to occasionally call WdfDeviceStopIdle to bring the device back to its working (D0) state or to prevent it from entering a low-power state.

Your driver does not have to call WdfDeviceStopIdle when a device is idle and the framework places an I/O request in the device's power-managed I/O queue. Additionally, your driver does not have to call WdfDeviceStopIdle when a device is idle and it detects a wake signal. In both of these cases, the framework requests the bus driver to restore the device's power state to D0.

Although drivers typically do not need to call WdfDeviceStopIdle when handling I/O requests that they obtain from a power-managed I/O queue, the call is allowed. However, drivers must not set the WaitForD0 parameter to TRUE when handling I/O requests from a power-managed I/O queue.

Your driver does have to call WdfDeviceStopIdle if it must access the device because of a request that the driver has received outside of a power-managed I/O queue. For example, your driver might support a driver-defined interface or a WMI request that requires accessing the device. In this case, you must ensure that the device is in its working state before the driver accesses the device, and that the device remains in its working state until the driver has finished accessing the device.

Calling WdfDeviceStopIdle forces the device into its working (D0) state, if the system is in its working (S0) state. The device remains in its working state until the driver calls WdfDeviceResumeIdle, at which point the framework can place the device in a low-power state if it remains idle.

Do not call WdfDeviceStopIdle before the framework has called the driver's EvtDeviceD0Entry callback function for the first time.

A call to WdfDeviceStopIdle can restore an idle device to its working state only if the system is in its working (S0) state. If the system is entering a low-power state when a driver calls WdfDeviceStopIdle with the WaitForD0 parameter set to TRUE, the function does not return until the system returns to its S0 state.

Every successful call to WdfDeviceStopIdle must eventually be followed by a call to WdfDeviceResumeIdle, or else the device will never return to a low-power state if it again becomes idle. Calls to WdfDeviceStopIdle can be nested, so the number of calls to WdfDeviceResumeIdle must equal the number of calls to WdfDeviceStopIdle. Do not call WdfDeviceResumeIdle if a call to WdfDeviceStopIdle fails.

If the system enters a low-power state after WdfDeviceStopIdle returns, the device also enters a low-power state. When the system returns to its working (S0) state, the device also returns to its working (D0) state. The power reference from the call to WdfDeviceStopIdle remains active and prevents the device from entering a low-power state until there is a matching call to WdfDeviceResumeIdle.

For more information, see Supporting Idle Power-Down.

If WaitForD0 is TRUE, WdfDeviceStopIdle must be called at IRQL = PASSIVE_LEVEL. If WaitForD0 is FALSE, this method must be called at IRQL <= DISPATCH_LEVEL.

Calling WdfDeviceStopIdleWithTag instead of WdfDeviceStopIdle provides additional information (tag value, line number, and file name) that you can view in Microsoft debuggers.


In the following code example, WdfDeviceStopIdle returns after the specified device has entered the D0 device power state.

NTSTATUS  status;

status = WdfDeviceStopIdle(Device, TRUE);


Target Platform Universal
Minimum KMDF version 1.0
Minimum UMDF version 2.0
Header wdfdevice.h (include Wdf.h)
Library Wdf01000.sys (KMDF); WUDFx02000.dll (UMDF)
IRQL See Remarks section.
DDI compliance rules DriverCreate, KmdfIrql, KmdfIrql2

See Also


Debugging Power Reference Leaks in WDF



Send comments about this topic to Microsoft