Hi,

I have a typical problem of IRP_MN_REMOVE not getting called. The
scenario
is like this.

We have a virtual USB bus which creates PDOs for each simulated
device. We
could simulate a mass storage device. We can 'unplug' it (from an
application) by means of our bus driver sending
IoInvalidateDeviceRelations
and then reporting the device as missing. We subsequently get
REMOVE_DEVICE
for the PDO and it successfully unloads.

However when we are copying some data to the device, if we 'unplug' it
while
still copy is in progress then we don't get the IRP_MN_REMOVE_DEVICE
from
the PNP manager.
We see that there are no pending requests (IRPs) with us and we have
successfully completed IRP_MN_SURPRISE_REMOVAL, still there is no
REMOVE.

After dumping the devobj I get the following trace :

0: kd> !devobj 852fe9f0
Device object (852fe9f0) is for:
00000089
\Driver\VUSB DriverObject 854cc858
Current Irp 00000000 RefCount 0 Type 0000002a Flags 00003040
Dacl e2430954 DevExt 852feaa8 DevObjExt 852fec08 DevNode 85538ee8
ExtensionFlags (0x00000008) DOE_REMOVE_PROCESSED
AttachedDevice (Upper) 8527b030 \Driver\USBSTOR
Device queue is not busy.

This tells that there are no open references as well. I am also
doubtful about "DOE_REMOVE_PROCESSED". Does this mean that system
thinks that it has sent me IRP_MN_REMOVE_DEVICE ??

Any hints please?
Thanks,

Regards,
Abhijit

IRP_MN_REMOVE not getting called by J

J
Tue Oct 16 09:46:28 PDT 2007

AM> This tells that there are no open references as well.

It also tells you something else.

AM> Any hints please?

Here's one:

AM> AttachedDevice (Upper) 8527b030 \Driver\USBSTOR


Re: IRP_MN_REMOVE not getting called by Doron

Doron
Tue Oct 16 09:39:42 PDT 2007

as long as there is an open handle, you will not get the remove device and
will be stuck in the surprise removed state. !object on your device object
and usbstor will tell you the handle count

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"Abhijit Mmirajkar" <abhijit.mirajkar@gmail.com> wrote in message
news:1192547397.878393.138270@y27g2000pre.googlegroups.com...
> Hi,
>
> I have a typical problem of IRP_MN_REMOVE not getting called. The
> scenario
> is like this.
>
> We have a virtual USB bus which creates PDOs for each simulated
> device. We
> could simulate a mass storage device. We can 'unplug' it (from an
> application) by means of our bus driver sending
> IoInvalidateDeviceRelations
> and then reporting the device as missing. We subsequently get
> REMOVE_DEVICE
> for the PDO and it successfully unloads.
>
> However when we are copying some data to the device, if we 'unplug' it
> while
> still copy is in progress then we don't get the IRP_MN_REMOVE_DEVICE
> from
> the PNP manager.
> We see that there are no pending requests (IRPs) with us and we have
> successfully completed IRP_MN_SURPRISE_REMOVAL, still there is no
> REMOVE.
>
> After dumping the devobj I get the following trace :
>
> 0: kd> !devobj 852fe9f0
> Device object (852fe9f0) is for:
> 00000089
> \Driver\VUSB DriverObject 854cc858
> Current Irp 00000000 RefCount 0 Type 0000002a Flags 00003040
> Dacl e2430954 DevExt 852feaa8 DevObjExt 852fec08 DevNode 85538ee8
> ExtensionFlags (0x00000008) DOE_REMOVE_PROCESSED
> AttachedDevice (Upper) 8527b030 \Driver\USBSTOR
> Device queue is not busy.
>
> This tells that there are no open references as well. I am also
> doubtful about "DOE_REMOVE_PROCESSED". Does this mean that system
> thinks that it has sent me IRP_MN_REMOVE_DEVICE ??
>
> Any hints please?
> Thanks,
>
> Regards,
> Abhijit
>


Re: IRP_MN_REMOVE not getting called by Abhijit

Abhijit
Wed Oct 17 08:01:03 PDT 2007

Thanks Doron, but the !object also reveals that there are no open
handles ! There is some entry under 'PointerCount', but that number is
also there when it successfully unloads when no file transfer is going
on.

The values for my device object are : HandleCount: 0 PointerCount: 3
and for USBSTOR are : HandleCount: 0 PointerCount: 2

I also experimented with plugging a mass storage device to a physical
usb port on the same system and repeating the procedure. I noticed
that there are 2 calls to "IoInvalidateDeviceRelations" when directly
plugged into the usb port, one from the USBHUB (as expected) and other
from ClassPnp, disk (as shown in the trace below).
With my driver there's only one call, made from my virtual bus driver
itseld.

