Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 14: Kernel Activities


When stacks with 8-KiB size, that is, two page frames, are used, IRQ handling is simplified because a
potential stack switch does not need to be taken into account andirq_desc[irq]->handle_irqcan be
called immediately in any case.

Old-Style Processing


In the discussion of how AMD64 calls the flow control handler, it was mentioned that the code ends up in
generic_handle_irq, which selects and activates the properhandle_irqfunction from the IRQ database
irq_desc. However,generic_handle_irqis a little more complicated in practice:

<irq.h>
static inline void generic_handle_irq(unsigned int irq)
{
struct irq_desc *desc = irq_desc + irq;

#ifdef CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ
desc->handle_irq(irq, desc);
#else
if (likely(desc->handle_irq))
desc->handle_irq(irq, desc);
else
__do_IRQ(irq);
#endif
}

Before the generic IRQ rework, the kernel used a colorful mixture of architecture-dependentapproaches
to IRQ handling. Most important, there was no separation between flow handling and ISR han-
dling: Both tasks were performed simultaneously in a single architecture-specific routine usually
called__do_IRQ.

Modern code should activate the configuration optionGENRIC_HARDIRQS_NO__DO_IRQand implement
flow handling as shown in the preceding discussions. In this case,generic_handle_irqreally boils
down to just callingirq_desc[irq]->handle_irq.

What if this option is not set? The kernel provides a default implementation of__do_IRQthat com-
bines flow handling for all interrupt types, and also calls the required ISRs.^15 Basically, there are three
possibilities of how to use this function and implement flow handling:


  1. Use generic flow handlers for some IRQs, and leave the handlers for others undefined. For
    these,__do_IRQis employed to handle both flow and high-level processing. It is required to
    callgeneric_handle_IRQfromdo_IRQin this case.

  2. Call__do_IRQdirectly fromdo_IRQ. This bypasses the flow separation completely. Some
    off-mainstream architectures like M32R, H8300, SuperH, and Cris still use this approach.

  3. Handle IRQs in a completely architecture-dependent way without reusing any of the exist-
    ing frameworks. Clearly, this is not the brightest idea — to say the least.


Since it is needless to say that the long-term goal forall architectures is to convert to the generic IRQ
framework,__do_IRQis not discussed in detail.

(^15) The implementation is based on the version used on IA-32 systems before the generic IRQ framework was introduced.

Free download pdf