USB Device Driver Restart Time

Experts,

I wonder what controls how much time the driver for a given USB device has for shutting down before another instance of the same device is launched by the PnP Manager. The scenarios cover just a very quick unplug/plugin, done either manually or via GPIO triggered internal device power off / on, or a resume from hibernation once Windows discovers that a device lost power and needs to be re-enumerated. It varies for me on multiple platforms from seconds to 9 milliseconds. To be precise, I’m measuring an interval between the IRP_MN_SURPRISE_REMOVAL (the first indication that something is going on) and the next AddDevice(). Really need to avoid having a second instance started for a variety of reasons. There is no way I can stop a large enough device tree running off this USB device in just 9 milliseconds. Is that something hopefully configurable in the BIOS, Plug and Play service or the USB bus driver? Would like to afford myself a complete second or so if possible. :slight_smile:

Many thanks for your insights,

Ilya Faenson
Rockville, MD USA

Nothing like that exists.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Wednesday, June 22, 2011 12:08 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] USB Device Driver Restart Time

Experts,

I wonder what controls how much time the driver for a given USB device has for shutting down before another instance of the same device is launched by the PnP Manager. The scenarios cover just a very quick unplug/plugin, done either manually or via GPIO triggered internal device power off / on, or a resume from hibernation once Windows discovers that a device lost power and needs to be re-enumerated. It varies for me on multiple platforms from seconds to 9 milliseconds. To be precise, I’m measuring an interval between the IRP_MN_SURPRISE_REMOVAL (the first indication that something is going on) and the next AddDevice(). Really need to avoid having a second instance started for a variety of reasons. There is no way I can stop a large enough device tree running off this USB device in just 9 milliseconds. Is that something hopefully configurable in the BIOS, Plug and Play service or the USB bus driver? Would like to afford myself a complete second or so if possible. :slight_smile:

Many thanks for your insights,

Ilya Faenson
Rockville, MD USA


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Appreciate a prompt response, Doron. So there are no alternatives to starting a second device tree instance in this case? Familiar to you Microsoft’s own device stack fails on this “9 millisecond” platform too: this is not limited to our own drivers. Network stack, for example, is very slow in unbinding / shutting down, so there is often trouble when a network device is on a branch.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]
On Behalf Of xxxxx@microsoft.com Sent: Wednesday, June 22, 2011 12:15 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] USB Device Driver Restart Time

Nothing like that exists.

d

I’d say that NOT creating the second instance is a bug, not a feature :wink:

Think about it. Device disconnect has to lead to surprise removal and stack destroy. Neither HC nor OS can verify that the new device is the same. Even within 9 ms it is possible to connect new device (using a hw switch).

Michal

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-460901-
xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Wednesday, June 22, 2011 9:33 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] USB Device Driver Restart Time

Appreciate a prompt response, Doron. So there are no alternatives to
starting a second device tree instance in this case? Familiar to you
Microsoft’s own device stack fails on this “9 millisecond” platform too: this is
not limited to our own drivers. Network stack, for example, is very slow in
unbinding / shutting down, so there is often trouble when a network device
is on a branch.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]
On Behalf Of xxxxx@microsoft.com Sent: Wednesday, June 22, 2011 12:15
PM
To: Windows System Software Devs Interest List
Subject: [ntdev] USB Device Driver Restart Time

Nothing like that exists.

d


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

NOTE: The information in this message is intended for the personal and confidential use of the designated recipient(s) named above. To the extent the recipient(s) is/are bound by a non-disclosure agreement, or other agreement that contains an obligation of confidentiality, with AuthenTec, then this message and/or any attachments shall be considered confidential information and subject to the confidentiality terms of that agreement. If the reader of this message is not the intended recipient named above, you are notified that you have received this document in error, and any review, dissemination, distribution or copying of this message is strictly prohibited. If you have received this document in error, please delete the original message and notify the sender immediately.
Thank You!
AuthenTec, Inc. http://www.authentec.com/

Michal,

Both HC and OS know it’s the same device. This particular device features the same USB serial number, for example. The AddDevice() is being called after USB enumeration has completed again. No install of the additional instance is involved. Yes, the device stack is being destroyed completely upon removal but it just takes longer than 9 milliseconds.

This extremely low measurement is from the resume after hibernation test, by the way. I’ve never seen anything that rapid with a hardware switch but fingers quicker than mine could indeed be pretty fast. :slight_smile:

Thanks,
-Ilya

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]
On Behalf Of xxxxx@authentec.com
Sent: Wednesday, June 22, 2011 14:04 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] USB Device Driver Restart Time

I’d say that NOT creating the second instance is a bug, not a feature :wink:

Think about it. Device disconnect has to lead to surprise removal and stack destroy. Neither HC nor OS can verify that the new device is the same. Even within 9 ms it is possible to connect new device (using a hw switch).

Michal

Ilya,

OS would have to cache all the device info (descriptors) and compare. Still, the device may not be in the same state which’d make confusion for software already using the existing device. In our case communication session would be broken, for some devices fw patches disappearing etc. Surprise removal is the only way how everybody can get info about disconnect and reconnect.

Hardware switch can be software driven :wink:

Michal

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-460930-
xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Wednesday, June 22, 2011 11:33 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] USB Device Driver Restart Time

Michal,

Both HC and OS know it’s the same device. This particular device features
the same USB serial number, for example. The AddDevice() is being called
after USB enumeration has completed again. No install of the additional
instance is involved. Yes, the device stack is being destroyed completely
upon removal but it just takes longer than 9 milliseconds.

This extremely low measurement is from the resume after hibernation test,
by the way. I’ve never seen anything that rapid with a hardware switch but
fingers quicker than mine could indeed be pretty fast. :slight_smile:

Thanks,
-Ilya

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]
On Behalf Of xxxxx@authentec.com
Sent: Wednesday, June 22, 2011 14:04 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] USB Device Driver Restart Time

I’d say that NOT creating the second instance is a bug, not a feature :wink:

Think about it. Device disconnect has to lead to surprise removal and stack
destroy. Neither HC nor OS can verify that the new device is the same. Even
within 9 ms it is possible to connect new device (using a hw switch).

Michal


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

NOTE: The information in this message is intended for the personal and confidential use of the designated recipient(s) named above. To the extent the recipient(s) is/are bound by a non-disclosure agreement, or other agreement that contains an obligation of confidentiality, with AuthenTec, then this message and/or any attachments shall be considered confidential information and subject to the confidentiality terms of that agreement. If the reader of this message is not the intended recipient named above, you are notified that you have received this document in error, and any review, dissemination, distribution or copying of this message is strictly prohibited. If you have received this document in error, please delete the original message and notify the sender immediately.
Thank You!
AuthenTec, Inc. http://www.authentec.com/

Michal,

Good points all… Chances are I was not clear enough. I don’t mind the surprise removal at all. In fact, just as you say, I do need it for all the relevant reasons. I’m just asking for a few more milliseconds to process the removal before another instance is started.

I’ve actually done something of that sort in one of my bus drivers many moons ago. Once the bus needed to plug a new PDO in at an address where the removal was taking place, the bus driver waited some to let that removal complete. If the removal was still not done upon a certain timeout (basically never in operation), the PDO was placed at a new unique address which was undesirable. I hope USB bus driver could be that nice too.

Thanks,
-Ilya

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]
On Behalf Of xxxxx@authentec.com
Sent: Wednesday, June 22, 2011 14:40 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] USB Device Driver Restart Time

Ilya,

OS would have to cache all the device info (descriptors) and compare. Still, the device may not be in the same state which’d make confusion for software already using the existing device. In our case communication session would be broken, for some devices fw patches disappearing etc. Surprise removal is the only way how everybody can get info about disconnect and reconnect.

Hardware switch can be software driven :wink:

Michal

Ilya,

Ah, now I understand. Your intention wasn’t clear to me which could be my reading :slight_smile:

Well, I’m afraid you can’t count with anything and have to solve it yourself. Quick USB devices reconnects are pain; we created a hw/sw tool just for testing it and in many times saw running remove/add new paths in parallel (never measured times between entry points). Older OS versions crashed often with this test, at least this improved.

I presume you know it but removal finish can be blocked by opened device handle and two device instances can live forever.

Michal

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-460941-
xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Thursday, June 23, 2011 12:04 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] USB Device Driver Restart Time

Michal,

Good points all… Chances are I was not clear enough. I don’t mind the
surprise removal at all. In fact, just as you say, I do need it for all the relevant
reasons. I’m just asking for a few more milliseconds to process the removal
before another instance is started.

I’ve actually done something of that sort in one of my bus drivers many
moons ago. Once the bus needed to plug a new PDO in at an address where
the removal was taking place, the bus driver waited some to let that removal
complete. If the removal was still not done upon a certain timeout (basically
never in operation), the PDO was placed at a new unique address which was
undesirable. I hope USB bus driver could be that nice too.

Thanks,
-Ilya

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]
On Behalf Of xxxxx@authentec.com
Sent: Wednesday, June 22, 2011 14:40 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] USB Device Driver Restart Time

Ilya,

OS would have to cache all the device info (descriptors) and compare. Still,
the device may not be in the same state which’d make confusion for
software already using the existing device. In our case communication
session would be broken, for some devices fw patches disappearing etc.
Surprise removal is the only way how everybody can get info about
disconnect and reconnect.

Hardware switch can be software driven :wink:

Michal


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

NOTE: The information in this message is intended for the personal and confidential use of the designated recipient(s) named above. To the extent the recipient(s) is/are bound by a non-disclosure agreement, or other agreement that contains an obligation of confidentiality, with AuthenTec, then this message and/or any attachments shall be considered confidential information and subject to the confidentiality terms of that agreement. If the reader of this message is not the intended recipient named above, you are notified that you have received this document in error, and any review, dissemination, distribution or copying of this message is strictly prohibited. If you have received this document in error, please delete the original message and notify the sender immediately.
Thank You!
AuthenTec, Inc. http://www.authentec.com/

> I presume you know it but removal finish can be blocked by opened device handle
and two device instances can live forever.

+1
No way for a driver to forcibly close pending usermode handles.
Kind of “priority inversion” situation when any app can interfere with operation of PnP.
This is an old, er… feature - and now we probably can expect it will stay in Win8.

/* I only wish the safelyremove.com & lockhunter.com guy to prosper and keep the excellent work going. */

Regards,
–pa

Appreciate your insights, Michal and Pavel.

I am certainly aware of the open handles issue (track them pretty well by now) but it is not a concern in this case. Even if there are no open handles at all, the device tree can’t shut down in 9 milliseconds.

Thanks,
-Ilya

Ilya, so what exactly is the problem? Your device has a serial number, thus the system fails to enumerate a second instance? or it crashes ?

–pa

xxxxx@fastmail.fm wrote:

Ilya, so what exactly is the problem? Your device has a serial number, thus the system fails to enumerate a second instance? or it crashes ?

I believe he said the system creates a second instance while the first
is still alive, and their driver isn’t fully prepared to handle that.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.