Does it mean that I need to register some interface or something
similar by which system (ClassPnP or disk) will come to know of the
change in topology.

Here's the trace. Thanks for all the suggesstions.

Breakpoint 0 hit
nt!IoInvalidateDeviceRelations:
8050c9e1 8bff mov edi,edi
1: kd> kb
ChildEBP RetAddr Args to Child
f7a5ad30 f78103c5 853dc030 00000000 00000008 nt!
IoInvalidateDeviceRelations
f7a5ad50 f7816eeb f7a5ad74 00000004 8560f800 usbhub!
USBH_ProcessPortStateChange+0x111
f7a5ad7c 804e29d6 855d8ca8 00000000 857c63c8 usbhub!
USBH_ChangeIndicationWorker+0x145
f7a5adac 80576b24 855d8ca8 00000000 00000000 nt!ExpWorkerThread+0xef
f7a5addc 804eed86 804e2912 00000001 00000000 nt!PspSystemThreadStartup
+0x34
00000000 00000000 00000000 00000000 00000000 nt!KiThreadStartup+0x16

Breakpoint 0 hit
nt!IoInvalidateDeviceRelations:
8050c9e1 8bff mov edi,edi
0: kd> kb
ChildEBP RetAddr Args to Child
80558064 f7630961 8549bea0 00000000 c0000185 nt!
IoInvalidateDeviceRelations
80558080 f7641270 8510d420 855cdc6c 8510d1f0 disk!DiskFdoProcessError
+0x15b
80558184 f7643bde 8510d420 855cdc6c 00000004 CLASSPNP!
ClassInterpretSenseInfo+0x678
805581b4 f76426e0 855cdbc0 8510d2db 8510d1d8 CLASSPNP!
InterpretTransferPacketError+0x106
805581d4 804e1f14 00000000 8510d1d8 855cdbc0 CLASSPNP!
TransferPktComplete+0x67
*** ERROR: Module load completed but symbols could not be loaded for
IrpSys.sys
80558204 f63bdf97 850ef740 855cdc6c 00000000 nt!IopfCompleteRequest
+0xa2
WARNING: Stack unwind information not available. Following frames may
be wrong.
80558220 f79e1043 850ef688 8510d1d8 f79df564 IrpSys+0x1f97
80558240 804e6691 850ef688 0110d1d8 8549bf58 USBSTOR!USBSTOR_StartIo
+0x11d
80558260 f79dfaee 850ef688 8510d1d8 855cdc98 nt!IoStartPacket+0xa1
80558284 804e19ee 8549bea0 8510d1d8 00000000 USBSTOR!USBSTOR_Scsi
+0x108
80558294 f63bde48 8510d2d8 855cdbc0 8549bea0 nt!IopfCallDriver+0x31
805582c0 f7640061 f7644f9c 80558308 00000000 IrpSys+0x1e48
805582d4 f7644fa9 855cdbc0 805583fc 804e31d4 CLASSPNP!
SubmitTransferPacket+0x82
805582e0 804e31d4 855cdc08 855cdbc0 227e27c8 CLASSPNP!
TransferPacketRetryTimerDpc+0xd
805583fc 804e269e 80562f00 ffdff9c0 ffdff000 nt!KiTimerListExpire
+0x14b
80558428 804dd26b 80563300 00000000 00005d0d nt!KiTimerExpiration+0xb1
80558450 804dd14b 00000000 0000000e 00000000 nt!KiRetireDpcList+0x61
80558454 00000000 0000000e 00000000 00000000 nt!KiIdleLoop+0x28


Regards,
Abhijit

On Oct 16, 9:39 pm, "Doron Holan [MSFT]" <dor...@online.microsoft.com>
wrote:
> as long as there is an open handle, you will not get the remove device and
> will be stuck in the surprise removed state. !object on your device object
> and usbstor will tell you the handle count
>
> d
>
> --
> Please do not send e-mail directly to this alias. this alias is for
> newsgroup purposes only.
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "Abhijit Mmirajkar" <abhijit.miraj...@gmail.com> wrote in message
>
> news:1192547397.878393.138270@y27g2000pre.googlegroups.com...
>
>
>
> > Hi,
>
> > I have a typical problem of IRP_MN_REMOVE not getting called. The
> > scenario
> > is like this.
>
> > We have a virtual USB bus which creates PDOs for each simulated
> > device. We
> > could simulate a mass storage device. We can 'unplug' it (from an
> > application) by means of our bus driver sending
> > IoInvalidateDeviceRelations
> > and then reporting the device as missing. We subsequently get
> > REMOVE_DEVICE
> > for the PDO and it successfully unloads.
>
> > However when we are copying some data to the device, if we 'unplug' it
> > while
> > still copy is in progress then we don't get the IRP_MN_REMOVE_DEVICE
> > from
> > the PNP manager.
> > We see that there are no pending requests (IRPs) with us and we have
> > successfully completed IRP_MN_SURPRISE_REMOVAL, still there is no
> > REMOVE.
>
> > After dumping the devobj I get the following trace :
>
> > 0: kd> !devobj 852fe9f0
> > Device object (852fe9f0) is for:
> > 00000089
> > \Driver\VUSB DriverObject 854cc858
> > Current Irp 00000000 RefCount 0 Type 0000002a Flags 00003040
> > Dacl e2430954 DevExt 852feaa8 DevObjExt 852fec08 DevNode 85538ee8
> > ExtensionFlags (0x00000008) DOE_REMOVE_PROCESSED
> > AttachedDevice (Upper) 8527b030 \Driver\USBSTOR
> > Device queue is not busy.
>
> > This tells that there are no open references as well. I am also
> > doubtful about "DOE_REMOVE_PROCESSED". Does this mean that system
> > thinks that it has sent me IRP_MN_REMOVE_DEVICE ??
>
> > Any hints please?
> > Thanks,
>
> > Regards,
> > Abhijit- Hide quoted text -
>
> - Show quoted text -



Re: IRP_MN_REMOVE not getting called by Doron

Doron
Wed Oct 17 10:38:44 PDT 2007

