A few more questions
1. If I want to put a thread to sleep in KMDF, what mechanisms can I use?
E.g., lets say EvtIoRead callback is called, yet the hardware resources to
process that are not available yet. I want EvtIoRead to go to sleep until
its woken up by the ISR. In Linux kernel there are wait queues that a
function can sleep on until woken up. Are there similar native constructs
in KMDF, or if not, can I use WDM (if they are available) or WIN32 calls?
Anything besides WaitLock? (WaitLock doesn't seem do just that, as it forces
the code that acquires it to execute as a critical section, AFAIK)
2. Let say the immediate availability of hardware for a DMA depends on how
many scatter-gather elements are in the request and the current state of
hardware due to outstanding requests. I.e., if I follow the framework, I
won't know how many scatter-gather elements are in the request until I am
inside EvtProgramDma callback. If at that point the resources are not
available, I would need to wait for their availability. So:
a) EvtProgramDma runs at DISPATCH IRQL, which means that even WaitLock
cannot be executed in blocking mode. If the hardware resources are not
immediately available, what should the driver do at this point? Spinning for
them seems like a huge waste of processor cycles.
b) Alternatively, I could postpone DmaExecute until all the resources are
available and spin on that in the Io callback at passive IRQL (see quesetion
1). However, is there a way to infer how many items will be in the
scatter-gather list at that point? Is (request_size/PAGE_SIZE+1) a definite
upper bound?