Lifetime of a WDFINTERRUPT created in EvtDevicePrepareHardware?

Hello,

Is it safe to assume that an interrupt object created in the EvtDevicePrepareHardware callback exists until EvtDeviceReleaseHardware is called?

Also, what happens if, say, the hardware has two interrupts, and I create two interrupt objects in EvtDeviceAdd, and then create an interrupt object for each interrupt resource that I get in EvtDevicePrepareHardware? I assume that either the framework calls both objects’ callbacks when an interrupt happens, or that the one created in DeviceAdd gets disconnected… or perhaps the ones in DeviceAdd are only connected after PrepareHardware completes?

Thanks in advance!

-Alex

They are connected right before EvtDeviceD0EntryPostInterruptsEnabled, they are disconnected right after EvtDeviceD0ExitPreInterruptsDisabled. Connect/disconnect state does not affect the lifetime of the WDFINTERRUPT object itself.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Thursday, July 2, 2015 11:24 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Lifetime of a WDFINTERRUPT created in EvtDevicePrepareHardware?

Hello,

Is it safe to assume that an interrupt object created in the EvtDevicePrepareHardware callback exists until EvtDeviceReleaseHardware is called?

Also, what happens if, say, the hardware has two interrupts, and I create two interrupt objects in EvtDeviceAdd, and then create an interrupt object for each interrupt resource that I get in EvtDevicePrepareHardware? I assume that either the framework calls both objects’ callbacks when an interrupt happens, or that the one created in DeviceAdd gets disconnected… or perhaps the ones in DeviceAdd are only connected after PrepareHardware completes?

Thanks in advance!

-Alex


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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

>They are connected right before EvtDeviceD0EntryPostInterruptsEnabled, they are disconnected right after EvtDeviceD0ExitPreInterruptsDisabled. Connect/disconnect state does not affect the lifetime of the WDFINTERRUPT object itself.

Hi Doron,

I used the wrong words.
My confusion comes from the fact that since KMDF1.11 it’s possible to create an interrupt object within the EvtDevicePrepareHardware function, if the InterruptRaw and InterruptTranslated fields of the WDF_INTERRUPT_CONFIG structure are set, which implies that the object is manually associated with an interrupt resource (not “connected” - again, sorry for the confusion). Since EvtDeviceReleaseHardware can happen due to PnP resource rebalancing (i.e. pretty much immediately followed by an EvtDevicePrepareHardware event), I assumed that the interrupt objects created during EvtDevicePrepareHardware would be destroyed at that point (or at least not reused), as their assigned resources are no longer valid - hence, my question whether my assumption is correct.

Hi Alexander,

You are correct, interrupt objects created in EvtDevicePrepareHardware are deleted after the EvtDeviceReleaseHardware callback runs.

If you’re curious, you can see the details of this on GitHub. Look for FxPkgPnp::PnpReleaseHardware which invokes EvtDevicePrepareHardware and then calls FxInterrupt::OnPostReleaseHardware for each interrupt. That routine deletes the interrupt object if the m_CreatedInPrepareHardware flag is set.

https://github.com/Microsoft/Windows-Driver-Frameworks/blob/master/src/framework/shared/irphandlers/pnp/pnpstatemachine.cpp
https://github.com/Microsoft/Windows-Driver-Frameworks/blob/master/src/framework/shared/irphandlers/pnp/interruptobject.cpp

* Correction for above, FxPkgPnp::PnpReleaseHardware invokes EvtDeviceReleaseHardware, not Prepare.