the handle can be opened on a child device below usbstor.

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"Abhijit Mmirajkar" <abhijit.mirajkar@gmail.com> wrote in message
news:1192633263.357864.95700@k35g2000prh.googlegroups.com...
> Thanks Doron, but the !object also reveals that there are no open
> handles ! There is some entry under 'PointerCount', but that number is
> also there when it successfully unloads when no file transfer is going
> on.
>
> The values for my device object are : HandleCount: 0 PointerCount: 3
> and for USBSTOR are : HandleCount: 0 PointerCount: 2
>
> I also experimented with plugging a mass storage device to a physical
> usb port on the same system and repeating the procedure. I noticed
> that there are 2 calls to "IoInvalidateDeviceRelations" when directly
> plugged into the usb port, one from the USBHUB (as expected) and other
> from ClassPnp, disk (as shown in the trace below).
> With my driver there's only one call, made from my virtual bus driver
> itseld.
>
> Does it mean that I need to register some interface or something
> similar by which system (ClassPnP or disk) will come to know of the
> change in topology.
>
> Here's the trace. Thanks for all the suggesstions.
>
> Breakpoint 0 hit
> nt!IoInvalidateDeviceRelations:
> 8050c9e1 8bff mov edi,edi
> 1: kd> kb
> ChildEBP RetAddr Args to Child
> f7a5ad30 f78103c5 853dc030 00000000 00000008 nt!
> IoInvalidateDeviceRelations
> f7a5ad50 f7816eeb f7a5ad74 00000004 8560f800 usbhub!
> USBH_ProcessPortStateChange+0x111
> f7a5ad7c 804e29d6 855d8ca8 00000000 857c63c8 usbhub!
> USBH_ChangeIndicationWorker+0x145
> f7a5adac 80576b24 855d8ca8 00000000 00000000 nt!ExpWorkerThread+0xef
> f7a5addc 804eed86 804e2912 00000001 00000000 nt!PspSystemThreadStartup
> +0x34
> 00000000 00000000 00000000 00000000 00000000 nt!KiThreadStartup+0x16
>
> Breakpoint 0 hit
> nt!IoInvalidateDeviceRelations:
> 8050c9e1 8bff mov edi,edi
> 0: kd> kb
> ChildEBP RetAddr Args to Child
> 80558064 f7630961 8549bea0 00000000 c0000185 nt!
> IoInvalidateDeviceRelations
> 80558080 f7641270 8510d420 855cdc6c 8510d1f0 disk!DiskFdoProcessError
> +0x15b
> 80558184 f7643bde 8510d420 855cdc6c 00000004 CLASSPNP!
> ClassInterpretSenseInfo+0x678
> 805581b4 f76426e0 855cdbc0 8510d2db 8510d1d8 CLASSPNP!
> InterpretTransferPacketError+0x106
> 805581d4 804e1f14 00000000 8510d1d8 855cdbc0 CLASSPNP!
> TransferPktComplete+0x67
> *** ERROR: Module load completed but symbols could not be loaded for
> IrpSys.sys
> 80558204 f63bdf97 850ef740 855cdc6c 00000000 nt!IopfCompleteRequest
> +0xa2
> WARNING: Stack unwind information not available. Following frames may
> be wrong.
> 80558220 f79e1043 850ef688 8510d1d8 f79df564 IrpSys+0x1f97
> 80558240 804e6691 850ef688 0110d1d8 8549bf58 USBSTOR!USBSTOR_StartIo
> +0x11d
> 80558260 f79dfaee 850ef688 8510d1d8 855cdc98 nt!IoStartPacket+0xa1
> 80558284 804e19ee 8549bea0 8510d1d8 00000000 USBSTOR!USBSTOR_Scsi
> +0x108
> 80558294 f63bde48 8510d2d8 855cdbc0 8549bea0 nt!IopfCallDriver+0x31
> 805582c0 f7640061 f7644f9c 80558308 00000000 IrpSys+0x1e48
> 805582d4 f7644fa9 855cdbc0 805583fc 804e31d4 CLASSPNP!
> SubmitTransferPacket+0x82
> 805582e0 804e31d4 855cdc08 855cdbc0 227e27c8 CLASSPNP!
> TransferPacketRetryTimerDpc+0xd
> 805583fc 804e269e 80562f00 ffdff9c0 ffdff000 nt!KiTimerListExpire
> +0x14b
> 80558428 804dd26b 80563300 00000000 00005d0d nt!KiTimerExpiration+0xb1
> 80558450 804dd14b 00000000 0000000e 00000000 nt!KiRetireDpcList+0x61
> 80558454 00000000 0000000e 00000000 00000000 nt!KiIdleLoop+0x28
>
>
> Regards,
> Abhijit
>
> On Oct 16, 9:39 pm, "Doron Holan [MSFT]" <dor...@online.microsoft.com>
> wrote:
>> as long as there is an open handle, you will not get the remove device
>> and
>> will be stuck in the surprise removed state. !object on your device
>> object
>> and usbstor will tell you the handle count
>>
>> d
>>
>> --
>> Please do not send e-mail directly to this alias. this alias is for
>> newsgroup purposes only.
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>> "Abhijit Mmirajkar" <abhijit.miraj...@gmail.com> wrote in message
>>
>> news:1192547397.878393.138270@y27g2000pre.googlegroups.com...
>>
>>
>>
>> > Hi,
>>
>> > I have a typical problem of IRP_MN_REMOVE not getting called. The
>> > scenario
>> > is like this.
>>
>> > We have a virtual USB bus which creates PDOs for each simulated
>> > device. We
>> > could simulate a mass storage device. We can 'unplug' it (from an
>> > application) by means of our bus driver sending
>> > IoInvalidateDeviceRelations
>> > and then reporting the device as missing. We subsequently get
>> > REMOVE_DEVICE
>> > for the PDO and it successfully unloads.
>>
>> > However when we are copying some data to the device, if we 'unplug' it
>> > while
>> > still copy is in progress then we don't get the IRP_MN_REMOVE_DEVICE
>> > from
>> > the PNP manager.
>> > We see that there are no pending requests (IRPs) with us and we have
>> > successfully completed IRP_MN_SURPRISE_REMOVAL, still there is no
>> > REMOVE.
>>
>> > After dumping the devobj I get the following trace :
>>
>> > 0: kd> !devobj 852fe9f0
>> > Device object (852fe9f0) is for:
>> > 00000089
>> > \Driver\VUSB DriverObject 854cc858
>> > Current Irp 00000000 RefCount 0 Type 0000002a Flags 00003040
>> > Dacl e2430954 DevExt 852feaa8 DevObjExt 852fec08 DevNode 85538ee8
>> > ExtensionFlags (0x00000008) DOE_REMOVE_PROCESSED
>> > AttachedDevice (Upper) 8527b030 \Driver\USBSTOR
>> > Device queue is not busy.
>>
>> > This tells that there are no open references as well. I am also
>> > doubtful about "DOE_REMOVE_PROCESSED". Does this mean that system
>> > thinks that it has sent me IRP_MN_REMOVE_DEVICE ??
>>
>> > Any hints please?
>> > Thanks,
>>
>> > Regards,
>> > Abhijit- Hide quoted text -
>>
>> - Show quoted text -
>
>


Re: IRP_MN_REMOVE not getting called by chris

chris
Thu Oct 18 11:24:20 PDT 2007

On Oct 17, 12:38 pm, "Doron Holan [MSFT]"
<dor...@online.microsoft.com> wrote:

> the handle can be opened on a child device below usbstor.

Probably more like "will be opened" -- can you open a handle to the
usbstor FDO? If so, what could you do with this?