Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * boot.c - Architecture-Specific Low-Level ACPI Boot Support |
| 3 | * |
| 4 | * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> |
| 5 | * Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com> |
| 6 | * |
| 7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 22 | * |
| 23 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 24 | */ |
| 25 | |
| 26 | #include <linux/init.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #include <linux/acpi.h> |
Thomas Gleixner | d66bea5 | 2007-02-16 01:27:57 -0800 | [diff] [blame] | 28 | #include <linux/acpi_pmtmr.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | #include <linux/efi.h> |
Ashok Raj | 73fea17 | 2006-09-26 10:52:35 +0200 | [diff] [blame] | 30 | #include <linux/cpumask.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #include <linux/module.h> |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 32 | #include <linux/dmi.h> |
Nick Piggin | b33fa1f | 2005-10-01 02:34:42 +1000 | [diff] [blame] | 33 | #include <linux/irq.h> |
adurbin@google.com | f0f4c34 | 2006-09-26 10:52:39 +0200 | [diff] [blame] | 34 | #include <linux/bootmem.h> |
| 35 | #include <linux/ioport.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
| 37 | #include <asm/pgtable.h> |
| 38 | #include <asm/io_apic.h> |
| 39 | #include <asm/apic.h> |
Ingo Molnar | 183fe06 | 2008-07-09 11:32:10 +0200 | [diff] [blame] | 40 | #include <asm/genapic.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | #include <asm/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #include <asm/mpspec.h> |
Alexey Starikovskiy | dfac218 | 2008-04-04 23:41:50 +0400 | [diff] [blame] | 43 | #include <asm/smp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
Glauber de Oliveira Costa | f6bc402 | 2008-03-19 14:25:53 -0300 | [diff] [blame] | 45 | #ifdef CONFIG_X86_LOCAL_APIC |
| 46 | # include <mach_apic.h> |
| 47 | #endif |
| 48 | |
Adrian Bunk | e8924ac | 2006-09-26 10:52:35 +0200 | [diff] [blame] | 49 | static int __initdata acpi_force = 0; |
Zhao Yakui | 237889b | 2008-12-17 16:55:18 +0800 | [diff] [blame] | 50 | u32 acpi_rsdt_forced; |
Andi Kleen | df3bb57 | 2006-09-26 10:52:33 +0200 | [diff] [blame] | 51 | #ifdef CONFIG_ACPI |
| 52 | int acpi_disabled = 0; |
| 53 | #else |
| 54 | int acpi_disabled = 1; |
| 55 | #endif |
| 56 | EXPORT_SYMBOL(acpi_disabled); |
| 57 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | #ifdef CONFIG_X86_64 |
| 59 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | #include <asm/proto.h> |
Linus Torvalds | 637029c | 2006-02-27 20:41:56 -0800 | [diff] [blame] | 61 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 62 | #else /* X86 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | |
| 64 | #ifdef CONFIG_X86_LOCAL_APIC |
| 65 | #include <mach_apic.h> |
| 66 | #include <mach_mpparse.h> |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 67 | #endif /* CONFIG_X86_LOCAL_APIC */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 69 | #endif /* X86 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | |
| 71 | #define BAD_MADT_ENTRY(entry, end) ( \ |
| 72 | (!entry) || (unsigned long)entry + sizeof(*entry) > end || \ |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 73 | ((struct acpi_subtable_header *)entry)->length < sizeof(*entry)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
| 75 | #define PREFIX "ACPI: " |
| 76 | |
Andrew Morton | 90d5390 | 2006-11-02 22:07:18 -0800 | [diff] [blame] | 77 | int acpi_noirq; /* skip ACPI IRQ initialization */ |
Yinghai Lu | 6e4be1ff | 2008-02-05 00:01:48 -0800 | [diff] [blame] | 78 | int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */ |
| 79 | EXPORT_SYMBOL(acpi_pci_disabled); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | int acpi_ht __initdata = 1; /* enable HT */ |
| 81 | |
| 82 | int acpi_lapic; |
| 83 | int acpi_ioapic; |
| 84 | int acpi_strict; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 86 | u8 acpi_sci_flags __initdata; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | int acpi_sci_override_gsi __initdata; |
| 88 | int acpi_skip_timer_override __initdata; |
Andi Kleen | fa18f47 | 2006-11-14 16:57:46 +0100 | [diff] [blame] | 89 | int acpi_use_timer_override __initdata; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | |
| 91 | #ifdef CONFIG_X86_LOCAL_APIC |
| 92 | static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE; |
| 93 | #endif |
| 94 | |
| 95 | #ifndef __HAVE_ARCH_CMPXCHG |
| 96 | #warning ACPI uses CMPXCHG, i486 and later hardware |
| 97 | #endif |
| 98 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | /* -------------------------------------------------------------------------- |
| 100 | Boot-time Configuration |
| 101 | -------------------------------------------------------------------------- */ |
| 102 | |
| 103 | /* |
| 104 | * The default interrupt routing model is PIC (8259). This gets |
Simon Arlott | 27b46d7 | 2007-10-20 01:13:56 +0200 | [diff] [blame] | 105 | * overridden if IOAPICs are enumerated (below). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 107 | enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | |
| 110 | /* |
| 111 | * Temporarily use the virtual area starting from FIX_IO_APIC_BASE_END, |
| 112 | * to map the target physical address. The problem is that set_fixmap() |
| 113 | * provides a single page, and it is possible that the page is not |
| 114 | * sufficient. |
| 115 | * By using this area, we can map up to MAX_IO_APICS pages temporarily, |
| 116 | * i.e. until the next __va_range() call. |
| 117 | * |
| 118 | * Important Safety Note: The fixed I/O APIC page numbers are *subtracted* |
| 119 | * from the fixed base. That's why we start at FIX_IO_APIC_BASE_END and |
| 120 | * count idx down while incrementing the phys address. |
| 121 | */ |
Jan Beulich | 2fdf074 | 2007-12-13 08:33:59 +0000 | [diff] [blame] | 122 | char *__init __acpi_map_table(unsigned long phys, unsigned long size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | { |
| 124 | unsigned long base, offset, mapped_size; |
| 125 | int idx; |
| 126 | |
Yinghai Lu | f34fa82 | 2008-07-09 20:16:36 -0700 | [diff] [blame] | 127 | if (!phys || !size) |
| 128 | return NULL; |
| 129 | |
Yinghai Lu | f361a45 | 2008-07-10 20:38:26 -0700 | [diff] [blame] | 130 | if (phys+size <= (max_low_pfn_mapped << PAGE_SHIFT)) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 131 | return __va(phys); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | |
| 133 | offset = phys & (PAGE_SIZE - 1); |
| 134 | mapped_size = PAGE_SIZE - offset; |
Yinghai Lu | f34fa82 | 2008-07-09 20:16:36 -0700 | [diff] [blame] | 135 | clear_fixmap(FIX_ACPI_END); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | set_fixmap(FIX_ACPI_END, phys); |
| 137 | base = fix_to_virt(FIX_ACPI_END); |
| 138 | |
| 139 | /* |
| 140 | * Most cases can be covered by the below. |
| 141 | */ |
| 142 | idx = FIX_ACPI_END; |
| 143 | while (mapped_size < size) { |
| 144 | if (--idx < FIX_ACPI_BEGIN) |
| 145 | return NULL; /* cannot handle this */ |
| 146 | phys += PAGE_SIZE; |
Yinghai Lu | f34fa82 | 2008-07-09 20:16:36 -0700 | [diff] [blame] | 147 | clear_fixmap(idx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | set_fixmap(idx, phys); |
| 149 | mapped_size += PAGE_SIZE; |
| 150 | } |
| 151 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 152 | return ((unsigned char *)base + offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | |
| 155 | #ifdef CONFIG_PCI_MMCONFIG |
Pavel Vasilyev | 1339c36 | 2008-10-15 17:33:48 -0400 | [diff] [blame] | 156 | |
| 157 | static int acpi_mcfg_64bit_base_addr __initdata = FALSE; |
| 158 | |
Greg Kroah-Hartman | 5454939 | 2005-06-23 17:35:56 -0700 | [diff] [blame] | 159 | /* The physical address of the MMCONFIG aperture. Set from ACPI tables. */ |
Alexey Starikovskiy | 15a58ed | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 160 | struct acpi_mcfg_allocation *pci_mmcfg_config; |
Greg Kroah-Hartman | 5454939 | 2005-06-23 17:35:56 -0700 | [diff] [blame] | 161 | int pci_mmcfg_config_num; |
| 162 | |
John Keller | a726c60 | 2008-07-29 14:34:16 -0500 | [diff] [blame] | 163 | static int __init acpi_mcfg_oem_check(struct acpi_table_mcfg *mcfg) |
| 164 | { |
| 165 | if (!strcmp(mcfg->header.oem_id, "SGI")) |
| 166 | acpi_mcfg_64bit_base_addr = TRUE; |
| 167 | |
| 168 | return 0; |
| 169 | } |
| 170 | |
Alexey Starikovskiy | ceb6c46 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 171 | int __init acpi_parse_mcfg(struct acpi_table_header *header) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | { |
| 173 | struct acpi_table_mcfg *mcfg; |
Greg Kroah-Hartman | 5454939 | 2005-06-23 17:35:56 -0700 | [diff] [blame] | 174 | unsigned long i; |
| 175 | int config_size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | |
Alexey Starikovskiy | ceb6c46 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 177 | if (!header) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | return -EINVAL; |
| 179 | |
Alexey Starikovskiy | ceb6c46 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 180 | mcfg = (struct acpi_table_mcfg *)header; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | |
Greg Kroah-Hartman | 5454939 | 2005-06-23 17:35:56 -0700 | [diff] [blame] | 182 | /* how many config structures do we have */ |
| 183 | pci_mmcfg_config_num = 0; |
Alexey Starikovskiy | ceb6c46 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 184 | i = header->length - sizeof(struct acpi_table_mcfg); |
Alexey Starikovskiy | 15a58ed | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 185 | while (i >= sizeof(struct acpi_mcfg_allocation)) { |
Greg Kroah-Hartman | 5454939 | 2005-06-23 17:35:56 -0700 | [diff] [blame] | 186 | ++pci_mmcfg_config_num; |
Alexey Starikovskiy | 15a58ed | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 187 | i -= sizeof(struct acpi_mcfg_allocation); |
Greg Kroah-Hartman | 5454939 | 2005-06-23 17:35:56 -0700 | [diff] [blame] | 188 | }; |
| 189 | if (pci_mmcfg_config_num == 0) { |
| 190 | printk(KERN_ERR PREFIX "MMCONFIG has no entries\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | return -ENODEV; |
| 192 | } |
| 193 | |
Greg Kroah-Hartman | 5454939 | 2005-06-23 17:35:56 -0700 | [diff] [blame] | 194 | config_size = pci_mmcfg_config_num * sizeof(*pci_mmcfg_config); |
| 195 | pci_mmcfg_config = kmalloc(config_size, GFP_KERNEL); |
| 196 | if (!pci_mmcfg_config) { |
| 197 | printk(KERN_WARNING PREFIX |
| 198 | "No memory for MCFG config tables\n"); |
| 199 | return -ENOMEM; |
| 200 | } |
| 201 | |
Alexey Starikovskiy | ad363f8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 202 | memcpy(pci_mmcfg_config, &mcfg[1], config_size); |
John Keller | a726c60 | 2008-07-29 14:34:16 -0500 | [diff] [blame] | 203 | |
| 204 | acpi_mcfg_oem_check(mcfg); |
| 205 | |
Greg Kroah-Hartman | 5454939 | 2005-06-23 17:35:56 -0700 | [diff] [blame] | 206 | for (i = 0; i < pci_mmcfg_config_num; ++i) { |
John Keller | a726c60 | 2008-07-29 14:34:16 -0500 | [diff] [blame] | 207 | if ((pci_mmcfg_config[i].address > 0xFFFFFFFF) && |
| 208 | !acpi_mcfg_64bit_base_addr) { |
Greg Kroah-Hartman | 5454939 | 2005-06-23 17:35:56 -0700 | [diff] [blame] | 209 | printk(KERN_ERR PREFIX |
| 210 | "MMCONFIG not in low 4GB of memory\n"); |
Konrad Rzeszutek | acc7c2e | 2006-06-15 12:08:30 -0400 | [diff] [blame] | 211 | kfree(pci_mmcfg_config); |
| 212 | pci_mmcfg_config_num = 0; |
Greg Kroah-Hartman | 5454939 | 2005-06-23 17:35:56 -0700 | [diff] [blame] | 213 | return -ENODEV; |
| 214 | } |
| 215 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | |
| 217 | return 0; |
| 218 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 219 | #endif /* CONFIG_PCI_MMCONFIG */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | |
| 221 | #ifdef CONFIG_X86_LOCAL_APIC |
Alexey Starikovskiy | 15a58ed | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 222 | static int __init acpi_parse_madt(struct acpi_table_header *table) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 224 | struct acpi_table_madt *madt = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | |
Alexey Starikovskiy | 15a58ed | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 226 | if (!cpu_has_apic) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | return -EINVAL; |
| 228 | |
Alexey Starikovskiy | 15a58ed | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 229 | madt = (struct acpi_table_madt *)table; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | if (!madt) { |
| 231 | printk(KERN_WARNING PREFIX "Unable to map MADT\n"); |
| 232 | return -ENODEV; |
| 233 | } |
| 234 | |
Alexey Starikovskiy | ad363f8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 235 | if (madt->address) { |
| 236 | acpi_lapic_addr = (u64) madt->address; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | |
| 238 | printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n", |
Alexey Starikovskiy | ad363f8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 239 | madt->address); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | } |
| 241 | |
Ingo Molnar | 306db03 | 2009-01-28 03:43:47 +0100 | [diff] [blame^] | 242 | default_acpi_madt_oem_check(madt->header.oem_id, |
| 243 | madt->header.oem_table_id); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 244 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | return 0; |
| 246 | } |
| 247 | |
Alexey Starikovskiy | dfac218 | 2008-04-04 23:41:50 +0400 | [diff] [blame] | 248 | static void __cpuinit acpi_register_lapic(int id, u8 enabled) |
| 249 | { |
Yinghai Lu | fb3bbd6 | 2008-05-22 18:22:30 -0700 | [diff] [blame] | 250 | unsigned int ver = 0; |
| 251 | |
Alexey Starikovskiy | dfac218 | 2008-04-04 23:41:50 +0400 | [diff] [blame] | 252 | if (!enabled) { |
| 253 | ++disabled_cpus; |
| 254 | return; |
| 255 | } |
| 256 | |
Yinghai Lu | fb3bbd6 | 2008-05-22 18:22:30 -0700 | [diff] [blame] | 257 | if (boot_cpu_physical_apicid != -1U) |
| 258 | ver = apic_version[boot_cpu_physical_apicid]; |
Yinghai Lu | fb3bbd6 | 2008-05-22 18:22:30 -0700 | [diff] [blame] | 259 | |
| 260 | generic_processor_info(id, ver); |
Alexey Starikovskiy | dfac218 | 2008-04-04 23:41:50 +0400 | [diff] [blame] | 261 | } |
| 262 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | static int __init |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 264 | acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | { |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 266 | struct acpi_madt_local_apic *processor = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 268 | processor = (struct acpi_madt_local_apic *)header; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | |
| 270 | if (BAD_MADT_ENTRY(processor, end)) |
| 271 | return -EINVAL; |
| 272 | |
| 273 | acpi_table_print_madt_entry(header); |
| 274 | |
Ashok Raj | 7f66ae4 | 2006-02-03 21:51:50 +0100 | [diff] [blame] | 275 | /* |
| 276 | * We need to register disabled CPU as well to permit |
| 277 | * counting disabled CPUs. This allows us to size |
| 278 | * cpus_possible_map more accurately, to permit |
| 279 | * to not preallocating memory for all NR_CPUS |
| 280 | * when we use CPU hotplug. |
| 281 | */ |
Alexey Starikovskiy | dfac218 | 2008-04-04 23:41:50 +0400 | [diff] [blame] | 282 | acpi_register_lapic(processor->id, /* APIC ID */ |
| 283 | processor->lapic_flags & ACPI_MADT_ENABLED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | |
| 285 | return 0; |
| 286 | } |
| 287 | |
| 288 | static int __init |
Jack Steiner | ac049c1 | 2008-03-28 14:12:09 -0500 | [diff] [blame] | 289 | acpi_parse_sapic(struct acpi_subtable_header *header, const unsigned long end) |
| 290 | { |
| 291 | struct acpi_madt_local_sapic *processor = NULL; |
| 292 | |
| 293 | processor = (struct acpi_madt_local_sapic *)header; |
| 294 | |
| 295 | if (BAD_MADT_ENTRY(processor, end)) |
| 296 | return -EINVAL; |
| 297 | |
| 298 | acpi_table_print_madt_entry(header); |
| 299 | |
Alexey Starikovskiy | dfac218 | 2008-04-04 23:41:50 +0400 | [diff] [blame] | 300 | acpi_register_lapic((processor->id << 8) | processor->eid,/* APIC ID */ |
| 301 | processor->lapic_flags & ACPI_MADT_ENABLED); |
Jack Steiner | ac049c1 | 2008-03-28 14:12:09 -0500 | [diff] [blame] | 302 | |
| 303 | return 0; |
| 304 | } |
| 305 | |
| 306 | static int __init |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 307 | acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 308 | const unsigned long end) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | { |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 310 | struct acpi_madt_local_apic_override *lapic_addr_ovr = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 312 | lapic_addr_ovr = (struct acpi_madt_local_apic_override *)header; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | |
| 314 | if (BAD_MADT_ENTRY(lapic_addr_ovr, end)) |
| 315 | return -EINVAL; |
| 316 | |
| 317 | acpi_lapic_addr = lapic_addr_ovr->address; |
| 318 | |
| 319 | return 0; |
| 320 | } |
| 321 | |
| 322 | static int __init |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 323 | acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long end) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | { |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 325 | struct acpi_madt_local_apic_nmi *lapic_nmi = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 327 | lapic_nmi = (struct acpi_madt_local_apic_nmi *)header; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | |
| 329 | if (BAD_MADT_ENTRY(lapic_nmi, end)) |
| 330 | return -EINVAL; |
| 331 | |
| 332 | acpi_table_print_madt_entry(header); |
| 333 | |
| 334 | if (lapic_nmi->lint != 1) |
| 335 | printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n"); |
| 336 | |
| 337 | return 0; |
| 338 | } |
| 339 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 340 | #endif /*CONFIG_X86_LOCAL_APIC */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | |
Len Brown | 8466361 | 2005-08-24 12:09:07 -0400 | [diff] [blame] | 342 | #ifdef CONFIG_X86_IO_APIC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | |
| 344 | static int __init |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 345 | acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | { |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 347 | struct acpi_madt_io_apic *ioapic = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 349 | ioapic = (struct acpi_madt_io_apic *)header; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | |
| 351 | if (BAD_MADT_ENTRY(ioapic, end)) |
| 352 | return -EINVAL; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 353 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | acpi_table_print_madt_entry(header); |
| 355 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 356 | mp_register_ioapic(ioapic->id, |
| 357 | ioapic->address, ioapic->global_irq_base); |
| 358 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | return 0; |
| 360 | } |
| 361 | |
| 362 | /* |
| 363 | * Parse Interrupt Source Override for the ACPI SCI |
| 364 | */ |
Len Brown | e82c354 | 2006-12-21 01:29:59 -0500 | [diff] [blame] | 365 | static void __init acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | { |
| 367 | if (trigger == 0) /* compatible SCI trigger is level */ |
| 368 | trigger = 3; |
| 369 | |
| 370 | if (polarity == 0) /* compatible SCI polarity is low */ |
| 371 | polarity = 3; |
| 372 | |
| 373 | /* Command-line over-ride via acpi_sci= */ |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 374 | if (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) |
| 375 | trigger = (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) >> 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 377 | if (acpi_sci_flags & ACPI_MADT_POLARITY_MASK) |
| 378 | polarity = acpi_sci_flags & ACPI_MADT_POLARITY_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | |
| 380 | /* |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 381 | * mp_config_acpi_legacy_irqs() already setup IRQs < 16 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 382 | * If GSI is < 16, this will update its flags, |
| 383 | * else it will create a new mp_irqs[] entry. |
| 384 | */ |
Len Brown | 7bdd21c | 2006-12-02 02:27:46 -0500 | [diff] [blame] | 385 | mp_override_legacy_irq(gsi, polarity, trigger, gsi); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | |
| 387 | /* |
| 388 | * stash over-ride to indicate we've been here |
Alexey Starikovskiy | cee324b | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 389 | * and for later update of acpi_gbl_FADT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | */ |
Len Brown | 7bdd21c | 2006-12-02 02:27:46 -0500 | [diff] [blame] | 391 | acpi_sci_override_gsi = gsi; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | return; |
| 393 | } |
| 394 | |
| 395 | static int __init |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 396 | acpi_parse_int_src_ovr(struct acpi_subtable_header * header, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 397 | const unsigned long end) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | { |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 399 | struct acpi_madt_interrupt_override *intsrc = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 401 | intsrc = (struct acpi_madt_interrupt_override *)header; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | |
| 403 | if (BAD_MADT_ENTRY(intsrc, end)) |
| 404 | return -EINVAL; |
| 405 | |
| 406 | acpi_table_print_madt_entry(header); |
| 407 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 408 | if (intsrc->source_irq == acpi_gbl_FADT.sci_interrupt) { |
Len Brown | 7bdd21c | 2006-12-02 02:27:46 -0500 | [diff] [blame] | 409 | acpi_sci_ioapic_setup(intsrc->global_irq, |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 410 | intsrc->inti_flags & ACPI_MADT_POLARITY_MASK, |
| 411 | (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | return 0; |
| 413 | } |
| 414 | |
| 415 | if (acpi_skip_timer_override && |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 416 | intsrc->source_irq == 0 && intsrc->global_irq == 2) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 417 | printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n"); |
| 418 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | } |
| 420 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 421 | mp_override_legacy_irq(intsrc->source_irq, |
| 422 | intsrc->inti_flags & ACPI_MADT_POLARITY_MASK, |
| 423 | (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2, |
| 424 | intsrc->global_irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | |
| 426 | return 0; |
| 427 | } |
| 428 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | static int __init |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 430 | acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | { |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 432 | struct acpi_madt_nmi_source *nmi_src = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 434 | nmi_src = (struct acpi_madt_nmi_source *)header; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | |
| 436 | if (BAD_MADT_ENTRY(nmi_src, end)) |
| 437 | return -EINVAL; |
| 438 | |
| 439 | acpi_table_print_madt_entry(header); |
| 440 | |
| 441 | /* TBD: Support nimsrc entries? */ |
| 442 | |
| 443 | return 0; |
| 444 | } |
| 445 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 446 | #endif /* CONFIG_X86_IO_APIC */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | /* |
| 449 | * acpi_pic_sci_set_trigger() |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 450 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | * use ELCR to set PIC-mode trigger type for SCI |
| 452 | * |
| 453 | * If a PIC-mode SCI is not recognized or gives spurious IRQ7's |
| 454 | * it may require Edge Trigger -- use "acpi_sci=edge" |
| 455 | * |
| 456 | * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers |
| 457 | * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge. |
Simon Arlott | 27b46d7 | 2007-10-20 01:13:56 +0200 | [diff] [blame] | 458 | * ECLR1 is IRQs 0-7 (IRQ 0, 1, 2 must be 0) |
| 459 | * ECLR2 is IRQs 8-15 (IRQ 8, 13 must be 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | */ |
| 461 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 462 | void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | { |
| 464 | unsigned int mask = 1 << irq; |
| 465 | unsigned int old, new; |
| 466 | |
| 467 | /* Real old ELCR mask */ |
| 468 | old = inb(0x4d0) | (inb(0x4d1) << 8); |
| 469 | |
| 470 | /* |
Simon Arlott | 27b46d7 | 2007-10-20 01:13:56 +0200 | [diff] [blame] | 471 | * If we use ACPI to set PCI IRQs, then we should clear ELCR |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | * since we will set it correctly as we enable the PCI irq |
| 473 | * routing. |
| 474 | */ |
| 475 | new = acpi_noirq ? old : 0; |
| 476 | |
| 477 | /* |
| 478 | * Update SCI information in the ELCR, it isn't in the PCI |
| 479 | * routing tables.. |
| 480 | */ |
| 481 | switch (trigger) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 482 | case 1: /* Edge - clear */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | new &= ~mask; |
| 484 | break; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 485 | case 3: /* Level - set */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | new |= mask; |
| 487 | break; |
| 488 | } |
| 489 | |
| 490 | if (old == new) |
| 491 | return; |
| 492 | |
| 493 | printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old); |
| 494 | outb(new, 0x4d0); |
| 495 | outb(new >> 8, 0x4d1); |
| 496 | } |
| 497 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | int acpi_gsi_to_irq(u32 gsi, unsigned int *irq) |
| 499 | { |
Eric W. Biederman | f023d76 | 2006-10-04 02:16:52 -0700 | [diff] [blame] | 500 | *irq = gsi; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | return 0; |
| 502 | } |
| 503 | |
Kenji Kaneshige | 1f3a6a1 | 2005-07-28 14:42:00 -0400 | [diff] [blame] | 504 | /* |
| 505 | * success: return IRQ number (>=0) |
| 506 | * failure: return < 0 |
| 507 | */ |
Len Brown | cb65469 | 2005-12-28 02:43:51 -0500 | [diff] [blame] | 508 | int acpi_register_gsi(u32 gsi, int triggering, int polarity) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | { |
| 510 | unsigned int irq; |
| 511 | unsigned int plat_gsi = gsi; |
| 512 | |
| 513 | #ifdef CONFIG_PCI |
| 514 | /* |
| 515 | * Make sure all (legacy) PCI IRQs are set as level-triggered. |
| 516 | */ |
| 517 | if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) { |
Len Brown | cb65469 | 2005-12-28 02:43:51 -0500 | [diff] [blame] | 518 | if (triggering == ACPI_LEVEL_SENSITIVE) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 519 | eisa_set_level_irq(gsi); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | } |
| 521 | #endif |
| 522 | |
| 523 | #ifdef CONFIG_X86_IO_APIC |
| 524 | if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) { |
Len Brown | cb65469 | 2005-12-28 02:43:51 -0500 | [diff] [blame] | 525 | plat_gsi = mp_register_gsi(gsi, triggering, polarity); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | } |
| 527 | #endif |
| 528 | acpi_gsi_to_irq(plat_gsi, &irq); |
| 529 | return irq; |
| 530 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 531 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 532 | /* |
| 533 | * ACPI based hotplug support for CPU |
| 534 | */ |
| 535 | #ifdef CONFIG_ACPI_HOTPLUG_CPU |
Sam Ravnborg | 009cbad | 2008-02-01 17:49:42 +0100 | [diff] [blame] | 536 | |
| 537 | static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | { |
Ashok Raj | 73fea17 | 2006-09-26 10:52:35 +0200 | [diff] [blame] | 539 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
| 540 | union acpi_object *obj; |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 541 | struct acpi_madt_local_apic *lapic; |
Rusty Russell | ee943a8 | 2008-12-31 18:08:47 -0800 | [diff] [blame] | 542 | cpumask_var_t tmp_map, new_map; |
Ashok Raj | 73fea17 | 2006-09-26 10:52:35 +0200 | [diff] [blame] | 543 | u8 physid; |
| 544 | int cpu; |
Rusty Russell | ee943a8 | 2008-12-31 18:08:47 -0800 | [diff] [blame] | 545 | int retval = -ENOMEM; |
Ashok Raj | 73fea17 | 2006-09-26 10:52:35 +0200 | [diff] [blame] | 546 | |
| 547 | if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer))) |
| 548 | return -EINVAL; |
| 549 | |
| 550 | if (!buffer.length || !buffer.pointer) |
| 551 | return -EINVAL; |
| 552 | |
| 553 | obj = buffer.pointer; |
| 554 | if (obj->type != ACPI_TYPE_BUFFER || |
| 555 | obj->buffer.length < sizeof(*lapic)) { |
| 556 | kfree(buffer.pointer); |
| 557 | return -EINVAL; |
| 558 | } |
| 559 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 560 | lapic = (struct acpi_madt_local_apic *)obj->buffer.pointer; |
Ashok Raj | 73fea17 | 2006-09-26 10:52:35 +0200 | [diff] [blame] | 561 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 562 | if (lapic->header.type != ACPI_MADT_TYPE_LOCAL_APIC || |
| 563 | !(lapic->lapic_flags & ACPI_MADT_ENABLED)) { |
Ashok Raj | 73fea17 | 2006-09-26 10:52:35 +0200 | [diff] [blame] | 564 | kfree(buffer.pointer); |
| 565 | return -EINVAL; |
| 566 | } |
| 567 | |
| 568 | physid = lapic->id; |
| 569 | |
| 570 | kfree(buffer.pointer); |
| 571 | buffer.length = ACPI_ALLOCATE_BUFFER; |
| 572 | buffer.pointer = NULL; |
| 573 | |
Rusty Russell | ee943a8 | 2008-12-31 18:08:47 -0800 | [diff] [blame] | 574 | if (!alloc_cpumask_var(&tmp_map, GFP_KERNEL)) |
| 575 | goto out; |
| 576 | |
| 577 | if (!alloc_cpumask_var(&new_map, GFP_KERNEL)) |
| 578 | goto free_tmp_map; |
| 579 | |
| 580 | cpumask_copy(tmp_map, cpu_present_mask); |
Alexey Starikovskiy | dfac218 | 2008-04-04 23:41:50 +0400 | [diff] [blame] | 581 | acpi_register_lapic(physid, lapic->lapic_flags & ACPI_MADT_ENABLED); |
Ashok Raj | 73fea17 | 2006-09-26 10:52:35 +0200 | [diff] [blame] | 582 | |
| 583 | /* |
| 584 | * If mp_register_lapic successfully generates a new logical cpu |
| 585 | * number, then the following will get us exactly what was mapped |
| 586 | */ |
Rusty Russell | ee943a8 | 2008-12-31 18:08:47 -0800 | [diff] [blame] | 587 | cpumask_andnot(new_map, cpu_present_mask, tmp_map); |
| 588 | if (cpumask_empty(new_map)) { |
Ashok Raj | 73fea17 | 2006-09-26 10:52:35 +0200 | [diff] [blame] | 589 | printk ("Unable to map lapic to logical cpu number\n"); |
Rusty Russell | ee943a8 | 2008-12-31 18:08:47 -0800 | [diff] [blame] | 590 | retval = -EINVAL; |
| 591 | goto free_new_map; |
Ashok Raj | 73fea17 | 2006-09-26 10:52:35 +0200 | [diff] [blame] | 592 | } |
| 593 | |
Rusty Russell | ee943a8 | 2008-12-31 18:08:47 -0800 | [diff] [blame] | 594 | cpu = cpumask_first(new_map); |
Ashok Raj | 73fea17 | 2006-09-26 10:52:35 +0200 | [diff] [blame] | 595 | |
| 596 | *pcpu = cpu; |
Rusty Russell | ee943a8 | 2008-12-31 18:08:47 -0800 | [diff] [blame] | 597 | retval = 0; |
| 598 | |
| 599 | free_new_map: |
| 600 | free_cpumask_var(new_map); |
| 601 | free_tmp_map: |
| 602 | free_cpumask_var(tmp_map); |
| 603 | out: |
| 604 | return retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 606 | |
Sam Ravnborg | 009cbad | 2008-02-01 17:49:42 +0100 | [diff] [blame] | 607 | /* wrapper to silence section mismatch warning */ |
| 608 | int __ref acpi_map_lsapic(acpi_handle handle, int *pcpu) |
| 609 | { |
| 610 | return _acpi_map_lsapic(handle, pcpu); |
| 611 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | EXPORT_SYMBOL(acpi_map_lsapic); |
| 613 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 614 | int acpi_unmap_lsapic(int cpu) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 615 | { |
Mike Travis | 71fff5e | 2007-10-19 20:35:03 +0200 | [diff] [blame] | 616 | per_cpu(x86_cpu_to_apicid, cpu) = -1; |
Mike Travis | 9628937 | 2008-12-31 18:08:46 -0800 | [diff] [blame] | 617 | set_cpu_present(cpu, false); |
Ashok Raj | 73fea17 | 2006-09-26 10:52:35 +0200 | [diff] [blame] | 618 | num_processors--; |
| 619 | |
| 620 | return (0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 622 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | EXPORT_SYMBOL(acpi_unmap_lsapic); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 624 | #endif /* CONFIG_ACPI_HOTPLUG_CPU */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 626 | int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base) |
Kenji Kaneshige | b1bb248 | 2005-04-28 00:25:58 -0700 | [diff] [blame] | 627 | { |
| 628 | /* TBD */ |
| 629 | return -EINVAL; |
| 630 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 631 | |
Kenji Kaneshige | b1bb248 | 2005-04-28 00:25:58 -0700 | [diff] [blame] | 632 | EXPORT_SYMBOL(acpi_register_ioapic); |
| 633 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 634 | int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base) |
Kenji Kaneshige | b1bb248 | 2005-04-28 00:25:58 -0700 | [diff] [blame] | 635 | { |
| 636 | /* TBD */ |
| 637 | return -EINVAL; |
| 638 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 639 | |
Kenji Kaneshige | b1bb248 | 2005-04-28 00:25:58 -0700 | [diff] [blame] | 640 | EXPORT_SYMBOL(acpi_unregister_ioapic); |
| 641 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 642 | static int __init acpi_parse_sbf(struct acpi_table_header *table) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | { |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 644 | struct acpi_table_boot *sb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 646 | sb = (struct acpi_table_boot *)table; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | if (!sb) { |
| 648 | printk(KERN_WARNING PREFIX "Unable to map SBF\n"); |
| 649 | return -ENODEV; |
| 650 | } |
| 651 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 652 | sbf_port = sb->cmos_index; /* Save CMOS port */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | |
| 654 | return 0; |
| 655 | } |
| 656 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | #ifdef CONFIG_HPET_TIMER |
john stultz | 2d0c87c | 2007-02-16 01:28:18 -0800 | [diff] [blame] | 658 | #include <asm/hpet.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | |
Aaron Durbin | a1dfd85 | 2007-07-21 17:11:39 +0200 | [diff] [blame] | 660 | static struct __initdata resource *hpet_res; |
| 661 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 662 | static int __init acpi_parse_hpet(struct acpi_table_header *table) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | { |
| 664 | struct acpi_table_hpet *hpet_tbl; |
| 665 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 666 | hpet_tbl = (struct acpi_table_hpet *)table; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 | if (!hpet_tbl) { |
| 668 | printk(KERN_WARNING PREFIX "Unable to map HPET\n"); |
| 669 | return -ENODEV; |
| 670 | } |
| 671 | |
Alexey Starikovskiy | ad363f8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 672 | if (hpet_tbl->address.space_id != ACPI_SPACE_MEM) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | printk(KERN_WARNING PREFIX "HPET timers must be located in " |
| 674 | "memory.\n"); |
| 675 | return -1; |
| 676 | } |
adurbin@google.com | f0f4c34 | 2006-09-26 10:52:39 +0200 | [diff] [blame] | 677 | |
john stultz | 2d0c87c | 2007-02-16 01:28:18 -0800 | [diff] [blame] | 678 | hpet_address = hpet_tbl->address.address; |
Thomas Gleixner | f4df73c | 2007-11-15 21:41:50 -0500 | [diff] [blame] | 679 | |
| 680 | /* |
| 681 | * Some broken BIOSes advertise HPET at 0x0. We really do not |
| 682 | * want to allocate a resource there. |
| 683 | */ |
| 684 | if (!hpet_address) { |
| 685 | printk(KERN_WARNING PREFIX |
| 686 | "HPET id: %#x base: %#lx is invalid\n", |
| 687 | hpet_tbl->id, hpet_address); |
| 688 | return 0; |
| 689 | } |
| 690 | #ifdef CONFIG_X86_64 |
| 691 | /* |
| 692 | * Some even more broken BIOSes advertise HPET at |
| 693 | * 0xfed0000000000000 instead of 0xfed00000. Fix it up and add |
| 694 | * some noise: |
| 695 | */ |
| 696 | if (hpet_address == 0xfed0000000000000UL) { |
| 697 | if (!hpet_force_user) { |
| 698 | printk(KERN_WARNING PREFIX "HPET id: %#x " |
| 699 | "base: 0xfed0000000000000 is bogus\n " |
| 700 | "try hpet=force on the kernel command line to " |
| 701 | "fix it up to 0xfed00000.\n", hpet_tbl->id); |
| 702 | hpet_address = 0; |
| 703 | return 0; |
| 704 | } |
| 705 | printk(KERN_WARNING PREFIX |
| 706 | "HPET id: %#x base: 0xfed0000000000000 fixed up " |
| 707 | "to 0xfed00000.\n", hpet_tbl->id); |
| 708 | hpet_address >>= 32; |
| 709 | } |
| 710 | #endif |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 711 | printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n", |
john stultz | 2d0c87c | 2007-02-16 01:28:18 -0800 | [diff] [blame] | 712 | hpet_tbl->id, hpet_address); |
adurbin@google.com | f0f4c34 | 2006-09-26 10:52:39 +0200 | [diff] [blame] | 713 | |
Aaron Durbin | a1dfd85 | 2007-07-21 17:11:39 +0200 | [diff] [blame] | 714 | /* |
| 715 | * Allocate and initialize the HPET firmware resource for adding into |
| 716 | * the resource tree during the lateinit timeframe. |
| 717 | */ |
| 718 | #define HPET_RESOURCE_NAME_SIZE 9 |
| 719 | hpet_res = alloc_bootmem(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE); |
| 720 | |
Aaron Durbin | a1dfd85 | 2007-07-21 17:11:39 +0200 | [diff] [blame] | 721 | hpet_res->name = (void *)&hpet_res[1]; |
| 722 | hpet_res->flags = IORESOURCE_MEM; |
| 723 | snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE, "HPET %u", |
| 724 | hpet_tbl->sequence); |
| 725 | |
| 726 | hpet_res->start = hpet_address; |
| 727 | hpet_res->end = hpet_address + (1 * 1024) - 1; |
| 728 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 729 | return 0; |
| 730 | } |
Aaron Durbin | a1dfd85 | 2007-07-21 17:11:39 +0200 | [diff] [blame] | 731 | |
| 732 | /* |
| 733 | * hpet_insert_resource inserts the HPET resources used into the resource |
| 734 | * tree. |
| 735 | */ |
| 736 | static __init int hpet_insert_resource(void) |
| 737 | { |
| 738 | if (!hpet_res) |
| 739 | return 1; |
| 740 | |
| 741 | return insert_resource(&iomem_resource, hpet_res); |
| 742 | } |
| 743 | |
| 744 | late_initcall(hpet_insert_resource); |
| 745 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 746 | #else |
| 747 | #define acpi_parse_hpet NULL |
| 748 | #endif |
| 749 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 750 | static int __init acpi_parse_fadt(struct acpi_table_header *table) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 751 | { |
Jason Davis | 90660ec | 2005-04-16 15:24:53 -0700 | [diff] [blame] | 752 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 753 | #ifdef CONFIG_X86_PM_TIMER |
| 754 | /* detect the location of the ACPI PM Timer */ |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 755 | if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 756 | /* FADT rev. 2 */ |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 757 | if (acpi_gbl_FADT.xpm_timer_block.space_id != |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 758 | ACPI_ADR_SPACE_SYSTEM_IO) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 759 | return 0; |
| 760 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 761 | pmtmr_ioport = acpi_gbl_FADT.xpm_timer_block.address; |
David Shaohua Li | e6e87b4 | 2005-09-21 01:35:00 -0400 | [diff] [blame] | 762 | /* |
| 763 | * "X" fields are optional extensions to the original V1.0 |
| 764 | * fields, so we must selectively expand V1.0 fields if the |
| 765 | * corresponding X field is zero. |
| 766 | */ |
| 767 | if (!pmtmr_ioport) |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 768 | pmtmr_ioport = acpi_gbl_FADT.pm_timer_block; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 769 | } else { |
| 770 | /* FADT rev. 1 */ |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 771 | pmtmr_ioport = acpi_gbl_FADT.pm_timer_block; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 772 | } |
| 773 | if (pmtmr_ioport) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 774 | printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n", |
| 775 | pmtmr_ioport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 776 | #endif |
| 777 | return 0; |
| 778 | } |
| 779 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 780 | #ifdef CONFIG_X86_LOCAL_APIC |
| 781 | /* |
| 782 | * Parse LAPIC entries in MADT |
| 783 | * returns 0 on success, < 0 on error |
| 784 | */ |
Alexey Starikovskiy | 31d2092 | 2008-04-04 23:41:57 +0400 | [diff] [blame] | 785 | |
| 786 | static void __init acpi_register_lapic_address(unsigned long address) |
| 787 | { |
| 788 | mp_lapic_addr = address; |
| 789 | |
| 790 | set_fixmap_nocache(FIX_APIC_BASE, address); |
Yinghai Lu | fb3bbd6 | 2008-05-22 18:22:30 -0700 | [diff] [blame] | 791 | if (boot_cpu_physical_apicid == -1U) { |
Yinghai Lu | 4c9961d | 2008-07-11 18:44:16 -0700 | [diff] [blame] | 792 | boot_cpu_physical_apicid = read_apic_id(); |
Yinghai Lu | fb3bbd6 | 2008-05-22 18:22:30 -0700 | [diff] [blame] | 793 | apic_version[boot_cpu_physical_apicid] = |
| 794 | GET_APIC_VERSION(apic_read(APIC_LVR)); |
Yinghai Lu | fb3bbd6 | 2008-05-22 18:22:30 -0700 | [diff] [blame] | 795 | } |
Alexey Starikovskiy | 31d2092 | 2008-04-04 23:41:57 +0400 | [diff] [blame] | 796 | } |
| 797 | |
Yinghai Lu | cbf9bd6 | 2008-02-19 03:21:06 -0800 | [diff] [blame] | 798 | static int __init early_acpi_parse_madt_lapic_addr_ovr(void) |
| 799 | { |
| 800 | int count; |
| 801 | |
| 802 | if (!cpu_has_apic) |
| 803 | return -ENODEV; |
| 804 | |
| 805 | /* |
| 806 | * Note that the LAPIC address is obtained from the MADT (32-bit value) |
| 807 | * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value). |
| 808 | */ |
| 809 | |
| 810 | count = |
| 811 | acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE, |
| 812 | acpi_parse_lapic_addr_ovr, 0); |
| 813 | if (count < 0) { |
| 814 | printk(KERN_ERR PREFIX |
| 815 | "Error parsing LAPIC address override entry\n"); |
| 816 | return count; |
| 817 | } |
| 818 | |
| 819 | acpi_register_lapic_address(acpi_lapic_addr); |
| 820 | |
| 821 | return count; |
| 822 | } |
| 823 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 824 | static int __init acpi_parse_madt_lapic_entries(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 825 | { |
| 826 | int count; |
| 827 | |
Andi Kleen | 0fcd270 | 2006-04-11 12:54:36 +0200 | [diff] [blame] | 828 | if (!cpu_has_apic) |
| 829 | return -ENODEV; |
| 830 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 831 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 832 | * Note that the LAPIC address is obtained from the MADT (32-bit value) |
| 833 | * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value). |
| 834 | */ |
| 835 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 836 | count = |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 837 | acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 838 | acpi_parse_lapic_addr_ovr, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 839 | if (count < 0) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 840 | printk(KERN_ERR PREFIX |
| 841 | "Error parsing LAPIC address override entry\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 842 | return count; |
| 843 | } |
| 844 | |
Alexey Starikovskiy | 31d2092 | 2008-04-04 23:41:57 +0400 | [diff] [blame] | 845 | acpi_register_lapic_address(acpi_lapic_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 846 | |
Jack Steiner | ac049c1 | 2008-03-28 14:12:09 -0500 | [diff] [blame] | 847 | count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_SAPIC, |
| 848 | acpi_parse_sapic, MAX_APICS); |
| 849 | |
| 850 | if (!count) |
| 851 | count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC, |
| 852 | acpi_parse_lapic, MAX_APICS); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 853 | if (!count) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 854 | printk(KERN_ERR PREFIX "No LAPIC entries present\n"); |
| 855 | /* TBD: Cleanup to allow fallback to MPS */ |
| 856 | return -ENODEV; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 857 | } else if (count < 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 858 | printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n"); |
| 859 | /* TBD: Cleanup to allow fallback to MPS */ |
| 860 | return count; |
| 861 | } |
| 862 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 863 | count = |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 864 | acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_NMI, acpi_parse_lapic_nmi, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 865 | if (count < 0) { |
| 866 | printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n"); |
| 867 | /* TBD: Cleanup to allow fallback to MPS */ |
| 868 | return count; |
| 869 | } |
| 870 | return 0; |
| 871 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 872 | #endif /* CONFIG_X86_LOCAL_APIC */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 873 | |
Len Brown | 8466361 | 2005-08-24 12:09:07 -0400 | [diff] [blame] | 874 | #ifdef CONFIG_X86_IO_APIC |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 875 | #define MP_ISA_BUS 0 |
| 876 | |
Yinghai Lu | d49c428 | 2008-06-08 18:31:54 -0700 | [diff] [blame] | 877 | #ifdef CONFIG_X86_ES7000 |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 878 | extern int es7000_plat; |
| 879 | #endif |
| 880 | |
Alexey Starikovskiy | 5f89514 | 2008-05-14 19:03:04 +0400 | [diff] [blame] | 881 | static struct { |
| 882 | int apic_id; |
| 883 | int gsi_base; |
| 884 | int gsi_end; |
| 885 | DECLARE_BITMAP(pin_programmed, MP_MAX_IOAPIC_PIN + 1); |
| 886 | } mp_ioapic_routing[MAX_IO_APICS]; |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 887 | |
| 888 | static int mp_find_ioapic(int gsi) |
| 889 | { |
| 890 | int i = 0; |
| 891 | |
| 892 | /* Find the IOAPIC that manages this GSI. */ |
| 893 | for (i = 0; i < nr_ioapics; i++) { |
| 894 | if ((gsi >= mp_ioapic_routing[i].gsi_base) |
| 895 | && (gsi <= mp_ioapic_routing[i].gsi_end)) |
| 896 | return i; |
| 897 | } |
| 898 | |
| 899 | printk(KERN_ERR "ERROR: Unable to locate IOAPIC for GSI %d\n", gsi); |
| 900 | return -1; |
| 901 | } |
| 902 | |
| 903 | static u8 __init uniq_ioapic_id(u8 id) |
| 904 | { |
| 905 | #ifdef CONFIG_X86_32 |
| 906 | if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) && |
| 907 | !APIC_XAPIC(apic_version[boot_cpu_physical_apicid])) |
| 908 | return io_apic_get_unique_id(nr_ioapics, id); |
| 909 | else |
| 910 | return id; |
| 911 | #else |
| 912 | int i; |
| 913 | DECLARE_BITMAP(used, 256); |
| 914 | bitmap_zero(used, 256); |
| 915 | for (i = 0; i < nr_ioapics; i++) { |
Jaswinder Singh Rajput | b5ba7e6d | 2009-01-12 17:46:17 +0530 | [diff] [blame] | 916 | struct mpc_ioapic *ia = &mp_ioapics[i]; |
| 917 | __set_bit(ia->apicid, used); |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 918 | } |
| 919 | if (!test_bit(id, used)) |
| 920 | return id; |
| 921 | return find_first_zero_bit(used, 256); |
| 922 | #endif |
| 923 | } |
| 924 | |
| 925 | static int bad_ioapic(unsigned long address) |
| 926 | { |
| 927 | if (nr_ioapics >= MAX_IO_APICS) { |
| 928 | printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded " |
| 929 | "(found %d)\n", MAX_IO_APICS, nr_ioapics); |
| 930 | panic("Recompile kernel with bigger MAX_IO_APICS!\n"); |
| 931 | } |
| 932 | if (!address) { |
| 933 | printk(KERN_ERR "WARNING: Bogus (zero) I/O APIC address" |
| 934 | " found in table, skipping!\n"); |
| 935 | return 1; |
| 936 | } |
| 937 | return 0; |
| 938 | } |
| 939 | |
| 940 | void __init mp_register_ioapic(int id, u32 address, u32 gsi_base) |
| 941 | { |
| 942 | int idx = 0; |
| 943 | |
| 944 | if (bad_ioapic(address)) |
| 945 | return; |
| 946 | |
| 947 | idx = nr_ioapics; |
| 948 | |
Jaswinder Singh Rajput | b5ba7e6d | 2009-01-12 17:46:17 +0530 | [diff] [blame] | 949 | mp_ioapics[idx].type = MP_IOAPIC; |
| 950 | mp_ioapics[idx].flags = MPC_APIC_USABLE; |
| 951 | mp_ioapics[idx].apicaddr = address; |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 952 | |
| 953 | set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address); |
Jaswinder Singh Rajput | b5ba7e6d | 2009-01-12 17:46:17 +0530 | [diff] [blame] | 954 | mp_ioapics[idx].apicid = uniq_ioapic_id(id); |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 955 | #ifdef CONFIG_X86_32 |
Jaswinder Singh Rajput | b5ba7e6d | 2009-01-12 17:46:17 +0530 | [diff] [blame] | 956 | mp_ioapics[idx].apicver = io_apic_get_version(idx); |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 957 | #else |
Jaswinder Singh Rajput | b5ba7e6d | 2009-01-12 17:46:17 +0530 | [diff] [blame] | 958 | mp_ioapics[idx].apicver = 0; |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 959 | #endif |
| 960 | /* |
| 961 | * Build basic GSI lookup table to facilitate gsi->io_apic lookups |
| 962 | * and to prevent reprogramming of IOAPIC pins (PCI GSIs). |
| 963 | */ |
Jaswinder Singh Rajput | b5ba7e6d | 2009-01-12 17:46:17 +0530 | [diff] [blame] | 964 | mp_ioapic_routing[idx].apic_id = mp_ioapics[idx].apicid; |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 965 | mp_ioapic_routing[idx].gsi_base = gsi_base; |
| 966 | mp_ioapic_routing[idx].gsi_end = gsi_base + |
| 967 | io_apic_get_redir_entries(idx); |
| 968 | |
Jaswinder Singh Rajput | b5ba7e6d | 2009-01-12 17:46:17 +0530 | [diff] [blame] | 969 | printk(KERN_INFO "IOAPIC[%d]: apic_id %d, version %d, address 0x%x, " |
| 970 | "GSI %d-%d\n", idx, mp_ioapics[idx].apicid, |
| 971 | mp_ioapics[idx].apicver, mp_ioapics[idx].apicaddr, |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 972 | mp_ioapic_routing[idx].gsi_base, mp_ioapic_routing[idx].gsi_end); |
| 973 | |
| 974 | nr_ioapics++; |
| 975 | } |
| 976 | |
Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 977 | static void assign_to_mp_irq(struct mpc_intsrc *m, |
| 978 | struct mpc_intsrc *mp_irq) |
Yinghai Lu | fcfa146 | 2008-06-18 17:29:31 -0700 | [diff] [blame] | 979 | { |
Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 980 | memcpy(mp_irq, m, sizeof(struct mpc_intsrc)); |
Yinghai Lu | fcfa146 | 2008-06-18 17:29:31 -0700 | [diff] [blame] | 981 | } |
| 982 | |
Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 983 | static int mp_irq_cmp(struct mpc_intsrc *mp_irq, |
| 984 | struct mpc_intsrc *m) |
Yinghai Lu | fcfa146 | 2008-06-18 17:29:31 -0700 | [diff] [blame] | 985 | { |
Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 986 | return memcmp(mp_irq, m, sizeof(struct mpc_intsrc)); |
Yinghai Lu | fcfa146 | 2008-06-18 17:29:31 -0700 | [diff] [blame] | 987 | } |
| 988 | |
Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 989 | static void save_mp_irq(struct mpc_intsrc *m) |
Yinghai Lu | fcfa146 | 2008-06-18 17:29:31 -0700 | [diff] [blame] | 990 | { |
| 991 | int i; |
| 992 | |
| 993 | for (i = 0; i < mp_irq_entries; i++) { |
| 994 | if (!mp_irq_cmp(&mp_irqs[i], m)) |
| 995 | return; |
| 996 | } |
| 997 | |
| 998 | assign_to_mp_irq(m, &mp_irqs[mp_irq_entries]); |
| 999 | if (++mp_irq_entries == MAX_IRQ_SOURCES) |
| 1000 | panic("Max # of irq sources exceeded!!\n"); |
| 1001 | } |
| 1002 | |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 1003 | void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi) |
| 1004 | { |
Yinghai Lu | 6df8809 | 2008-06-15 18:19:46 -0700 | [diff] [blame] | 1005 | int ioapic; |
| 1006 | int pin; |
Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 1007 | struct mpc_intsrc mp_irq; |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 1008 | |
| 1009 | /* |
| 1010 | * Convert 'gsi' to 'ioapic.pin'. |
| 1011 | */ |
| 1012 | ioapic = mp_find_ioapic(gsi); |
| 1013 | if (ioapic < 0) |
| 1014 | return; |
| 1015 | pin = gsi - mp_ioapic_routing[ioapic].gsi_base; |
| 1016 | |
| 1017 | /* |
| 1018 | * TBD: This check is for faulty timer entries, where the override |
| 1019 | * erroneously sets the trigger to level, resulting in a HUGE |
| 1020 | * increase of timer interrupts! |
| 1021 | */ |
| 1022 | if ((bus_irq == 0) && (trigger == 3)) |
| 1023 | trigger = 1; |
| 1024 | |
Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 1025 | mp_irq.type = MP_INTSRC; |
| 1026 | mp_irq.irqtype = mp_INT; |
| 1027 | mp_irq.irqflag = (trigger << 2) | polarity; |
| 1028 | mp_irq.srcbus = MP_ISA_BUS; |
| 1029 | mp_irq.srcbusirq = bus_irq; /* IRQ */ |
| 1030 | mp_irq.dstapic = mp_ioapics[ioapic].apicid; /* APIC ID */ |
| 1031 | mp_irq.dstirq = pin; /* INTIN# */ |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 1032 | |
Yinghai Lu | fcfa146 | 2008-06-18 17:29:31 -0700 | [diff] [blame] | 1033 | save_mp_irq(&mp_irq); |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 1034 | } |
| 1035 | |
| 1036 | void __init mp_config_acpi_legacy_irqs(void) |
| 1037 | { |
Yinghai Lu | 6df8809 | 2008-06-15 18:19:46 -0700 | [diff] [blame] | 1038 | int i; |
| 1039 | int ioapic; |
| 1040 | unsigned int dstapic; |
Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 1041 | struct mpc_intsrc mp_irq; |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 1042 | |
| 1043 | #if defined (CONFIG_MCA) || defined (CONFIG_EISA) |
| 1044 | /* |
| 1045 | * Fabricate the legacy ISA bus (bus #31). |
| 1046 | */ |
| 1047 | mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA; |
| 1048 | #endif |
| 1049 | set_bit(MP_ISA_BUS, mp_bus_not_pci); |
Thomas Gleixner | cfc1b9a | 2008-07-21 21:35:38 +0200 | [diff] [blame] | 1050 | pr_debug("Bus #%d is ISA\n", MP_ISA_BUS); |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 1051 | |
Yinghai Lu | d49c428 | 2008-06-08 18:31:54 -0700 | [diff] [blame] | 1052 | #ifdef CONFIG_X86_ES7000 |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 1053 | /* |
| 1054 | * Older generations of ES7000 have no legacy identity mappings |
| 1055 | */ |
| 1056 | if (es7000_plat == 1) |
| 1057 | return; |
| 1058 | #endif |
| 1059 | |
| 1060 | /* |
| 1061 | * Locate the IOAPIC that manages the ISA IRQs (0-15). |
| 1062 | */ |
| 1063 | ioapic = mp_find_ioapic(0); |
| 1064 | if (ioapic < 0) |
| 1065 | return; |
Jaswinder Singh Rajput | b5ba7e6d | 2009-01-12 17:46:17 +0530 | [diff] [blame] | 1066 | dstapic = mp_ioapics[ioapic].apicid; |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 1067 | |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 1068 | /* |
| 1069 | * Use the default configuration for the IRQs 0-15. Unless |
| 1070 | * overridden by (MADT) interrupt source override entries. |
| 1071 | */ |
| 1072 | for (i = 0; i < 16; i++) { |
| 1073 | int idx; |
| 1074 | |
| 1075 | for (idx = 0; idx < mp_irq_entries; idx++) { |
Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 1076 | struct mpc_intsrc *irq = mp_irqs + idx; |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 1077 | |
| 1078 | /* Do we already have a mapping for this ISA IRQ? */ |
Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 1079 | if (irq->srcbus == MP_ISA_BUS && irq->srcbusirq == i) |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 1080 | break; |
| 1081 | |
| 1082 | /* Do we already have a mapping for this IOAPIC pin */ |
Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 1083 | if (irq->dstapic == dstapic && irq->dstirq == i) |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 1084 | break; |
| 1085 | } |
| 1086 | |
| 1087 | if (idx != mp_irq_entries) { |
| 1088 | printk(KERN_DEBUG "ACPI: IRQ%d used by override.\n", i); |
| 1089 | continue; /* IRQ already used */ |
| 1090 | } |
| 1091 | |
Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 1092 | mp_irq.type = MP_INTSRC; |
| 1093 | mp_irq.irqflag = 0; /* Conforming */ |
| 1094 | mp_irq.srcbus = MP_ISA_BUS; |
| 1095 | mp_irq.dstapic = dstapic; |
| 1096 | mp_irq.irqtype = mp_INT; |
| 1097 | mp_irq.srcbusirq = i; /* Identity mapped */ |
| 1098 | mp_irq.dstirq = i; |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 1099 | |
Yinghai Lu | fcfa146 | 2008-06-18 17:29:31 -0700 | [diff] [blame] | 1100 | save_mp_irq(&mp_irq); |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 1101 | } |
| 1102 | } |
| 1103 | |
| 1104 | int mp_register_gsi(u32 gsi, int triggering, int polarity) |
| 1105 | { |
| 1106 | int ioapic; |
| 1107 | int ioapic_pin; |
| 1108 | #ifdef CONFIG_X86_32 |
| 1109 | #define MAX_GSI_NUM 4096 |
| 1110 | #define IRQ_COMPRESSION_START 64 |
| 1111 | |
| 1112 | static int pci_irq = IRQ_COMPRESSION_START; |
| 1113 | /* |
| 1114 | * Mapping between Global System Interrupts, which |
| 1115 | * represent all possible interrupts, and IRQs |
| 1116 | * assigned to actual devices. |
| 1117 | */ |
| 1118 | static int gsi_to_irq[MAX_GSI_NUM]; |
| 1119 | #else |
| 1120 | |
| 1121 | if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC) |
| 1122 | return gsi; |
| 1123 | #endif |
| 1124 | |
| 1125 | /* Don't set up the ACPI SCI because it's already set up */ |
| 1126 | if (acpi_gbl_FADT.sci_interrupt == gsi) |
| 1127 | return gsi; |
| 1128 | |
| 1129 | ioapic = mp_find_ioapic(gsi); |
| 1130 | if (ioapic < 0) { |
| 1131 | printk(KERN_WARNING "No IOAPIC for GSI %u\n", gsi); |
| 1132 | return gsi; |
| 1133 | } |
| 1134 | |
| 1135 | ioapic_pin = gsi - mp_ioapic_routing[ioapic].gsi_base; |
| 1136 | |
| 1137 | #ifdef CONFIG_X86_32 |
| 1138 | if (ioapic_renumber_irq) |
| 1139 | gsi = ioapic_renumber_irq(ioapic, gsi); |
| 1140 | #endif |
| 1141 | |
| 1142 | /* |
| 1143 | * Avoid pin reprogramming. PRTs typically include entries |
| 1144 | * with redundant pin->gsi mappings (but unique PCI devices); |
| 1145 | * we only program the IOAPIC on the first. |
| 1146 | */ |
| 1147 | if (ioapic_pin > MP_MAX_IOAPIC_PIN) { |
| 1148 | printk(KERN_ERR "Invalid reference to IOAPIC pin " |
| 1149 | "%d-%d\n", mp_ioapic_routing[ioapic].apic_id, |
| 1150 | ioapic_pin); |
| 1151 | return gsi; |
| 1152 | } |
| 1153 | if (test_bit(ioapic_pin, mp_ioapic_routing[ioapic].pin_programmed)) { |
Gustavo F. Padovan | 5541079 | 2008-10-15 10:37:04 -0300 | [diff] [blame] | 1154 | pr_debug("Pin %d-%d already programmed\n", |
Thomas Gleixner | cfc1b9a | 2008-07-21 21:35:38 +0200 | [diff] [blame] | 1155 | mp_ioapic_routing[ioapic].apic_id, ioapic_pin); |
Alexey Starikovskiy | 11113f8 | 2008-05-14 19:02:57 +0400 | [diff] [blame] | 1156 | #ifdef CONFIG_X86_32 |
| 1157 | return (gsi < IRQ_COMPRESSION_START ? gsi : gsi_to_irq[gsi]); |
| 1158 | #else |
| 1159 | return gsi; |
| 1160 | #endif |
| 1161 | } |
| 1162 | |
| 1163 | set_bit(ioapic_pin, mp_ioapic_routing[ioapic].pin_programmed); |
| 1164 | #ifdef CONFIG_X86_32 |
| 1165 | /* |
| 1166 | * For GSI >= 64, use IRQ compression |
| 1167 | */ |
| 1168 | if ((gsi >= IRQ_COMPRESSION_START) |
| 1169 | && (triggering == ACPI_LEVEL_SENSITIVE)) { |
| 1170 | /* |
| 1171 | * For PCI devices assign IRQs in order, avoiding gaps |
| 1172 | * due to unused I/O APIC pins. |
| 1173 | */ |
| 1174 | int irq = gsi; |
| 1175 | if (gsi < MAX_GSI_NUM) { |
| 1176 | /* |
| 1177 | * Retain the VIA chipset work-around (gsi > 15), but |
| 1178 | * avoid a problem where the 8254 timer (IRQ0) is setup |
| 1179 | * via an override (so it's not on pin 0 of the ioapic), |
| 1180 | * and at the same time, the pin 0 interrupt is a PCI |
| 1181 | * type. The gsi > 15 test could cause these two pins |
| 1182 | * to be shared as IRQ0, and they are not shareable. |
| 1183 | * So test for this condition, and if necessary, avoid |
| 1184 | * the pin collision. |
| 1185 | */ |
| 1186 | gsi = pci_irq++; |
| 1187 | /* |
| 1188 | * Don't assign IRQ used by ACPI SCI |
| 1189 | */ |
| 1190 | if (gsi == acpi_gbl_FADT.sci_interrupt) |
| 1191 | gsi = pci_irq++; |
| 1192 | gsi_to_irq[irq] = gsi; |
| 1193 | } else { |
| 1194 | printk(KERN_ERR "GSI %u is too high\n", gsi); |
| 1195 | return gsi; |
| 1196 | } |
| 1197 | } |
| 1198 | #endif |
| 1199 | io_apic_set_pci_routing(ioapic, ioapic_pin, gsi, |
| 1200 | triggering == ACPI_EDGE_SENSITIVE ? 0 : 1, |
| 1201 | polarity == ACPI_ACTIVE_HIGH ? 0 : 1); |
| 1202 | return gsi; |
| 1203 | } |
| 1204 | |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 1205 | int mp_config_acpi_gsi(unsigned char number, unsigned int devfn, u8 pin, |
| 1206 | u32 gsi, int triggering, int polarity) |
| 1207 | { |
Yinghai Lu | fcfa146 | 2008-06-18 17:29:31 -0700 | [diff] [blame] | 1208 | #ifdef CONFIG_X86_MPPARSE |
Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 1209 | struct mpc_intsrc mp_irq; |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 1210 | int ioapic; |
| 1211 | |
Yinghai Lu | fcfa146 | 2008-06-18 17:29:31 -0700 | [diff] [blame] | 1212 | if (!acpi_ioapic) |
Yinghai Lu | d867e53 | 2008-06-14 01:26:41 -0700 | [diff] [blame] | 1213 | return 0; |
| 1214 | |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 1215 | /* print the entry should happen on mptable identically */ |
Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 1216 | mp_irq.type = MP_INTSRC; |
| 1217 | mp_irq.irqtype = mp_INT; |
| 1218 | mp_irq.irqflag = (triggering == ACPI_EDGE_SENSITIVE ? 4 : 0x0c) | |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 1219 | (polarity == ACPI_ACTIVE_HIGH ? 1 : 3); |
Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 1220 | mp_irq.srcbus = number; |
| 1221 | mp_irq.srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3); |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 1222 | ioapic = mp_find_ioapic(gsi); |
Jaswinder Singh Rajput | c2c2174 | 2009-01-12 17:47:22 +0530 | [diff] [blame] | 1223 | mp_irq.dstapic = mp_ioapic_routing[ioapic].apic_id; |
| 1224 | mp_irq.dstirq = gsi - mp_ioapic_routing[ioapic].gsi_base; |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 1225 | |
Yinghai Lu | fcfa146 | 2008-06-18 17:29:31 -0700 | [diff] [blame] | 1226 | save_mp_irq(&mp_irq); |
| 1227 | #endif |
Yinghai Lu | 2944e16 | 2008-06-01 13:17:38 -0700 | [diff] [blame] | 1228 | return 0; |
| 1229 | } |
| 1230 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1231 | /* |
| 1232 | * Parse IOAPIC related entries in MADT |
| 1233 | * returns 0 on success, < 0 on error |
| 1234 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1235 | static int __init acpi_parse_madt_ioapic_entries(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1236 | { |
| 1237 | int count; |
| 1238 | |
| 1239 | /* |
| 1240 | * ACPI interpreter is required to complete interrupt setup, |
| 1241 | * so if it is off, don't enumerate the io-apics with ACPI. |
| 1242 | * If MPS is present, it will handle them, |
| 1243 | * otherwise the system will stay in PIC mode |
| 1244 | */ |
| 1245 | if (acpi_disabled || acpi_noirq) { |
| 1246 | return -ENODEV; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1247 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1248 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 1249 | if (!cpu_has_apic) |
Andi Kleen | d3b6a34 | 2006-04-07 19:49:39 +0200 | [diff] [blame] | 1250 | return -ENODEV; |
| 1251 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1252 | /* |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1253 | * if "noapic" boot option, don't look for IO-APICs |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1254 | */ |
| 1255 | if (skip_ioapic_setup) { |
| 1256 | printk(KERN_INFO PREFIX "Skipping IOAPIC probe " |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1257 | "due to 'noapic' option.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1258 | return -ENODEV; |
| 1259 | } |
| 1260 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1261 | count = |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 1262 | acpi_table_parse_madt(ACPI_MADT_TYPE_IO_APIC, acpi_parse_ioapic, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1263 | MAX_IO_APICS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1264 | if (!count) { |
| 1265 | printk(KERN_ERR PREFIX "No IOAPIC entries present\n"); |
| 1266 | return -ENODEV; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1267 | } else if (count < 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1268 | printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n"); |
| 1269 | return count; |
| 1270 | } |
| 1271 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1272 | count = |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 1273 | acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE, acpi_parse_int_src_ovr, |
Yinghai Lu | 71f521b | 2008-08-19 20:50:03 -0700 | [diff] [blame] | 1274 | nr_irqs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1275 | if (count < 0) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1276 | printk(KERN_ERR PREFIX |
| 1277 | "Error parsing interrupt source overrides entry\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1278 | /* TBD: Cleanup to allow fallback to MPS */ |
| 1279 | return count; |
| 1280 | } |
| 1281 | |
| 1282 | /* |
| 1283 | * If BIOS did not supply an INT_SRC_OVR for the SCI |
| 1284 | * pretend we got one so we can set the SCI flags. |
| 1285 | */ |
| 1286 | if (!acpi_sci_override_gsi) |
Alexey Starikovskiy | cee324b | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 1287 | acpi_sci_ioapic_setup(acpi_gbl_FADT.sci_interrupt, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1288 | |
| 1289 | /* Fill in identity legacy mapings where no override */ |
| 1290 | mp_config_acpi_legacy_irqs(); |
| 1291 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1292 | count = |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 1293 | acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE, acpi_parse_nmi_src, |
Yinghai Lu | 71f521b | 2008-08-19 20:50:03 -0700 | [diff] [blame] | 1294 | nr_irqs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1295 | if (count < 0) { |
| 1296 | printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n"); |
| 1297 | /* TBD: Cleanup to allow fallback to MPS */ |
| 1298 | return count; |
| 1299 | } |
| 1300 | |
| 1301 | return 0; |
| 1302 | } |
| 1303 | #else |
| 1304 | static inline int acpi_parse_madt_ioapic_entries(void) |
| 1305 | { |
| 1306 | return -1; |
| 1307 | } |
Len Brown | 8466361 | 2005-08-24 12:09:07 -0400 | [diff] [blame] | 1308 | #endif /* !CONFIG_X86_IO_APIC */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1309 | |
Yinghai Lu | cbf9bd6 | 2008-02-19 03:21:06 -0800 | [diff] [blame] | 1310 | static void __init early_acpi_process_madt(void) |
| 1311 | { |
| 1312 | #ifdef CONFIG_X86_LOCAL_APIC |
| 1313 | int error; |
| 1314 | |
| 1315 | if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) { |
| 1316 | |
| 1317 | /* |
| 1318 | * Parse MADT LAPIC entries |
| 1319 | */ |
| 1320 | error = early_acpi_parse_madt_lapic_addr_ovr(); |
| 1321 | if (!error) { |
| 1322 | acpi_lapic = 1; |
| 1323 | smp_found_config = 1; |
| 1324 | } |
| 1325 | if (error == -EINVAL) { |
| 1326 | /* |
| 1327 | * Dell Precision Workstation 410, 610 come here. |
| 1328 | */ |
| 1329 | printk(KERN_ERR PREFIX |
| 1330 | "Invalid BIOS MADT, disabling ACPI\n"); |
| 1331 | disable_acpi(); |
| 1332 | } |
| 1333 | } |
| 1334 | #endif |
| 1335 | } |
| 1336 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1337 | static void __init acpi_process_madt(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1338 | { |
| 1339 | #ifdef CONFIG_X86_LOCAL_APIC |
Len Brown | 7f8f97c | 2007-02-10 21:28:03 -0500 | [diff] [blame] | 1340 | int error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1341 | |
Len Brown | 7f8f97c | 2007-02-10 21:28:03 -0500 | [diff] [blame] | 1342 | if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1343 | |
| 1344 | /* |
| 1345 | * Parse MADT LAPIC entries |
| 1346 | */ |
| 1347 | error = acpi_parse_madt_lapic_entries(); |
| 1348 | if (!error) { |
| 1349 | acpi_lapic = 1; |
| 1350 | |
Venkatesh Pallipadi | 911a62d | 2005-09-03 15:56:31 -0700 | [diff] [blame] | 1351 | #ifdef CONFIG_X86_GENERICARCH |
| 1352 | generic_bigsmp_probe(); |
| 1353 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1354 | /* |
| 1355 | * Parse MADT IO-APIC entries |
| 1356 | */ |
| 1357 | error = acpi_parse_madt_ioapic_entries(); |
| 1358 | if (!error) { |
| 1359 | acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1360 | acpi_ioapic = 1; |
| 1361 | |
| 1362 | smp_found_config = 1; |
Suresh Siddha | 6e1cb38 | 2008-07-10 11:16:58 -0700 | [diff] [blame] | 1363 | #ifdef CONFIG_X86_32 |
Ingo Molnar | 3c43f03 | 2007-05-02 19:27:04 +0200 | [diff] [blame] | 1364 | setup_apic_routing(); |
Suresh Siddha | 6e1cb38 | 2008-07-10 11:16:58 -0700 | [diff] [blame] | 1365 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1366 | } |
| 1367 | } |
| 1368 | if (error == -EINVAL) { |
| 1369 | /* |
| 1370 | * Dell Precision Workstation 410, 610 come here. |
| 1371 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1372 | printk(KERN_ERR PREFIX |
| 1373 | "Invalid BIOS MADT, disabling ACPI\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1374 | disable_acpi(); |
| 1375 | } |
Len Brown | 7b37b5f | 2008-12-23 01:47:42 -0500 | [diff] [blame] | 1376 | } else { |
| 1377 | /* |
| 1378 | * ACPI found no MADT, and so ACPI wants UP PIC mode. |
| 1379 | * In the event an MPS table was found, forget it. |
| 1380 | * Boot with "acpi=off" to use MPS on such a system. |
| 1381 | */ |
| 1382 | if (smp_found_config) { |
| 1383 | printk(KERN_WARNING PREFIX |
| 1384 | "No APIC-table, disabling MPS\n"); |
| 1385 | smp_found_config = 0; |
| 1386 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1387 | } |
Yinghai Lu | 69b88af | 2008-12-05 22:45:50 -0800 | [diff] [blame] | 1388 | |
| 1389 | /* |
| 1390 | * ACPI supports both logical (e.g. Hyper-Threading) and physical |
| 1391 | * processors, where MPS only supports physical. |
| 1392 | */ |
| 1393 | if (acpi_lapic && acpi_ioapic) |
| 1394 | printk(KERN_INFO "Using ACPI (MADT) for SMP configuration " |
| 1395 | "information\n"); |
| 1396 | else if (acpi_lapic) |
| 1397 | printk(KERN_INFO "Using ACPI for processor (LAPIC) " |
| 1398 | "configuration information\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1399 | #endif |
| 1400 | return; |
| 1401 | } |
| 1402 | |
Jeff Garzik | 1855256 | 2007-10-03 15:15:40 -0400 | [diff] [blame] | 1403 | static int __init disable_acpi_irq(const struct dmi_system_id *d) |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1404 | { |
| 1405 | if (!acpi_force) { |
| 1406 | printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n", |
| 1407 | d->ident); |
| 1408 | acpi_noirq_set(); |
| 1409 | } |
| 1410 | return 0; |
| 1411 | } |
| 1412 | |
Jeff Garzik | 1855256 | 2007-10-03 15:15:40 -0400 | [diff] [blame] | 1413 | static int __init disable_acpi_pci(const struct dmi_system_id *d) |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1414 | { |
| 1415 | if (!acpi_force) { |
| 1416 | printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n", |
| 1417 | d->ident); |
| 1418 | acpi_disable_pci(); |
| 1419 | } |
| 1420 | return 0; |
| 1421 | } |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1422 | |
Jeff Garzik | 1855256 | 2007-10-03 15:15:40 -0400 | [diff] [blame] | 1423 | static int __init dmi_disable_acpi(const struct dmi_system_id *d) |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1424 | { |
| 1425 | if (!acpi_force) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1426 | printk(KERN_NOTICE "%s detected: acpi off\n", d->ident); |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1427 | disable_acpi(); |
| 1428 | } else { |
| 1429 | printk(KERN_NOTICE |
| 1430 | "Warning: DMI blacklist says broken, but acpi forced\n"); |
| 1431 | } |
| 1432 | return 0; |
| 1433 | } |
| 1434 | |
| 1435 | /* |
| 1436 | * Limit ACPI to CPU enumeration for HT |
| 1437 | */ |
Jeff Garzik | 1855256 | 2007-10-03 15:15:40 -0400 | [diff] [blame] | 1438 | static int __init force_acpi_ht(const struct dmi_system_id *d) |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1439 | { |
| 1440 | if (!acpi_force) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1441 | printk(KERN_NOTICE "%s detected: force use of acpi=ht\n", |
| 1442 | d->ident); |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1443 | disable_acpi(); |
| 1444 | acpi_ht = 1; |
| 1445 | } else { |
| 1446 | printk(KERN_NOTICE |
| 1447 | "Warning: acpi=force overrules DMI blacklist: acpi=ht\n"); |
| 1448 | } |
| 1449 | return 0; |
| 1450 | } |
| 1451 | |
| 1452 | /* |
Rafael J. Wysocki | e2079c4 | 2008-07-08 16:12:26 +0200 | [diff] [blame] | 1453 | * Force ignoring BIOS IRQ0 pin2 override |
| 1454 | */ |
| 1455 | static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d) |
| 1456 | { |
Ingo Molnar | 8d89adf | 2008-10-07 06:47:52 +0200 | [diff] [blame] | 1457 | /* |
| 1458 | * The ati_ixp4x0_rev() early PCI quirk should have set |
| 1459 | * the acpi_skip_timer_override flag already: |
| 1460 | */ |
| 1461 | if (!acpi_skip_timer_override) { |
| 1462 | WARN(1, KERN_ERR "ati_ixp4x0 quirk not complete.\n"); |
| 1463 | pr_notice("%s detected: Ignoring BIOS IRQ0 pin2 override\n", |
| 1464 | d->ident); |
| 1465 | acpi_skip_timer_override = 1; |
| 1466 | } |
Rafael J. Wysocki | e2079c4 | 2008-07-08 16:12:26 +0200 | [diff] [blame] | 1467 | return 0; |
| 1468 | } |
| 1469 | |
| 1470 | /* |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1471 | * If your system is blacklisted here, but you find that acpi=force |
| 1472 | * works for you, please contact acpi-devel@sourceforge.net |
| 1473 | */ |
| 1474 | static struct dmi_system_id __initdata acpi_dmi_table[] = { |
| 1475 | /* |
| 1476 | * Boxes that need ACPI disabled |
| 1477 | */ |
| 1478 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1479 | .callback = dmi_disable_acpi, |
| 1480 | .ident = "IBM Thinkpad", |
| 1481 | .matches = { |
| 1482 | DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), |
| 1483 | DMI_MATCH(DMI_BOARD_NAME, "2629H1G"), |
| 1484 | }, |
| 1485 | }, |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1486 | |
| 1487 | /* |
| 1488 | * Boxes that need acpi=ht |
| 1489 | */ |
| 1490 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1491 | .callback = force_acpi_ht, |
| 1492 | .ident = "FSC Primergy T850", |
| 1493 | .matches = { |
| 1494 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), |
| 1495 | DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"), |
| 1496 | }, |
| 1497 | }, |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1498 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1499 | .callback = force_acpi_ht, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1500 | .ident = "HP VISUALIZE NT Workstation", |
| 1501 | .matches = { |
| 1502 | DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"), |
| 1503 | DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"), |
| 1504 | }, |
| 1505 | }, |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1506 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1507 | .callback = force_acpi_ht, |
| 1508 | .ident = "Compaq Workstation W8000", |
| 1509 | .matches = { |
| 1510 | DMI_MATCH(DMI_SYS_VENDOR, "Compaq"), |
| 1511 | DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"), |
| 1512 | }, |
| 1513 | }, |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1514 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1515 | .callback = force_acpi_ht, |
| 1516 | .ident = "ASUS P4B266", |
| 1517 | .matches = { |
| 1518 | DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), |
| 1519 | DMI_MATCH(DMI_BOARD_NAME, "P4B266"), |
| 1520 | }, |
| 1521 | }, |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1522 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1523 | .callback = force_acpi_ht, |
| 1524 | .ident = "ASUS P2B-DS", |
| 1525 | .matches = { |
| 1526 | DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), |
| 1527 | DMI_MATCH(DMI_BOARD_NAME, "P2B-DS"), |
| 1528 | }, |
| 1529 | }, |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1530 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1531 | .callback = force_acpi_ht, |
| 1532 | .ident = "ASUS CUR-DLS", |
| 1533 | .matches = { |
| 1534 | DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), |
| 1535 | DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"), |
| 1536 | }, |
| 1537 | }, |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1538 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1539 | .callback = force_acpi_ht, |
| 1540 | .ident = "ABIT i440BX-W83977", |
| 1541 | .matches = { |
| 1542 | DMI_MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"), |
| 1543 | DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"), |
| 1544 | }, |
| 1545 | }, |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1546 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1547 | .callback = force_acpi_ht, |
| 1548 | .ident = "IBM Bladecenter", |
| 1549 | .matches = { |
| 1550 | DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), |
| 1551 | DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"), |
| 1552 | }, |
| 1553 | }, |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1554 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1555 | .callback = force_acpi_ht, |
| 1556 | .ident = "IBM eServer xSeries 360", |
| 1557 | .matches = { |
| 1558 | DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), |
| 1559 | DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"), |
| 1560 | }, |
| 1561 | }, |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1562 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1563 | .callback = force_acpi_ht, |
| 1564 | .ident = "IBM eserver xSeries 330", |
| 1565 | .matches = { |
| 1566 | DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), |
| 1567 | DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"), |
| 1568 | }, |
| 1569 | }, |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1570 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1571 | .callback = force_acpi_ht, |
| 1572 | .ident = "IBM eserver xSeries 440", |
| 1573 | .matches = { |
| 1574 | DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), |
| 1575 | DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"), |
| 1576 | }, |
| 1577 | }, |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1578 | |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1579 | /* |
| 1580 | * Boxes that need ACPI PCI IRQ routing disabled |
| 1581 | */ |
| 1582 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1583 | .callback = disable_acpi_irq, |
| 1584 | .ident = "ASUS A7V", |
| 1585 | .matches = { |
| 1586 | DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"), |
| 1587 | DMI_MATCH(DMI_BOARD_NAME, "<A7V>"), |
| 1588 | /* newer BIOS, Revision 1011, does work */ |
| 1589 | DMI_MATCH(DMI_BIOS_VERSION, |
| 1590 | "ASUS A7V ACPI BIOS Revision 1007"), |
| 1591 | }, |
| 1592 | }, |
Len Brown | 74586fc | 2007-03-08 02:48:30 -0500 | [diff] [blame] | 1593 | { |
| 1594 | /* |
| 1595 | * Latest BIOS for IBM 600E (1.16) has bad pcinum |
| 1596 | * for LPC bridge, which is needed for the PCI |
| 1597 | * interrupt links to work. DSDT fix is in bug 5966. |
| 1598 | * 2645, 2646 model numbers are shared with 600/600E/600X |
| 1599 | */ |
| 1600 | .callback = disable_acpi_irq, |
| 1601 | .ident = "IBM Thinkpad 600 Series 2645", |
| 1602 | .matches = { |
| 1603 | DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), |
| 1604 | DMI_MATCH(DMI_BOARD_NAME, "2645"), |
| 1605 | }, |
| 1606 | }, |
| 1607 | { |
| 1608 | .callback = disable_acpi_irq, |
| 1609 | .ident = "IBM Thinkpad 600 Series 2646", |
| 1610 | .matches = { |
| 1611 | DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), |
| 1612 | DMI_MATCH(DMI_BOARD_NAME, "2646"), |
| 1613 | }, |
| 1614 | }, |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1615 | /* |
| 1616 | * Boxes that need ACPI PCI IRQ routing and PCI scan disabled |
| 1617 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1618 | { /* _BBN 0 bug */ |
| 1619 | .callback = disable_acpi_pci, |
| 1620 | .ident = "ASUS PR-DLS", |
| 1621 | .matches = { |
| 1622 | DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), |
| 1623 | DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"), |
| 1624 | DMI_MATCH(DMI_BIOS_VERSION, |
| 1625 | "ASUS PR-DLS ACPI BIOS Revision 1010"), |
| 1626 | DMI_MATCH(DMI_BIOS_DATE, "03/21/2003") |
| 1627 | }, |
| 1628 | }, |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1629 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1630 | .callback = disable_acpi_pci, |
| 1631 | .ident = "Acer TravelMate 36x Laptop", |
| 1632 | .matches = { |
| 1633 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
| 1634 | DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"), |
| 1635 | }, |
| 1636 | }, |
Andreas Herrmann | 35af282 | 2008-10-22 13:08:31 +0200 | [diff] [blame] | 1637 | {} |
| 1638 | }; |
| 1639 | |
| 1640 | /* second table for DMI checks that should run after early-quirks */ |
| 1641 | static struct dmi_system_id __initdata acpi_dmi_table_late[] = { |
Matthew Garrett | 9340e1c | 2008-07-01 01:12:06 +0100 | [diff] [blame] | 1642 | /* |
| 1643 | * HP laptops which use a DSDT reporting as HP/SB400/10000, |
| 1644 | * which includes some code which overrides all temperature |
| 1645 | * trip points to 16C if the INTIN2 input of the I/O APIC |
| 1646 | * is enabled. This input is incorrectly designated the |
| 1647 | * ISA IRQ 0 via an interrupt source override even though |
| 1648 | * it is wired to the output of the master 8259A and INTIN0 |
Rafael J. Wysocki | e2079c4 | 2008-07-08 16:12:26 +0200 | [diff] [blame] | 1649 | * is not connected at all. Force ignoring BIOS IRQ0 pin2 |
| 1650 | * override in that cases. |
| 1651 | */ |
| 1652 | { |
| 1653 | .callback = dmi_ignore_irq0_timer_override, |
Rafael J. Wysocki | e84956f | 2008-10-06 11:59:29 +0200 | [diff] [blame] | 1654 | .ident = "HP nx6115 laptop", |
| 1655 | .matches = { |
| 1656 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), |
| 1657 | DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6115"), |
| 1658 | }, |
| 1659 | }, |
| 1660 | { |
| 1661 | .callback = dmi_ignore_irq0_timer_override, |
Rafael J. Wysocki | e2079c4 | 2008-07-08 16:12:26 +0200 | [diff] [blame] | 1662 | .ident = "HP NX6125 laptop", |
| 1663 | .matches = { |
| 1664 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), |
| 1665 | DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6125"), |
| 1666 | }, |
| 1667 | }, |
| 1668 | { |
| 1669 | .callback = dmi_ignore_irq0_timer_override, |
| 1670 | .ident = "HP NX6325 laptop", |
| 1671 | .matches = { |
| 1672 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), |
| 1673 | DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6325"), |
| 1674 | }, |
| 1675 | }, |
Rafael J. Wysocki | e84956f | 2008-10-06 11:59:29 +0200 | [diff] [blame] | 1676 | { |
| 1677 | .callback = dmi_ignore_irq0_timer_override, |
| 1678 | .ident = "HP 6715b laptop", |
| 1679 | .matches = { |
| 1680 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), |
| 1681 | DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq 6715b"), |
| 1682 | }, |
| 1683 | }, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1684 | {} |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1685 | }; |
| 1686 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1687 | /* |
| 1688 | * acpi_boot_table_init() and acpi_boot_init() |
| 1689 | * called from setup_arch(), always. |
| 1690 | * 1. checksums all tables |
| 1691 | * 2. enumerates lapics |
| 1692 | * 3. enumerates io-apics |
| 1693 | * |
| 1694 | * acpi_table_init() is separate to allow reading SRAT without |
| 1695 | * other side effects. |
| 1696 | * |
| 1697 | * side effects of acpi_boot_init: |
| 1698 | * acpi_lapic = 1 if LAPIC found |
| 1699 | * acpi_ioapic = 1 if IOAPIC found |
| 1700 | * if (acpi_lapic && acpi_ioapic) smp_found_config = 1; |
| 1701 | * if acpi_blacklisted() acpi_disabled = 1; |
| 1702 | * acpi_irq_model=... |
| 1703 | * ... |
| 1704 | * |
| 1705 | * return value: (currently ignored) |
| 1706 | * 0: success |
| 1707 | * !0: failure |
| 1708 | */ |
| 1709 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1710 | int __init acpi_boot_table_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1711 | { |
| 1712 | int error; |
| 1713 | |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1714 | dmi_check_system(acpi_dmi_table); |
Andrey Panin | aea0014 | 2005-06-25 14:54:42 -0700 | [diff] [blame] | 1715 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1716 | /* |
| 1717 | * If acpi_disabled, bail out |
| 1718 | * One exception: acpi=ht continues far enough to enumerate LAPICs |
| 1719 | */ |
| 1720 | if (acpi_disabled && !acpi_ht) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1721 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1722 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 1723 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1724 | * Initialize the ACPI boot-time table parser. |
| 1725 | */ |
| 1726 | error = acpi_table_init(); |
| 1727 | if (error) { |
| 1728 | disable_acpi(); |
| 1729 | return error; |
| 1730 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1731 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 1732 | acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1733 | |
| 1734 | /* |
| 1735 | * blacklist may disable ACPI entirely |
| 1736 | */ |
| 1737 | error = acpi_blacklisted(); |
| 1738 | if (error) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1739 | if (acpi_force) { |
| 1740 | printk(KERN_WARNING PREFIX "acpi=force override\n"); |
| 1741 | } else { |
| 1742 | printk(KERN_WARNING PREFIX "Disabling ACPI support\n"); |
| 1743 | disable_acpi(); |
| 1744 | return error; |
| 1745 | } |
| 1746 | } |
| 1747 | |
| 1748 | return 0; |
| 1749 | } |
| 1750 | |
Yinghai Lu | cbf9bd6 | 2008-02-19 03:21:06 -0800 | [diff] [blame] | 1751 | int __init early_acpi_boot_init(void) |
| 1752 | { |
| 1753 | /* |
| 1754 | * If acpi_disabled, bail out |
| 1755 | * One exception: acpi=ht continues far enough to enumerate LAPICs |
| 1756 | */ |
| 1757 | if (acpi_disabled && !acpi_ht) |
| 1758 | return 1; |
| 1759 | |
| 1760 | /* |
| 1761 | * Process the Multiple APIC Description Table (MADT), if present |
| 1762 | */ |
| 1763 | early_acpi_process_madt(); |
| 1764 | |
| 1765 | return 0; |
| 1766 | } |
| 1767 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1768 | int __init acpi_boot_init(void) |
| 1769 | { |
Andreas Herrmann | 35af282 | 2008-10-22 13:08:31 +0200 | [diff] [blame] | 1770 | /* those are executed after early-quirks are executed */ |
| 1771 | dmi_check_system(acpi_dmi_table_late); |
| 1772 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1773 | /* |
| 1774 | * If acpi_disabled, bail out |
| 1775 | * One exception: acpi=ht continues far enough to enumerate LAPICs |
| 1776 | */ |
| 1777 | if (acpi_disabled && !acpi_ht) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1778 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1779 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 1780 | acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1781 | |
| 1782 | /* |
| 1783 | * set sci_int and PM timer address |
| 1784 | */ |
Alexey Starikovskiy | ceb6c46 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 1785 | acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1786 | |
| 1787 | /* |
| 1788 | * Process the Multiple APIC Description Table (MADT), if present |
| 1789 | */ |
| 1790 | acpi_process_madt(); |
| 1791 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 1792 | acpi_table_parse(ACPI_SIG_HPET, acpi_parse_hpet); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1793 | |
| 1794 | return 0; |
| 1795 | } |
Rusty Russell | 1a3f239 | 2006-09-26 10:52:32 +0200 | [diff] [blame] | 1796 | |
| 1797 | static int __init parse_acpi(char *arg) |
| 1798 | { |
| 1799 | if (!arg) |
| 1800 | return -EINVAL; |
| 1801 | |
| 1802 | /* "acpi=off" disables both ACPI table parsing and interpreter */ |
| 1803 | if (strcmp(arg, "off") == 0) { |
| 1804 | disable_acpi(); |
| 1805 | } |
| 1806 | /* acpi=force to over-ride black-list */ |
| 1807 | else if (strcmp(arg, "force") == 0) { |
| 1808 | acpi_force = 1; |
| 1809 | acpi_ht = 1; |
| 1810 | acpi_disabled = 0; |
| 1811 | } |
| 1812 | /* acpi=strict disables out-of-spec workarounds */ |
| 1813 | else if (strcmp(arg, "strict") == 0) { |
| 1814 | acpi_strict = 1; |
| 1815 | } |
| 1816 | /* Limit ACPI just to boot-time to enable HT */ |
| 1817 | else if (strcmp(arg, "ht") == 0) { |
| 1818 | if (!acpi_force) |
| 1819 | disable_acpi(); |
| 1820 | acpi_ht = 1; |
| 1821 | } |
Zhao Yakui | 237889b | 2008-12-17 16:55:18 +0800 | [diff] [blame] | 1822 | /* acpi=rsdt use RSDT instead of XSDT */ |
| 1823 | else if (strcmp(arg, "rsdt") == 0) { |
| 1824 | acpi_rsdt_forced = 1; |
| 1825 | } |
Rusty Russell | 1a3f239 | 2006-09-26 10:52:32 +0200 | [diff] [blame] | 1826 | /* "acpi=noirq" disables ACPI interrupt routing */ |
| 1827 | else if (strcmp(arg, "noirq") == 0) { |
| 1828 | acpi_noirq_set(); |
| 1829 | } else { |
| 1830 | /* Core will printk when we return error. */ |
| 1831 | return -EINVAL; |
| 1832 | } |
| 1833 | return 0; |
| 1834 | } |
| 1835 | early_param("acpi", parse_acpi); |
| 1836 | |
| 1837 | /* FIXME: Using pci= for an ACPI parameter is a travesty. */ |
| 1838 | static int __init parse_pci(char *arg) |
| 1839 | { |
| 1840 | if (arg && strcmp(arg, "noacpi") == 0) |
| 1841 | acpi_disable_pci(); |
| 1842 | return 0; |
| 1843 | } |
| 1844 | early_param("pci", parse_pci); |
| 1845 | |
Yinghai Lu | 3c999f1 | 2008-06-20 16:11:20 -0700 | [diff] [blame] | 1846 | int __init acpi_mps_check(void) |
| 1847 | { |
| 1848 | #if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_X86_MPPARSE) |
| 1849 | /* mptable code is not built-in*/ |
| 1850 | if (acpi_disabled || acpi_noirq) { |
| 1851 | printk(KERN_WARNING "MPS support code is not built-in.\n" |
| 1852 | "Using acpi=off or acpi=noirq or pci=noacpi " |
| 1853 | "may have problem\n"); |
| 1854 | return 1; |
| 1855 | } |
| 1856 | #endif |
| 1857 | return 0; |
| 1858 | } |
| 1859 | |
Rusty Russell | 1a3f239 | 2006-09-26 10:52:32 +0200 | [diff] [blame] | 1860 | #ifdef CONFIG_X86_IO_APIC |
| 1861 | static int __init parse_acpi_skip_timer_override(char *arg) |
| 1862 | { |
| 1863 | acpi_skip_timer_override = 1; |
| 1864 | return 0; |
| 1865 | } |
| 1866 | early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override); |
Andi Kleen | fa18f47 | 2006-11-14 16:57:46 +0100 | [diff] [blame] | 1867 | |
| 1868 | static int __init parse_acpi_use_timer_override(char *arg) |
| 1869 | { |
| 1870 | acpi_use_timer_override = 1; |
| 1871 | return 0; |
| 1872 | } |
| 1873 | early_param("acpi_use_timer_override", parse_acpi_use_timer_override); |
Rusty Russell | 1a3f239 | 2006-09-26 10:52:32 +0200 | [diff] [blame] | 1874 | #endif /* CONFIG_X86_IO_APIC */ |
| 1875 | |
| 1876 | static int __init setup_acpi_sci(char *s) |
| 1877 | { |
| 1878 | if (!s) |
| 1879 | return -EINVAL; |
| 1880 | if (!strcmp(s, "edge")) |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 1881 | acpi_sci_flags = ACPI_MADT_TRIGGER_EDGE | |
| 1882 | (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK); |
Rusty Russell | 1a3f239 | 2006-09-26 10:52:32 +0200 | [diff] [blame] | 1883 | else if (!strcmp(s, "level")) |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 1884 | acpi_sci_flags = ACPI_MADT_TRIGGER_LEVEL | |
| 1885 | (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK); |
Rusty Russell | 1a3f239 | 2006-09-26 10:52:32 +0200 | [diff] [blame] | 1886 | else if (!strcmp(s, "high")) |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 1887 | acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_HIGH | |
| 1888 | (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK); |
Rusty Russell | 1a3f239 | 2006-09-26 10:52:32 +0200 | [diff] [blame] | 1889 | else if (!strcmp(s, "low")) |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 1890 | acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_LOW | |
| 1891 | (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK); |
Rusty Russell | 1a3f239 | 2006-09-26 10:52:32 +0200 | [diff] [blame] | 1892 | else |
| 1893 | return -EINVAL; |
| 1894 | return 0; |
| 1895 | } |
| 1896 | early_param("acpi_sci", setup_acpi_sci); |
Andrew Morton | d0a9081 | 2006-10-20 14:30:27 -0700 | [diff] [blame] | 1897 | |
| 1898 | int __acpi_acquire_global_lock(unsigned int *lock) |
| 1899 | { |
| 1900 | unsigned int old, new, val; |
| 1901 | do { |
| 1902 | old = *lock; |
| 1903 | new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1)); |
| 1904 | val = cmpxchg(lock, old, new); |
| 1905 | } while (unlikely (val != old)); |
| 1906 | return (new < 3) ? -1 : 0; |
| 1907 | } |
| 1908 | |
| 1909 | int __acpi_release_global_lock(unsigned int *lock) |
| 1910 | { |
| 1911 | unsigned int old, new, val; |
| 1912 | do { |
| 1913 | old = *lock; |
| 1914 | new = old & ~0x3; |
| 1915 | val = cmpxchg(lock, old, new); |
| 1916 | } while (unlikely (val != old)); |
| 1917 | return old & 0x1; |
| 1918 | } |