2005-04-16 18:20:36 -04:00
|
|
|
/*
|
|
|
|
* linux/arch/ia64/kernel/irq.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* Copyright (C) Ashok Raj<ashok.raj@intel.com>, Intel Corporation 2004
|
|
|
|
*
|
|
|
|
* 4/14/2004: Added code to handle cpu migration and do safe irq
|
|
|
|
* migration without lossing interrupts for iosapic
|
|
|
|
* architecture.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <asm/delay.h>
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/seq_file.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/kernel_stat.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 'what should we do if we get a hw irq event on an illegal vector'.
|
|
|
|
* each architecture has to answer this themselves.
|
|
|
|
*/
|
|
|
|
void ack_bad_irq(unsigned int irq)
|
|
|
|
{
|
|
|
|
printk(KERN_ERR "Unexpected irq vector 0x%x on CPU %u!\n", irq, smp_processor_id());
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_IA64_GENERIC
|
|
|
|
unsigned int __ia64_local_vector_to_irq (ia64_vector vec)
|
|
|
|
{
|
|
|
|
return (unsigned int) vec;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Interrupt statistics:
|
|
|
|
*/
|
|
|
|
|
|
|
|
atomic_t irq_err_count;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* /proc/interrupts printing:
|
|
|
|
*/
|
|
|
|
|
|
|
|
int show_interrupts(struct seq_file *p, void *v)
|
|
|
|
{
|
|
|
|
int i = *(loff_t *) v, j;
|
|
|
|
struct irqaction * action;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (i == 0) {
|
|
|
|
seq_printf(p, " ");
|
2005-10-10 11:43:26 -04:00
|
|
|
for_each_online_cpu(j) {
|
|
|
|
seq_printf(p, "CPU%d ",j);
|
|
|
|
}
|
2005-04-16 18:20:36 -04:00
|
|
|
seq_putc(p, '\n');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i < NR_IRQS) {
|
|
|
|
spin_lock_irqsave(&irq_desc[i].lock, flags);
|
|
|
|
action = irq_desc[i].action;
|
|
|
|
if (!action)
|
|
|
|
goto skip;
|
|
|
|
seq_printf(p, "%3d: ",i);
|
|
|
|
#ifndef CONFIG_SMP
|
|
|
|
seq_printf(p, "%10u ", kstat_irqs(i));
|
|
|
|
#else
|
2005-10-10 11:43:26 -04:00
|
|
|
for_each_online_cpu(j) {
|
|
|
|
seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
|
|
|
|
}
|
2005-04-16 18:20:36 -04:00
|
|
|
#endif
|
2006-11-16 03:42:58 -05:00
|
|
|
seq_printf(p, " %14s", irq_desc[i].chip->name);
|
2005-04-16 18:20:36 -04:00
|
|
|
seq_printf(p, " %s", action->name);
|
|
|
|
|
|
|
|
for (action=action->next; action; action = action->next)
|
|
|
|
seq_printf(p, ", %s", action->name);
|
|
|
|
|
|
|
|
seq_putc(p, '\n');
|
|
|
|
skip:
|
|
|
|
spin_unlock_irqrestore(&irq_desc[i].lock, flags);
|
|
|
|
} else if (i == NR_IRQS)
|
|
|
|
seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
static char irq_redir [NR_IRQS]; // = { [0 ... NR_IRQS-1] = 1 };
|
|
|
|
|
|
|
|
void set_irq_affinity_info (unsigned int irq, int hwid, int redir)
|
|
|
|
{
|
|
|
|
cpumask_t mask = CPU_MASK_NONE;
|
|
|
|
|
|
|
|
cpu_set(cpu_logical_id(hwid), mask);
|
|
|
|
|
|
|
|
if (irq < NR_IRQS) {
|
2006-06-29 05:24:38 -04:00
|
|
|
irq_desc[irq].affinity = mask;
|
2005-04-16 18:20:36 -04:00
|
|
|
irq_redir[irq] = (char) (redir & 0xff);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_SMP */
|
|
|
|
|
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
|
|
|
unsigned int vectors_in_migration[NR_IRQS];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Since cpu_online_map is already updated, we just need to check for
|
|
|
|
* affinity that has zeros
|
|
|
|
*/
|
|
|
|
static void migrate_irqs(void)
|
|
|
|
{
|
|
|
|
cpumask_t mask;
|
|
|
|
irq_desc_t *desc;
|
|
|
|
int irq, new_cpu;
|
|
|
|
|
|
|
|
for (irq=0; irq < NR_IRQS; irq++) {
|
2006-06-29 05:24:38 -04:00
|
|
|
desc = irq_desc + irq;
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2007-02-03 04:13:48 -05:00
|
|
|
if (desc->status == IRQ_DISABLED)
|
|
|
|
continue;
|
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
/*
|
|
|
|
* No handling for now.
|
|
|
|
* TBD: Implement a disable function so we can now
|
|
|
|
* tell CPU not to respond to these local intr sources.
|
|
|
|
* such as ITV,CPEI,MCA etc.
|
|
|
|
*/
|
|
|
|
if (desc->status == IRQ_PER_CPU)
|
|
|
|
continue;
|
|
|
|
|
2006-06-29 05:24:38 -04:00
|
|
|
cpus_and(mask, irq_desc[irq].affinity, cpu_online_map);
|
2005-04-16 18:20:36 -04:00
|
|
|
if (any_online_cpu(mask) == NR_CPUS) {
|
|
|
|
/*
|
|
|
|
* Save it for phase 2 processing
|
|
|
|
*/
|
|
|
|
vectors_in_migration[irq] = irq;
|
|
|
|
|
|
|
|
new_cpu = any_online_cpu(cpu_online_map);
|
|
|
|
mask = cpumask_of_cpu(new_cpu);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Al three are essential, currently WARN_ON.. maybe panic?
|
|
|
|
*/
|
[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 05:24:36 -04:00
|
|
|
if (desc->chip && desc->chip->disable &&
|
|
|
|
desc->chip->enable && desc->chip->set_affinity) {
|
|
|
|
desc->chip->disable(irq);
|
|
|
|
desc->chip->set_affinity(irq, mask);
|
|
|
|
desc->chip->enable(irq);
|
2005-04-16 18:20:36 -04:00
|
|
|
} else {
|
[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 05:24:36 -04:00
|
|
|
WARN_ON((!(desc->chip) || !(desc->chip->disable) ||
|
|
|
|
!(desc->chip->enable) ||
|
|
|
|
!(desc->chip->set_affinity)));
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void fixup_irqs(void)
|
|
|
|
{
|
|
|
|
unsigned int irq;
|
|
|
|
extern void ia64_process_pending_intr(void);
|
2005-11-11 17:32:40 -05:00
|
|
|
extern void ia64_disable_timer(void);
|
|
|
|
extern volatile int time_keeper_id;
|
|
|
|
|
|
|
|
ia64_disable_timer();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find a new timesync master
|
|
|
|
*/
|
|
|
|
if (smp_processor_id() == time_keeper_id) {
|
|
|
|
time_keeper_id = first_cpu(cpu_online_map);
|
|
|
|
printk ("CPU %d is now promoted to time-keeper master\n", time_keeper_id);
|
|
|
|
}
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Phase 1: Locate irq's bound to this cpu and
|
|
|
|
* relocate them for cpu removal.
|
|
|
|
*/
|
|
|
|
migrate_irqs();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Phase 2: Perform interrupt processing for all entries reported in
|
|
|
|
* local APIC.
|
|
|
|
*/
|
|
|
|
ia64_process_pending_intr();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Phase 3: Now handle any interrupts not captured in local APIC.
|
|
|
|
* This is to account for cases that device interrupted during the time the
|
|
|
|
* rte was being disabled and re-programmed.
|
|
|
|
*/
|
|
|
|
for (irq=0; irq < NR_IRQS; irq++) {
|
|
|
|
if (vectors_in_migration[irq]) {
|
2006-10-06 13:09:41 -04:00
|
|
|
struct pt_regs *old_regs = set_irq_regs(NULL);
|
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
vectors_in_migration[irq]=0;
|
2006-11-16 03:43:07 -05:00
|
|
|
generic_handle_irq(irq);
|
2006-10-06 13:09:41 -04:00
|
|
|
set_irq_regs(old_regs);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now let processor die. We do irq disable and max_xtp() to
|
|
|
|
* ensure there is no more interrupts routed to this processor.
|
|
|
|
* But the local timer interrupt can have 1 pending which we
|
|
|
|
* take care in timer_interrupt().
|
|
|
|
*/
|
|
|
|
max_xtp();
|
|
|
|
local_irq_disable();
|
|
|
|
}
|
|
|
|
#endif
|