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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | /* |
| 27 | * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode. |
| 28 | */ |
Ingo Molnar | 72ce016 | 2009-01-28 06:50:47 +0100 | [diff] [blame] | 29 | void __init default_setup_apic_routing(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | { |
Suresh Siddha | 8b37e88 | 2011-05-20 17:51:18 -0700 | [diff] [blame] | 31 | struct apic **drv; |
Suresh Siddha | fa47f7e | 2010-08-27 11:09:50 -0700 | [diff] [blame] | 32 | |
| 33 | enable_IR_x2apic(); |
| 34 | |
Suresh Siddha | 8b37e88 | 2011-05-20 17:51:18 -0700 | [diff] [blame] | 35 | for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) { |
| 36 | if ((*drv)->probe && (*drv)->probe()) { |
| 37 | if (apic != *drv) { |
| 38 | apic = *drv; |
| 39 | pr_info("Switched APIC routing to %s.\n", |
| 40 | apic->name); |
| 41 | } |
Suresh Siddha | 9ebd680 | 2011-05-19 16:45:46 -0700 | [diff] [blame] | 42 | break; |
| 43 | } |
Yinghai Lu | d25ae38 | 2008-07-25 19:39:03 -0700 | [diff] [blame] | 44 | } |
| 45 | |
Ido Yariv | 7db971b | 2012-06-03 01:11:34 +0300 | [diff] [blame] | 46 | if (x86_platform.apic_post_init) |
| 47 | x86_platform.apic_post_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | } |
| 49 | |
Ingo Molnar | 07c7c47 | 2007-05-02 19:27:04 +0200 | [diff] [blame] | 50 | /* Same for both flat and physical. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
Suresh Siddha | cff73a6 | 2008-07-10 11:16:53 -0700 | [diff] [blame] | 52 | void apic_send_IPI_self(int vector) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | { |
Ingo Molnar | dac5f41 | 2009-01-28 15:42:24 +0100 | [diff] [blame] | 54 | __default_send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | } |
Jack Steiner | ae26186 | 2008-03-28 14:12:06 -0500 | [diff] [blame] | 56 | |
Ingo Molnar | 306db03 | 2009-01-28 03:43:47 +0100 | [diff] [blame] | 57 | 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] | 58 | { |
Suresh Siddha | 8b37e88 | 2011-05-20 17:51:18 -0700 | [diff] [blame] | 59 | struct apic **drv; |
Yinghai Lu | 1b9b89e | 2008-07-21 22:08:21 -0700 | [diff] [blame] | 60 | |
Suresh Siddha | 8b37e88 | 2011-05-20 17:51:18 -0700 | [diff] [blame] | 61 | for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) { |
| 62 | if ((*drv)->acpi_madt_oem_check(oem_id, oem_table_id)) { |
| 63 | if (apic != *drv) { |
| 64 | apic = *drv; |
| 65 | pr_info("Setting APIC routing to %s.\n", |
| 66 | apic->name); |
| 67 | } |
Yinghai Lu | 1b9b89e | 2008-07-21 22:08:21 -0700 | [diff] [blame] | 68 | return 1; |
| 69 | } |
Jack Steiner | ae26186 | 2008-03-28 14:12:06 -0500 | [diff] [blame] | 70 | } |
| 71 | return 0; |
| 72 | } |