WdfInterruptCreate DISPATCH_LEVEL

I may need the ISR to run at Dispatch Level and not at the default device level (don’t ask why). Is there a way I can do this with WDF?

No. What you’re saying you “may need” doesn’t make any architectural sense in Windows.

“Don’t ask why” probably precludes our helping you further, so I’ll ask: What are you trying to accomplish that would requiring running at IRQL DISPATCH_LEVEL? Such work is typically done in your DpcForIsr.

Peter
OSR

WdfInterruptQueueDpcForIsr.
Mark Roddy

On Thu, Feb 12, 2009 at 11:17 AM, Calin Iaru wrote:

> I may need the ISR to run at Dispatch Level and not at the default device
> level (don’t ask why). Is there a way I can do this with WDF?
>
>
>
>
> —
> NTDEV is sponsored by OSR
>
> 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
>

Don’t think so - the WdfInterruptQueueDpcForIsr will call EvtInterruptDpc that was registered by the WdfInterruptCreate(). The ISR will still have to decide if the interrupt is claimed or not.

— On Thu, 2/12/09, Mark Roddy wrote:

> From: Mark Roddy
> Subject: Re: [ntdev] WdfInterruptCreate DISPATCH_LEVEL
> To: “Windows System Software Devs Interest List”
> Date: Thursday, February 12, 2009, 6:26 PM
> WdfInterruptQueueDpcForIsr.
> Mark Roddy
>
>
> On Thu, Feb 12, 2009 at 11:17 AM, Calin Iaru
> wrote:
>
> > I may need the ISR to run at Dispatch Level and not at
> the default device
> > level (don’t ask why). Is there a way I can do
> this with WDF?
> >
> >
> >
> >
> > —
> > NTDEV is sponsored by OSR
> >
> > 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
> >
>
> —
> NTDEV is sponsored by OSR
>
> 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

Yeah… OK… right. Not so much “claimed” as “from the device instance associated with the ISR invocation”. OK… Mark (and everyone else who reads this list) knows that.

So your point is?

Peter
OSR

Calin Iaru wrote:

Don’t think so - the WdfInterruptQueueDpcForIsr will call EvtInterruptDpc that was registered by the WdfInterruptCreate(). The ISR will still have to decide if the interrupt is claimed or not.

Are you looking how to sync between
ISR and DPCs? then use WdfInterruptAcquireLock or
WdfInterruptSynchronize or KeSynchronizeExecution.

–pa

— On Thu, 2/12/09, Mark Roddy wrote:
>
>> From: Mark Roddy
>> Subject: Re: [ntdev] WdfInterruptCreate DISPATCH_LEVEL
>> To: “Windows System Software Devs Interest List”
>> Date: Thursday, February 12, 2009, 6:26 PM
>> WdfInterruptQueueDpcForIsr.
>> Mark Roddy
>>
>>
>> On Thu, Feb 12, 2009 at 11:17 AM, Calin Iaru
>> wrote:
>>
>>> I may need the ISR to run at Dispatch Level and not at
>> the default device
>>> level (don’t ask why). Is there a way I can do
>> this with WDF?

Yes it will, for some interrupts, for others it won’t have to figure this
out at all. What is your point? Actually what is your problem? You’ve
explained what your solution is “violate some base assumption of the os”,
now perhaps you could explain the problem.
Mark Roddy

On Thu, Feb 12, 2009 at 11:44 AM, Calin Iaru wrote:

