Windows Driver Kit: Buses
USB Idle Notification Callback Routine

When the driver for the parent device (either an instance of the hub driver or the generic parent driver) determines that it is safe to suspend its device's children, it calls the idle notification callback routine supplied by each child.

A device driver must take the following actions in its idle notification callback routine:

  • Do nothing, if the device is no longer idle.
  • Issue an IRP_MN_WAIT_WAKE IRP to its parent if the device needs to be armed for remote wakeup.
  • Cancel all I/O and prepare the device to go to a lower power state.
  • Put the device in a WDM sleep state by calling PoRequestPowerIrp with the PowerState parameter set to the enumerator value PowerDeviceD2 (defined in ntpoapi.h). A driver must not put its device in PowerDeviceD3, even if the device is not armed for remote wake.

In Windows XP, a driver must rely on an idle notification callback routine to selectively suspend a device. If a driver running in Windows XP puts a device in a lower power state directly without using an idle notification callback routine, this might prevent other devices in the USB device tree from suspending. For more details on this topic, see sections Conditions for Global Suspend in Windows XP and Conditions for Global Suspend in Windows Vista.

Both the hub driver and the generic parent driver call the idle notification callback routine at IRQL = PASSIVE_LEVEL. This allows the callback routine to block while it waits for the power state change request to complete.

Parent drivers never call callback routines when in a system state other than S0 or when the parent device is in a device state other than D0.

These restrictions apply to idle request notification callback routines:

Device drivers can initiate a device power state transition from D0 to D2 in the idle notification callback routine, but no other power state transition is allowed. In particular, a driver must not attempt to change its device to D0 while executing its callback routine.

Device drivers must not request more than one power IRP from within the idle notification callback routine.

How Drivers Arm Devices for Wakeup in the Idle Notification Callback Routine

The idle notification callback routine should determine whether its device has an IRP_MN_WAIT_WAKE request pending. If no IRP_MN_WAIT_WAKE request is pending, the callback routine should submit an IRP_MN_WAIT_WAKE request before suspending the device. Ideally, a driver for a USB device capable of remote wakeup should submit a wait/wake IRP to the USB driver stack when it starts, and not in the idle notification callback routine. For more information about the wait/wake mechanism, see Supporting Devices That Have WakeUp Capabilities.


Send feedback on this topic
Built on October 01, 2009
Page view tracker