Hi Windows Driver Experts,
I have a requirement to aggregate multiple physical devices with same VID/DeviceID into a single unified controller DO to which clients can get handle, so that clients can have physical-device-agnostic implementation. I have found similar main thread on MSDN forums @ https://social.msdn.microsoft.com/Forums/sqlserver/en-US/41ef66ef-5e7e-4088-b225-b550eef89bb3/kmdf-bus-driver-pcie-child-devices?forum=wdk&prof=required which has been replied by Windows experts like Doron and Don. From the solutions proposed, I can make out that we can solve this requirement by having a separate DO which does not correspond to any particular physical device for this, and this can be a non-PnP CDO (control device object) or a virtual root-enumerated controller device ? both can solve the problem. I am more keen to use virtual root-enumerated PnP controller device because of following benefits which cannot be provided by non-PnP CDO:
? We can support device interfaces on PnP controller device and hence its easy for clients to get handle to the controller device by just waiting for GUID_DEVICE_INTERFACE_ARRIVAL notification.
? We have several clients running on top of base PnP driver, and we still would like individual physical devices to be disabled/enabled. So it?s very likely that we have active references to controller device taken by many clients, and hence controller device will not be able to delete when all physical devices are disabled. With non-PnP CDO, we will no longer be able to unload such driver in such scenarios. But with PnP CDO, we can still unload driver when we remove root-enumerated device from PnP manager.
Experts, please help me to get clarifications on below questions I have on ‘virtual root-enumerated PnP controller device’ approach I am planning to take to solve this design problem:
? Can I have the same driver expose the root enumerated virtual PnP controller device and also support multiple physical devices, instead of having different drivers for both ?
? Do you perceive such solution as non-standard with which we can get into any potential issues in future ?
? Are there any bad WHQL certification implications if we go for such approach ? Basically we are more inclined to have a solution without introducing an extra driver.
? Do we have to run WHQL tests on this virtual root enumerated PnP device also to get driver certified ?
? Do we have any drivers in Windows world that follows similar approach which I outlined here ?
I do agree that using non-PnP controller device have below benefits:
? No need to make extra efforts in installer/uninstaller and driver INF to add support for virtual PnP controller device.
? Virtual PnP device will only load driver at system startup even if there are no active/enabled physical devices related to the hardware. But with non-PnP CDO, driver will only load on detection of physical device and CDO will be created on 1st EvtDeviceAdd.
But I feel that the disadvantages outlined in the beginning overweighs the benefits. Especially I am not able to understand how the below user-case will work when using non-PnP CDO. Can experts here clarify on the below use-case also if we use a non-PnP CDO ?
? 2 physical devices detected, PnP loads the driver and call EvtDeviceAdd for each. In first EvtDeviceAdd, CDO also created and symbolic link created over it (for clients to use).
? Several clients got handle to the CDO and started using the device by issuing IOCTLs to that.
? Both devices get disabled one by one. At last device?s removal handling, WdfObjectDelete() is called on CDO to delete it but it will not get deleted because clients have active references to it. As a result, driver will also not get unloaded and cannot be unloaded again unless another physical device PnP removal gets triggered somehow.
? A physical device comes up again. I guess we are supposed to create a new CDO since we already called WdfObjectDelete() on old CDO, right ? Also if we do that, then does that mean that existing clients will keep on issuing IOCTLs to older CDO whereas new clients will get newly created CDO ? Also, does that mean that driver have to track the IO queue of the older [WdfDeleteObject() triggerred but not deleted yet] CDOs and current alive CDO ?