interface enbl/disbl

Hi,
In driver A i use a function IoRegisterPlugPlayNotification and expect to get notification GUID_DEVICE_INTERFACE_ARRIVAL when driver B will use WdfDeviceCreateDeviceInterface & WdfDeviceSetDeviceInterfaceState(enble) .

Once I got notification in A.
Now if Driver B unloaded of even use WdfDeviceSetDeviceInterfaceState(disable).
I expect to get notification about this as GUID_DEVICE_INTERFACE_REMOVAL.

But, as I see in MS doc :
http://msdn.microsoft.com/en-us/library/windows/hardware/ff545432(v=vs.85).aspx

“A driver can disable and re-enable a device interface if necessary. For example, if a driver determines that its device has stopped responding, the driver can call WdfDeviceSetDeviceInterfaceState to disable the device’s interfaces and prohibit applications from obtaining new handles to the interface. (Existing handles to the interface are not affected.)”

Why “Existing handles to the interface are not affected” ?
How can l get notification for interface disable ?

is TARGET_DEVICE_CUSTOM_NOTIFICATION more suitble for such needs?

Thank you in advance

It is rare that a driver needs to call WdfDeviceSetDeviceInterfaceState, kmdf manages it for you. If in the middle of running you want to turn the interface off, you call WdfDeviceSetDeviceInterfaceState. But that just prevents new drivers/apps from seeing the instance, calling WdfDeviceSetDeviceInterfaceState(FALSE) does not query remove/destroy existing handles. If you want to communicate a failed state at runtime, you must use some other means ( a custom target device notification is one of them)

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Wednesday, August 29, 2012 12:57 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] interface enbl/disbl

Hi,
In driver A i use a function IoRegisterPlugPlayNotification and expect to get notification GUID_DEVICE_INTERFACE_ARRIVAL when driver B will use WdfDeviceCreateDeviceInterface & WdfDeviceSetDeviceInterfaceState(enble) .

Once I got notification in A.
Now if Driver B unloaded of even use WdfDeviceSetDeviceInterfaceState(disable).
I expect to get notification about this as GUID_DEVICE_INTERFACE_REMOVAL.

But, as I see in MS doc :
http://msdn.microsoft.com/en-us/library/windows/hardware/ff545432(v=vs.85).aspx

“A driver can disable and re-enable a device interface if necessary. For example, if a driver determines that its device has stopped responding, the driver can call WdfDeviceSetDeviceInterfaceState to disable the device’s interfaces and prohibit applications from obtaining new handles to the interface. (Existing handles to the interface are not affected.)”

Why “Existing handles to the interface are not affected” ?
How can l get notification for interface disable ?

is TARGET_DEVICE_CUSTOM_NOTIFICATION more suitble for such needs?

Thank you in advance


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 just would like to ensure that other driver which is using the existing handle to my exposed interface will be notified.

You write :
If you want to communicate a failed state at runtime, you must use some
other means ( a custom target device notification is one of them)

What are standart and proper way to do that?

Thank you in advance

There is no standard or proper way to do that. Is the device stack in a state where it should be torn down and removed? Or is this failure state transient?

If you want to tear down the stack, call WdfDeviceSetFailed. If it is transient, complete pending io with some special NTSTATUS that indicates this state

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Thursday, August 30, 2012 12:42 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] interface enbl/disbl

I just would like to ensure that other driver which is using the existing handle to my exposed interface will be notified.

You write :
If you want to communicate a failed state at runtime, you must use some other means ( a custom target device notification is one of them)

What are standart and proper way to do that?

Thank you in advance


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 don’t speak about failure.
I also don;t speak about drivers from same stack.

If driver “A” holds interface to other driver “B”, and A calls B functions periodically.
Now driver B requested to unload (for any reason like res rebalancing … )

the possible soilutions is :
when DeviceQueryRemove() called in B-driver.
B calls (by private inteface) to A-driver and notify it about removing.
A-driver releases the interface and Interface.InterfaceDereference called inside the B.
B unlocks by WdfDeviceSetStaticStopRemove …
and now B-driver can be safety unloaded. (no one holds it)

but i don;t like this solution. I’m looking for “best cooperate with the OS” solution.

I will appreciate a lot for any referencing or idea …

Thank you in advance

Let’s get a couple of things straightened up

  1. resource rebalance does not unload driver B, it just gets a pnp stop. In kmdf, this means a power down and then power back up when the start arrives
  2. if you call WdfDeviceSetStaticStopRemove, you cannot get query removed at all, it will block it

Now, for an external reference to your stack, the proper thing to do is for driver A to open a handle to B’s stack and register for file handle notifications on A. The file handle is open for the entire time A is talking to B or vice versa. A remote WDFIOTARGET will do this for you. When B is query removed, A will be notified before B that the query remove is going to occur and this is where A must gracefully let get of all references to B and close the handle.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Thursday, August 30, 2012 2:31 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] interface enbl/disbl

I don’t speak about failure.
I also don;t speak about drivers from same stack.

If driver “A” holds interface to other driver “B”, and A calls B functions periodically.
Now driver B requested to unload (for any reason like res rebalancing … )

the possible soilutions is :
when DeviceQueryRemove() called in B-driver.
B calls (by private inteface) to A-driver and notify it about removing.
A-driver releases the interface and Interface.InterfaceDereference called inside the B.
B unlocks by WdfDeviceSetStaticStopRemove …
and now B-driver can be safety unloaded. (no one holds it)

but i don;t like this solution. I’m looking for “best cooperate with the OS” solution.

I will appreciate a lot for any referencing or idea …

Thank you in advance


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