You could think that the semantics of these two basic PNP IRPs should be very clear in the docs and correctly implemented in most drivers. But the real situation seems to be far from this.
A few days ago I raised an issue about the exact semantics in the managed newsgroup. Specifically, I raised the issue if a PNP STOP is (and if should be) an implicit power-down or not; and if a PNP START is (and if should be) *always* an implicit power-up or not.
I made then a little research and the results are almost astonishing. The issue seems to be one of the worst documented in the WDK. The WDK is ambiguous, sometimes almost contradictory and even possibly wrong. Similarly, checking the WDK sources for both illustrative samples and production ones, it seems that most drivers don’t implement them correctly.
The exact power management meaning of PNP start/stop is closely related to the fact that a driver can receive a PNP START in two different situations: One as the initial start-up, and another one after a PNP STOP. And a driver might need to handle both cases in a quite different way. Many drivers seem to be not fully aware about the two different situations. And they seem to be not completely ready to handle both situations correctly.
The unclear documentation of the topic might be the reason for the incorrect implementation on the drivers. Another reason could be that many drivers never realized a full transition from the NT legacy model to the PNP/WDM one. But there was one thing that I couldn’t understand at all:
If many drivers don’t have a robust handling of PNP STOP and (multiple) PNP START IRPs, then why Windows doesn’t frequently crash when the PNP manager performs a rebalance? (I’m far from being a storage expert, but after checking the storage class driver sources, I’m not sure the storage stack can always survive a rebalance).
The answer is probably obvious to some experts, but it wasn’t at all to me, not before the research. The answer is that Win 2k and later (as opposed to Win 98 and Me) will (almost) never perform a rebalance. And then NT drivers are extremely unlikely to get a PNP STOP at all. Let alone that it seems that Windows completely avoids a rebalance for devices that are just peer with critical ones.
This is supposed to change with the multilevel rebalance feature introduced in Vista. But some third party references indicate that this is not enabled in Vista yet. I don’t know if this is true or not (and I would like to hear an answer). The references mention hardware related complications. But I guess that a possible reason for not being enabled and/or implemented in Vista yet, is because it might break many drivers.
My modest conclusion of the research is that I was right about my initial assumptions. A PNP STOP should not be an implicit power down, and a subsequent PNP start should not be an implicit power-up. This is derived from the fact that a resource rebalance should be performed as quickly as possible, and that drivers should succeed a query STOP as much as possible.
It is unlikely that drivers would meet these requirements without proper documentation. And then the chances for realizing multilevel rebalance are small.
Some references:
http://support.microsoft.com/kb/314068
“The description includes an explanation of why many of the devices on your computer seem to use the same IRQ and why Windows XP does not include resource rebalancing.”
http://www.microsoft.com/whdc/system/pnppwr/hotadd/hotplugpci.mspx
“Dynamic configuration will exercise code paths that currently might not be exercised completely in Windows 2000 and Windows XP, so drivers that work on Windows 2000 and Windows XP might fail on later versions of Windows operating systems unless properly implemented.”
http://www.microsoft.com/whdc/system/bus/PCI/multilevel-rebal.mspx
“Handling Stop Semantics
…
Typical driver actions during the stop request should:
…
Keep the device in the D0 state—do not transition the device to a higher Dx state that would cause the hardware context to be lost.”