none
CM_Reenumerate_DevNode vs IoInvalidateDeviceRelations RRS feed

  • Question

  • The user mode CM_Reenumerate_DevNode API can be called synchronously (CM_REENUMERATE_SYNCHRONOUS).  The semi-equivalent IoInvalidateDeviceRelations kernel API returns asynchronously.  From a kernel driver, is there a way to call IoInvalidateDeviceRelations synchronously or to be notified when the invalidation completes?  I need to know when IoInvalidateDeviceRelations completes (like CM_Reenumerate_DevNode -> CM_REENUMERATE_SYNCHRONOUS offers).  Thanks.
    Monday, February 15, 2016 11:37 PM

Answers

  • there is neither  a synchronous IoInvalidateDeviceRelations   nor a notification when it completes. As degenerate cases, the QDR may never come (stack is surprise removed) or multiple requests are consolidated into one QDR. why do you need a sync IoInvalidateDeviceRelations   in KM?

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, February 16, 2016 3:18 AM

All replies

  • First, why do you think you need a synchronous call?  Normally you would detect the change by using IoRegisterPlugPlayNotification (WdfDeviceInitRegisterPnpStateChangeCallback in KMDF).  If you call IoInvalidateDeviceRelations you will cause the system to generate an IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS call.  You can monitor the completion of that call which will be close to the end of the IoInvalidateDeviceRelations actions.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    Tuesday, February 16, 2016 12:33 AM
  • there is neither  a synchronous IoInvalidateDeviceRelations   nor a notification when it completes. As degenerate cases, the QDR may never come (stack is surprise removed) or multiple requests are consolidated into one QDR. why do you need a sync IoInvalidateDeviceRelations   in KM?

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, February 16, 2016 3:18 AM
  • Thanks Doron and Don for the replies.

    This is a SAN environment where PnP (i.e. storport+miniport) does not always detect path arrival/removal.  In my KM driver, I know that paths need to be added or need to be removed.  IoInvalidateDeviceRelations -> BusRelations can be called to bring the host back in sync with the SAN.  That works fine but there are corner cases, on a heavy populated bus, where the bus rescan can take a very long time.  Ideally I would like to know when the rescan completes as it allows me to optimize my code further and avoid potential overlapped rescan requests.

    This is all in a worker thread so, while I'd prefer being notified asynchronously when the rescan completes, I can also wait for it to complete like CM_Reenumerate_DevNode -> CM_REENUMERATE_SYNCHRONOUS does.  Since it can be done from user mode, it seems like I should be able to do something equivalent from kernel mode.  Perhaps the IoRegisterPlugPlayNotification API Don mentioned can provide some assistance here.

    Tuesday, February 16, 2016 3:41 AM