HI,

MYusb function driver starts an i/o operation only after the earler one
has completed i.e. the USBD has only one IRP pending at any time. Do I need
to support IRP cancellation for this scenario.
What I would like to know what happens if the user yanks out the usb device
while the IRP is being procesed by the bus driver. The active IRP gets
completed with an error status or the IRP remains pending. Does my device
object get deleted? I guess no because it still has one reference to it?

What happns if the user yanks out the device and puts it back again in a
matter of few seconds. What I sometimes see that I now have two device
objects which is something I don't want as I support only one device at a
time. What should I do to avoid have two device objects. Does cancelling
IRPs when surprise removal happens helps to solve this problem.

Please guide me to any KB article on the behavior of USBD upon surprise
removal and and an IRP active at the same time. I tried to find an exact
answer but couldn't get it in DDK.

Regds.
Nitin

RE: USBD behavior on surprise removal by pavel_a

pavel_a
Wed May 17 14:31:01 CDT 2006

"tsindia" wrote:
> HI,
>
> MYusb function driver starts an i/o operation only after the earler one
> has completed i.e. the USBD has only one IRP pending at any time. Do I need
> to support IRP cancellation for this scenario.
> What I would like to know what happens if the user yanks out the usb device
> while the IRP is being procesed by the bus driver. The active IRP gets
> completed with an error status or the IRP remains pending. Does my device
> object get deleted? I guess no because it still has one reference to it?
>
> What happns if the user yanks out the device and puts it back again in a
> matter of few seconds. What I sometimes see that I now have two device
> objects which is something I don't want as I support only one device at a
> time. What should I do to avoid have two device objects. Does cancelling
> IRPs when surprise removal happens helps to solve this problem.
>
> Please guide me to any KB article on the behavior of USBD upon surprise
> removal and and an IRP active at the same time. I tried to find an exact
> answer but couldn't get it in DDK.
>
> Regds.
> Nitin

Check the WinHEC & DevCon 2005, 2004 papers available on WHDC site;
there are some guidelines for USB drivers.
Baisically, on surprise removal you should cancel all pending requests,
and the bus stack also can complete some requests on it's own, with
proper status code. You should be prepared to this.

Regards,
--PA

Re: USBD behavior on surprise removal by Tim

Tim
Fri May 19 00:48:51 CDT 2006

"tsindia" <tsindia@newsgroups.nospam> wrote:
>
> MYusb function driver starts an i/o operation only after the earler one
>has completed i.e. the USBD has only one IRP pending at any time. Do I need
>to support IRP cancellation for this scenario.
>What I would like to know what happens if the user yanks out the usb device
>while the IRP is being procesed by the bus driver. The active IRP gets
>completed with an error status or the IRP remains pending.

The active IRP gets completed with an error status. Your driver gets a
surprise removal notification.

>Does my device object get deleted? I guess no because it still has one reference to it?

Not until the last application with an open handle closes it.

> What happns if the user yanks out the device and puts it back again in a
>matter of few seconds. What I sometimes see that I now have two device
>objects which is something I don't want as I support only one device at a
>time. What should I do to avoid have two device objects.

You need to return an error to the application, and the application needs
to close the handle.

>Does cancelling IRPs when surprise removal happens helps to solve this problem.

No.
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.