> Don’t think so - the WdfInterruptQueueDpcForIsr will call EvtInterruptDpc
> that was registered by the WdfInterruptCreate(). The ISR will still have to
> decide if the interrupt is claimed or not.
>
>
> — On Thu, 2/12/09, Mark Roddy wrote:
>
> > From: Mark Roddy
> > Subject: Re: [ntdev] WdfInterruptCreate DISPATCH_LEVEL
> > To: “Windows System Software Devs Interest List”
> > Date: Thursday, February 12, 2009, 6:26 PM
> > WdfInterruptQueueDpcForIsr.
> > Mark Roddy
> >
> >
> > On Thu, Feb 12, 2009 at 11:17 AM, Calin Iaru
> > wrote:
> >
> > > I may need the ISR to run at Dispatch Level and not at
> > the default device
> > > level (don’t ask why). Is there a way I can do
> > this with WDF?
> > >
> > >
> > >
> > >
> > > —
> > > NTDEV is sponsored by OSR
> > >
> > > 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
> > >
> >
> > —
> > NTDEV is sponsored by OSR
> >
> > 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
>
>
>
>
> —
> NTDEV is sponsored by OSR
>
> 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
>

>

Yeah… OK… right. Not so much “claimed” as “from the device
instance
associated with the ISR invocation”. OK… Mark (and everyone else
who
reads this list) knows that.

So your point is?

It’s just a learning thing. I’m sure we’ve all been there - we assume
that the answer to our problem is going to be as simple as ‘cut and
paste this code’, or we assume that our problem is so complex that
nobody on the list could possibly understand it. Both assumptions are
flawed though, the first because there is rarely a simple answer to a
complex problem, and the second because the people on this list are
actually really clever :slight_smile:

Another tip - I have found that when I post to a mailing list like this,
the act of explaining my problem to others is actually really beneficial
to me too. Many times I have started an email many times, and figured
out the solution myself before I finished writing it, just because
explaining it forced me to think about it in different ways.

Is there a ‘How do I ask my question in a way that is likely to get me
the answer I need?’ FAQ anywhere? Maybe the standard response to such
questions should just be “we need more information - please read URL here> and try again” :slight_smile:

James

> -----Original Message-----

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of James Harper
Sent: Friday, February 13, 2009 1:12 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] WdfInterruptCreate DISPATCH_LEVEL

Another tip - I have found that when I post to a mailing list
like this,
the act of explaining my problem to others is actually really
beneficial
to me too. Many times I have started an email many times, and figured
out the solution myself before I finished writing it, just because
explaining it forced me to think about it in different ways.

Exactly. Most of my potential questions to the list are solved this way
and never sent :slight_smile:

I’d even say people who aren’t able to ask questions good way i.e.
explain problem sufficiently to others are unable to solve it anyway so
answering is waste of time. Harsh, I know, but seeing the same people
ask similar questions the same way for months and ignoring all answers
and queries for clarification is a bit hopeless.

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]

… umm … as a long time lurker/ occasional poster, I would conjecture based on a perusal of the answers to the “how do I do X on windows questions” over the last year on this list I have noticed …

  • 30-45% of them are “you ignorant [I cannot control my vocabulary], what a [I cannot control my vocabulary] idea!” … examples of this are the famous “how do I share userspace and kernel memory” question and the equally well received “how to I allocate a very large block of memory” question. This silliness was strikingly illustrated recently on the MS Kernel newsgroup, where one poster responded to a question of how to map Kernel memory into user space that this knowledge was evil, should never have existed and the poster would absolutely not help the OP one iota and wished only defeat in any attempts to obtain this information … which was, of course, immediately followed by the next poster to the question who provided this same black art knowledge in three lines of code …
  • 10-15% of them are “you ignorant [I cannot control my vocabulary], you must be a virus writer, no information for you! (sing to the tune of the Soup Nazi)” … such as when people ask about undocumented/ barely documented structures or want to intercept system calls.
  • 15-20% of them are “you poor [I cannot control my vocabulary], if only you were using Linux for this!” … the discussions about synchronization usually devolve into this …
  • 30-35% are answered intelligently (thanks Doron and Jake!) in a manner that doesn’t belittle the questioner or what he’s trying to accomplish, if only by directing the poster to an FAQ …

