| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/threads.h> |
| 12 | #include <linux/cpumask.h> |
| 13 | #include <linux/string.h> |
| Ingo Molnar | 07c7c47 | 2007-05-02 19:27:04 +0200 | [diff] [blame] | 14 | #include <linux/module.h> |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/kernel.h> |
| 16 | #include <linux/ctype.h> |
| 17 | #include <linux/init.h> |
| Jack Steiner | ac23d4e | 2008-03-28 14:12:16 -0500 | [diff] [blame] | 18 | #include <linux/hardirq.h> |
| Yinghai Lu | d25ae38 | 2008-07-25 19:39:03 -0700 | [diff] [blame] | 19 | #include <linux/dmar.h> |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | |
| 21 | #include <asm/smp.h> |
| Ingo Molnar | 7b6aa33 | 2009-02-17 13:58:15 +0100 | [diff] [blame] | 22 | #include <asm/apic.h> |
| Yinghai Lu | c1eeb2d | 2009-02-16 23:02:14 -0800 | [diff] [blame] | 23 | #include <asm/ipi.h> |
| Yinghai Lu | 54ac14a | 2008-11-17 15:19:53 -0800 | [diff] [blame] | 24 | #include <asm/setup.h> |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
| Ingo Molnar | be163a1 | 2009-02-17 16:28:46 +0100 | [diff] [blame] | 26 | extern struct apic apic_flat; |
| 27 | extern struct apic apic_physflat; |
| 28 | extern struct apic apic_x2xpic_uv_x; |
| 29 | extern struct apic apic_x2apic_phys; |
| 30 | extern struct apic apic_x2apic_cluster; |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
| Ingo Molnar | be163a1 | 2009-02-17 16:28:46 +0100 | [diff] [blame] | 32 | struct apic __read_mostly *apic = &apic_flat; |
| Ingo Molnar | 7d01d32 | 2009-02-17 12:33:20 +0100 | [diff] [blame] | 33 | EXPORT_SYMBOL_GPL(apic); |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
| Ingo Molnar | be163a1 | 2009-02-17 16:28:46 +0100 | [diff] [blame] | 35 | static struct apic *apic_probe[] __initdata = { |
| Nick Piggin | 03b4863 | 2009-01-20 04:36:04 +0100 | [diff] [blame] | 36 | #ifdef CONFIG_X86_UV |
| Yinghai Lu | 1b9b89e | 2008-07-21 22:08:21 -0700 | [diff] [blame] | 37 | &apic_x2apic_uv_x, |
| Nick Piggin | 03b4863 | 2009-01-20 04:36:04 +0100 | [diff] [blame] | 38 | #endif |
| Yinghai Lu | 06cd9a7 | 2009-02-16 17:29:58 -0800 | [diff] [blame] | 39 | #ifdef CONFIG_X86_X2APIC |
| Yinghai Lu | 1b9b89e | 2008-07-21 22:08:21 -0700 | [diff] [blame] | 40 | &apic_x2apic_phys, |
| 41 | &apic_x2apic_cluster, |
| Yinghai Lu | 06cd9a7 | 2009-02-16 17:29:58 -0800 | [diff] [blame] | 42 | #endif |
| Yinghai Lu | 1b9b89e | 2008-07-21 22:08:21 -0700 | [diff] [blame] | 43 | &apic_physflat, |
| 44 | NULL, |
| 45 | }; |
| Jack Steiner | ae26186 | 2008-03-28 14:12:06 -0500 | [diff] [blame] | 46 | |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | /* |
| 48 | * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode. |
| 49 | */ |
| Ingo Molnar | 72ce016 | 2009-01-28 06:50:47 +0100 | [diff] [blame] | 50 | void __init default_setup_apic_routing(void) |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | { |
| Yinghai Lu | 06cd9a7 | 2009-02-16 17:29:58 -0800 | [diff] [blame] | 52 | #ifdef CONFIG_X86_X2APIC |
| Suresh Siddha | ef1f87a | 2009-02-21 14:23:21 -0800 | [diff] [blame] | 53 | 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 Lu | d25ae38 | 2008-07-25 19:39:03 -0700 | [diff] [blame] | 63 | } |
| Yinghai Lu | 06cd9a7 | 2009-02-16 17:29:58 -0800 | [diff] [blame] | 64 | #endif |
| Yinghai Lu | d25ae38 | 2008-07-25 19:39:03 -0700 | [diff] [blame] | 65 | |
| Ingo Molnar | c8d46cf | 2009-01-28 00:14:11 +0100 | [diff] [blame] | 66 | if (apic == &apic_flat) { |
| Yinghai Lu | 1b9b89e | 2008-07-21 22:08:21 -0700 | [diff] [blame] | 67 | if (max_physical_apicid >= 8) |
| Ingo Molnar | c8d46cf | 2009-01-28 00:14:11 +0100 | [diff] [blame] | 68 | apic = &apic_physflat; |
| 69 | printk(KERN_INFO "Setting APIC routing to %s\n", apic->name); |
| Yinghai Lu | 1b9b89e | 2008-07-21 22:08:21 -0700 | [diff] [blame] | 70 | } |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | } |
| 72 | |
| Ingo Molnar | 07c7c47 | 2007-05-02 19:27:04 +0200 | [diff] [blame] | 73 | /* Same for both flat and physical. */ |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
| Suresh Siddha | cff73a6 | 2008-07-10 11:16:53 -0700 | [diff] [blame] | 75 | void apic_send_IPI_self(int vector) |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | { |
| Ingo Molnar | dac5f41 | 2009-01-28 15:42:24 +0100 | [diff] [blame] | 77 | __default_send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL); |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | } |
| Jack Steiner | ae26186 | 2008-03-28 14:12:06 -0500 | [diff] [blame] | 79 | |
| Ingo Molnar | 306db03 | 2009-01-28 03:43:47 +0100 | [diff] [blame] | 80 | int __init default_acpi_madt_oem_check(char *oem_id, char *oem_table_id) |
| Jack Steiner | ae26186 | 2008-03-28 14:12:06 -0500 | [diff] [blame] | 81 | { |
| Yinghai Lu | 1b9b89e | 2008-07-21 22:08:21 -0700 | [diff] [blame] | 82 | 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 Molnar | c8d46cf | 2009-01-28 00:14:11 +0100 | [diff] [blame] | 86 | apic = apic_probe[i]; |
| Yinghai Lu | 1b9b89e | 2008-07-21 22:08:21 -0700 | [diff] [blame] | 87 | printk(KERN_INFO "Setting APIC routing to %s.\n", |
| Ingo Molnar | c8d46cf | 2009-01-28 00:14:11 +0100 | [diff] [blame] | 88 | apic->name); |
| Yinghai Lu | 1b9b89e | 2008-07-21 22:08:21 -0700 | [diff] [blame] | 89 | return 1; |
| 90 | } |
| Jack Steiner | ae26186 | 2008-03-28 14:12:06 -0500 | [diff] [blame] | 91 | } |
| 92 | return 0; |
| 93 | } |