My understanding of this has always been that you can only complete requests you own, and you do not own a request that is in a queue [no matter what the flavor]- you've given ownership of it back to the framework. Only once it has been presented to you again in a callback [or by retrieval by you, which again removes it from the queue] do you own it.
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Philip D. Barila
Sent: Friday, October 24, 2008 9:18 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] WDF queueing
I think you'll have more success with a WDFTIMER than implementing your own
timeout logic. Just beware of how you allocate the timer, you can allocate
it as part of your preprocessing for each IO, but that falls down when you
have very high IO rates, because the WDFTIMER gets deleted by a passive
level work item, and if you are pushing the system hard enough, the passive
level work items never get to run and you end up with zillions of them in a
pending delete state, and you can't allocate a new one. We discovered that
one in a test harness that has really tested the limits of KMDF.
Keep in mind that our test harness is intended to drive HBAs and attached
disk drives at maximum speed. Our current setup involves an
EvtIoInCallerContext that locks down the UM buffers (because we have to do
direct DMA to any arbitrary buffer, we use a METHOD_BUFFERED IOCTL with a
command structure that contains embedded pointers for the data in and data
out buffers) and forwards the WDFREQUEST to a parallel WDFQUEUE. The
EvtIoDeviceControl preprocesses the IOs by grabbing an IO resource blob
(which contains, among other things, a pre-allocated SGL buffer and a
WDFTIMER), building the SGL by calling BuildScatterGatherList, and then
starting the IO on the hardware or putting the IO on a ready list. If it's
started on the hardware, we start the attached timer and mark it
cancellable. If it's on the ready list, it's just marked cancellable. In
either case, we have the appropriate callbacks to tear everything down and
put back what we need. Because the hardware capacity for IOs is relatively
small (511 is the biggest HBA we've done so far), we just keep IOs in flight
in an array, and count on the timer/cancellation callbacks to tell us we
need to abort an IO.
If I had some form of WDF container that managed the cancellation for me,
but didn't have the unpleasant contract of a manual WDFQUEUE, I could do
away with the dance of WdfRequestMarkCancelable / EvtRequestCancel /
WdfRequestUnmarkCancelable. My ideal container would allow me to stop the
timer and call WdfRequestComplete and friends without concern for the
container, it would "just work". I'd still have to have the
EvtIoCanceledOnQueue, but it's still simpler than what I have.
So back to Doron and/or Peter, will an automatic WDFQUEUE that has been
stopped give me that behavior, or is that abusing the framework?
Phil
Philip D. Barila
Seagate Technology LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.
wrote in message news:xxxxx@ntdev...
>I was hoping that the queues would simplify the logic for timing out
>requests that the hardware didn't return to me. But it sure doesn't seem
>that way. Previous implementation is to have a good old linked list of
>IRPs being service by the hardware, and when the periodic timer runs, it
>goes through the list, decrements the timer count for each, removes those
>timed out and completes them (leaving out some details here). With the
>manual queue I will still have to spinlock the thing to prevent the timer
>from working on a request that is being completed elsewhere. But now I
>have to do this business of removing each request from the queue so I can
>decrement the timer, then putting in back on. Plus, since it is a manual
>queue, in the non-error case, some internal function is going to have to
>walk the queue via WdfIoQueueFindRequest for each of those requests during
>Request completion.
>
> Am I missing something? Not liking this solution much...
>
> Diane
>
---
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
OSR Seminars – OSR
To unsubscribe, visit the List Server section of OSR Online at ListServer/Forum