blob: 8d7748efe6a801859e2cda4c96354a57d69237ea [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Copyright 2004 James Cleverdon, IBM.
3 * Subject to the GNU Public License, v.2
4 *
5 * Generic APIC sub-arch probe layer.
6 *
7 * Hacked for x86-64 by James Cleverdon from i386 architecture code by
8 * Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and
9 * James Cleverdon.
10 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <linux/threads.h>
12#include <linux/cpumask.h>
13#include <linux/string.h>
Ingo Molnar07c7c472007-05-02 19:27:04 +020014#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <linux/kernel.h>
16#include <linux/ctype.h>
17#include <linux/init.h>
Jack Steinerac23d4e2008-03-28 14:12:16 -050018#include <linux/hardirq.h>
Yinghai Lud25ae382008-07-25 19:39:03 -070019#include <linux/dmar.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
21#include <asm/smp.h>
Ingo Molnar7b6aa332009-02-17 13:58:15 +010022#include <asm/apic.h>
Yinghai Luc1eeb2d2009-02-16 23:02:14 -080023#include <asm/ipi.h>
Yinghai Lu54ac14a2008-11-17 15:19:53 -080024#include <asm/setup.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Ingo Molnarbe163a12009-02-17 16:28:46 +010026extern struct apic apic_flat;
27extern struct apic apic_physflat;
28extern struct apic apic_x2xpic_uv_x;
29extern struct apic apic_x2apic_phys;
30extern struct apic apic_x2apic_cluster;
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
Ingo Molnarbe163a12009-02-17 16:28:46 +010032struct apic __read_mostly *apic = &apic_flat;
Ingo Molnar7d01d322009-02-17 12:33:20 +010033EXPORT_SYMBOL_GPL(apic);
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Ingo Molnarbe163a12009-02-17 16:28:46 +010035static struct apic *apic_probe[] __initdata = {
Nick Piggin03b48632009-01-20 04:36:04 +010036#ifdef CONFIG_X86_UV
Yinghai Lu1b9b89e2008-07-21 22:08:21 -070037 &apic_x2apic_uv_x,
Nick Piggin03b48632009-01-20 04:36:04 +010038#endif
Yinghai Lu06cd9a72009-02-16 17:29:58 -080039#ifdef CONFIG_X86_X2APIC
Yinghai Lu1b9b89e2008-07-21 22:08:21 -070040 &apic_x2apic_phys,
41 &apic_x2apic_cluster,
Yinghai Lu06cd9a72009-02-16 17:29:58 -080042#endif
Yinghai Lu1b9b89e2008-07-21 22:08:21 -070043 &apic_physflat,
44 NULL,
45};
Jack Steinerae261862008-03-28 14:12:06 -050046
Linus Torvalds1da177e2005-04-16 15:20:36 -070047/*
48 * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode.
49 */
Ingo Molnar72ce0162009-01-28 06:50:47 +010050void __init default_setup_apic_routing(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070051{
Yinghai Lu06cd9a72009-02-16 17:29:58 -080052#ifdef CONFIG_X86_X2APIC
Suresh Siddhaef1f87a2009-02-21 14:23:21 -080053 if (x2apic && (apic != &apic_x2apic_phys &&
54#ifdef CONFIG_X86_UV
55 apic != &apic_x2apic_uv_x &&
56#endif
57 apic != &apic_x2apic_cluster)) {
58 if (x2apic_phys)
59 apic = &apic_x2apic_phys;
60 else
61 apic = &apic_x2apic_cluster;
62 printk(KERN_INFO "Setting APIC routing to %s\n", apic->name);
Yinghai Lud25ae382008-07-25 19:39:03 -070063 }
Yinghai Lu06cd9a72009-02-16 17:29:58 -080064#endif
Yinghai Lud25ae382008-07-25 19:39:03 -070065
Ingo Molnarc8d46cf2009-01-28 00:14:11 +010066 if (apic == &apic_flat) {
Yinghai Lu1b9b89e2008-07-21 22:08:21 -070067 if (max_physical_apicid >= 8)
Ingo Molnarc8d46cf2009-01-28 00:14:11 +010068 apic = &apic_physflat;
69 printk(KERN_INFO "Setting APIC routing to %s\n", apic->name);
Yinghai Lu1b9b89e2008-07-21 22:08:21 -070070 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070071}
72
Ingo Molnar07c7c472007-05-02 19:27:04 +020073/* Same for both flat and physical. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070074
Suresh Siddhacff73a62008-07-10 11:16:53 -070075void apic_send_IPI_self(int vector)
Linus Torvalds1da177e2005-04-16 15:20:36 -070076{
Ingo Molnardac5f412009-01-28 15:42:24 +010077 __default_send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070078}
Jack Steinerae261862008-03-28 14:12:06 -050079
Ingo Molnar306db032009-01-28 03:43:47 +010080int __init default_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
Jack Steinerae261862008-03-28 14:12:06 -050081{
Yinghai Lu1b9b89e2008-07-21 22:08:21 -070082 int i;
83
84 for (i = 0; apic_probe[i]; ++i) {
85 if (apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id)) {
Ingo Molnarc8d46cf2009-01-28 00:14:11 +010086 apic = apic_probe[i];
Yinghai Lu1b9b89e2008-07-21 22:08:21 -070087 printk(KERN_INFO "Setting APIC routing to %s.\n",
Ingo Molnarc8d46cf2009-01-28 00:14:11 +010088 apic->name);
Yinghai Lu1b9b89e2008-07-21 22:08:21 -070089 return 1;
90 }
Jack Steinerae261862008-03-28 14:12:06 -050091 }
92 return 0;
93}