This is a mirror of official site: http://jasper-net.blogspot.com/

How to recover from USB errors ?

| Sunday, August 29, 2010
A USB client driver sends in and out transfers to its device. At times transfers to/from the device fail and the client driver needs to recover from the error condition. Failure may be due to a legitimate error response from the USB device (e.g. transfer failed with status USBD_STATUS_STALL_PID) or it may be unexpected (e.g. transfer failed with status USBD_STATUS_XACT_ERROR).

Various articles do talk about the recovery process, however they are not comprehensive. Thus it can be confusing for a client driver writer. Some examples are:

USB Transfer May Fail Due to Transaction Error
USB Device I/O
URB_HEADER Structure  

In this blog series, I will provide clear guidelines on the steps a client driver should take to recover from USB transfer errors. This blog will give you an overview of the recovery process, and the future ones will describe the recovery steps needed by a WDM client driver, a WDF client driver and a WinUSB driver.

The Recovery Process:
When a transfer to/from the device fails, the corresponding pipe transitions into halted state. No further transfers for that pipe are processed until the error condition on the pipe is cleared. A client driver can do the following types of error recovery:

(In case the error is due to device having disconnected, client driver should not invoke the following error recovery)

Reset pipe: clears the error condition on the pipe on which the error occurred
Reset port: resets the USB device thereby bringing it to a clean state
Cycle Port: resets the USB device and in addition performs PNP re-enumeration of the client driver stack

Usually it is a good idea to do a reset pipe first, and if the problem persists do the reset port or cycle port.

Note that some of the operations mentioned below can only be executed at PASSIVE LEVEL, thus your driver may need to queue a work item.

Read more: Microsoft Windows USB Core Team Blog

Posted via email from .NET Info

0 comments: