From: Xiaofan C. <xia...@gm...> - 2011-06-11 06:38:24
|
On Sat, Jun 11, 2011 at 1:04 AM, Tim Roberts <ti...@pr...> wrote: > Hans de Goede wrote: >> >> Not sure what you mean here, but we need for a way for drivers to say >> no to a software caused disconnection. See my usb mass storage device >> which is still mounted getting redirected to a vm example. This cannot >> be reliably done from userspace. Where as it is trivial to do this >> from kernel space. > > FWIW, this is somewhat similar to the Windows shutdown mechanism. When > the system wants to tear down a driver stack for any reason, it sends > down an IRP_MN_QUERY_STOP_DEVICE request. That asks each driver in the > stack "are you ready to stop?" Any driver can veto the request. If a > driver objects, then the system sends IRP_MN_CANCEL_STOP_DEVICE, and > things go back to normal. If all the drivers agree, then > IRP_MN_STOP_DEVICE gets sent, and that's when things really shut down. Are there any timeout mechanism? Is this the reason why sometimes it takes a long time for Windows to shut down? :-) And sometimes Windows hangs during shutting down. It is quite often in the Windows 98SE days but still happens occasionally under XP and then Vista and Win7. > The problem with this mechanism is that there are a vast number of > corner cases and edge conditions. Most existing drivers handle these > requests crudely, in a way that works most of the time, but cracks under > pressure. In KMDF, the state machine that handles plug-and-play state > changes has something like 100 states. (The power management state > machine is much, much worse, but that's a tale for another day.) > -- Xiaofan |