Reporting Device Failures
There are two ways to report device failures:
The driver can call WdfDeviceSetFailed.
For both methods, the framework effectively removes the device. If the device's drivers are not supporting other devices on the system, the I/O manager unloads the drivers.
If a driver's device object callback function returns a value for which NT_SUCCESS(status) equals FALSE, the framework notifies the PnP manager, which then attempts to restart the device by requesting the bus driver to reenumerate its devices. Your driver will be reloaded, if it was unloaded.
If your driver calls WdfDeviceSetFailed, it supplies an input argument that determines whether the device will be restarted. The argument values are WdfDeviceFailedAttemptRestart and WdfDeviceFailedNoRestart.
UMDF A UMDF driver must set this value to WdfDeviceFailedNoRestart.
For more information about these argument values, see WDF_DEVICE_FAILED_ACTION. Before a driver's device object callback function returns with a value for which NT_SUCCESS(status) equals FALSE, the callback function can prevent restarts by calling WdfDeviceSetFailed with an input argument of WdfDeviceFailedNoRestart. Otherwise, these callback functions do not have to call WdfDeviceSetFailed.
If, within a short period of time, several consecutive restart attempts fail (because the restarted driver again reports an error), the framework stops trying to restart the device.
If a bus driver's EvtDeviceD0Entry function returns a value for which NT_SUCCESS(status) equals FALSE, the framework might still call the EvtDeviceD0Entry functions of drivers associated with the bus driver's child devices.