KMDF Stuck Device

I have a bus driver that creates virtual devices. Once in a while a
device gets stuck…(i.e gone from device manager but not gone from a
system perspective). Here is the dump from WinDBG. Its stuck in
WdfDevStatePnpFailedWaitForRemove.

My question is two part:

  1. How does this happen?
  2. What can I do to recover from this?

!wdfkd.WDFDEVICE 0x7cfb9820

Dumping WDFDEVICE 0x7cfb9820

=================================

WDM PDEVICE_OBJECTs: self 83084d28

Pnp state: 12e ( WdfDevStatePnpFailedWaitForRemove )

Power state: 315 ( WdfDevStatePowerStopped )

Power Pol state: 563 ( WdfDevStatePwrPolStopped )

Parent WDFDEVICE 7cfc9bf0

Parent states:

Pnp state: 119 ( WdfDevStatePnpStarted )

Power state: 307 ( WdfDevStatePowerD0 )

Power Pol state: 565 ( WdfDevStatePwrPolStarted )

No pended pnp or power irps

Thanks

Pankaj

There is most likely an open pointer or handle reference on the device
object.

On Nov 27, 2007 6:18 PM, Pankaj Garg wrote:

> I have a bus driver that creates virtual devices. Once in a while a
> device gets stuck?.(i.e gone from device manager but not gone from a
> system perspective). Here is the dump from WinDBG. Its stuck in
> WdfDevStatePnpFailedWaitForRemove.
>
> My question is two part:
>
> 1. How does this happen?
> 2. What can I do to recover from this?
>
>
>
>
>
> !wdfkd.WDFDEVICE 0x7cfb9820
>
>
>
> Dumping WDFDEVICE 0x7cfb9820
>
> =================================
>
>
>
> WDM PDEVICE_OBJECTs: self 83084d28
>
>
>
> Pnp state: 12e ( WdfDevStatePnpFailedWaitForRemove )
>
> Power state: 315 ( WdfDevStatePowerStopped )
>
> Power Pol state: 563 ( WdfDevStatePwrPolStopped )
>
>
>
> Parent WDFDEVICE 7cfc9bf0
>
> Parent states:
>
> Pnp state: 119 ( WdfDevStatePnpStarted )
>
> Power state: 307 ( WdfDevStatePowerD0 )
>
> Power Pol state: 565 ( WdfDevStatePwrPolStarted )
>
>
>
> No pended pnp or power irps
>
>
>
>
>
> Thanks
>
> Pankaj
>
> —
> 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
>


Mark Roddy

The PDO is waiting for the remove irp to show up. either the PDO failed the start irp b/c one of your power up routines returned !NT_SUCCESS or you successfully started and then the PDO was reported as failed or missing. Can you rerun !wdfdevice and specify 0xF as the flags and send the output? For instance !wdfdevice 0x7cfb9820 0xF. This will show the history of the pnp state machine which should be able to indicate if it was a failed start or a s.r.

d

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Pankaj Garg
Sent: Tuesday, November 27, 2007 3:18 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] KMDF Stuck Device

I have a bus driver that creates virtual devices. Once in a while a device gets stuck…(i.e gone from device manager but not gone from a system perspective). Here is the dump from WinDBG. Its stuck in WdfDevStatePnpFailedWaitForRemove.
My question is two part:

  1. How does this happen?
  2. What can I do to recover from this?

!wdfkd.WDFDEVICE 0x7cfb9820

Dumping WDFDEVICE 0x7cfb9820

WDM PDEVICE_OBJECTs: self 83084d28

Pnp state: 12e ( WdfDevStatePnpFailedWaitForRemove )
Power state: 315 ( WdfDevStatePowerStopped )
Power Pol state: 563 ( WdfDevStatePwrPolStopped )

Parent WDFDEVICE 7cfc9bf0
Parent states:
Pnp state: 119 ( WdfDevStatePnpStarted )
Power state: 307 ( WdfDevStatePowerD0 )
Power Pol state: 565 ( WdfDevStatePwrPolStarted )

No pended pnp or power irps

Thanks
Pankaj


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

I create virtual USB devices using my Bus Driver. I am able to get
explorer to recognize flash drives and I can do data transfers.

However when I’m in the middle of a transfer and if the device is
deleted from the BUS, the stack should get cleaned up, i.e. explorer
should get a notification that device went away and should close its
handle.

It does that for regular USB devices.

In my case it keeps a handle open and so my PDO is stuck unless I go and
click on dialog boxes thrown up by explorer and kill it. As soon as I
kill it, everything gets cleaned up.

