WdfDeviceSetFailed doesn't remove all the stack

Hi,

I have a WDF kernel driver bus.sys, which has a child - WDF NDIS miniport driver eth.sys.

I wanted to restart all the stack and issued WdfDeviceSetFailed from bus.sys.
bus.sys got unloaded while eth.sys - not, which caused BSOD, because eth.sys proceeded to work over bus.sys.

!devnode <eth.sys> at the time when bus!EvtDeviceD0Exit is called shows

State = DeviceNodeDeletePendingCloses (0x313)
Previous State = DeviceNodeRemovePendingCloses (0x311)

but eth!MPHalt is never called.

Is it an expected behavior ?
Is there a way to cause first to remove the child and then - the father device ?

Thank you.</eth.sys>

Marking the parent as failed should remove the child device first. What is the state of the parent when your child is in this state? What is the root cause of the bugcheck, what went wrong?

d

debt from my phone


From: xxxxx@mellanox.co.il
Sent: 2/15/2012 6:03 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] WdfDeviceSetFailed doesn’t remove all the stack

Hi,

I have a WDF kernel driver bus.sys, which has a child - WDF NDIS miniport driver eth.sys.

I wanted to restart all the stack and issued WdfDeviceSetFailed from bus.sys.
bus.sys got unloaded while eth.sys - not, which caused BSOD, because eth.sys proceeded to work over bus.sys.

!devnode <eth.sys> at the time when bus!EvtDeviceD0Exit is called shows

State = DeviceNodeDeletePendingCloses (0x313)
Previous State = DeviceNodeRemovePendingCloses (0x311)

but eth!MPHalt is never called.

Is it an expected behavior ?
Is there a way to cause first to remove the child and then - the father device ?

Thank you.


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</eth.sys>

Thank you, Doron.

The state before issuing WdfDeviceSetFailed (from !wdfdrivreinfo):
bus: Pnp/Power State: WdfDevStatePnpStarted, WdfDevStatePowerD0, WdfDevStatePwrPolStarted
eth: Pnp/Power State: WdfDevStatePnpStarted, WdfDevStatePowerD0BusWakeOwner, WdfDevStatePwrPolStartingSucceeded

Both drivers are working OK.
At some moment bus driver calls WdfDeviceSetFailed() on itself.
Neither eth!MPHalt, nor eth!HandleSetPowerOid is not called.
bus!EvtDeviceD0Exit is called and the state now:
bus: Pnp/Power State: WdfDevStatePnpFailedIoStarting, WdfDevStatePowerGotoD3Stopped, WdfDevStatePwrPolStopping
eth: Pnp/Power State: WdfDevStatePnpFailedWaitForRemove, WdfDevStatePowerStopped, WdfDevStatePwrPolStopped

If bus driver waits for releasing interfaces, taken from eth, it’s - *forever*.
If it proceeds and exits, BSOD happens, because eth driver continues to work and uses bus resources which are already released.

Is there a way to collect the trace of all PnP and Power IRPs, sent to the selected drivers ?
What more info could I provide ?

Seems like I found the problem - child device din’t have WdfSurpriseRemoval set.
But I ran into another one: WdfDeviceSetFailed() removes the driver stack, but fails to restart it.
bus.sys device node is marked with CM_PROB_FAILED_POST_START.
It happens after removal of bus.sys and there is no *visible* attempt of restarting, meaning neither DriverEntry, nor AddDevice or other callbacks are called.
pnpdtest(SurproseRemoval) on bus.sys works OK.
Is there a way to find out, why pci.sys fails the restart ?

Leonid,

You can get trace output from PCI by editing nt!kd_pci_mask in the debugger
and running a checked build of PCI.sys. It will tell you while it failed.

Jake Oshins
Windows Kernel Team

This post implies no warrantees and confers no rights.

wrote in message news:xxxxx@ntdev…

Seems like I found the problem - child device din’t have WdfSurpriseRemoval
set.
But I ran into another one: WdfDeviceSetFailed() removes the driver stack,
but fails to restart it.
bus.sys device node is marked with CM_PROB_FAILED_POST_START.
It happens after removal of bus.sys and there is no *visible* attempt of
restarting, meaning neither DriverEntry, nor AddDevice or other callbacks
are called.
pnpdtest(SurproseRemoval) on bus.sys works OK.
Is there a way to find out, why pci.sys fails the restart ?