]>
Commit | Line | Data |
---|---|---|
1a59d1b8 | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
1da177e4 LT |
2 | /* |
3 | * boot.c - Architecture-Specific Low-Level ACPI Boot Support | |
4 | * | |
5 | * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> | |
6 | * Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com> | |
1da177e4 | 7 | */ |
14fad24d | 8 | #define pr_fmt(fmt) "ACPI: " fmt |
1da177e4 LT |
9 | |
10 | #include <linux/init.h> | |
1da177e4 | 11 | #include <linux/acpi.h> |
d66bea57 | 12 | #include <linux/acpi_pmtmr.h> |
1da177e4 | 13 | #include <linux/efi.h> |
73fea175 | 14 | #include <linux/cpumask.h> |
186f4360 | 15 | #include <linux/export.h> |
aea00143 | 16 | #include <linux/dmi.h> |
b33fa1f3 | 17 | #include <linux/irq.h> |
5a0e3ad6 | 18 | #include <linux/slab.h> |
57c8a661 | 19 | #include <linux/memblock.h> |
f0f4c343 | 20 | #include <linux/ioport.h> |
a31f8205 | 21 | #include <linux/pci.h> |
7b0a9114 | 22 | #include <linux/efi-bgrt.h> |
0231d000 | 23 | #include <linux/serial_core.h> |
65fddcfc | 24 | #include <linux/pgtable.h> |
1da177e4 | 25 | |
5520b7e7 | 26 | #include <asm/e820/api.h> |
f7a0c786 | 27 | #include <asm/irqdomain.h> |
b72d0db9 | 28 | #include <asm/pci_x86.h> |
1da177e4 LT |
29 | #include <asm/io_apic.h> |
30 | #include <asm/apic.h> | |
31 | #include <asm/io.h> | |
1da177e4 | 32 | #include <asm/mpspec.h> |
dfac2189 | 33 | #include <asm/smp.h> |
95d76acc | 34 | #include <asm/i8259.h> |
e7b66d16 | 35 | #include <asm/setup.h> |
1da177e4 | 36 | |
d6a77ead | 37 | #include "sleep.h" /* To include x86_acpi_suspend_lowlevel */ |
e8924acb | 38 | static int __initdata acpi_force = 0; |
c636f753 | 39 | int acpi_disabled; |
df3bb57d AK |
40 | EXPORT_SYMBOL(acpi_disabled); |
41 | ||
1da177e4 | 42 | #ifdef CONFIG_X86_64 |
1dcdd3d1 | 43 | # include <asm/proto.h> |
4be44fcd | 44 | #endif /* X86 */ |
1da177e4 | 45 | |
90d53909 | 46 | int acpi_noirq; /* skip ACPI IRQ initialization */ |
b5432a69 | 47 | static int acpi_nobgrt; /* skip ACPI BGRT */ |
6e4be1ff YL |
48 | int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */ |
49 | EXPORT_SYMBOL(acpi_pci_disabled); | |
1da177e4 LT |
50 | |
51 | int acpi_lapic; | |
52 | int acpi_ioapic; | |
53 | int acpi_strict; | |
9ad95879 | 54 | int acpi_disable_cmcff; |
c6a1fd91 | 55 | bool acpi_int_src_ovr[NR_IRQS_LEGACY]; |
1da177e4 | 56 | |
4565c4f6 | 57 | /* ACPI SCI override configuration */ |
5f3b1a8b | 58 | u8 acpi_sci_flags __initdata; |
4565c4f6 | 59 | u32 acpi_sci_override_gsi __initdata = INVALID_ACPI_IRQ; |
1da177e4 | 60 | int acpi_skip_timer_override __initdata; |
fa18f477 | 61 | int acpi_use_timer_override __initdata; |
7f74f8f2 | 62 | int acpi_fix_pin2_polarity __initdata; |
1da177e4 LT |
63 | |
64 | #ifdef CONFIG_X86_LOCAL_APIC | |
65 | static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE; | |
aa06e20f | 66 | static bool acpi_support_online_capable; |
1da177e4 LT |
67 | #endif |
68 | ||
f39642d0 KS |
69 | #ifdef CONFIG_X86_64 |
70 | /* Physical address of the Multiprocessor Wakeup Structure mailbox */ | |
71 | static u64 acpi_mp_wake_mailbox_paddr; | |
72 | /* Virtual address of the Multiprocessor Wakeup Structure mailbox */ | |
73 | static struct acpi_madt_multiproc_wakeup_mailbox *acpi_mp_wake_mailbox; | |
74 | #endif | |
75 | ||
d2d9c4a3 | 76 | #ifdef CONFIG_X86_IO_APIC |
5da2fd26 JL |
77 | /* |
78 | * Locks related to IOAPIC hotplug | |
79 | * Hotplug side: | |
80 | * ->device_hotplug_lock | |
81 | * ->acpi_ioapic_lock | |
82 | * ->ioapic_lock | |
83 | * Interrupt mapping side: | |
84 | * ->acpi_ioapic_lock | |
85 | * ->ioapic_mutex | |
86 | * ->ioapic_lock | |
87 | */ | |
88 | static DEFINE_MUTEX(acpi_ioapic_lock); | |
d2d9c4a3 | 89 | #endif |
5da2fd26 | 90 | |
1da177e4 LT |
91 | /* -------------------------------------------------------------------------- |
92 | Boot-time Configuration | |
93 | -------------------------------------------------------------------------- */ | |
94 | ||
95 | /* | |
96 | * The default interrupt routing model is PIC (8259). This gets | |
27b46d76 | 97 | * overridden if IOAPICs are enumerated (below). |
1da177e4 | 98 | */ |
4be44fcd | 99 | enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC; |
1da177e4 | 100 | |
1da177e4 | 101 | |
988856ee EB |
102 | /* |
103 | * ISA irqs by default are the first 16 gsis but can be | |
104 | * any gsi as specified by an interrupt source override. | |
105 | */ | |
106 | static u32 isa_irq_to_gsi[NR_IRQS_LEGACY] __read_mostly = { | |
107 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 | |
108 | }; | |
109 | ||
1da177e4 | 110 | /* |
f7750a79 | 111 | * This is just a simple wrapper around early_memremap(), |
45f1330a | 112 | * with sanity checks for phys == 0 and size == 0. |
1da177e4 | 113 | */ |
6c9a58e8 | 114 | void __init __iomem *__acpi_map_table(unsigned long phys, unsigned long size) |
1da177e4 | 115 | { |
1da177e4 | 116 | |
f34fa82b YL |
117 | if (!phys || !size) |
118 | return NULL; | |
119 | ||
f7750a79 | 120 | return early_memremap(phys, size); |
7d97277b | 121 | } |
45f1330a | 122 | |
6c9a58e8 | 123 | void __init __acpi_unmap_table(void __iomem *map, unsigned long size) |
7d97277b YL |
124 | { |
125 | if (!map || !size) | |
126 | return; | |
1da177e4 | 127 | |
f7750a79 | 128 | early_memunmap(map, size); |
1da177e4 | 129 | } |
1da177e4 | 130 | |
1da177e4 | 131 | #ifdef CONFIG_X86_LOCAL_APIC |
15a58ed1 | 132 | static int __init acpi_parse_madt(struct acpi_table_header *table) |
1da177e4 | 133 | { |
4be44fcd | 134 | struct acpi_table_madt *madt = NULL; |
1da177e4 | 135 | |
93984fbd | 136 | if (!boot_cpu_has(X86_FEATURE_APIC)) |
1da177e4 LT |
137 | return -EINVAL; |
138 | ||
15a58ed1 | 139 | madt = (struct acpi_table_madt *)table; |
1da177e4 | 140 | if (!madt) { |
14fad24d | 141 | pr_warn("Unable to map MADT\n"); |
1da177e4 LT |
142 | return -ENODEV; |
143 | } | |
144 | ||
ad363f80 AS |
145 | if (madt->address) { |
146 | acpi_lapic_addr = (u64) madt->address; | |
1da177e4 | 147 | |
14fad24d | 148 | pr_debug("Local APIC address 0x%08x\n", madt->address); |
1da177e4 | 149 | } |
a74fabfb | 150 | |
128b0c97 TG |
151 | if (madt->flags & ACPI_MADT_PCAT_COMPAT) |
152 | legacy_pic_pcat_compat(); | |
153 | ||
a74fabfb ML |
154 | /* ACPI 6.3 and newer support the online capable bit. */ |
155 | if (acpi_gbl_FADT.header.revision > 6 || | |
156 | (acpi_gbl_FADT.header.revision == 6 && | |
157 | acpi_gbl_FADT.minor_revision >= 3)) | |
aa06e20f | 158 | acpi_support_online_capable = true; |
1da177e4 | 159 | |
306db03b IM |
160 | default_acpi_madt_oem_check(madt->header.oem_id, |
161 | madt->header.oem_table_id); | |
4be44fcd | 162 | |
1da177e4 LT |
163 | return 0; |
164 | } | |
165 | ||
7e1f85f9 JL |
166 | /** |
167 | * acpi_register_lapic - register a local apic and generates a logic cpu number | |
168 | * @id: local apic id to register | |
3e9e57fa | 169 | * @acpiid: ACPI id to register |
7e1f85f9 JL |
170 | * @enabled: this cpu is enabled or not |
171 | * | |
172 | * Returns the logic cpu number which maps to the local apic | |
173 | */ | |
3e9e57fa | 174 | static int acpi_register_lapic(int id, u32 acpiid, u8 enabled) |
dfac2189 | 175 | { |
3e9e57fa | 176 | int cpu; |
fb3bbd6a | 177 | |
82982d72 | 178 | if (id >= MAX_LOCAL_APIC) { |
14fad24d | 179 | pr_info("skipped apicid that is too big\n"); |
7e1f85f9 | 180 | return -EINVAL; |
d3bd0588 YL |
181 | } |
182 | ||
2b85b3d2 DL |
183 | if (!enabled) { |
184 | ++disabled_cpus; | |
185 | return -EINVAL; | |
186 | } | |
187 | ||
249ada2c | 188 | cpu = generic_processor_info(id); |
3e9e57fa VK |
189 | if (cpu >= 0) |
190 | early_per_cpu(x86_cpu_to_acpiid, cpu) = acpiid; | |
191 | ||
192 | return cpu; | |
dfac2189 AS |
193 | } |
194 | ||
e2869bd7 KVA |
195 | static bool __init acpi_is_processor_usable(u32 lapic_flags) |
196 | { | |
197 | if (lapic_flags & ACPI_MADT_ENABLED) | |
198 | return true; | |
199 | ||
fed8d877 ED |
200 | if (!acpi_support_online_capable || |
201 | (lapic_flags & ACPI_MADT_ONLINE_CAPABLE)) | |
e2869bd7 KVA |
202 | return true; |
203 | ||
204 | return false; | |
205 | } | |
206 | ||
7237d3de | 207 | static int __init |
60574d1e | 208 | acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end) |
7237d3de SS |
209 | { |
210 | struct acpi_madt_local_x2apic *processor = NULL; | |
861a6ee8 | 211 | #ifdef CONFIG_X86_X2APIC |
a774635d | 212 | u32 apic_id; |
a35fd282 | 213 | u8 enabled; |
861a6ee8 | 214 | #endif |
7237d3de SS |
215 | |
216 | processor = (struct acpi_madt_local_x2apic *)header; | |
217 | ||
218 | if (BAD_MADT_ENTRY(processor, end)) | |
219 | return -EINVAL; | |
220 | ||
60574d1e | 221 | acpi_table_print_madt_entry(&header->common); |
7237d3de | 222 | |
861a6ee8 | 223 | #ifdef CONFIG_X86_X2APIC |
a35fd282 YL |
224 | apic_id = processor->local_apic_id; |
225 | enabled = processor->lapic_flags & ACPI_MADT_ENABLED; | |
861a6ee8 | 226 | |
10daf10a DL |
227 | /* Ignore invalid ID */ |
228 | if (apic_id == 0xffffffff) | |
229 | return 0; | |
230 | ||
e2869bd7 KVA |
231 | /* don't register processors that cannot be onlined */ |
232 | if (!acpi_is_processor_usable(processor->lapic_flags)) | |
233 | return 0; | |
234 | ||
7237d3de SS |
235 | /* |
236 | * We need to register disabled CPU as well to permit | |
237 | * counting disabled CPUs. This allows us to size | |
238 | * cpus_possible_map more accurately, to permit | |
239 | * to not preallocating memory for all NR_CPUS | |
240 | * when we use CPU hotplug. | |
241 | */ | |
9132d720 | 242 | if (!apic_id_valid(apic_id)) { |
a774635d | 243 | if (enabled) |
14fad24d | 244 | pr_warn("x2apic entry ignored\n"); |
a774635d LR |
245 | return 0; |
246 | } | |
247 | ||
248 | acpi_register_lapic(apic_id, processor->uid, enabled); | |
7237d3de | 249 | #else |
14fad24d | 250 | pr_warn("x2apic entry ignored\n"); |
7237d3de SS |
251 | #endif |
252 | ||
253 | return 0; | |
254 | } | |
255 | ||
1da177e4 | 256 | static int __init |
60574d1e | 257 | acpi_parse_lapic(union acpi_subtable_headers * header, const unsigned long end) |
1da177e4 | 258 | { |
5f3b1a8b | 259 | struct acpi_madt_local_apic *processor = NULL; |
1da177e4 | 260 | |
5f3b1a8b | 261 | processor = (struct acpi_madt_local_apic *)header; |
1da177e4 LT |
262 | |
263 | if (BAD_MADT_ENTRY(processor, end)) | |
264 | return -EINVAL; | |
265 | ||
60574d1e | 266 | acpi_table_print_madt_entry(&header->common); |
1da177e4 | 267 | |
f3bf1dbe TG |
268 | /* Ignore invalid ID */ |
269 | if (processor->id == 0xff) | |
270 | return 0; | |
271 | ||
aa06e20f | 272 | /* don't register processors that can not be onlined */ |
e2869bd7 | 273 | if (!acpi_is_processor_usable(processor->lapic_flags)) |
aa06e20f ML |
274 | return 0; |
275 | ||
7f66ae48 AR |
276 | /* |
277 | * We need to register disabled CPU as well to permit | |
278 | * counting disabled CPUs. This allows us to size | |
279 | * cpus_possible_map more accurately, to permit | |
280 | * to not preallocating memory for all NR_CPUS | |
281 | * when we use CPU hotplug. | |
282 | */ | |
dfac2189 | 283 | acpi_register_lapic(processor->id, /* APIC ID */ |
3e9e57fa | 284 | processor->processor_id, /* ACPI ID */ |
dfac2189 | 285 | processor->lapic_flags & ACPI_MADT_ENABLED); |
1da177e4 LT |
286 | |
287 | return 0; | |
288 | } | |
289 | ||
ac049c1d | 290 | static int __init |
60574d1e | 291 | acpi_parse_sapic(union acpi_subtable_headers *header, const unsigned long end) |
ac049c1d JS |
292 | { |
293 | struct acpi_madt_local_sapic *processor = NULL; | |
294 | ||
295 | processor = (struct acpi_madt_local_sapic *)header; | |
296 | ||
297 | if (BAD_MADT_ENTRY(processor, end)) | |
298 | return -EINVAL; | |
299 | ||
60574d1e | 300 | acpi_table_print_madt_entry(&header->common); |
ac049c1d | 301 | |
dfac2189 | 302 | acpi_register_lapic((processor->id << 8) | processor->eid,/* APIC ID */ |
3e9e57fa | 303 | processor->processor_id, /* ACPI ID */ |
dfac2189 | 304 | processor->lapic_flags & ACPI_MADT_ENABLED); |
ac049c1d JS |
305 | |
306 | return 0; | |
307 | } | |
308 | ||
1da177e4 | 309 | static int __init |
60574d1e | 310 | acpi_parse_lapic_addr_ovr(union acpi_subtable_headers * header, |
4be44fcd | 311 | const unsigned long end) |
1da177e4 | 312 | { |
5f3b1a8b | 313 | struct acpi_madt_local_apic_override *lapic_addr_ovr = NULL; |
1da177e4 | 314 | |
5f3b1a8b | 315 | lapic_addr_ovr = (struct acpi_madt_local_apic_override *)header; |
1da177e4 LT |
316 | |
317 | if (BAD_MADT_ENTRY(lapic_addr_ovr, end)) | |
318 | return -EINVAL; | |
319 | ||
60574d1e | 320 | acpi_table_print_madt_entry(&header->common); |
6de42119 | 321 | |
1da177e4 LT |
322 | acpi_lapic_addr = lapic_addr_ovr->address; |
323 | ||
324 | return 0; | |
325 | } | |
326 | ||
7237d3de | 327 | static int __init |
60574d1e | 328 | acpi_parse_x2apic_nmi(union acpi_subtable_headers *header, |
7237d3de SS |
329 | const unsigned long end) |
330 | { | |
331 | struct acpi_madt_local_x2apic_nmi *x2apic_nmi = NULL; | |
332 | ||
333 | x2apic_nmi = (struct acpi_madt_local_x2apic_nmi *)header; | |
334 | ||
335 | if (BAD_MADT_ENTRY(x2apic_nmi, end)) | |
336 | return -EINVAL; | |
337 | ||
60574d1e | 338 | acpi_table_print_madt_entry(&header->common); |
7237d3de SS |
339 | |
340 | if (x2apic_nmi->lint != 1) | |
14fad24d | 341 | pr_warn("NMI not connected to LINT 1!\n"); |
7237d3de SS |
342 | |
343 | return 0; | |
344 | } | |
345 | ||
1da177e4 | 346 | static int __init |
60574d1e | 347 | acpi_parse_lapic_nmi(union acpi_subtable_headers * header, const unsigned long end) |
1da177e4 | 348 | { |
5f3b1a8b | 349 | struct acpi_madt_local_apic_nmi *lapic_nmi = NULL; |
1da177e4 | 350 | |
5f3b1a8b | 351 | lapic_nmi = (struct acpi_madt_local_apic_nmi *)header; |
1da177e4 LT |
352 | |
353 | if (BAD_MADT_ENTRY(lapic_nmi, end)) | |
354 | return -EINVAL; | |
355 | ||
60574d1e | 356 | acpi_table_print_madt_entry(&header->common); |
1da177e4 LT |
357 | |
358 | if (lapic_nmi->lint != 1) | |
14fad24d | 359 | pr_warn("NMI not connected to LINT 1!\n"); |
1da177e4 LT |
360 | |
361 | return 0; | |
362 | } | |
363 | ||
f39642d0 KS |
364 | #ifdef CONFIG_X86_64 |
365 | static int acpi_wakeup_cpu(int apicid, unsigned long start_ip) | |
366 | { | |
367 | /* | |
368 | * Remap mailbox memory only for the first call to acpi_wakeup_cpu(). | |
369 | * | |
370 | * Wakeup of secondary CPUs is fully serialized in the core code. | |
371 | * No need to protect acpi_mp_wake_mailbox from concurrent accesses. | |
372 | */ | |
373 | if (!acpi_mp_wake_mailbox) { | |
374 | acpi_mp_wake_mailbox = memremap(acpi_mp_wake_mailbox_paddr, | |
375 | sizeof(*acpi_mp_wake_mailbox), | |
376 | MEMREMAP_WB); | |
377 | } | |
378 | ||
379 | /* | |
380 | * Mailbox memory is shared between the firmware and OS. Firmware will | |
381 | * listen on mailbox command address, and once it receives the wakeup | |
382 | * command, the CPU associated with the given apicid will be booted. | |
383 | * | |
384 | * The value of 'apic_id' and 'wakeup_vector' must be visible to the | |
385 | * firmware before the wakeup command is visible. smp_store_release() | |
386 | * ensures ordering and visibility. | |
387 | */ | |
388 | acpi_mp_wake_mailbox->apic_id = apicid; | |
389 | acpi_mp_wake_mailbox->wakeup_vector = start_ip; | |
390 | smp_store_release(&acpi_mp_wake_mailbox->command, | |
391 | ACPI_MP_WAKE_COMMAND_WAKEUP); | |
392 | ||
393 | /* | |
394 | * Wait for the CPU to wake up. | |
395 | * | |
396 | * The CPU being woken up is essentially in a spin loop waiting to be | |
397 | * woken up. It should not take long for it wake up and acknowledge by | |
398 | * zeroing out ->command. | |
399 | * | |
400 | * ACPI specification doesn't provide any guidance on how long kernel | |
401 | * has to wait for a wake up acknowledgement. It also doesn't provide | |
402 | * a way to cancel a wake up request if it takes too long. | |
403 | * | |
404 | * In TDX environment, the VMM has control over how long it takes to | |
405 | * wake up secondary. It can postpone scheduling secondary vCPU | |
406 | * indefinitely. Giving up on wake up request and reporting error opens | |
407 | * possible attack vector for VMM: it can wake up a secondary CPU when | |
408 | * kernel doesn't expect it. Wait until positive result of the wake up | |
409 | * request. | |
410 | */ | |
411 | while (READ_ONCE(acpi_mp_wake_mailbox->command)) | |
412 | cpu_relax(); | |
413 | ||
414 | return 0; | |
415 | } | |
416 | #endif /* CONFIG_X86_64 */ | |
417 | #endif /* CONFIG_X86_LOCAL_APIC */ | |
1da177e4 | 418 | |
8466361a | 419 | #ifdef CONFIG_X86_IO_APIC |
8d7cdcb9 JL |
420 | #define MP_ISA_BUS 0 |
421 | ||
4ee2ec1b VS |
422 | static int __init mp_register_ioapic_irq(u8 bus_irq, u8 polarity, |
423 | u8 trigger, u32 gsi); | |
424 | ||
8d7cdcb9 JL |
425 | static void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, |
426 | u32 gsi) | |
427 | { | |
dad5ab0d SH |
428 | /* |
429 | * Check bus_irq boundary. | |
430 | */ | |
431 | if (bus_irq >= NR_IRQS_LEGACY) { | |
432 | pr_warn("Invalid bus_irq %u for legacy override\n", bus_irq); | |
433 | return; | |
434 | } | |
435 | ||
8d7cdcb9 JL |
436 | /* |
437 | * TBD: This check is for faulty timer entries, where the override | |
438 | * erroneously sets the trigger to level, resulting in a HUGE | |
439 | * increase of timer interrupts! | |
440 | */ | |
441 | if ((bus_irq == 0) && (trigger == 3)) | |
442 | trigger = 1; | |
443 | ||
4ee2ec1b VS |
444 | if (mp_register_ioapic_irq(bus_irq, polarity, trigger, gsi) < 0) |
445 | return; | |
2e0ad0e2 JL |
446 | /* |
447 | * Reset default identity mapping if gsi is also an legacy IRQ, | |
448 | * otherwise there will be more than one entry with the same GSI | |
449 | * and acpi_isa_irq_to_gsi() may give wrong result. | |
450 | */ | |
95d76acc | 451 | if (gsi < nr_legacy_irqs() && isa_irq_to_gsi[gsi] == gsi) |
220580fb | 452 | isa_irq_to_gsi[gsi] = INVALID_ACPI_IRQ; |
8d7cdcb9 JL |
453 | isa_irq_to_gsi[bus_irq] = gsi; |
454 | } | |
455 | ||
24773e6c | 456 | static void mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger, |
8d7cdcb9 JL |
457 | int polarity) |
458 | { | |
459 | #ifdef CONFIG_X86_MPPARSE | |
460 | struct mpc_intsrc mp_irq; | |
461 | struct pci_dev *pdev; | |
462 | unsigned char number; | |
463 | unsigned int devfn; | |
464 | int ioapic; | |
465 | u8 pin; | |
466 | ||
467 | if (!acpi_ioapic) | |
24773e6c | 468 | return; |
8d7cdcb9 | 469 | if (!dev || !dev_is_pci(dev)) |
24773e6c | 470 | return; |
8d7cdcb9 JL |
471 | |
472 | pdev = to_pci_dev(dev); | |
473 | number = pdev->bus->number; | |
474 | devfn = pdev->devfn; | |
475 | pin = pdev->pin; | |
476 | /* print the entry should happen on mptable identically */ | |
477 | mp_irq.type = MP_INTSRC; | |
478 | mp_irq.irqtype = mp_INT; | |
479 | mp_irq.irqflag = (trigger == ACPI_EDGE_SENSITIVE ? 4 : 0x0c) | | |
480 | (polarity == ACPI_ACTIVE_HIGH ? 1 : 3); | |
481 | mp_irq.srcbus = number; | |
482 | mp_irq.srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3); | |
483 | ioapic = mp_find_ioapic(gsi); | |
484 | mp_irq.dstapic = mpc_ioapic_id(ioapic); | |
485 | mp_irq.dstirq = mp_find_ioapic_pin(ioapic, gsi); | |
486 | ||
487 | mp_save_irq(&mp_irq); | |
488 | #endif | |
8d7cdcb9 JL |
489 | } |
490 | ||
25271415 VS |
491 | static int __init mp_register_ioapic_irq(u8 bus_irq, u8 polarity, |
492 | u8 trigger, u32 gsi) | |
493 | { | |
494 | struct mpc_intsrc mp_irq; | |
495 | int ioapic, pin; | |
496 | ||
497 | /* Convert 'gsi' to 'ioapic.pin'(INTIN#) */ | |
498 | ioapic = mp_find_ioapic(gsi); | |
499 | if (ioapic < 0) { | |
500 | pr_warn("Failed to find ioapic for gsi : %u\n", gsi); | |
501 | return ioapic; | |
502 | } | |
503 | ||
504 | pin = mp_find_ioapic_pin(ioapic, gsi); | |
505 | ||
506 | mp_irq.type = MP_INTSRC; | |
507 | mp_irq.irqtype = mp_INT; | |
508 | mp_irq.irqflag = (trigger << 2) | polarity; | |
509 | mp_irq.srcbus = MP_ISA_BUS; | |
510 | mp_irq.srcbusirq = bus_irq; | |
511 | mp_irq.dstapic = mpc_ioapic_id(ioapic); | |
512 | mp_irq.dstirq = pin; | |
513 | ||
514 | mp_save_irq(&mp_irq); | |
515 | ||
516 | return 0; | |
517 | } | |
518 | ||
1da177e4 | 519 | static int __init |
60574d1e | 520 | acpi_parse_ioapic(union acpi_subtable_headers * header, const unsigned long end) |
1da177e4 | 521 | { |
5f3b1a8b | 522 | struct acpi_madt_io_apic *ioapic = NULL; |
ca7e28aa JL |
523 | struct ioapic_domain_cfg cfg = { |
524 | .type = IOAPIC_DOMAIN_DYNAMIC, | |
f7a0c786 | 525 | .ops = &mp_ioapic_irqdomain_ops, |
ca7e28aa | 526 | }; |
1da177e4 | 527 | |
5f3b1a8b | 528 | ioapic = (struct acpi_madt_io_apic *)header; |
1da177e4 LT |
529 | |
530 | if (BAD_MADT_ENTRY(ioapic, end)) | |
531 | return -EINVAL; | |
4be44fcd | 532 | |
60574d1e | 533 | acpi_table_print_madt_entry(&header->common); |
1da177e4 | 534 | |
ca7e28aa JL |
535 | /* Statically assign IRQ numbers for IOAPICs hosting legacy IRQs */ |
536 | if (ioapic->global_irq_base < nr_legacy_irqs()) | |
537 | cfg.type = IOAPIC_DOMAIN_LEGACY; | |
538 | ||
539 | mp_register_ioapic(ioapic->id, ioapic->address, ioapic->global_irq_base, | |
540 | &cfg); | |
4be44fcd | 541 | |
1da177e4 LT |
542 | return 0; |
543 | } | |
544 | ||
545 | /* | |
546 | * Parse Interrupt Source Override for the ACPI SCI | |
547 | */ | |
9d2062b8 | 548 | static void __init acpi_sci_ioapic_setup(u8 bus_irq, u16 polarity, u16 trigger, u32 gsi) |
1da177e4 LT |
549 | { |
550 | if (trigger == 0) /* compatible SCI trigger is level */ | |
551 | trigger = 3; | |
552 | ||
553 | if (polarity == 0) /* compatible SCI polarity is low */ | |
554 | polarity = 3; | |
555 | ||
556 | /* Command-line over-ride via acpi_sci= */ | |
5f3b1a8b AS |
557 | if (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) |
558 | trigger = (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) >> 2; | |
1da177e4 | 559 | |
5f3b1a8b AS |
560 | if (acpi_sci_flags & ACPI_MADT_POLARITY_MASK) |
561 | polarity = acpi_sci_flags & ACPI_MADT_POLARITY_MASK; | |
1da177e4 | 562 | |
25271415 VS |
563 | if (bus_irq < NR_IRQS_LEGACY) |
564 | mp_override_legacy_irq(bus_irq, polarity, trigger, gsi); | |
565 | else | |
566 | mp_register_ioapic_irq(bus_irq, polarity, trigger, gsi); | |
567 | ||
f1caa61d | 568 | acpi_penalize_sci_irq(bus_irq, trigger, polarity); |
1da177e4 LT |
569 | |
570 | /* | |
571 | * stash over-ride to indicate we've been here | |
cee324b1 | 572 | * and for later update of acpi_gbl_FADT |
1da177e4 | 573 | */ |
7bdd21ce | 574 | acpi_sci_override_gsi = gsi; |
1da177e4 LT |
575 | return; |
576 | } | |
577 | ||
578 | static int __init | |
60574d1e | 579 | acpi_parse_int_src_ovr(union acpi_subtable_headers * header, |
4be44fcd | 580 | const unsigned long end) |
1da177e4 | 581 | { |
5f3b1a8b | 582 | struct acpi_madt_interrupt_override *intsrc = NULL; |
1da177e4 | 583 | |
5f3b1a8b | 584 | intsrc = (struct acpi_madt_interrupt_override *)header; |
1da177e4 LT |
585 | |
586 | if (BAD_MADT_ENTRY(intsrc, end)) | |
587 | return -EINVAL; | |
588 | ||
60574d1e | 589 | acpi_table_print_madt_entry(&header->common); |
1da177e4 | 590 | |
c6a1fd91 HG |
591 | if (intsrc->source_irq < NR_IRQS_LEGACY) |
592 | acpi_int_src_ovr[intsrc->source_irq] = true; | |
593 | ||
5f3b1a8b | 594 | if (intsrc->source_irq == acpi_gbl_FADT.sci_interrupt) { |
9d2062b8 | 595 | acpi_sci_ioapic_setup(intsrc->source_irq, |
5f3b1a8b | 596 | intsrc->inti_flags & ACPI_MADT_POLARITY_MASK, |
9d2062b8 EB |
597 | (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2, |
598 | intsrc->global_irq); | |
1da177e4 LT |
599 | return 0; |
600 | } | |
601 | ||
ae10ccdc | 602 | if (intsrc->source_irq == 0) { |
7f74f8f2 | 603 | if (acpi_skip_timer_override) { |
14fad24d | 604 | pr_warn("BIOS IRQ0 override ignored.\n"); |
7f74f8f2 AH |
605 | return 0; |
606 | } | |
ae10ccdc FT |
607 | |
608 | if ((intsrc->global_irq == 2) && acpi_fix_pin2_polarity | |
609 | && (intsrc->inti_flags & ACPI_MADT_POLARITY_MASK)) { | |
7f74f8f2 | 610 | intsrc->inti_flags &= ~ACPI_MADT_POLARITY_MASK; |
14fad24d | 611 | pr_warn("BIOS IRQ0 pin2 override: forcing polarity to high active.\n"); |
7f74f8f2 | 612 | } |
1da177e4 LT |
613 | } |
614 | ||
5f3b1a8b AS |
615 | mp_override_legacy_irq(intsrc->source_irq, |
616 | intsrc->inti_flags & ACPI_MADT_POLARITY_MASK, | |
617 | (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2, | |
618 | intsrc->global_irq); | |
1da177e4 LT |
619 | |
620 | return 0; | |
621 | } | |
622 | ||
1da177e4 | 623 | static int __init |
60574d1e | 624 | acpi_parse_nmi_src(union acpi_subtable_headers * header, const unsigned long end) |
1da177e4 | 625 | { |
5f3b1a8b | 626 | struct acpi_madt_nmi_source *nmi_src = NULL; |
1da177e4 | 627 | |
5f3b1a8b | 628 | nmi_src = (struct acpi_madt_nmi_source *)header; |
1da177e4 LT |
629 | |
630 | if (BAD_MADT_ENTRY(nmi_src, end)) | |
631 | return -EINVAL; | |
632 | ||
60574d1e | 633 | acpi_table_print_madt_entry(&header->common); |
1da177e4 LT |
634 | |
635 | /* TBD: Support nimsrc entries? */ | |
636 | ||
637 | return 0; | |
638 | } | |
639 | ||
4be44fcd | 640 | #endif /* CONFIG_X86_IO_APIC */ |
1da177e4 | 641 | |
1da177e4 LT |
642 | /* |
643 | * acpi_pic_sci_set_trigger() | |
5f3b1a8b | 644 | * |
1da177e4 LT |
645 | * use ELCR to set PIC-mode trigger type for SCI |
646 | * | |
647 | * If a PIC-mode SCI is not recognized or gives spurious IRQ7's | |
648 | * it may require Edge Trigger -- use "acpi_sci=edge" | |
649 | * | |
34739a28 | 650 | * Port 0x4d0-4d1 are ELCR1 and ELCR2, the Edge/Level Control Registers |
1da177e4 | 651 | * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge. |
34739a28 MR |
652 | * ELCR1 is IRQs 0-7 (IRQ 0, 1, 2 must be 0) |
653 | * ELCR2 is IRQs 8-15 (IRQ 8, 13 must be 0) | |
1da177e4 LT |
654 | */ |
655 | ||
4be44fcd | 656 | void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger) |
1da177e4 LT |
657 | { |
658 | unsigned int mask = 1 << irq; | |
659 | unsigned int old, new; | |
660 | ||
661 | /* Real old ELCR mask */ | |
d2531661 | 662 | old = inb(PIC_ELCR1) | (inb(PIC_ELCR2) << 8); |
1da177e4 LT |
663 | |
664 | /* | |
27b46d76 | 665 | * If we use ACPI to set PCI IRQs, then we should clear ELCR |
1da177e4 LT |
666 | * since we will set it correctly as we enable the PCI irq |
667 | * routing. | |
668 | */ | |
669 | new = acpi_noirq ? old : 0; | |
670 | ||
671 | /* | |
672 | * Update SCI information in the ELCR, it isn't in the PCI | |
673 | * routing tables.. | |
674 | */ | |
675 | switch (trigger) { | |
4be44fcd | 676 | case 1: /* Edge - clear */ |
1da177e4 LT |
677 | new &= ~mask; |
678 | break; | |
4be44fcd | 679 | case 3: /* Level - set */ |
1da177e4 LT |
680 | new |= mask; |
681 | break; | |
682 | } | |
683 | ||
684 | if (old == new) | |
685 | return; | |
686 | ||
14fad24d | 687 | pr_warn("setting ELCR to %04x (from %04x)\n", new, old); |
d2531661 MR |
688 | outb(new, PIC_ELCR1); |
689 | outb(new >> 8, PIC_ELCR2); | |
1da177e4 LT |
690 | } |
691 | ||
6b9fb708 | 692 | int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp) |
1da177e4 | 693 | { |
b568b860 JL |
694 | int rc, irq, trigger, polarity; |
695 | ||
1ea76fba JL |
696 | if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) { |
697 | *irqp = gsi; | |
698 | return 0; | |
699 | } | |
700 | ||
b568b860 | 701 | rc = acpi_get_override_irq(gsi, &trigger, &polarity); |
a89bca27 AS |
702 | if (rc) |
703 | return rc; | |
b568b860 | 704 | |
a89bca27 AS |
705 | trigger = trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE; |
706 | polarity = polarity ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH; | |
707 | irq = acpi_register_gsi(NULL, gsi, trigger, polarity); | |
708 | if (irq < 0) | |
709 | return irq; | |
710 | ||
711 | *irqp = irq; | |
712 | return 0; | |
1da177e4 | 713 | } |
81e88fdc | 714 | EXPORT_SYMBOL_GPL(acpi_gsi_to_irq); |
1da177e4 | 715 | |
2c2df841 EB |
716 | int acpi_isa_irq_to_gsi(unsigned isa_irq, u32 *gsi) |
717 | { | |
95d76acc | 718 | if (isa_irq < nr_legacy_irqs() && |
220580fb | 719 | isa_irq_to_gsi[isa_irq] != INVALID_ACPI_IRQ) { |
032329ee JL |
720 | *gsi = isa_irq_to_gsi[isa_irq]; |
721 | return 0; | |
722 | } | |
723 | ||
724 | return -1; | |
2c2df841 EB |
725 | } |
726 | ||
2f065aef JF |
727 | static int acpi_register_gsi_pic(struct device *dev, u32 gsi, |
728 | int trigger, int polarity) | |
1da177e4 | 729 | { |
1da177e4 LT |
730 | #ifdef CONFIG_PCI |
731 | /* | |
732 | * Make sure all (legacy) PCI IRQs are set as level-triggered. | |
733 | */ | |
2f065aef | 734 | if (trigger == ACPI_LEVEL_SENSITIVE) |
ea6cd250 | 735 | elcr_set_level_irq(gsi); |
1da177e4 LT |
736 | #endif |
737 | ||
2f065aef JF |
738 | return gsi; |
739 | } | |
740 | ||
2f82c9dc | 741 | #ifdef CONFIG_X86_LOCAL_APIC |
2f065aef JF |
742 | static int acpi_register_gsi_ioapic(struct device *dev, u32 gsi, |
743 | int trigger, int polarity) | |
744 | { | |
84245af7 | 745 | int irq = gsi; |
1da177e4 | 746 | #ifdef CONFIG_X86_IO_APIC |
46176f39 JL |
747 | int node; |
748 | struct irq_alloc_info info; | |
749 | ||
750 | node = dev ? dev_to_node(dev) : NUMA_NO_NODE; | |
751 | trigger = trigger == ACPI_EDGE_SENSITIVE ? 0 : 1; | |
752 | polarity = polarity == ACPI_ACTIVE_HIGH ? 0 : 1; | |
753 | ioapic_set_alloc_attr(&info, node, trigger, polarity); | |
754 | ||
5da2fd26 | 755 | mutex_lock(&acpi_ioapic_lock); |
46176f39 JL |
756 | irq = mp_map_gsi_to_irq(gsi, IOAPIC_MAP_ALLOC, &info); |
757 | /* Don't set up the ACPI SCI because it's already set up */ | |
7d7fb91c | 758 | if (irq >= 0 && enable_update_mptable && gsi != acpi_gbl_FADT.sci_interrupt) |
46176f39 | 759 | mp_config_acpi_gsi(dev, gsi, trigger, polarity); |
5da2fd26 | 760 | mutex_unlock(&acpi_ioapic_lock); |
1da177e4 | 761 | #endif |
2f065aef | 762 | |
84245af7 | 763 | return irq; |
2f065aef JF |
764 | } |
765 | ||
6a38fa0e JL |
766 | static void acpi_unregister_gsi_ioapic(u32 gsi) |
767 | { | |
768 | #ifdef CONFIG_X86_IO_APIC | |
46176f39 JL |
769 | int irq; |
770 | ||
5da2fd26 | 771 | mutex_lock(&acpi_ioapic_lock); |
46176f39 JL |
772 | irq = mp_map_gsi_to_irq(gsi, 0, NULL); |
773 | if (irq > 0) | |
774 | mp_unmap_irq(irq); | |
5da2fd26 | 775 | mutex_unlock(&acpi_ioapic_lock); |
6a38fa0e | 776 | #endif |
2f065aef | 777 | } |
2f82c9dc | 778 | #endif |
2f065aef | 779 | |
90f6881e JF |
780 | int (*__acpi_register_gsi)(struct device *dev, u32 gsi, |
781 | int trigger, int polarity) = acpi_register_gsi_pic; | |
6a38fa0e | 782 | void (*__acpi_unregister_gsi)(u32 gsi) = NULL; |
2f065aef | 783 | |
d6a77ead KRW |
784 | #ifdef CONFIG_ACPI_SLEEP |
785 | int (*acpi_suspend_lowlevel)(void) = x86_acpi_suspend_lowlevel; | |
786 | #else | |
787 | int (*acpi_suspend_lowlevel)(void); | |
788 | #endif | |
789 | ||
2f065aef JF |
790 | /* |
791 | * success: return IRQ number (>=0) | |
792 | * failure: return < 0 | |
793 | */ | |
794 | int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity) | |
795 | { | |
84245af7 | 796 | return __acpi_register_gsi(dev, gsi, trigger, polarity); |
1da177e4 | 797 | } |
35e92b78 AS |
798 | EXPORT_SYMBOL_GPL(acpi_register_gsi); |
799 | ||
800 | void acpi_unregister_gsi(u32 gsi) | |
801 | { | |
6a38fa0e JL |
802 | if (__acpi_unregister_gsi) |
803 | __acpi_unregister_gsi(gsi); | |
35e92b78 AS |
804 | } |
805 | EXPORT_SYMBOL_GPL(acpi_unregister_gsi); | |
4be44fcd | 806 | |
9f50c6ea | 807 | #ifdef CONFIG_X86_LOCAL_APIC |
e819813f | 808 | static void __init acpi_set_irq_model_ioapic(void) |
2f065aef JF |
809 | { |
810 | acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC; | |
811 | __acpi_register_gsi = acpi_register_gsi_ioapic; | |
6a38fa0e | 812 | __acpi_unregister_gsi = acpi_unregister_gsi_ioapic; |
2f065aef JF |
813 | acpi_ioapic = 1; |
814 | } | |
9f50c6ea | 815 | #endif |
2f065aef | 816 | |
1da177e4 LT |
817 | /* |
818 | * ACPI based hotplug support for CPU | |
819 | */ | |
820 | #ifdef CONFIG_ACPI_HOTPLUG_CPU | |
d8191fa4 | 821 | #include <acpi/processor.h> |
009cbadb | 822 | |
c962cff1 | 823 | static int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid) |
0271f910 HL |
824 | { |
825 | #ifdef CONFIG_ACPI_NUMA | |
826 | int nid; | |
827 | ||
828 | nid = acpi_get_node(handle); | |
4370a3ef | 829 | if (nid != NUMA_NO_NODE) { |
896dc506 JL |
830 | set_apicid_to_node(physid, nid); |
831 | numa_set_node(cpu, nid); | |
832 | } | |
0271f910 | 833 | #endif |
dc6db24d | 834 | return 0; |
0271f910 | 835 | } |
009cbadb | 836 | |
febf2407 VK |
837 | int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id, |
838 | int *pcpu) | |
1da177e4 | 839 | { |
73fea175 | 840 | int cpu; |
ee943a82 | 841 | |
febf2407 | 842 | cpu = acpi_register_lapic(physid, acpi_id, ACPI_MADT_ENABLED); |
7e1f85f9 | 843 | if (cpu < 0) { |
14fad24d | 844 | pr_info("Unable to map lapic to logical cpu number\n"); |
7e1f85f9 | 845 | return cpu; |
73fea175 AR |
846 | } |
847 | ||
d8191fa4 | 848 | acpi_processor_set_pdc(handle); |
0271f910 | 849 | acpi_map_cpu2node(handle, cpu, physid); |
73fea175 AR |
850 | |
851 | *pcpu = cpu; | |
7e1f85f9 | 852 | return 0; |
1da177e4 | 853 | } |
d02dc27d | 854 | EXPORT_SYMBOL(acpi_map_cpu); |
1da177e4 | 855 | |
d02dc27d | 856 | int acpi_unmap_cpu(int cpu) |
1da177e4 | 857 | { |
c4c60524 WC |
858 | #ifdef CONFIG_ACPI_NUMA |
859 | set_apicid_to_node(per_cpu(x86_cpu_to_apicid, cpu), NUMA_NO_NODE); | |
860 | #endif | |
861 | ||
71fff5e6 | 862 | per_cpu(x86_cpu_to_apicid, cpu) = -1; |
9628937d | 863 | set_cpu_present(cpu, false); |
73fea175 AR |
864 | num_processors--; |
865 | ||
866 | return (0); | |
1da177e4 | 867 | } |
d02dc27d | 868 | EXPORT_SYMBOL(acpi_unmap_cpu); |
4be44fcd | 869 | #endif /* CONFIG_ACPI_HOTPLUG_CPU */ |
1da177e4 | 870 | |
4be44fcd | 871 | int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base) |
b1bb248a | 872 | { |
7db298cb JL |
873 | int ret = -ENOSYS; |
874 | #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC | |
875 | int ioapic_id; | |
876 | u64 addr; | |
877 | struct ioapic_domain_cfg cfg = { | |
878 | .type = IOAPIC_DOMAIN_DYNAMIC, | |
f7a0c786 | 879 | .ops = &mp_ioapic_irqdomain_ops, |
7db298cb JL |
880 | }; |
881 | ||
882 | ioapic_id = acpi_get_ioapic_id(handle, gsi_base, &addr); | |
883 | if (ioapic_id < 0) { | |
884 | unsigned long long uid; | |
885 | acpi_status status; | |
886 | ||
887 | status = acpi_evaluate_integer(handle, METHOD_NAME__UID, | |
888 | NULL, &uid); | |
889 | if (ACPI_FAILURE(status)) { | |
890 | acpi_handle_warn(handle, "failed to get IOAPIC ID.\n"); | |
891 | return -EINVAL; | |
892 | } | |
893 | ioapic_id = (int)uid; | |
894 | } | |
895 | ||
896 | mutex_lock(&acpi_ioapic_lock); | |
897 | ret = mp_register_ioapic(ioapic_id, phys_addr, gsi_base, &cfg); | |
898 | mutex_unlock(&acpi_ioapic_lock); | |
899 | #endif | |
900 | ||
901 | return ret; | |
b1bb248a KK |
902 | } |
903 | EXPORT_SYMBOL(acpi_register_ioapic); | |
904 | ||
4be44fcd | 905 | int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base) |
b1bb248a | 906 | { |
15516a3b JL |
907 | int ret = -ENOSYS; |
908 | ||
909 | #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC | |
910 | mutex_lock(&acpi_ioapic_lock); | |
911 | ret = mp_unregister_ioapic(gsi_base); | |
912 | mutex_unlock(&acpi_ioapic_lock); | |
913 | #endif | |
4be44fcd | 914 | |
15516a3b JL |
915 | return ret; |
916 | } | |
b1bb248a KK |
917 | EXPORT_SYMBOL(acpi_unregister_ioapic); |
918 | ||
e89900c9 | 919 | /** |
d9f6e12f | 920 | * acpi_ioapic_registered - Check whether IOAPIC associated with @gsi_base |
e89900c9 | 921 | * has been registered |
a97673a1 | 922 | * @handle: ACPI handle of the IOAPIC device |
e89900c9 JL |
923 | * @gsi_base: GSI base associated with the IOAPIC |
924 | * | |
925 | * Assume caller holds some type of lock to serialize acpi_ioapic_registered() | |
926 | * with acpi_register_ioapic()/acpi_unregister_ioapic(). | |
927 | */ | |
928 | int acpi_ioapic_registered(acpi_handle handle, u32 gsi_base) | |
929 | { | |
930 | int ret = 0; | |
931 | ||
932 | #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC | |
933 | mutex_lock(&acpi_ioapic_lock); | |
934 | ret = mp_ioapic_registered(gsi_base); | |
935 | mutex_unlock(&acpi_ioapic_lock); | |
936 | #endif | |
937 | ||
938 | return ret; | |
939 | } | |
940 | ||
5f3b1a8b | 941 | static int __init acpi_parse_sbf(struct acpi_table_header *table) |
1da177e4 | 942 | { |
2fad9308 | 943 | struct acpi_table_boot *sb = (struct acpi_table_boot *)table; |
1da177e4 | 944 | |
5f3b1a8b | 945 | sbf_port = sb->cmos_index; /* Save CMOS port */ |
1da177e4 LT |
946 | |
947 | return 0; | |
948 | } | |
949 | ||
1da177e4 | 950 | #ifdef CONFIG_HPET_TIMER |
2d0c87c3 | 951 | #include <asm/hpet.h> |
1da177e4 | 952 | |
dd96dc32 | 953 | static struct resource *hpet_res __initdata; |
a1dfd851 | 954 | |
5f3b1a8b | 955 | static int __init acpi_parse_hpet(struct acpi_table_header *table) |
1da177e4 | 956 | { |
2fad9308 | 957 | struct acpi_table_hpet *hpet_tbl = (struct acpi_table_hpet *)table; |
1da177e4 | 958 | |
ad363f80 | 959 | if (hpet_tbl->address.space_id != ACPI_SPACE_MEM) { |
14fad24d | 960 | pr_warn("HPET timers must be located in memory.\n"); |
1da177e4 LT |
961 | return -1; |
962 | } | |
f0f4c343 | 963 | |
2d0c87c3 | 964 | hpet_address = hpet_tbl->address.address; |
c8bc6f3c | 965 | hpet_blockid = hpet_tbl->sequence; |
f4df73c2 TG |
966 | |
967 | /* | |
968 | * Some broken BIOSes advertise HPET at 0x0. We really do not | |
969 | * want to allocate a resource there. | |
970 | */ | |
971 | if (!hpet_address) { | |
14fad24d | 972 | pr_warn("HPET id: %#x base: %#lx is invalid\n", hpet_tbl->id, hpet_address); |
f4df73c2 TG |
973 | return 0; |
974 | } | |
975 | #ifdef CONFIG_X86_64 | |
976 | /* | |
977 | * Some even more broken BIOSes advertise HPET at | |
978 | * 0xfed0000000000000 instead of 0xfed00000. Fix it up and add | |
979 | * some noise: | |
980 | */ | |
981 | if (hpet_address == 0xfed0000000000000UL) { | |
982 | if (!hpet_force_user) { | |
14fad24d HK |
983 | pr_warn("HPET id: %#x base: 0xfed0000000000000 is bogus, try hpet=force on the kernel command line to fix it up to 0xfed00000.\n", |
984 | hpet_tbl->id); | |
f4df73c2 TG |
985 | hpet_address = 0; |
986 | return 0; | |
987 | } | |
14fad24d HK |
988 | pr_warn("HPET id: %#x base: 0xfed0000000000000 fixed up to 0xfed00000.\n", |
989 | hpet_tbl->id); | |
f4df73c2 TG |
990 | hpet_address >>= 32; |
991 | } | |
992 | #endif | |
14fad24d | 993 | pr_info("HPET id: %#x base: %#lx\n", hpet_tbl->id, hpet_address); |
1da177e4 | 994 | |
a1dfd851 AD |
995 | /* |
996 | * Allocate and initialize the HPET firmware resource for adding into | |
997 | * the resource tree during the lateinit timeframe. | |
998 | */ | |
999 | #define HPET_RESOURCE_NAME_SIZE 9 | |
2a5bda5a | 1000 | hpet_res = memblock_alloc(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE, |
7e1c4e27 | 1001 | SMP_CACHE_BYTES); |
8a7f97b9 MR |
1002 | if (!hpet_res) |
1003 | panic("%s: Failed to allocate %zu bytes\n", __func__, | |
1004 | sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE); | |
a1dfd851 | 1005 | |
a1dfd851 AD |
1006 | hpet_res->name = (void *)&hpet_res[1]; |
1007 | hpet_res->flags = IORESOURCE_MEM; | |
1008 | snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE, "HPET %u", | |
1009 | hpet_tbl->sequence); | |
1010 | ||
1011 | hpet_res->start = hpet_address; | |
1012 | hpet_res->end = hpet_address + (1 * 1024) - 1; | |
1013 | ||
1da177e4 LT |
1014 | return 0; |
1015 | } | |
a1dfd851 AD |
1016 | |
1017 | /* | |
1018 | * hpet_insert_resource inserts the HPET resources used into the resource | |
1019 | * tree. | |
1020 | */ | |
1021 | static __init int hpet_insert_resource(void) | |
1022 | { | |
1023 | if (!hpet_res) | |
1024 | return 1; | |
1025 | ||
1026 | return insert_resource(&iomem_resource, hpet_res); | |
1027 | } | |
1028 | ||
1029 | late_initcall(hpet_insert_resource); | |
1030 | ||
1da177e4 LT |
1031 | #else |
1032 | #define acpi_parse_hpet NULL | |
1033 | #endif | |
1034 | ||
5f3b1a8b | 1035 | static int __init acpi_parse_fadt(struct acpi_table_header *table) |
1da177e4 | 1036 | { |
7a17b82c | 1037 | if (!(acpi_gbl_FADT.boot_flags & ACPI_FADT_LEGACY_DEVICES)) { |
14fad24d | 1038 | pr_debug("no legacy devices present\n"); |
7a17b82c LR |
1039 | x86_platform.legacy.devices.pnpbios = 0; |
1040 | } | |
1041 | ||
93ffa9a4 DT |
1042 | if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID && |
1043 | !(acpi_gbl_FADT.boot_flags & ACPI_FADT_8042) && | |
1044 | x86_platform.legacy.i8042 != X86_LEGACY_I8042_PLATFORM_ABSENT) { | |
14fad24d | 1045 | pr_debug("i8042 controller is absent\n"); |
93ffa9a4 DT |
1046 | x86_platform.legacy.i8042 = X86_LEGACY_I8042_FIRMWARE_ABSENT; |
1047 | } | |
1048 | ||
088a8ef8 | 1049 | if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) { |
14fad24d | 1050 | pr_debug("not registering RTC platform device\n"); |
088a8ef8 LR |
1051 | x86_platform.legacy.rtc = 0; |
1052 | } | |
90660ec3 | 1053 | |
6d730525 | 1054 | if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_VGA) { |
14fad24d | 1055 | pr_debug("probing for VGA not safe\n"); |
6d730525 JG |
1056 | x86_platform.legacy.no_vga = 1; |
1057 | } | |
1058 | ||
1da177e4 LT |
1059 | #ifdef CONFIG_X86_PM_TIMER |
1060 | /* detect the location of the ACPI PM Timer */ | |
5f3b1a8b | 1061 | if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) { |
1da177e4 | 1062 | /* FADT rev. 2 */ |
5f3b1a8b | 1063 | if (acpi_gbl_FADT.xpm_timer_block.space_id != |
4be44fcd | 1064 | ACPI_ADR_SPACE_SYSTEM_IO) |
1da177e4 LT |
1065 | return 0; |
1066 | ||
5f3b1a8b | 1067 | pmtmr_ioport = acpi_gbl_FADT.xpm_timer_block.address; |
e6e87b4b DSL |
1068 | /* |
1069 | * "X" fields are optional extensions to the original V1.0 | |
1070 | * fields, so we must selectively expand V1.0 fields if the | |
1071 | * corresponding X field is zero. | |
1072 | */ | |
1073 | if (!pmtmr_ioport) | |
5f3b1a8b | 1074 | pmtmr_ioport = acpi_gbl_FADT.pm_timer_block; |
1da177e4 LT |
1075 | } else { |
1076 | /* FADT rev. 1 */ | |
5f3b1a8b | 1077 | pmtmr_ioport = acpi_gbl_FADT.pm_timer_block; |
1da177e4 LT |
1078 | } |
1079 | if (pmtmr_ioport) | |
14fad24d | 1080 | pr_info("PM-Timer IO Port: %#x\n", pmtmr_ioport); |
1da177e4 LT |
1081 | #endif |
1082 | return 0; | |
1083 | } | |
1084 | ||
1da177e4 LT |
1085 | #ifdef CONFIG_X86_LOCAL_APIC |
1086 | /* | |
1087 | * Parse LAPIC entries in MADT | |
1088 | * returns 0 on success, < 0 on error | |
1089 | */ | |
31d2092e | 1090 | |
cbf9bd60 YL |
1091 | static int __init early_acpi_parse_madt_lapic_addr_ovr(void) |
1092 | { | |
1093 | int count; | |
1094 | ||
93984fbd | 1095 | if (!boot_cpu_has(X86_FEATURE_APIC)) |
cbf9bd60 YL |
1096 | return -ENODEV; |
1097 | ||
1098 | /* | |
1099 | * Note that the LAPIC address is obtained from the MADT (32-bit value) | |
6a6256f9 | 1100 | * and (optionally) overridden by a LAPIC_ADDR_OVR entry (64-bit value). |
cbf9bd60 YL |
1101 | */ |
1102 | ||
e819813f JL |
1103 | count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE, |
1104 | acpi_parse_lapic_addr_ovr, 0); | |
cbf9bd60 | 1105 | if (count < 0) { |
14fad24d | 1106 | pr_err("Error parsing LAPIC address override entry\n"); |
cbf9bd60 YL |
1107 | return count; |
1108 | } | |
1109 | ||
c0104d38 | 1110 | register_lapic_address(acpi_lapic_addr); |
cbf9bd60 YL |
1111 | |
1112 | return count; | |
1113 | } | |
1114 | ||
4be44fcd | 1115 | static int __init acpi_parse_madt_lapic_entries(void) |
1da177e4 LT |
1116 | { |
1117 | int count; | |
7237d3de | 1118 | int x2count = 0; |
d81056b5 LA |
1119 | int ret; |
1120 | struct acpi_subtable_proc madt_proc[2]; | |
1da177e4 | 1121 | |
93984fbd | 1122 | if (!boot_cpu_has(X86_FEATURE_APIC)) |
0fcd2709 AK |
1123 | return -ENODEV; |
1124 | ||
ac049c1d | 1125 | count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_SAPIC, |
cb2ded37 | 1126 | acpi_parse_sapic, MAX_LOCAL_APIC); |
ac049c1d | 1127 | |
7237d3de | 1128 | if (!count) { |
d81056b5 LA |
1129 | memset(madt_proc, 0, sizeof(madt_proc)); |
1130 | madt_proc[0].id = ACPI_MADT_TYPE_LOCAL_APIC; | |
1131 | madt_proc[0].handler = acpi_parse_lapic; | |
1132 | madt_proc[1].id = ACPI_MADT_TYPE_LOCAL_X2APIC; | |
1133 | madt_proc[1].handler = acpi_parse_x2apic; | |
1134 | ret = acpi_table_parse_entries_array(ACPI_SIG_MADT, | |
1135 | sizeof(struct acpi_table_madt), | |
1136 | madt_proc, ARRAY_SIZE(madt_proc), MAX_LOCAL_APIC); | |
1137 | if (ret < 0) { | |
14fad24d | 1138 | pr_err("Error parsing LAPIC/X2APIC entries\n"); |
d81056b5 LA |
1139 | return ret; |
1140 | } | |
1141 | ||
c12f29a5 AS |
1142 | count = madt_proc[0].count; |
1143 | x2count = madt_proc[1].count; | |
7237d3de SS |
1144 | } |
1145 | if (!count && !x2count) { | |
14fad24d | 1146 | pr_err("No LAPIC entries present\n"); |
1da177e4 LT |
1147 | /* TBD: Cleanup to allow fallback to MPS */ |
1148 | return -ENODEV; | |
7237d3de | 1149 | } else if (count < 0 || x2count < 0) { |
14fad24d | 1150 | pr_err("Error parsing LAPIC entry\n"); |
1da177e4 LT |
1151 | /* TBD: Cleanup to allow fallback to MPS */ |
1152 | return count; | |
1153 | } | |
1154 | ||
e819813f JL |
1155 | x2count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_X2APIC_NMI, |
1156 | acpi_parse_x2apic_nmi, 0); | |
1157 | count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_NMI, | |
1158 | acpi_parse_lapic_nmi, 0); | |
7237d3de | 1159 | if (count < 0 || x2count < 0) { |
14fad24d | 1160 | pr_err("Error parsing LAPIC NMI entry\n"); |
1da177e4 LT |
1161 | /* TBD: Cleanup to allow fallback to MPS */ |
1162 | return count; | |
1163 | } | |
1164 | return 0; | |
1165 | } | |
f39642d0 KS |
1166 | |
1167 | #ifdef CONFIG_X86_64 | |
1168 | static int __init acpi_parse_mp_wake(union acpi_subtable_headers *header, | |
1169 | const unsigned long end) | |
1170 | { | |
1171 | struct acpi_madt_multiproc_wakeup *mp_wake; | |
1172 | ||
1173 | if (!IS_ENABLED(CONFIG_SMP)) | |
1174 | return -ENODEV; | |
1175 | ||
1176 | mp_wake = (struct acpi_madt_multiproc_wakeup *)header; | |
1177 | if (BAD_MADT_ENTRY(mp_wake, end)) | |
1178 | return -EINVAL; | |
1179 | ||
1180 | acpi_table_print_madt_entry(&header->common); | |
1181 | ||
1182 | acpi_mp_wake_mailbox_paddr = mp_wake->base_address; | |
1183 | ||
2744a7ce | 1184 | apic_update_callback(wakeup_secondary_cpu_64, acpi_wakeup_cpu); |
f39642d0 KS |
1185 | |
1186 | return 0; | |
1187 | } | |
1188 | #endif /* CONFIG_X86_64 */ | |
4be44fcd | 1189 | #endif /* CONFIG_X86_LOCAL_APIC */ |
1da177e4 | 1190 | |
8466361a | 1191 | #ifdef CONFIG_X86_IO_APIC |
a491cc90 | 1192 | static void __init mp_config_acpi_legacy_irqs(void) |
11113f84 | 1193 | { |
6df8809b | 1194 | int i; |
c2c21745 | 1195 | struct mpc_intsrc mp_irq; |
11113f84 | 1196 | |
bb8187d3 | 1197 | #ifdef CONFIG_EISA |
11113f84 AS |
1198 | /* |
1199 | * Fabricate the legacy ISA bus (bus #31). | |
1200 | */ | |
1201 | mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA; | |
1202 | #endif | |
1203 | set_bit(MP_ISA_BUS, mp_bus_not_pci); | |
42d516ce | 1204 | pr_debug("Bus #%d is ISA (nIRQs: %d)\n", MP_ISA_BUS, nr_legacy_irqs()); |
11113f84 | 1205 | |
11113f84 AS |
1206 | /* |
1207 | * Use the default configuration for the IRQs 0-15. Unless | |
1208 | * overridden by (MADT) interrupt source override entries. | |
1209 | */ | |
95d76acc | 1210 | for (i = 0; i < nr_legacy_irqs(); i++) { |
0fd52670 EB |
1211 | int ioapic, pin; |
1212 | unsigned int dstapic; | |
11113f84 | 1213 | int idx; |
0fd52670 EB |
1214 | u32 gsi; |
1215 | ||
1216 | /* Locate the gsi that irq i maps to. */ | |
1217 | if (acpi_isa_irq_to_gsi(i, &gsi)) | |
1218 | continue; | |
1219 | ||
1220 | /* | |
1221 | * Locate the IOAPIC that manages the ISA IRQ. | |
1222 | */ | |
1223 | ioapic = mp_find_ioapic(gsi); | |
1224 | if (ioapic < 0) | |
1225 | continue; | |
1226 | pin = mp_find_ioapic_pin(ioapic, gsi); | |
d5371430 | 1227 | dstapic = mpc_ioapic_id(ioapic); |
11113f84 AS |
1228 | |
1229 | for (idx = 0; idx < mp_irq_entries; idx++) { | |
c2c21745 | 1230 | struct mpc_intsrc *irq = mp_irqs + idx; |
11113f84 AS |
1231 | |
1232 | /* Do we already have a mapping for this ISA IRQ? */ | |
c2c21745 | 1233 | if (irq->srcbus == MP_ISA_BUS && irq->srcbusirq == i) |
11113f84 AS |
1234 | break; |
1235 | ||
1236 | /* Do we already have a mapping for this IOAPIC pin */ | |
0fd52670 | 1237 | if (irq->dstapic == dstapic && irq->dstirq == pin) |
11113f84 AS |
1238 | break; |
1239 | } | |
1240 | ||
1241 | if (idx != mp_irq_entries) { | |
14fad24d | 1242 | pr_debug("ACPI: IRQ%d used by override.\n", i); |
11113f84 AS |
1243 | continue; /* IRQ already used */ |
1244 | } | |
1245 | ||
c2c21745 JSR |
1246 | mp_irq.type = MP_INTSRC; |
1247 | mp_irq.irqflag = 0; /* Conforming */ | |
1248 | mp_irq.srcbus = MP_ISA_BUS; | |
1249 | mp_irq.dstapic = dstapic; | |
1250 | mp_irq.irqtype = mp_INT; | |
1251 | mp_irq.srcbusirq = i; /* Identity mapped */ | |
0fd52670 | 1252 | mp_irq.dstirq = pin; |
11113f84 | 1253 | |
2d8009ba | 1254 | mp_save_irq(&mp_irq); |
11113f84 AS |
1255 | } |
1256 | } | |
1257 | ||
1da177e4 LT |
1258 | /* |
1259 | * Parse IOAPIC related entries in MADT | |
1260 | * returns 0 on success, < 0 on error | |
1261 | */ | |
4be44fcd | 1262 | static int __init acpi_parse_madt_ioapic_entries(void) |
1da177e4 LT |
1263 | { |
1264 | int count; | |
1265 | ||
1266 | /* | |
1267 | * ACPI interpreter is required to complete interrupt setup, | |
1268 | * so if it is off, don't enumerate the io-apics with ACPI. | |
1269 | * If MPS is present, it will handle them, | |
1270 | * otherwise the system will stay in PIC mode | |
1271 | */ | |
6b2b171a | 1272 | if (acpi_disabled || acpi_noirq) |
1da177e4 | 1273 | return -ENODEV; |
1da177e4 | 1274 | |
93984fbd | 1275 | if (!boot_cpu_has(X86_FEATURE_APIC)) |
d3b6a349 AK |
1276 | return -ENODEV; |
1277 | ||
1da177e4 | 1278 | /* |
4be44fcd | 1279 | * if "noapic" boot option, don't look for IO-APICs |
1da177e4 | 1280 | */ |
ecf600f8 | 1281 | if (ioapic_is_disabled) { |
14fad24d | 1282 | pr_info("Skipping IOAPIC probe due to 'noapic' option.\n"); |
1da177e4 LT |
1283 | return -ENODEV; |
1284 | } | |
1285 | ||
e819813f JL |
1286 | count = acpi_table_parse_madt(ACPI_MADT_TYPE_IO_APIC, acpi_parse_ioapic, |
1287 | MAX_IO_APICS); | |
1da177e4 | 1288 | if (!count) { |
14fad24d | 1289 | pr_err("No IOAPIC entries present\n"); |
1da177e4 | 1290 | return -ENODEV; |
4be44fcd | 1291 | } else if (count < 0) { |
14fad24d | 1292 | pr_err("Error parsing IOAPIC entry\n"); |
1da177e4 LT |
1293 | return count; |
1294 | } | |
1295 | ||
e819813f JL |
1296 | count = acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE, |
1297 | acpi_parse_int_src_ovr, nr_irqs); | |
1da177e4 | 1298 | if (count < 0) { |
14fad24d | 1299 | pr_err("Error parsing interrupt source overrides entry\n"); |
1da177e4 LT |
1300 | /* TBD: Cleanup to allow fallback to MPS */ |
1301 | return count; | |
1302 | } | |
1303 | ||
1304 | /* | |
1305 | * If BIOS did not supply an INT_SRC_OVR for the SCI | |
1306 | * pretend we got one so we can set the SCI flags. | |
7c7bcfea | 1307 | * But ignore setting up SCI on hardware reduced platforms. |
1da177e4 | 1308 | */ |
7c7bcfea | 1309 | if (acpi_sci_override_gsi == INVALID_ACPI_IRQ && !acpi_gbl_reduced_hardware) |
9d2062b8 EB |
1310 | acpi_sci_ioapic_setup(acpi_gbl_FADT.sci_interrupt, 0, 0, |
1311 | acpi_gbl_FADT.sci_interrupt); | |
1da177e4 | 1312 | |
af901ca1 | 1313 | /* Fill in identity legacy mappings where no override */ |
1da177e4 LT |
1314 | mp_config_acpi_legacy_irqs(); |
1315 | ||
e819813f JL |
1316 | count = acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE, |
1317 | acpi_parse_nmi_src, nr_irqs); | |
1da177e4 | 1318 | if (count < 0) { |
14fad24d | 1319 | pr_err("Error parsing NMI SRC entry\n"); |
1da177e4 LT |
1320 | /* TBD: Cleanup to allow fallback to MPS */ |
1321 | return count; | |
1322 | } | |
1323 | ||
1324 | return 0; | |
1325 | } | |
1326 | #else | |
1327 | static inline int acpi_parse_madt_ioapic_entries(void) | |
1328 | { | |
1329 | return -1; | |
1330 | } | |
8466361a | 1331 | #endif /* !CONFIG_X86_IO_APIC */ |
1da177e4 | 1332 | |
cbf9bd60 YL |
1333 | static void __init early_acpi_process_madt(void) |
1334 | { | |
1335 | #ifdef CONFIG_X86_LOCAL_APIC | |
1336 | int error; | |
1337 | ||
1338 | if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) { | |
1339 | ||
1340 | /* | |
1341 | * Parse MADT LAPIC entries | |
1342 | */ | |
1343 | error = early_acpi_parse_madt_lapic_addr_ovr(); | |
1344 | if (!error) { | |
1345 | acpi_lapic = 1; | |
1346 | smp_found_config = 1; | |
1347 | } | |
1348 | if (error == -EINVAL) { | |
1349 | /* | |
1350 | * Dell Precision Workstation 410, 610 come here. | |
1351 | */ | |
14fad24d | 1352 | pr_err("Invalid BIOS MADT, disabling ACPI\n"); |
cbf9bd60 YL |
1353 | disable_acpi(); |
1354 | } | |
1355 | } | |
1356 | #endif | |
1357 | } | |
1358 | ||
4be44fcd | 1359 | static void __init acpi_process_madt(void) |
1da177e4 LT |
1360 | { |
1361 | #ifdef CONFIG_X86_LOCAL_APIC | |
7f8f97c3 | 1362 | int error; |
1da177e4 | 1363 | |
7f8f97c3 | 1364 | if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) { |
1da177e4 LT |
1365 | |
1366 | /* | |
1367 | * Parse MADT LAPIC entries | |
1368 | */ | |
1369 | error = acpi_parse_madt_lapic_entries(); | |
1370 | if (!error) { | |
1371 | acpi_lapic = 1; | |
1372 | ||
1373 | /* | |
1374 | * Parse MADT IO-APIC entries | |
1375 | */ | |
5da2fd26 | 1376 | mutex_lock(&acpi_ioapic_lock); |
1da177e4 | 1377 | error = acpi_parse_madt_ioapic_entries(); |
5da2fd26 | 1378 | mutex_unlock(&acpi_ioapic_lock); |
1da177e4 | 1379 | if (!error) { |
2f065aef | 1380 | acpi_set_irq_model_ioapic(); |
1da177e4 LT |
1381 | |
1382 | smp_found_config = 1; | |
1da177e4 | 1383 | } |
f39642d0 KS |
1384 | |
1385 | #ifdef CONFIG_X86_64 | |
1386 | /* | |
1387 | * Parse MADT MP Wake entry. | |
1388 | */ | |
1389 | acpi_table_parse_madt(ACPI_MADT_TYPE_MULTIPROC_WAKEUP, | |
1390 | acpi_parse_mp_wake, 1); | |
1391 | #endif | |
1da177e4 LT |
1392 | } |
1393 | if (error == -EINVAL) { | |
1394 | /* | |
1395 | * Dell Precision Workstation 410, 610 come here. | |
1396 | */ | |
14fad24d | 1397 | pr_err("Invalid BIOS MADT, disabling ACPI\n"); |
1da177e4 LT |
1398 | disable_acpi(); |
1399 | } | |
7b37b5fd LB |
1400 | } else { |
1401 | /* | |
1402 | * ACPI found no MADT, and so ACPI wants UP PIC mode. | |
1403 | * In the event an MPS table was found, forget it. | |
1404 | * Boot with "acpi=off" to use MPS on such a system. | |
1405 | */ | |
1406 | if (smp_found_config) { | |
14fad24d | 1407 | pr_warn("No APIC-table, disabling MPS\n"); |
7b37b5fd LB |
1408 | smp_found_config = 0; |
1409 | } | |
1da177e4 | 1410 | } |
69b88afa YL |
1411 | |
1412 | /* | |
1413 | * ACPI supports both logical (e.g. Hyper-Threading) and physical | |
1414 | * processors, where MPS only supports physical. | |
1415 | */ | |
1416 | if (acpi_lapic && acpi_ioapic) | |
14fad24d | 1417 | pr_info("Using ACPI (MADT) for SMP configuration information\n"); |
69b88afa | 1418 | else if (acpi_lapic) |
14fad24d | 1419 | pr_info("Using ACPI for processor (LAPIC) configuration information\n"); |
1da177e4 LT |
1420 | #endif |
1421 | return; | |
1422 | } | |
1423 | ||
1855256c | 1424 | static int __init disable_acpi_irq(const struct dmi_system_id *d) |
aea00143 AP |
1425 | { |
1426 | if (!acpi_force) { | |
14fad24d | 1427 | pr_notice("%s detected: force use of acpi=noirq\n", d->ident); |
aea00143 AP |
1428 | acpi_noirq_set(); |
1429 | } | |
1430 | return 0; | |
1431 | } | |
1432 | ||
1855256c | 1433 | static int __init disable_acpi_pci(const struct dmi_system_id *d) |
aea00143 AP |
1434 | { |
1435 | if (!acpi_force) { | |
14fad24d | 1436 | pr_notice("%s detected: force use of pci=noacpi\n", d->ident); |
aea00143 AP |
1437 | acpi_disable_pci(); |
1438 | } | |
1439 | return 0; | |
1440 | } | |
aea00143 | 1441 | |
e702196b MC |
1442 | static int __init disable_acpi_xsdt(const struct dmi_system_id *d) |
1443 | { | |
1444 | if (!acpi_force) { | |
1445 | pr_notice("%s detected: force use of acpi=rsdt\n", d->ident); | |
1446 | acpi_gbl_do_not_use_xsdt = TRUE; | |
1447 | } else { | |
1448 | pr_notice("Warning: DMI blacklist says broken, but acpi XSDT forced\n"); | |
1449 | } | |
1450 | return 0; | |
1451 | } | |
1452 | ||
1855256c | 1453 | static int __init dmi_disable_acpi(const struct dmi_system_id *d) |
aea00143 AP |
1454 | { |
1455 | if (!acpi_force) { | |
14fad24d | 1456 | pr_notice("%s detected: acpi off\n", d->ident); |
aea00143 AP |
1457 | disable_acpi(); |
1458 | } else { | |
14fad24d | 1459 | pr_notice("Warning: DMI blacklist says broken, but acpi forced\n"); |
aea00143 AP |
1460 | } |
1461 | return 0; | |
1462 | } | |
1463 | ||
e2079c43 | 1464 | /* |
ae10ccdc | 1465 | * Force ignoring BIOS IRQ0 override |
e2079c43 RW |
1466 | */ |
1467 | static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d) | |
1468 | { | |
8d89adf4 | 1469 | if (!acpi_skip_timer_override) { |
ae10ccdc | 1470 | pr_notice("%s detected: Ignoring BIOS IRQ0 override\n", |
8d89adf4 IM |
1471 | d->ident); |
1472 | acpi_skip_timer_override = 1; | |
1473 | } | |
e2079c43 RW |
1474 | return 0; |
1475 | } | |
1476 | ||
7486341a LA |
1477 | /* |
1478 | * ACPI offers an alternative platform interface model that removes | |
1479 | * ACPI hardware requirements for platforms that do not implement | |
1480 | * the PC Architecture. | |
1481 | * | |
1482 | * We initialize the Hardware-reduced ACPI model here: | |
1483 | */ | |
50beba07 AS |
1484 | void __init acpi_generic_reduced_hw_init(void) |
1485 | { | |
1486 | /* | |
1487 | * Override x86_init functions and bypass legacy PIC in | |
1488 | * hardware reduced ACPI mode. | |
1489 | */ | |
1490 | x86_init.timers.timer_init = x86_init_noop; | |
1491 | x86_init.irqs.pre_vector_init = x86_init_noop; | |
1492 | legacy_pic = &null_legacy_pic; | |
1493 | } | |
1494 | ||
7486341a LA |
1495 | static void __init acpi_reduced_hw_init(void) |
1496 | { | |
50beba07 | 1497 | if (acpi_gbl_reduced_hardware) |
81b53e5f | 1498 | x86_init.acpi.reduced_hw_early_init(); |
7486341a LA |
1499 | } |
1500 | ||
aea00143 AP |
1501 | /* |
1502 | * If your system is blacklisted here, but you find that acpi=force | |
5b4c0b6f | 1503 | * works for you, please contact linux-acpi@vger.kernel.org |
aea00143 | 1504 | */ |
6faadbbb | 1505 | static const struct dmi_system_id acpi_dmi_table[] __initconst = { |
aea00143 AP |
1506 | /* |
1507 | * Boxes that need ACPI disabled | |
1508 | */ | |
1509 | { | |
4be44fcd LB |
1510 | .callback = dmi_disable_acpi, |
1511 | .ident = "IBM Thinkpad", | |
1512 | .matches = { | |
1513 | DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), | |
1514 | DMI_MATCH(DMI_BOARD_NAME, "2629H1G"), | |
1515 | }, | |
1516 | }, | |
aea00143 | 1517 | |
aea00143 AP |
1518 | /* |
1519 | * Boxes that need ACPI PCI IRQ routing disabled | |
1520 | */ | |
1521 | { | |
4be44fcd LB |
1522 | .callback = disable_acpi_irq, |
1523 | .ident = "ASUS A7V", | |
1524 | .matches = { | |
1525 | DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"), | |
1526 | DMI_MATCH(DMI_BOARD_NAME, "<A7V>"), | |
1527 | /* newer BIOS, Revision 1011, does work */ | |
1528 | DMI_MATCH(DMI_BIOS_VERSION, | |
1529 | "ASUS A7V ACPI BIOS Revision 1007"), | |
1530 | }, | |
1531 | }, | |
74586fca LB |
1532 | { |
1533 | /* | |
1534 | * Latest BIOS for IBM 600E (1.16) has bad pcinum | |
1535 | * for LPC bridge, which is needed for the PCI | |
1536 | * interrupt links to work. DSDT fix is in bug 5966. | |
1537 | * 2645, 2646 model numbers are shared with 600/600E/600X | |
1538 | */ | |
1539 | .callback = disable_acpi_irq, | |
1540 | .ident = "IBM Thinkpad 600 Series 2645", | |
1541 | .matches = { | |
1542 | DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), | |
1543 | DMI_MATCH(DMI_BOARD_NAME, "2645"), | |
1544 | }, | |
1545 | }, | |
1546 | { | |
1547 | .callback = disable_acpi_irq, | |
1548 | .ident = "IBM Thinkpad 600 Series 2646", | |
1549 | .matches = { | |
1550 | DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), | |
1551 | DMI_MATCH(DMI_BOARD_NAME, "2646"), | |
1552 | }, | |
1553 | }, | |
aea00143 AP |
1554 | /* |
1555 | * Boxes that need ACPI PCI IRQ routing and PCI scan disabled | |
1556 | */ | |
4be44fcd LB |
1557 | { /* _BBN 0 bug */ |
1558 | .callback = disable_acpi_pci, | |
1559 | .ident = "ASUS PR-DLS", | |
1560 | .matches = { | |
1561 | DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), | |
1562 | DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"), | |
1563 | DMI_MATCH(DMI_BIOS_VERSION, | |
1564 | "ASUS PR-DLS ACPI BIOS Revision 1010"), | |
1565 | DMI_MATCH(DMI_BIOS_DATE, "03/21/2003") | |
1566 | }, | |
1567 | }, | |
aea00143 | 1568 | { |
4be44fcd LB |
1569 | .callback = disable_acpi_pci, |
1570 | .ident = "Acer TravelMate 36x Laptop", | |
1571 | .matches = { | |
1572 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), | |
1573 | DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"), | |
1574 | }, | |
1575 | }, | |
e702196b MC |
1576 | /* |
1577 | * Boxes that need ACPI XSDT use disabled due to corrupted tables | |
1578 | */ | |
1579 | { | |
1580 | .callback = disable_acpi_xsdt, | |
1581 | .ident = "Advantech DAC-BJ01", | |
1582 | .matches = { | |
1583 | DMI_MATCH(DMI_SYS_VENDOR, "NEC"), | |
1584 | DMI_MATCH(DMI_PRODUCT_NAME, "Bearlake CRB Board"), | |
1585 | DMI_MATCH(DMI_BIOS_VERSION, "V1.12"), | |
1586 | DMI_MATCH(DMI_BIOS_DATE, "02/01/2011"), | |
1587 | }, | |
1588 | }, | |
35af2821 AH |
1589 | {} |
1590 | }; | |
1591 | ||
1592 | /* second table for DMI checks that should run after early-quirks */ | |
6faadbbb | 1593 | static const struct dmi_system_id acpi_dmi_table_late[] __initconst = { |
e2079c43 RW |
1594 | /* |
1595 | * HP laptops which use a DSDT reporting as HP/SB400/10000, | |
1596 | * which includes some code which overrides all temperature | |
1597 | * trip points to 16C if the INTIN2 input of the I/O APIC | |
1598 | * is enabled. This input is incorrectly designated the | |
1599 | * ISA IRQ 0 via an interrupt source override even though | |
1600 | * it is wired to the output of the master 8259A and INTIN0 | |
ae10ccdc | 1601 | * is not connected at all. Force ignoring BIOS IRQ0 |
e2079c43 RW |
1602 | * override in that cases. |
1603 | */ | |
e84956f9 RW |
1604 | { |
1605 | .callback = dmi_ignore_irq0_timer_override, | |
1606 | .ident = "HP nx6115 laptop", | |
1607 | .matches = { | |
1608 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), | |
1609 | DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6115"), | |
1610 | }, | |
1611 | }, | |
e2079c43 RW |
1612 | { |
1613 | .callback = dmi_ignore_irq0_timer_override, | |
1614 | .ident = "HP NX6125 laptop", | |
1615 | .matches = { | |
1616 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), | |
1617 | DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6125"), | |
1618 | }, | |
1619 | }, | |
1620 | { | |
1621 | .callback = dmi_ignore_irq0_timer_override, | |
1622 | .ident = "HP NX6325 laptop", | |
1623 | .matches = { | |
1624 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), | |
1625 | DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6325"), | |
1626 | }, | |
1627 | }, | |
e84956f9 RW |
1628 | { |
1629 | .callback = dmi_ignore_irq0_timer_override, | |
1630 | .ident = "HP 6715b laptop", | |
1631 | .matches = { | |
1632 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), | |
1633 | DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq 6715b"), | |
1634 | }, | |
1635 | }, | |
f6b54f08 FT |
1636 | { |
1637 | .callback = dmi_ignore_irq0_timer_override, | |
1638 | .ident = "FUJITSU SIEMENS", | |
1639 | .matches = { | |
1640 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), | |
1641 | DMI_MATCH(DMI_PRODUCT_NAME, "AMILO PRO V2030"), | |
1642 | }, | |
1643 | }, | |
4be44fcd | 1644 | {} |
aea00143 AP |
1645 | }; |
1646 | ||
1da177e4 LT |
1647 | /* |
1648 | * acpi_boot_table_init() and acpi_boot_init() | |
1649 | * called from setup_arch(), always. | |
1650 | * 1. checksums all tables | |
1651 | * 2. enumerates lapics | |
1652 | * 3. enumerates io-apics | |
1653 | * | |
1654 | * acpi_table_init() is separate to allow reading SRAT without | |
1655 | * other side effects. | |
1656 | * | |
1657 | * side effects of acpi_boot_init: | |
1658 | * acpi_lapic = 1 if LAPIC found | |
1659 | * acpi_ioapic = 1 if IOAPIC found | |
1660 | * if (acpi_lapic && acpi_ioapic) smp_found_config = 1; | |
1661 | * if acpi_blacklisted() acpi_disabled = 1; | |
1662 | * acpi_irq_model=... | |
1663 | * ... | |
1da177e4 LT |
1664 | */ |
1665 | ||
8558e394 | 1666 | void __init acpi_boot_table_init(void) |
1da177e4 | 1667 | { |
aea00143 | 1668 | dmi_check_system(acpi_dmi_table); |
aea00143 | 1669 | |
1da177e4 LT |
1670 | /* |
1671 | * If acpi_disabled, bail out | |
1da177e4 | 1672 | */ |
68ca4069 | 1673 | if (acpi_disabled) |
0f61aaa4 | 1674 | return; |
1da177e4 | 1675 | |
5f3b1a8b | 1676 | /* |
1da177e4 LT |
1677 | * Initialize the ACPI boot-time table parser. |
1678 | */ | |
1a1c130a | 1679 | if (acpi_locate_initial_tables()) |
1da177e4 | 1680 | disable_acpi(); |
1a1c130a RW |
1681 | else |
1682 | acpi_reserve_initial_tables(); | |
1683 | } | |
1684 | ||
1685 | int __init early_acpi_boot_init(void) | |
1686 | { | |
1687 | if (acpi_disabled) | |
1688 | return 1; | |
1689 | ||
1690 | acpi_table_init_complete(); | |
1da177e4 | 1691 | |
5f3b1a8b | 1692 | acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf); |
1da177e4 LT |
1693 | |
1694 | /* | |
1695 | * blacklist may disable ACPI entirely | |
1696 | */ | |
8558e394 | 1697 | if (acpi_blacklisted()) { |
1da177e4 | 1698 | if (acpi_force) { |
14fad24d | 1699 | pr_warn("acpi=force override\n"); |
1da177e4 | 1700 | } else { |
14fad24d | 1701 | pr_warn("Disabling ACPI support\n"); |
1da177e4 | 1702 | disable_acpi(); |
1a1c130a | 1703 | return 1; |
1da177e4 LT |
1704 | } |
1705 | } | |
cbf9bd60 YL |
1706 | |
1707 | /* | |
1708 | * Process the Multiple APIC Description Table (MADT), if present | |
1709 | */ | |
1710 | early_acpi_process_madt(); | |
1da177e4 | 1711 | |
7486341a LA |
1712 | /* |
1713 | * Hardware-reduced ACPI mode initialization: | |
1714 | */ | |
1715 | acpi_reduced_hw_init(); | |
1716 | ||
1da177e4 LT |
1717 | return 0; |
1718 | } | |
1719 | ||
1da177e4 LT |
1720 | int __init acpi_boot_init(void) |
1721 | { | |
35af2821 AH |
1722 | /* those are executed after early-quirks are executed */ |
1723 | dmi_check_system(acpi_dmi_table_late); | |
1724 | ||
1da177e4 LT |
1725 | /* |
1726 | * If acpi_disabled, bail out | |
1da177e4 | 1727 | */ |
68ca4069 | 1728 | if (acpi_disabled) |
4be44fcd | 1729 | return 1; |
1da177e4 | 1730 | |
5f3b1a8b | 1731 | acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf); |
1da177e4 LT |
1732 | |
1733 | /* | |
1734 | * set sci_int and PM timer address | |
1735 | */ | |
ceb6c468 | 1736 | acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt); |
1da177e4 LT |
1737 | |
1738 | /* | |
1739 | * Process the Multiple APIC Description Table (MADT), if present | |
1740 | */ | |
1741 | acpi_process_madt(); | |
1742 | ||
5f3b1a8b | 1743 | acpi_table_parse(ACPI_SIG_HPET, acpi_parse_hpet); |
1ffb8d03 | 1744 | if (IS_ENABLED(CONFIG_ACPI_BGRT) && !acpi_nobgrt) |
7b0a9114 | 1745 | acpi_table_parse(ACPI_SIG_BGRT, acpi_parse_bgrt); |
1da177e4 | 1746 | |
b72d0db9 TG |
1747 | if (!acpi_noirq) |
1748 | x86_init.pci.init = pci_acpi_init; | |
1749 | ||
0231d000 PB |
1750 | /* Do not enable ACPI SPCR console by default */ |
1751 | acpi_parse_spcr(earlycon_acpi_spcr_enable, false); | |
1da177e4 LT |
1752 | return 0; |
1753 | } | |
1a3f239d RR |
1754 | |
1755 | static int __init parse_acpi(char *arg) | |
1756 | { | |
1757 | if (!arg) | |
1758 | return -EINVAL; | |
1759 | ||
1760 | /* "acpi=off" disables both ACPI table parsing and interpreter */ | |
1761 | if (strcmp(arg, "off") == 0) { | |
1762 | disable_acpi(); | |
1763 | } | |
1764 | /* acpi=force to over-ride black-list */ | |
1765 | else if (strcmp(arg, "force") == 0) { | |
1766 | acpi_force = 1; | |
1a3f239d RR |
1767 | acpi_disabled = 0; |
1768 | } | |
1769 | /* acpi=strict disables out-of-spec workarounds */ | |
1770 | else if (strcmp(arg, "strict") == 0) { | |
1771 | acpi_strict = 1; | |
1772 | } | |
237889bf ZY |
1773 | /* acpi=rsdt use RSDT instead of XSDT */ |
1774 | else if (strcmp(arg, "rsdt") == 0) { | |
fab46105 | 1775 | acpi_gbl_do_not_use_xsdt = TRUE; |
237889bf | 1776 | } |
1a3f239d RR |
1777 | /* "acpi=noirq" disables ACPI interrupt routing */ |
1778 | else if (strcmp(arg, "noirq") == 0) { | |
1779 | acpi_noirq_set(); | |
aa2110cb | 1780 | } |
d9f6e12f | 1781 | /* "acpi=copy_dsdt" copies DSDT */ |
aa2110cb LM |
1782 | else if (strcmp(arg, "copy_dsdt") == 0) { |
1783 | acpi_gbl_copy_dsdt_locally = 1; | |
9ad95879 NR |
1784 | } |
1785 | /* "acpi=nocmcff" disables FF mode for corrected errors */ | |
1786 | else if (strcmp(arg, "nocmcff") == 0) { | |
1787 | acpi_disable_cmcff = 1; | |
1a3f239d RR |
1788 | } else { |
1789 | /* Core will printk when we return error. */ | |
1790 | return -EINVAL; | |
1791 | } | |
1792 | return 0; | |
1793 | } | |
1794 | early_param("acpi", parse_acpi); | |
1795 | ||
1ffb8d03 AH |
1796 | static int __init parse_acpi_bgrt(char *arg) |
1797 | { | |
1798 | acpi_nobgrt = true; | |
1799 | return 0; | |
1800 | } | |
1801 | early_param("bgrt_disable", parse_acpi_bgrt); | |
1802 | ||
1a3f239d RR |
1803 | /* FIXME: Using pci= for an ACPI parameter is a travesty. */ |
1804 | static int __init parse_pci(char *arg) | |
1805 | { | |
1806 | if (arg && strcmp(arg, "noacpi") == 0) | |
1807 | acpi_disable_pci(); | |
1808 | return 0; | |
1809 | } | |
1810 | early_param("pci", parse_pci); | |
1811 | ||
3c999f14 YL |
1812 | int __init acpi_mps_check(void) |
1813 | { | |
1814 | #if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_X86_MPPARSE) | |
1815 | /* mptable code is not built-in*/ | |
1816 | if (acpi_disabled || acpi_noirq) { | |
14fad24d | 1817 | pr_warn("MPS support code is not built-in, using acpi=off or acpi=noirq or pci=noacpi may have problem\n"); |
3c999f14 YL |
1818 | return 1; |
1819 | } | |
1820 | #endif | |
1821 | return 0; | |
1822 | } | |
1823 | ||
1a3f239d RR |
1824 | #ifdef CONFIG_X86_IO_APIC |
1825 | static int __init parse_acpi_skip_timer_override(char *arg) | |
1826 | { | |
1827 | acpi_skip_timer_override = 1; | |
1828 | return 0; | |
1829 | } | |
1830 | early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override); | |
fa18f477 AK |
1831 | |
1832 | static int __init parse_acpi_use_timer_override(char *arg) | |
1833 | { | |
1834 | acpi_use_timer_override = 1; | |
1835 | return 0; | |
1836 | } | |
1837 | early_param("acpi_use_timer_override", parse_acpi_use_timer_override); | |
1a3f239d RR |
1838 | #endif /* CONFIG_X86_IO_APIC */ |
1839 | ||
1840 | static int __init setup_acpi_sci(char *s) | |
1841 | { | |
1842 | if (!s) | |
1843 | return -EINVAL; | |
1844 | if (!strcmp(s, "edge")) | |
5f3b1a8b AS |
1845 | acpi_sci_flags = ACPI_MADT_TRIGGER_EDGE | |
1846 | (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK); | |
1a3f239d | 1847 | else if (!strcmp(s, "level")) |
5f3b1a8b AS |
1848 | acpi_sci_flags = ACPI_MADT_TRIGGER_LEVEL | |
1849 | (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK); | |
1a3f239d | 1850 | else if (!strcmp(s, "high")) |
5f3b1a8b AS |
1851 | acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_HIGH | |
1852 | (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK); | |
1a3f239d | 1853 | else if (!strcmp(s, "low")) |
5f3b1a8b AS |
1854 | acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_LOW | |
1855 | (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK); | |
1a3f239d RR |
1856 | else |
1857 | return -EINVAL; | |
1858 | return 0; | |
1859 | } | |
1860 | early_param("acpi_sci", setup_acpi_sci); | |
d0a9081b AM |
1861 | |
1862 | int __acpi_acquire_global_lock(unsigned int *lock) | |
1863 | { | |
22767544 | 1864 | unsigned int old, new, val; |
890a0794 UB |
1865 | |
1866 | old = READ_ONCE(*lock); | |
d0a9081b | 1867 | do { |
22767544 UB |
1868 | val = (old >> 1) & 0x1; |
1869 | new = (old & ~0x3) + 2 + val; | |
890a0794 | 1870 | } while (!try_cmpxchg(lock, &old, new)); |
22767544 UB |
1871 | |
1872 | if (val) | |
1873 | return 0; | |
1874 | ||
1875 | return -1; | |
d0a9081b AM |
1876 | } |
1877 | ||
1878 | int __acpi_release_global_lock(unsigned int *lock) | |
1879 | { | |
890a0794 UB |
1880 | unsigned int old, new; |
1881 | ||
1882 | old = READ_ONCE(*lock); | |
d0a9081b | 1883 | do { |
d0a9081b | 1884 | new = old & ~0x3; |
890a0794 | 1885 | } while (!try_cmpxchg(lock, &old, new)); |
d0a9081b AM |
1886 | return old & 0x1; |
1887 | } | |
8e30524d TR |
1888 | |
1889 | void __init arch_reserve_mem_area(acpi_physical_address addr, size_t size) | |
1890 | { | |
84958f38 | 1891 | e820__range_add(addr, size, E820_TYPE_NVS); |
6464d294 | 1892 | e820__update_table_print(); |
8e30524d | 1893 | } |
e7b66d16 | 1894 | |
41fa1ee9 JB |
1895 | void x86_default_set_root_pointer(u64 addr) |
1896 | { | |
1897 | boot_params.acpi_rsdp_addr = addr; | |
1898 | } | |
1899 | ||
e7b66d16 JG |
1900 | u64 x86_default_get_root_pointer(void) |
1901 | { | |
e6e094e0 | 1902 | return boot_params.acpi_rsdp_addr; |
e7b66d16 | 1903 | } |