More for the archives than for Cliff (since it was #1 below for him),
another cause could be the device’s coinstaller (esp. if it’s one built
into windows) requesting a restart of the device. This is very common
the first time a storage device is seen by the system.
.
-----Original Message-----
From: Doron Holan
Sent: Wednesday, January 19, 2005 11:14 PM
Subject: RE: Why is Windows “restarting” my device
-
are your children marked as raw? If so, they will be started and
then pnp will try to find a match, resulting in another start
-
what are you returing for the device state in handling
IRP_MN_QUERY_PNP_DEVICE_STATE? If the right bits are set, this can
cause a restart, but that is usually start->stop->start
-
relying on the pdo to start should not be a part of your device.
There are so many things that can fail in the interim, including pnp not
install a dirver for the pdo. If the pdo is marked as raw, the pnp
install part is less of a problem. Things that can fail: failure to
allocate a device object, failure to allocate a device relations,
failure to allocate and return an set of hw IDs asked for, failure to
allocate a devnode in the kernel, etc etc. I have written a stack like
this and attempted to do the wait for start thing, it doesn’t work in
the end. Instead, have the PDO you enumerate register a device
interface. You can be notified of the interface arrival if the device
is successfully started. To differentiate between different interfaces,
you can set a property when you ask for enumeration and then ask for
that property when the interface arrives (or look for it in the devnode
(which the driver wrote to)).
d
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Cliff Russell
Sent: Wednesday, January 19, 2005 9:15 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Why is Windows “restarting” my device
I have a Bus driver for a virtual device. One operation that happens
frequently is the currently enumerated devices are replaced with new
devices. The new devices are reported when I receive
IRP_MJ_PNP/IRN_MN_DEVICE_RELATIONS(BusRelations) and the old ones are
not. The old devices receive IRP_MJ_PNP/IRN_MN_SURPRISE_REMOVAL
notifications . This operation is triggered by an IOCTL from my config
app. The driver handles all this, and it all works quite nicely…
Except, sometimes (maybe even always) the new devices are “restarted”.
Shortly after I get the START_DEVICE notification I receive an
IRP_MN_REMOVE_DEVICE, followed by a bunch of IRP_MN_QUERY…s, and
another IRP_MN_START_DEVICE.
Before I could only speculate that the devices were being restarted, but
this was sort of confirmed when I set a break point and saw
PiRestartDevice in the stack.
So, some questions:
- Why would my device be restarted?
- How can I prevent my device from being restarted?
- What’s to stop my device from being restarted a third time (or more
times)?
- Or, is it safe to assume that my devices will always be started then
restarted?
The reason I ask this is because I am tracking down a couple bugs in my
driver and they seem to be related to accessing the device before I get
the second start message. Sometimes everything works fine other times I
see some weird behavior. The last thing that the IOCTL from my config
app does, is it wait for all the devices to be started (the device
extension has an event that I wait on). But, waiting on this event is
useless. It’s really the second START_DEVICE message that I want to wait
for.
(As I was typing this email I modified the driver to wait for the second
start message. Ever thing seems to work ok and my problems go away, but
it just doesn’t sit right with me. It really doesn’t seem like the right
thing to do.)
I’ve seen the side effect of this issue on Win2k (SP4) and WinXP (SP1
SP2) but I’ve only poked around with a debugger on WinXP.
–
Cliff
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com