2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* linux/arch/alpha/kernel/irq.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 1995 Linus Torvalds
|
|
|
|
*
|
|
|
|
* This file contains the code used by various IRQ handling routines:
|
|
|
|
* asking for different IRQ's should be done through these routines
|
|
|
|
* instead of just grabbing them. Thus setups with different IRQ numbers
|
|
|
|
* shouldn't result in any weird surprises, and installing new handlers
|
|
|
|
* should be easier.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/kernel_stat.h>
|
|
|
|
#include <linux/signal.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/ptrace.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/random.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/irq.h>
|
|
|
|
#include <linux/proc_fs.h>
|
|
|
|
#include <linux/seq_file.h>
|
|
|
|
#include <linux/profile.h>
|
|
|
|
#include <linux/bitops.h>
|
|
|
|
|
|
|
|
#include <asm/system.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
|
|
|
|
volatile unsigned long irq_err_count;
|
|
|
|
|
2006-01-06 01:12:22 -07:00
|
|
|
void ack_bad_irq(unsigned int irq)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
irq_err_count++;
|
|
|
|
printk(KERN_CRIT "Unexpected IRQ trap at vector %u\n", irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
static char irq_user_affinity[NR_IRQS];
|
|
|
|
|
2008-05-29 12:02:52 -06:00
|
|
|
int irq_select_affinity(unsigned int irq)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
static int last_cpu;
|
|
|
|
int cpu = last_cpu + 1;
|
|
|
|
|
[PATCH] genirq: rename desc->handler to desc->chip
This patch-queue improves the generic IRQ layer to be truly generic, by adding
various abstractions and features to it, without impacting existing
functionality.
While the queue can be best described as "fix and improve everything in the
generic IRQ layer that we could think of", and thus it consists of many
smaller features and lots of cleanups, the one feature that stands out most is
the new 'irq chip' abstraction.
The irq-chip abstraction is about describing and coding and IRQ controller
driver by mapping its raw hardware capabilities [and quirks, if needed] in a
straightforward way, without having to think about "IRQ flow"
(level/edge/etc.) type of details.
This stands in contrast with the current 'irq-type' model of genirq
architectures, which 'mixes' raw hardware capabilities with 'flow' details.
The patchset supports both types of irq controller designs at once, and
converts i386 and x86_64 to the new irq-chip design.
As a bonus side-effect of the irq-chip approach, chained interrupt controllers
(master/slave PIC constructs, etc.) are now supported by design as well.
The end result of this patchset intends to be simpler architecture-level code
and more consolidation between architectures.
We reused many bits of code and many concepts from Russell King's ARM IRQ
layer, the merging of which was one of the motivations for this patchset.
This patch:
rename desc->handler to desc->chip.
Originally i did not want to do this, because it's a big patch. But having
both "desc->handler", "desc->handle_irq" and "action->handler" caused a
large degree of confusion and made the code appear alot less clean than it
truly is.
I have also attempted a dual approach as well by introducing a
desc->chip alias - but that just wasnt robust enough and broke
frequently.
So lets get over with this quickly. The conversion was done automatically
via scripts and converts all the code in the kernel.
This renaming patch is the first one amongst the patches, so that the
remaining patches can stay flexible and can be merged and split up
without having some big monolithic patch act as a merge barrier.
[akpm@osdl.org: build fix]
[akpm@osdl.org: another build fix]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-29 03:24:36 -06:00
|
|
|
if (!irq_desc[irq].chip->set_affinity || irq_user_affinity[irq])
|
2006-01-06 01:12:22 -07:00
|
|
|
return 1;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2008-12-31 16:42:26 -07:00
|
|
|
while (!cpu_possible(cpu) ||
|
|
|
|
!cpumask_test_cpu(cpu, irq_default_affinity))
|
2005-04-16 16:20:36 -06:00
|
|
|
cpu = (cpu < (NR_CPUS-1) ? cpu + 1 : 0);
|
|
|
|
last_cpu = cpu;
|
|
|
|
|
2006-06-29 03:24:38 -06:00
|
|
|
irq_desc[irq].affinity = cpumask_of_cpu(cpu);
|
2008-12-13 03:50:26 -07:00
|
|
|
irq_desc[irq].chip->set_affinity(irq, cpumask_of(cpu));
|
2006-01-06 01:12:22 -07:00
|
|
|
return 0;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
#endif /* CONFIG_SMP */
|
|
|
|
|
|
|
|
int
|
|
|
|
show_interrupts(struct seq_file *p, void *v)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
int j;
|
|
|
|
#endif
|
2006-02-01 04:06:13 -07:00
|
|
|
int irq = *(loff_t *) v;
|
2005-04-16 16:20:36 -06:00
|
|
|
struct irqaction * action;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
2006-02-01 04:06:13 -07:00
|
|
|
if (irq == 0) {
|
2005-04-16 16:20:36 -06:00
|
|
|
seq_puts(p, " ");
|
2006-02-01 04:06:13 -07:00
|
|
|
for_each_online_cpu(j)
|
|
|
|
seq_printf(p, "CPU%d ", j);
|
2005-04-16 16:20:36 -06:00
|
|
|
seq_putc(p, '\n');
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-02-01 04:06:13 -07:00
|
|
|
if (irq < ACTUAL_NR_IRQS) {
|
|
|
|
spin_lock_irqsave(&irq_desc[irq].lock, flags);
|
|
|
|
action = irq_desc[irq].action;
|
2005-04-16 16:20:36 -06:00
|
|
|
if (!action)
|
|
|
|
goto unlock;
|
2006-02-01 04:06:13 -07:00
|
|
|
seq_printf(p, "%3d: ", irq);
|
2005-04-16 16:20:36 -06:00
|
|
|
#ifndef CONFIG_SMP
|
2006-02-01 04:06:13 -07:00
|
|
|
seq_printf(p, "%10u ", kstat_irqs(irq));
|
2005-04-16 16:20:36 -06:00
|
|
|
#else
|
2006-02-01 04:06:13 -07:00
|
|
|
for_each_online_cpu(j)
|
2009-01-11 14:35:56 -07:00
|
|
|
seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));
|
2005-04-16 16:20:36 -06:00
|
|
|
#endif
|
[PATCH] genirq: rename desc->handler to desc->chip
This patch-queue improves the generic IRQ layer to be truly generic, by adding
various abstractions and features to it, without impacting existing
functionality.
While the queue can be best described as "fix and improve everything in the
generic IRQ layer that we could think of", and thus it consists of many
smaller features and lots of cleanups, the one feature that stands out most is
the new 'irq chip' abstraction.
The irq-chip abstraction is about describing and coding and IRQ controller
driver by mapping its raw hardware capabilities [and quirks, if needed] in a
straightforward way, without having to think about "IRQ flow"
(level/edge/etc.) type of details.
This stands in contrast with the current 'irq-type' model of genirq
architectures, which 'mixes' raw hardware capabilities with 'flow' details.
The patchset supports both types of irq controller designs at once, and
converts i386 and x86_64 to the new irq-chip design.
As a bonus side-effect of the irq-chip approach, chained interrupt controllers
(master/slave PIC constructs, etc.) are now supported by design as well.
The end result of this patchset intends to be simpler architecture-level code
and more consolidation between architectures.
We reused many bits of code and many concepts from Russell King's ARM IRQ
layer, the merging of which was one of the motivations for this patchset.
This patch:
rename desc->handler to desc->chip.
Originally i did not want to do this, because it's a big patch. But having
both "desc->handler", "desc->handle_irq" and "action->handler" caused a
large degree of confusion and made the code appear alot less clean than it
truly is.
I have also attempted a dual approach as well by introducing a
desc->chip alias - but that just wasnt robust enough and broke
frequently.
So lets get over with this quickly. The conversion was done automatically
via scripts and converts all the code in the kernel.
This renaming patch is the first one amongst the patches, so that the
remaining patches can stay flexible and can be merged and split up
without having some big monolithic patch act as a merge barrier.
[akpm@osdl.org: build fix]
[akpm@osdl.org: another build fix]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-29 03:24:36 -06:00
|
|
|
seq_printf(p, " %14s", irq_desc[irq].chip->typename);
|
2005-04-16 16:20:36 -06:00
|
|
|
seq_printf(p, " %c%s",
|
2006-07-01 20:29:11 -06:00
|
|
|
(action->flags & IRQF_DISABLED)?'+':' ',
|
2005-04-16 16:20:36 -06:00
|
|
|
action->name);
|
|
|
|
|
|
|
|
for (action=action->next; action; action = action->next) {
|
|
|
|
seq_printf(p, ", %c%s",
|
2006-07-01 20:29:11 -06:00
|
|
|
(action->flags & IRQF_DISABLED)?'+':' ',
|
2005-04-16 16:20:36 -06:00
|
|
|
action->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
seq_putc(p, '\n');
|
|
|
|
unlock:
|
2006-02-01 04:06:13 -07:00
|
|
|
spin_unlock_irqrestore(&irq_desc[irq].lock, flags);
|
|
|
|
} else if (irq == ACTUAL_NR_IRQS) {
|
2005-04-16 16:20:36 -06:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
seq_puts(p, "IPI: ");
|
2006-02-01 04:06:13 -07:00
|
|
|
for_each_online_cpu(j)
|
|
|
|
seq_printf(p, "%10lu ", cpu_data[j].ipi_count);
|
2005-04-16 16:20:36 -06:00
|
|
|
seq_putc(p, '\n');
|
|
|
|
#endif
|
|
|
|
seq_printf(p, "ERR: %10lu\n", irq_err_count);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* handle_irq handles all normal device IRQ's (the special
|
|
|
|
* SMP cross-CPU interrupts have their own specific
|
|
|
|
* handlers).
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define MAX_ILLEGAL_IRQS 16
|
|
|
|
|
|
|
|
void
|
2006-10-08 07:37:32 -06:00
|
|
|
handle_irq(int irq)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* We ack quickly, we don't want the irq controller
|
|
|
|
* thinking we're snobs just because some other CPU has
|
|
|
|
* disabled global interrupts (we have already done the
|
|
|
|
* INT_ACK cycles, it's too late to try to pretend to the
|
|
|
|
* controller that we aren't taking the interrupt).
|
|
|
|
*
|
|
|
|
* 0 return value means that this irq is already being
|
|
|
|
* handled by some other CPU. (or is disabled)
|
|
|
|
*/
|
|
|
|
static unsigned int illegal_count=0;
|
|
|
|
|
|
|
|
if ((unsigned) irq > ACTUAL_NR_IRQS && illegal_count < MAX_ILLEGAL_IRQS ) {
|
|
|
|
irq_err_count++;
|
|
|
|
illegal_count++;
|
|
|
|
printk(KERN_CRIT "device_interrupt: invalid interrupt %d\n",
|
|
|
|
irq);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
irq_enter();
|
2006-03-09 18:33:37 -07:00
|
|
|
/*
|
|
|
|
* __do_IRQ() must be called with IPL_MAX. Note that we do not
|
|
|
|
* explicitly enable interrupts afterwards - some MILO PALcode
|
|
|
|
* (namely LX164 one) seems to have severe problems with RTI
|
|
|
|
* at IPL 0.
|
|
|
|
*/
|
2006-01-06 01:12:22 -07:00
|
|
|
local_irq_disable();
|
2006-10-07 07:17:31 -06:00
|
|
|
__do_IRQ(irq);
|
2005-04-16 16:20:36 -06:00
|
|
|
irq_exit();
|
|
|
|
}
|