2009-04-09 10:52:26 +02:00
|
|
|
#include <linux/linkage.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/signal.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/interrupt.h>
|
2009-04-09 10:52:26 +02:00
|
|
|
#include <linux/timex.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/random.h>
|
2009-04-10 14:58:05 +02:00
|
|
|
#include <linux/kprobes.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/kernel_stat.h>
|
2011-12-22 01:26:03 +01:00
|
|
|
#include <linux/device.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/bitops.h>
|
2009-04-09 10:52:26 +02:00
|
|
|
#include <linux/acpi.h>
|
2009-01-04 12:05:17 +01:00
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/delay.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2011-07-27 01:09:06 +02:00
|
|
|
#include <linux/atomic.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <asm/timer.h>
|
2009-04-09 10:52:26 +02:00
|
|
|
#include <asm/hw_irq.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <asm/pgtable.h>
|
|
|
|
#include <asm/desc.h>
|
|
|
|
#include <asm/apic.h>
|
2009-02-23 00:34:39 +01:00
|
|
|
#include <asm/setup.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <asm/i8259.h>
|
2009-01-04 12:05:17 +01:00
|
|
|
#include <asm/traps.h>
|
2011-02-22 21:07:40 +01:00
|
|
|
#include <asm/prom.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2009-04-09 10:52:26 +02:00
|
|
|
/*
|
|
|
|
* ISA PIC or low IO-APIC triggered (INTA-cycle or APIC) interrupts:
|
|
|
|
* (these are usually mapped to vectors 0x30-0x3f)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The IO-APIC gives us many more interrupt sources. Most of these
|
|
|
|
* are unused but an SMP system is supposed to have enough memory ...
|
|
|
|
* sometimes (mostly wrt. hw bugs) we get corrupted vectors all
|
|
|
|
* across the spectrum, so we really want to be prepared to get all
|
|
|
|
* of these. Plus, more powerful systems might have more than 64
|
|
|
|
* IO-APIC registers.
|
|
|
|
*
|
|
|
|
* (these are usually mapped into the 0x30-0xff vector range)
|
|
|
|
*/
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-08-11 16:34:08 +02:00
|
|
|
/*
|
|
|
|
* IRQ2 is cascade interrupt to second interrupt controller
|
|
|
|
*/
|
|
|
|
static struct irqaction irq2 = {
|
|
|
|
.handler = no_action,
|
|
|
|
.name = "cascade",
|
2011-01-27 18:17:01 +01:00
|
|
|
.flags = IRQF_NO_THREAD,
|
2008-08-11 16:34:08 +02:00
|
|
|
};
|
|
|
|
|
2008-08-20 05:50:28 +02:00
|
|
|
DEFINE_PER_CPU(vector_irq_t, vector_irq) = {
|
2010-01-19 21:20:54 +01:00
|
|
|
[0 ... NR_VECTORS - 1] = -1,
|
2008-08-20 05:50:28 +02:00
|
|
|
};
|
|
|
|
|
2008-12-20 00:23:44 +01:00
|
|
|
int vector_used_by_percpu_irq(unsigned int vector)
|
|
|
|
{
|
|
|
|
int cpu;
|
|
|
|
|
|
|
|
for_each_online_cpu(cpu) {
|
|
|
|
if (per_cpu(vector_irq, cpu)[vector] != -1)
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-20 09:41:38 +02:00
|
|
|
void __init init_ISA_irqs(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2010-09-28 00:15:31 +02:00
|
|
|
struct irq_chip *chip = legacy_pic->chip;
|
|
|
|
const char *name = chip->name;
|
2005-04-17 00:20:36 +02:00
|
|
|
int i;
|
|
|
|
|
2009-04-09 10:52:24 +02:00
|
|
|
#if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC)
|
2009-04-09 10:52:19 +02:00
|
|
|
init_bsp_APIC();
|
|
|
|
#endif
|
2009-11-09 20:27:04 +01:00
|
|
|
legacy_pic->init(0);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2010-09-28 00:15:31 +02:00
|
|
|
for (i = 0; i < legacy_pic->nr_legacy_irqs; i++)
|
2011-03-12 12:20:43 +01:00
|
|
|
irq_set_chip_and_handler_name(i, chip, handle_level_irq, name);
|
2009-04-09 10:52:19 +02:00
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2009-09-16 08:42:26 +02:00
|
|
|
void __init init_IRQ(void)
|
2009-08-20 09:59:09 +02:00
|
|
|
{
|
2010-01-19 21:20:54 +01:00
|
|
|
int i;
|
|
|
|
|
2011-02-22 21:07:44 +01:00
|
|
|
/*
|
|
|
|
* We probably need a better place for this, but it works for
|
|
|
|
* now ...
|
|
|
|
*/
|
|
|
|
x86_add_irq_domains();
|
|
|
|
|
2010-01-19 21:20:54 +01:00
|
|
|
/*
|
|
|
|
* On cpu 0, Assign IRQ0_VECTOR..IRQ15_VECTOR's to IRQ 0..15.
|
|
|
|
* If these IRQ's are handled by legacy interrupt-controllers like PIC,
|
|
|
|
* then this configuration will likely be static after the boot. If
|
|
|
|
* these IRQ's are handled by more mordern controllers like IO-APIC,
|
|
|
|
* then this vector space can be freed and re-used dynamically as the
|
|
|
|
* irq's migrate etc.
|
|
|
|
*/
|
2010-02-24 05:27:48 +01:00
|
|
|
for (i = 0; i < legacy_pic->nr_legacy_irqs; i++)
|
2010-01-19 21:20:54 +01:00
|
|
|
per_cpu(vector_irq, 0)[IRQ0_VECTOR + i] = i;
|
|
|
|
|
2009-08-20 09:59:09 +02:00
|
|
|
x86_init.irqs.intr_init();
|
|
|
|
}
|
2008-08-11 16:34:08 +02:00
|
|
|
|
2010-03-15 23:33:06 +01:00
|
|
|
/*
|
|
|
|
* Setup the vector to irq mappings.
|
|
|
|
*/
|
|
|
|
void setup_vector_irq(int cpu)
|
|
|
|
{
|
|
|
|
#ifndef CONFIG_X86_IO_APIC
|
|
|
|
int irq;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* On most of the platforms, legacy PIC delivers the interrupts on the
|
|
|
|
* boot cpu. But there are certain platforms where PIC interrupts are
|
|
|
|
* delivered to multiple cpu's. If the legacy IRQ is handled by the
|
|
|
|
* legacy PIC, for the new cpu that is coming online, setup the static
|
|
|
|
* legacy vector to irq mapping:
|
|
|
|
*/
|
|
|
|
for (irq = 0; irq < legacy_pic->nr_legacy_irqs; irq++)
|
|
|
|
per_cpu(vector_irq, cpu)[IRQ0_VECTOR + irq] = irq;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
__setup_vector_irq(cpu);
|
|
|
|
}
|
|
|
|
|
2009-04-09 10:52:20 +02:00
|
|
|
static void __init smp_intr_init(void)
|
|
|
|
{
|
2009-04-09 10:52:23 +02:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
#if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC)
|
2008-08-11 16:34:08 +02:00
|
|
|
/*
|
|
|
|
* The reschedule interrupt is a CPU-to-CPU reschedule-helper
|
|
|
|
* IPI, driven by wakeup.
|
|
|
|
*/
|
|
|
|
alloc_intr_gate(RESCHEDULE_VECTOR, reschedule_interrupt);
|
|
|
|
|
|
|
|
/* IPI for generic function call */
|
|
|
|
alloc_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt);
|
|
|
|
|
2009-04-09 10:52:23 +02:00
|
|
|
/* IPI for generic single function call */
|
2008-12-20 00:23:44 +01:00
|
|
|
alloc_intr_gate(CALL_FUNCTION_SINGLE_VECTOR,
|
2009-04-09 10:52:23 +02:00
|
|
|
call_function_single_interrupt);
|
2008-08-20 05:50:28 +02:00
|
|
|
|
|
|
|
/* Low priority IPI to cleanup after moving an irq */
|
|
|
|
set_intr_gate(IRQ_MOVE_CLEANUP_VECTOR, irq_move_cleanup_interrupt);
|
2008-12-20 00:23:44 +01:00
|
|
|
set_bit(IRQ_MOVE_CLEANUP_VECTOR, used_vectors);
|
x86: fix panic with interrupts off (needed for MCE)
For some time each panic() called with interrupts disabled
triggered the !irqs_disabled() WARN_ON in smp_call_function(),
producing ugly backtraces and confusing users.
This is a common situation with machine checks for example which
tend to call panic with interrupts disabled, but will also hit
in other situations e.g. panic during early boot. In fact it
means that panic cannot be called in many circumstances, which
would be bad.
This all started with the new fancy queued smp_call_function,
which is then used by the shutdown path to shut down the other
CPUs.
On closer examination it turned out that the fancy RCU
smp_call_function() does lots of things not suitable in a panic
situation anyways, like allocating memory and relying on complex
system state.
I originally tried to patch this over by checking for panic
there, but it was quite complicated and the original patch
was also not very popular. This also didn't fix some of the
underlying complexity problems.
The new code in post 2.6.29 tries to patch around this by
checking for oops_in_progress, but that is not enough to make
this fully safe and I don't think that's a real solution
because panic has to be reliable.
So instead use an own vector to reboot. This makes the reboot
code extremly straight forward, which is definitely a big plus
in a panic situation where it is important to avoid relying on
too much kernel state. The new simple code is also safe to be
called from interupts off region because it is very very simple.
There can be situations where it is important that panic
is reliable. For example on a fatal machine check the panic
is needed to get the system up again and running as quickly
as possible. So it's important that panic is reliable and
all function it calls simple.
This is why I came up with this simple vector scheme.
It's very hard to beat in simplicity. Vectors are not
particularly precious anymore since all big systems are
using per CPU vectors.
Another possibility would have been to use an NMI similar
to kdump, but there is still the problem that NMIs don't
work reliably on some systems due to BIOS issues. NMIs
would have been able to stop CPUs running with interrupts
off too. In the sake of universal reliability I opted for
using a non NMI vector for now.
I put the reboot vector into the highest priority bucket of
the APIC vectors and moved the 64bit UV_BAU message down
instead into the next lower priority.
[ Impact: bug fix, fixes an old regression ]
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-05-27 21:56:52 +02:00
|
|
|
|
|
|
|
/* IPI used for rebooting/stopping */
|
|
|
|
alloc_intr_gate(REBOOT_VECTOR, reboot_interrupt);
|
2008-08-11 16:34:08 +02:00
|
|
|
#endif
|
2009-04-09 10:52:23 +02:00
|
|
|
#endif /* CONFIG_SMP */
|
2009-04-09 10:52:20 +02:00
|
|
|
}
|
|
|
|
|
2009-04-09 10:52:21 +02:00
|
|
|
static void __init apic_intr_init(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2009-04-09 10:52:20 +02:00
|
|
|
smp_intr_init();
|
2008-08-11 16:34:08 +02:00
|
|
|
|
2009-06-02 00:13:02 +02:00
|
|
|
#ifdef CONFIG_X86_THERMAL_VECTOR
|
2009-04-09 10:52:27 +02:00
|
|
|
alloc_intr_gate(THERMAL_APIC_VECTOR, thermal_interrupt);
|
2009-06-02 00:13:02 +02:00
|
|
|
#endif
|
2009-07-22 04:56:20 +02:00
|
|
|
#ifdef CONFIG_X86_MCE_THRESHOLD
|
2009-04-09 10:52:27 +02:00
|
|
|
alloc_intr_gate(THRESHOLD_APIC_VECTOR, threshold_interrupt);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC)
|
2008-08-11 16:34:08 +02:00
|
|
|
/* self generated IPI for local APIC timer */
|
|
|
|
alloc_intr_gate(LOCAL_TIMER_VECTOR, apic_timer_interrupt);
|
|
|
|
|
2009-10-14 16:22:57 +02:00
|
|
|
/* IPI for X86 platform specific use */
|
|
|
|
alloc_intr_gate(X86_PLATFORM_IPI_VECTOR, x86_platform_ipi);
|
2013-04-11 13:25:11 +02:00
|
|
|
#ifdef CONFIG_HAVE_KVM
|
|
|
|
/* IPI for KVM to deliver posted interrupt */
|
|
|
|
alloc_intr_gate(POSTED_INTR_VECTOR, kvm_posted_intr_ipi);
|
|
|
|
#endif
|
2009-03-04 19:56:05 +01:00
|
|
|
|
2008-08-11 16:34:08 +02:00
|
|
|
/* IPI vectors for APIC spurious and error interrupts */
|
|
|
|
alloc_intr_gate(SPURIOUS_APIC_VECTOR, spurious_interrupt);
|
|
|
|
alloc_intr_gate(ERROR_APIC_VECTOR, error_interrupt);
|
|
|
|
|
2010-10-14 08:01:34 +02:00
|
|
|
/* IRQ work interrupts: */
|
|
|
|
# ifdef CONFIG_IRQ_WORK
|
|
|
|
alloc_intr_gate(IRQ_WORK_VECTOR, irq_work_interrupt);
|
2009-04-10 14:58:05 +02:00
|
|
|
# endif
|
|
|
|
|
2008-08-11 16:34:08 +02:00
|
|
|
#endif
|
2009-04-09 10:52:21 +02:00
|
|
|
}
|
2008-08-11 16:34:08 +02:00
|
|
|
|
2009-04-09 10:52:21 +02:00
|
|
|
void __init native_init_IRQ(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Execute any quirks before the call gates are initialised: */
|
2009-08-20 09:41:38 +02:00
|
|
|
x86_init.irqs.pre_vector_init();
|
2009-04-09 10:52:21 +02:00
|
|
|
|
2009-04-15 20:57:01 +02:00
|
|
|
apic_intr_init();
|
|
|
|
|
2009-04-09 10:52:21 +02:00
|
|
|
/*
|
|
|
|
* Cover the whole vector space, no vector can escape
|
|
|
|
* us. (some of these will be overridden and become
|
|
|
|
* 'special' SMP interrupts)
|
|
|
|
*/
|
2012-03-23 23:02:06 +01:00
|
|
|
i = FIRST_EXTERNAL_VECTOR;
|
|
|
|
for_each_clear_bit_from(i, used_vectors, NR_VECTORS) {
|
2009-04-15 20:57:01 +02:00
|
|
|
/* IA32_SYSCALL_VECTOR could be used in trap_init already. */
|
2012-03-23 23:02:06 +01:00
|
|
|
set_intr_gate(i, interrupt[i - FIRST_EXTERNAL_VECTOR]);
|
2009-04-09 10:52:21 +02:00
|
|
|
}
|
2009-04-28 23:32:56 +02:00
|
|
|
|
2011-02-22 21:07:40 +01:00
|
|
|
if (!acpi_ioapic && !of_ioapic)
|
2008-08-11 16:34:08 +02:00
|
|
|
setup_irq(2, &irq2);
|
|
|
|
|
2009-04-09 10:52:25 +02:00
|
|
|
#ifdef CONFIG_X86_32
|
2005-04-17 00:20:36 +02:00
|
|
|
irq_ctx_init(smp_processor_id());
|
2009-04-09 10:52:25 +02:00
|
|
|
#endif
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|