KMDF does not assert anything about the context that IRP_MJ_CLEANUP is
processed in, but others in the stack might assume the context is
correct. IRP_MJ_CLEANUP’s contract is that this is the last IRP
guaranteed to be in the calling process’s context and this is where you
do cleanup. KMDF does not provide a native way to pend the cleanup or
close IRPs, they are supposed to be synchronously processed. My
suggestion of dropping KMDF locking is b/c you are starting to move
outside of the built in locking capabilities and you will need to manage
your own state now b/c you are dropping into WDM IRP preprocessing.
Is another KM component sending you I/O? If not and it is only a user
mode application which is opening a handle and sending i/o, the passive
execution level is not needed if you choose not to use device level
locking. By choosing no locking and no execution level, i/o will still
be presented at passive if it comes from a UM application.
d
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of David R. Cattley
Sent: Tuesday, April 24, 2007 4:59 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] KMDF handling of IRP_MJ_CLOSE - can it be pended?
Doron,
This makes me think I don’t quite understand the implications of
combination of WdfSyncronizationScopeDevice combined with
WdfExecutionLevelPassive. With that combination I am expecting that
the framework will ensure that my callback entries will be called at
PASSIVE_LEVEL. I also expected that to serialize the callbacks, the
framework would be acquiring the ‘lock’ associated with the WDFDEVICE
which owns the queue(s), file objects, work items, etc. which have
callbacks associated with them.
I am under the impression that if I wish to syncronize an external
callback from another source that is at PASSIVE_LEVEL to device scope
that I would need to acquire the ‘lock’ associated with the WDFDEVICE
using WdfObjectAcquireLock().
If the dispatch of IRP_MJ_CLEANUP (or IRP_MJ_CLOSE) blocks in the
framework callback EvtFileCleanup, wont the WDFDEVICE ‘lock’ be held
during that block? If so, that would require that any state that needs
to be modified be outside of the syncronization scope of framework
automatic syncronization.
I can build that, I just figured it far more convenient to complete the
IRP_MJ_CLEANUP (or close) asyncronously instead of holding a lock while
blocking a dispatch just waiting.
I am in the situation of interfacing to a third-party component that
requires PASSIVE_LEVEL execution only. The combination of
WdfSyncronizationScopeDevice and WdfExecutionLevelPassive seemed to be
the perfect way to satisfy this and avoid constructing a workitem based
syncronization scheme directly and explicit syncronization (locking).
I will give the preprocess route a try but here I believe I must *not*
delay the framework handling of IRP_MJ_CLEANUP because doing so will
break the contract of cleanup being processed by the framework in the
‘handle owner’ thread context. Am I correct to assume that the
framework is relying on the I/O manager to dispatch the IRP_MJ_CLEANUP
in that context and does no further work to defend against some driver
diverting the executing context to another thread?
Thanks for the ideas.
Regards,
-dave
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Monday, April 23, 2007 9:29 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] KMDF handling of IRP_MJ_CLOSE - can it be pended?
Why do you hang onto the close vs cleanup irp? The cleanup irp is the
one in the context of the application, the close irp can come in the
system context. I would forgo built in locking and then block in
EvtFileCleanup. Really needed to do this with the built in locking, set
a preprocess routine for IRP_MJ_CLEANUP, block in the preprocess routine
and when your wait is satisfied, send the IRP to KMDF for further
processing.
d
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer