Disable/Enable IRQ

Hello,

I read some threads which tell me that we should not use disable/enable IRQ. IRQ is disabled upon entering ISR callback and enabled when leaving by WDF framework. I understand fully.

But here is requirement. We need to disable IRQ when we’re entering ISR callback. We need to enable it in the other function which gets invoked by different thread later when meeting certain condition.

How can I implement this requirement with WDF?

Regards,
Sy

xxxxx@gmail.com wrote:

I read some threads which tell me that we should not use disable/enable IRQ. IRQ is disabled upon entering ISR callback and enabled when leaving by WDF framework. I understand fully.

But here is requirement. We need to disable IRQ when we’re entering ISR callback. We need to enable it in the other function which gets invoked by different thread later when meeting certain condition.

How can I implement this requirement with WDF?

You are certainly allowed to enable and disable the interrupts on your
board – you just do that by writing registers on your device, not by
managing the interrupt controller.

So, whatever you are doing in your EvtInterruptDisable routine, just do
that in your ISR. Then, whenever you are ready to start handling
interrupts again, you do whatever you are doing in EvtInterruptEnable.

From a performance point of view, you should be ready to service
interrupts as soon as your DPC is finished.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

I’m not sure what you are saying here. Generally, you do not disable global
interrupt state in a driver (there are some extremely rare exceptions which
are invisible to you). This is quite “untraditional” from most non-Windows
drivers which feel free to do CLI/STI at any point they feel like.

What you do relative to your device is your own business. However, it is
good practice to not disable the interrupts; when you leave your ISR you
should expect to be interrupted immediately. The implication of this is
that if there is any device state you need in your DPC, you should collect
this in the ISR and pass it to the DPC (this is often complicated by the
fact that you cannot allocate memory in the ISR, but that is just SMOP
(Small Matter Of Programming)). Many devices cannot generate a new
interrupt request until they are told “Start a new I/O transaction” (which,
years ago in another world we called “hitting the GO bit”), so there is no
need to disable interrupts because there won’t be any. If it is a streaming
device that *could* interrupt at regular intervals, then the disabling will
probably cause problems because the device NEEDS to interrupt and can’t.
Remember that you have 10us in the ISR, which is like two weeks of human
time (a 2GHz machine will execute one cycle in 500ps, and can dispatch two
instructions per CPU cycle, so under optimum conditions, 10us = 10,000ns =
20,000 cycles = 40,000 instructions. Now degrade this somewhat because
reading from the device takes a lot of CPU cycles [the PCI bus is dead slow
relative to CPU speed], you still have a lot of work you can do in the ISR.

So you really need to state this question very clearly, as to what you are
thinking you want to do, and say something about the characteristics of your
device (expected interrupt frequency, whether or not it is a streaming
device, etc.) Note that if you think you need to disable the interrupts, it
might suggest a bad driver architecture, and this group would be able to
offer advice on that.
joe

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Monday, June 27, 2011 7:11 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Disable/Enable IRQ

Hello,

I read some threads which tell me that we should not use disable/enable IRQ.
IRQ is disabled upon entering ISR callback and enabled when leaving by WDF
framework. I understand fully.

But here is requirement. We need to disable IRQ when we’re entering ISR
callback. We need to enable it in the other function which gets invoked by
different thread later when meeting certain condition.

How can I implement this requirement with WDF?

Regards,
Sy


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


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Joseph M. Newcomer wrote

What you do relative to your device is your own business. However, it
is good practice to not disable the interrupts; when you leave your
ISR you should expect to be interrupted immediately

I strongly disagree with this over-generalization. When dealing with
PCI* devices, for example, it is common practice to disable interrupts
of your device in ISR and re-enable them on exit from DPC. Ultimately,
it depends on device functionality.
To OP: if you need to disable interrupts of your own device, it is up
to you to know how it is done - usually by setting or cleaning some
bit(s) in your device’s Interrupt Control Register.

Best regards,
Alex Krol