Article ID: 2516416 - View products that this article applies to.
A USB device driver is based on the Microsoft Windows Kernel Mode Driver Framework (KMDF) may hang and be unable to be unloaded and reloaded after the USB device is surprise-removed.
This problem may occur if the USB device driver has all of the following characteristics:
Under this configuration, if the USB device is surprise-removed, USB transfers being performed by the USB Continuous Reader will complete with an error such as STATUS_NO_SUCH_DEVICE. If an EvtReadersFailed callback routine is not registered for the USB Continuous Reader, the failed transfers are retried continuously.
Meanwhile, the USB device driver's D0Exit handler may be called to handle the device surprise removal, and call WdfIoTargetStop for the USB Device to stop all pending transfers. If the USB device driver's D0Exit handler does not first call WdfIoTargetStop with a handle to each USB Pipe belonging to the USB Device to stop all pending transfers for each of the device's USB pipes, a deadlock may occur which prevents Windows from completing removal of the device and unloading the device's driver.
In this scenario, there are two bugs in the Microsoft KMDF framework that can cause a WdfIoTargetStop operation for a USB Device to hang while attempting to cancel pending transfers for a USB Continuous Reader:
A KMDF-Based USB device driver can work around these problems by implementing the following solution:
This is the correct implementation for stopping a USB IO Target, and is demonstrated in KMDF-based USB device driver samples included in the Windows Driver Kit for Windows 7, including the USBSamp and OSRUSBFX2 samples.
A fix for this problem is being considered for inclusion in a future version of the Microsoft Windows Kernel Mode Driver Framework (KMDF).
Under some circumstances, it may be possible to reduce the likelihood or frequency of occurrence of this problem by implementing the following functionality in the affected KMDF-Based USB device driver:
For more information on Windows driver development details related to this issue, see the following topics in the Microsoft Windows Driver Kit (WDK) documentation:
WdfIoTargetStop Method (WDK)
Working with USB Pipes (WDK)
WdfUsbTargetPipeConfigContinuousReader Method (WDK)
UsbSamp sample (WDK)
OSRUSBFX2 sample (WDK)
(http://go.microsoft.com/fwlink/?LinkId=151500)for other considerations.
Article ID: 2516416 - Last Review: March 18, 2011 - Revision: 1.0