1 | /* |
---|
2 | * Local APIC handling, local APIC timers |
---|
3 | * |
---|
4 | * (c) 1999, 2000 Ingo Molnar <mingo@redhat.com> |
---|
5 | * |
---|
6 | * Fixes |
---|
7 | * Maciej W. Rozycki : Bits for genuine 82489DX APICs; |
---|
8 | * thanks to Eric Gilmore |
---|
9 | * and Rolf G. Tews |
---|
10 | * for testing these extensively. |
---|
11 | * Maciej W. Rozycki : Various updates and fixes. |
---|
12 | * Mikael Pettersson : Power Management for UP-APIC. |
---|
13 | * Pavel Machek and |
---|
14 | * Mikael Pettersson : PM converted to driver model. |
---|
15 | */ |
---|
16 | |
---|
17 | #include <linux/init.h> |
---|
18 | |
---|
19 | #include <linux/mm.h> |
---|
20 | #include <linux/delay.h> |
---|
21 | #include <linux/bootmem.h> |
---|
22 | #include <linux/smp_lock.h> |
---|
23 | #include <linux/interrupt.h> |
---|
24 | #include <linux/mc146818rtc.h> |
---|
25 | #include <linux/kernel_stat.h> |
---|
26 | #include <linux/sysdev.h> |
---|
27 | #include <linux/cpu.h> |
---|
28 | #include <linux/module.h> |
---|
29 | |
---|
30 | #include <asm/atomic.h> |
---|
31 | #include <asm/smp.h> |
---|
32 | #include <asm/mtrr.h> |
---|
33 | #include <asm/mpspec.h> |
---|
34 | #include <asm/desc.h> |
---|
35 | #include <asm/arch_hooks.h> |
---|
36 | #include <asm/hpet.h> |
---|
37 | #include <asm/i8253.h> |
---|
38 | #include <asm/nmi.h> |
---|
39 | |
---|
40 | #include <mach_apic.h> |
---|
41 | #include <mach_apicdef.h> |
---|
42 | #include <mach_ipi.h> |
---|
43 | |
---|
44 | #include "io_ports.h" |
---|
45 | |
---|
46 | #ifndef CONFIG_XEN |
---|
47 | /* |
---|
48 | * cpu_mask that denotes the CPUs that needs timer interrupt coming in as |
---|
49 | * IPIs in place of local APIC timers |
---|
50 | */ |
---|
51 | static cpumask_t timer_bcast_ipi; |
---|
52 | #endif |
---|
53 | |
---|
54 | /* |
---|
55 | * Knob to control our willingness to enable the local APIC. |
---|
56 | */ |
---|
57 | int enable_local_apic __initdata = 0; /* -1=force-disable, +1=force-enable */ |
---|
58 | |
---|
59 | /* |
---|
60 | * Debug level |
---|
61 | */ |
---|
62 | int apic_verbosity; |
---|
63 | |
---|
64 | #ifndef CONFIG_XEN |
---|
65 | static int modern_apic(void) |
---|
66 | { |
---|
67 | unsigned int lvr, version; |
---|
68 | /* AMD systems use old APIC versions, so check the CPU */ |
---|
69 | if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD && |
---|
70 | boot_cpu_data.x86 >= 0xf) |
---|
71 | return 1; |
---|
72 | lvr = apic_read(APIC_LVR); |
---|
73 | version = GET_APIC_VERSION(lvr); |
---|
74 | return version >= 0x14; |
---|
75 | } |
---|
76 | #endif /* !CONFIG_XEN */ |
---|
77 | |
---|
78 | /* |
---|
79 | * 'what should we do if we get a hw irq event on an illegal vector'. |
---|
80 | * each architecture has to answer this themselves. |
---|
81 | */ |
---|
82 | void ack_bad_irq(unsigned int irq) |
---|
83 | { |
---|
84 | printk("unexpected IRQ trap at vector %02x\n", irq); |
---|
85 | /* |
---|
86 | * Currently unexpected vectors happen only on SMP and APIC. |
---|
87 | * We _must_ ack these because every local APIC has only N |
---|
88 | * irq slots per priority level, and a 'hanging, unacked' IRQ |
---|
89 | * holds up an irq slot - in excessive cases (when multiple |
---|
90 | * unexpected vectors occur) that might lock up the APIC |
---|
91 | * completely. |
---|
92 | * But only ack when the APIC is enabled -AK |
---|
93 | */ |
---|
94 | if (cpu_has_apic) |
---|
95 | ack_APIC_irq(); |
---|
96 | } |
---|
97 | |
---|
98 | int get_physical_broadcast(void) |
---|
99 | { |
---|
100 | return 0xff; |
---|
101 | } |
---|
102 | |
---|
103 | #ifndef CONFIG_XEN |
---|
104 | #ifndef CONFIG_SMP |
---|
105 | static void up_apic_timer_interrupt_call(struct pt_regs *regs) |
---|
106 | { |
---|
107 | int cpu = smp_processor_id(); |
---|
108 | |
---|
109 | /* |
---|
110 | * the NMI deadlock-detector uses this. |
---|
111 | */ |
---|
112 | per_cpu(irq_stat, cpu).apic_timer_irqs++; |
---|
113 | |
---|
114 | smp_local_timer_interrupt(regs); |
---|
115 | } |
---|
116 | #endif |
---|
117 | |
---|
118 | void smp_send_timer_broadcast_ipi(struct pt_regs *regs) |
---|
119 | { |
---|
120 | cpumask_t mask; |
---|
121 | |
---|
122 | cpus_and(mask, cpu_online_map, timer_bcast_ipi); |
---|
123 | if (!cpus_empty(mask)) { |
---|
124 | #ifdef CONFIG_SMP |
---|
125 | send_IPI_mask(mask, LOCAL_TIMER_VECTOR); |
---|
126 | #else |
---|
127 | /* |
---|
128 | * We can directly call the apic timer interrupt handler |
---|
129 | * in UP case. Minus all irq related functions |
---|
130 | */ |
---|
131 | up_apic_timer_interrupt_call(regs); |
---|
132 | #endif |
---|
133 | } |
---|
134 | } |
---|
135 | #endif |
---|
136 | |
---|
137 | int setup_profiling_timer(unsigned int multiplier) |
---|
138 | { |
---|
139 | return -EINVAL; |
---|
140 | } |
---|
141 | |
---|
142 | /* |
---|
143 | * This initializes the IO-APIC and APIC hardware if this is |
---|
144 | * a UP kernel. |
---|
145 | */ |
---|
146 | int __init APIC_init_uniprocessor (void) |
---|
147 | { |
---|
148 | #ifdef CONFIG_X86_IO_APIC |
---|
149 | if (smp_found_config) |
---|
150 | if (!skip_ioapic_setup && nr_ioapics) |
---|
151 | setup_IO_APIC(); |
---|
152 | #endif |
---|
153 | |
---|
154 | return 0; |
---|
155 | } |
---|