Hm, let me reiterate my problem differently.
I have a simple KMDF PCI driver with an EvtIoRead routine.
In this routine, instead of actually performing an I/O read, it simple enables interrupts, so that the ISR can execute and the actual I/O is performed in the ISR’s DPC. Naturally, I want to block in EvtIoRead until the interrupt has occurred.
I have found that if I put a counter in my device context, which is incremented by my DPC, and have the EvtIoRead function wait on this boolean using a busywait, then everything occurs as I expect. The time interval between reads is similar to my interrupt time interval.
However, obviously I do not wish to include a busywait in my driver. So I’d rather use a notification event. However, simply putting a call to KeSetEvent() in my code exactly where I increase this counter, it sometimes works, but eventually at some point, after a few thousand fread() calls to the driver, my entire computer hangs — deadlock.
The documentation says that deadlock can be a problem if KeSetEvent has its Wait parameter set to TRUE. However, I am setting it to FALSE.
I understood that KeSetEvent was exactly designed for signaling an I/O routine from an interrupt handler, so I don’t understand what I’m doing wrong. An error message would be nice, but instead I get a deadlock with no messages in the debugger.
My KEVENT object, by the way, is stored in my device context.
I am going to try using a synchronization event instead of a notification event to see if that helps.