So, if I’m asking a question where I know I have a 60-70% chance of being referred to as a [I cannot control my vocabulary] writing a [I cannot control my vocabulary] driver using a [I cannot control my vocabulary] OS, exactly why are you surprised that people will ask only very specific questions with no follow up and not the more general “how do I do X on Windows” questions?

… Just a thought … cheers!

You’re right. It’s a terrible list, with only Jake and Doron providing the occasional good answer. What a bunch of assholes the rest of us are.

I mean… just look at the archives for the last few days. Terrible stuff, really.

Makes me wonder why anybody bothers at all… or why so many people are members. Go figure, huh?

Peter
OSR

> Makes me wonder why anybody bothers at all… or why so many people are members. Go figure, huh?

Simply because attacking newbies is just a hobby for all 65 698 of us (there are 65 700 members, so that if we exclude Doron and Jake 65 698 of us are left). We just wait for some newbie to ask some naive question, and then decide which of us is the best in attacking and insulting him. Top 3 are awarded respectively gold, silver and bronze medals (we choose winners on daily, weekly, monthly and yearly basis, as well as on per-thread one). This is the only reason why we are all subscribed to this list…

Anton Bassov

I may have lost a few points - I asked the question because some code which is out of my jurisdiction does use sync objects in the ISR. (I don’t have yet the power to change that, only to work around it - lowering the level through queueing or other mechanisms). How come that after so many years you don’t know what’s behind “don’t ask why”? Of course you do, and I see storms of lecture on horison. That would explain why I did not continue.

— On Thu, 2/12/09, xxxxx@osr.com wrote:

> From: xxxxx@osr.com
> Subject: RE:[ntdev] WdfInterruptCreate DISPATCH_LEVEL
> To: “Windows System Software Devs Interest List”
> Date: Thursday, February 12, 2009, 10:09 PM
> Yeah… OK… right. Not so much “claimed” as
> “from the device instance associated with the ISR
> invocation”. OK… Mark (and everyone else who reads
> this list) knows that.
>
> So your point is?
>
>


>
> Peter
> OSR
>
>
>
> —
> NTDEV is sponsored by OSR
>
> 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

> I asked the question because some code which is out of my jurisdiction does use sync

objects in the ISR. (I don’t have yet the power to change that, only to work around it -
lowering the level through queueing or other mechanisms).

I just love your approach - instead of requesting to fix the bug you are adjusting your code to it…

In any case, even if you want to adjust your code to this bug you should not lower IRQL in ISR but, instead, raise it to DIRQL in non-ISR code that uses this spinlock - you should raise it before trying to acquire spinlock, and then acquire a spinlock with KeAcquireSpinlockAtDpcLevel(), rather than with KeAcquireSpinlock(). Certainly this is still just a poor man’s solution - in order to do it properly you have to use KeSynchroniseExecution() (or interrupt spinlock on W2K+) in non-ISR code and to remove spinlock-related code from ISR, i.e. to fix the bug…

Anton Bassov

Uh… because I’m a freakin’ retard, who has a sincere interest in helping community members, and after answer questions on this list for, like… oh… TEN years, there are SO freakin’ many things behind “don’t ask why” I don’t have even the vaugest notion of what they might be.

We can HELP with the “some code out of my jurisdiction uses synchronization objects in the ISR”… Why not post THAT question? Though, admittedly, that’s not very clear either: HOW does it acquire these synchronization objects, and WHICH synchornization objects specifically.

Assuming it’s a spin lock, and it’s acquired in the ISR at DIRQL (ordinarily not allowed), it would have to use KeAcquireSpinLockAtDpcLevel in the ISR for it to work. In this case, you can use the mechanism Anton suggested.

It’s not the “don’t ask why” as much as it’s the very obviously ignored request for additional information that frustrates me. It’s like folks asking for first aid, but declining to say whether it’s their wrist or their ankle that hurts. We’re supposed to guess?

Peter
OSR

