I’ve noticed something strange which I think is relevant. I think this
is related to this thread
http://www.osronline.com/ShowThread.cfm?link=150915 from a few years
ago.
On hibernate, I see the following IRP_MN_SET_POWER IRP’s on my bus
driver:
PDO: Type = DevicePowerState, State = PowerDeviceD3, ShutdownType =
Hibernate
PDO: Type = SystemPowerState, State = PowerSystemHibernate
FDO: Type = SystemPowerState, State = PowerSystemHibernate
FDO: Type = DevicePowerState, State = PowerDeviceD3, ShutdownType =
Hibernate
That is pretty much as expected, but as per the thread in the above
link, WDF doesn’t behave correctly when it gets the power IRP’s in
Device-then-System order, it relies on getting them in
System-then-Device order. I can work around that though.
On resume however, I see:
FDO: Type = SystemPowerState, State = PowerSystemWorking
PDO: Type = DevicePowerState, State = PowerDeviceD0
FDO: Type = DevicePowerState, State = PowerDeviceD0
The SystemPowerState IRP never arrives on the PDO to set the state to
PowerSystemWorking. WDF isn’t going to like that based on what I know
about its internal state machine(s). The first and second hibernation
resumes seem to be okay without receiving the SystemPowerState, but on
the third resume it gets stuck. What I’ve seen before when I looked at
the power IRP that is ‘stuck’ on resume from hibernation is this:
d> !irp 81f94ad0
Irp is active with 5 stacks 1 is current (= 0x81f94b40)
No Mdl: No System Buffer: Thread 00000000: Irp stack trace. Pending
has been returned
cmd flg cl Device File Completion-Context
[f, 0] 0 e1 820bf880 00000000 f889fa4c-81f864fc Success Error
Cancel pending
\Driver\XenVbd IrpSys
Args: 81e4ade4 00000000 00000000 00000000
[16, 2] 0 e1 81e4aab8 00000000 f8727554-00000000 Success Error
Cancel pending
\Driver\Disk PartMgr!PmPowerCompletion
Args: 00000003 00000001 00000001 00000003
[16, 2] 0 e1 81feae08 00000000 80522f24-ba5bf80a Success Error
Cancel pending
\Driver\PartMgr nt!PopCompleteRequestIrp
Args: 00000003 00000001 00000001 00000003
[0, 0] 0 0 81feae08 00000000 00000000-00000000
\Driver\PartMgr
Args: 820bf880 00000002 00000001 00000000
[0, 0] 0 0 00000000 00000000 00000000-00000000
Args: 80559ce0 80559ce0 81f94ad0 00000000
Somewhere along the way the IRP_MN_SET_POWER IRP gets changed to a
IRP_MJ_SCSI IRP with a START_STOP_UNIT CDB. When pci.sys is the PDO I
guess it doesn’t much care, but my WDF bus driver isn’t happy.
Now this is Windows XP and scsiport, both of which are essentially
retired, so I’m pretty much looking for any sort of hack to sort this
out. Is it possible to inject a PowerSystemWorking IRP somewhere and
restore WDF’s state to what it should be? Would WDF’s self-managed-io
help anything along here?
Thanks
James