Question is what do I have to do in my BUS driver to support this kinda
scenario? Is there an interface I need to implement? Is there some kind
of flag or something I’m missing.

-pankaj

Well, first you have to report the PDO as missing. I am assuming that you are doing that part. Are you also purging the WDFQUEUEs? Perhaps explorer will close the handle when it sees a failed i/o.

d

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Pankaj Garg
Sent: Wednesday, November 28, 2007 9:36 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] KMDF Stuck Device

I create virtual USB devices using my Bus Driver. I am able to get explorer to recognize flash drives and I can do data transfers.
However when I’m in the middle of a transfer and if the device is deleted from the BUS, the stack should get cleaned up, i.e. explorer should get a notification that device went away and should close its handle.
It does that for regular USB devices.
In my case it keeps a handle open and so my PDO is stuck unless I go and click on dialog boxes thrown up by explorer and kill it. As soon as I kill it, everything gets cleaned up.

Question is what do I have to do in my BUS driver to support this kinda scenario? Is there an interface I need to implement? Is there some kind of flag or something I’m missing.

-pankaj


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

Doron,

I am reporting the PDO missing. Eveyrthing works ok in all other
scenarios. As soon as I either kill explorer or click on c:\ , it frees
that handle for my device.

I just tried both PurgeQueue calls and it didn’t make a difference.

I’m guessing explorer subscribes to device arrival and removal
notifications and should clean up as soon as it sees this device going
away.

Do I have to do anything special to generate those messages?

Thanks

Pankaj


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Wednesday, November 28, 2007 9:47 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] KMDF Stuck Device

Well, first you have to report the PDO as missing. I am assuming that
you are doing that part. Are you also purging the WDFQUEUEs? Perhaps
explorer will close the handle when it sees a failed i/o.

d

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Pankaj Garg
Sent: Wednesday, November 28, 2007 9:36 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] KMDF Stuck Device

I create virtual USB devices using my Bus Driver. I am able to get
explorer to recognize flash drives and I can do data transfers.

However when I’m in the middle of a transfer and if the device is
deleted from the BUS, the stack should get cleaned up, i.e. explorer
should get a notification that device went away and should close its
handle.

It does that for regular USB devices.

In my case it keeps a handle open and so my PDO is stuck unless I go and
click on dialog boxes thrown up by explorer and kill it. As soon as I
kill it, everything gets cleaned up.

Question is what do I have to do in my BUS driver to support this kinda
scenario? Is there an interface I need to implement? Is there some kind
of flag or something I’m missing.

-pankaj


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


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

No, the bus driver does not need to do anything to generate device interface arrival/departure notifications. It is up to the driver which registered the interface (typically the FDO) to set the interface state to false at the appropriate time. My point is that perhaps explorer is using a combination of interface state change + i/o completion before it closes the handle and that the normal usb bus driver causes this io to complete in the s.r. path while your bus driver does not.

d

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Pankaj Garg
Sent: Wednesday, November 28, 2007 10:40 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] KMDF Stuck Device

Doron,

I am reporting the PDO missing. Eveyrthing works ok in all other scenarios. As soon as I either kill explorer or click on c:\ , it frees that handle for my device.
I just tried both PurgeQueue calls and it didn’t make a difference.
I’m guessing explorer subscribes to device arrival and removal notifications and should clean up as soon as it sees this device going away.
Do I have to do anything special to generate those messages?

Thanks
Pankaj


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Wednesday, November 28, 2007 9:47 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] KMDF Stuck Device

Well, first you have to report the PDO as missing. I am assuming that you are doing that part. Are you also purging the WDFQUEUEs? Perhaps explorer will close the handle when it sees a failed i/o.

d

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Pankaj Garg
Sent: Wednesday, November 28, 2007 9:36 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] KMDF Stuck Device

I create virtual USB devices using my Bus Driver. I am able to get explorer to recognize flash drives and I can do data transfers.
However when I’m in the middle of a transfer and if the device is deleted from the BUS, the stack should get cleaned up, i.e. explorer should get a notification that device went away and should close its handle.
It does that for regular USB devices.
In my case it keeps a handle open and so my PDO is stuck unless I go and click on dialog boxes thrown up by explorer and kill it. As soon as I kill it, everything gets cleaned up.

Question is what do I have to do in my BUS driver to support this kinda scenario? Is there an interface I need to implement? Is there some kind of flag or something I’m missing.

-pankaj


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


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


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