Your post continues to make no sense. Just queue a dpc from your isr and
call that out of your jurisdiction code from your dpc routine instead of
your isr routine, all of course conditional on testing that your device
actually requested the interrupt.
Mark Roddy

On Fri, Feb 13, 2009 at 3:46 AM, Calin Iaru wrote:

> I may have lost a few points - I asked the question because some code which
> is out of my jurisdiction does use sync objects in the ISR. (I don’t have
> yet the power to change that, only to work around it - lowering the level
> through queueing or other mechanisms). How come that after so many years you
> don’t know what’s behind “don’t ask why”? Of course you do, and I see storms
> of lecture on horison. That would explain why I did not continue.
>
>
> — On Thu, 2/12/09, xxxxx@osr.com wrote:
>
> > From: xxxxx@osr.com
> > Subject: RE:[ntdev] WdfInterruptCreate DISPATCH_LEVEL
> > To: “Windows System Software Devs Interest List”
> > Date: Thursday, February 12, 2009, 10:09 PM
> > Yeah… OK… right. Not so much “claimed” as
> > “from the device instance associated with the ISR
> > invocation”. OK… Mark (and everyone else who reads
> > this list) knows that.
> >
> > So your point is?
> >
> >


> >
> > Peter
> > OSR
> >
> >
> >
> > —
> > NTDEV is sponsored by OSR
> >
> > 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
>
>
>
>
> —
> NTDEV is sponsored by OSR
>
> 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
>

That’s not how it works - I never thought in these terms. I think that my question is simple, I know about the “best practices” and this will certainly be fixed, later, whatever that later is. “why” does not matter at the moment.
I have a copy of “W NT DDD” where it shows a way to do this. I may test it after fixing other bugs.

— On Fri, 2/13/09, xxxxx@osr.com wrote:

> From: xxxxx@osr.com
> Subject: RE:[ntdev] WdfInterruptCreate DISPATCH_LEVEL
> To: “Windows System Software Devs Interest List”
> Date: Friday, February 13, 2009, 3:12 PM
>


>
> Uh… because I’m a freakin’ retard, who has a
> sincere interest in helping community members, and after
> answer questions on this list for, like… oh… TEN years,
> there are SO freakin’ many things behind “don’t
> ask why” I don’t have even the vaugest notion of
> what they might be.
>
> We can HELP with the “some code out of my jurisdiction
> uses synchronization objects in the ISR”… Why not
> post THAT question? Though, admittedly, that’s not very
> clear either: HOW does it acquire these synchronization
> objects, and WHICH synchornization objects specifically.
>
> Assuming it’s a spin lock, and it’s acquired in the
> ISR at DIRQL (ordinarily not allowed), it would have to use
> KeAcquireSpinLockAtDpcLevel in the ISR for it to work. In
> this case, you can use the mechanism Anton suggested.
>
> It’s not the “don’t ask why” as much as
> it’s the very obviously ignored request for additional
> information that frustrates me. It’s like folks asking
> for first aid, but declining to say whether it’s their
> wrist or their ankle that hurts. We’re supposed to
> guess?
>
> Peter
> OSR
>
>
> —
> NTDEV is sponsored by OSR
>
> 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

If your question was simple, then you got your simple answer within 6 minutes of your original post.

If this is the case, then any reasonable netiquette would dictate your next reply would be “Thanks… that’s really all I needed to know” not a reply which ignored the simple answer and asserted:

Which is a non-sequitur if I’ve ever seen one.

I’m out of this thread, which long ago ceased to be helpful to anybody.

Peter
OSR

Apparently, I am just too dumb, but I am just unable to understand how one may “have no jurisdiction” over the code that he writes. Could you please explain in detail what is written by you; what is written by some other party and which particular way these parts get into a conflict with one another. At this point we will, probably, be able to suggest at least something…

Anton Bassov

>to use KeSynchroniseExecution() (or interrupt spinlock on W2K+)

On XP+


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com