1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * boot.c - Architecture-Specific Low-Level ACPI Boot Support
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 * Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
8 #define pr_fmt(fmt) "ACPI: " fmt
10 #include <linux/init.h>
11 #include <linux/acpi.h>
12 #include <linux/acpi_pmtmr.h>
13 #include <linux/efi.h>
14 #include <linux/cpumask.h>
15 #include <linux/export.h>
16 #include <linux/dmi.h>
17 #include <linux/irq.h>
18 #include <linux/slab.h>
19 #include <linux/memblock.h>
20 #include <linux/ioport.h>
21 #include <linux/pci.h>
22 #include <linux/efi-bgrt.h>
23 #include <linux/serial_core.h>
24 #include <linux/pgtable.h>
26 #include <asm/e820/api.h>
27 #include <asm/irqdomain.h>
28 #include <asm/pci_x86.h>
29 #include <asm/io_apic.h>
32 #include <asm/mpspec.h>
34 #include <asm/i8259.h>
35 #include <asm/setup.h>
37 #include "sleep.h" /* To include x86_acpi_suspend_lowlevel */
38 static int __initdata acpi_force = 0;
40 EXPORT_SYMBOL(acpi_disabled);
43 # include <asm/proto.h>
46 int acpi_noirq; /* skip ACPI IRQ initialization */
47 static int acpi_nobgrt; /* skip ACPI BGRT */
48 int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */
49 EXPORT_SYMBOL(acpi_pci_disabled);
54 int acpi_disable_cmcff;
56 /* ACPI SCI override configuration */
57 u8 acpi_sci_flags __initdata;
58 u32 acpi_sci_override_gsi __initdata = INVALID_ACPI_IRQ;
59 int acpi_skip_timer_override __initdata;
60 int acpi_use_timer_override __initdata;
61 int acpi_fix_pin2_polarity __initdata;
63 #ifdef CONFIG_X86_LOCAL_APIC
64 static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
65 static bool acpi_support_online_capable;
69 /* Physical address of the Multiprocessor Wakeup Structure mailbox */
70 static u64 acpi_mp_wake_mailbox_paddr;
71 /* Virtual address of the Multiprocessor Wakeup Structure mailbox */
72 static struct acpi_madt_multiproc_wakeup_mailbox *acpi_mp_wake_mailbox;
75 #ifdef CONFIG_X86_IO_APIC
77 * Locks related to IOAPIC hotplug
79 * ->device_hotplug_lock
82 * Interrupt mapping side:
87 static DEFINE_MUTEX(acpi_ioapic_lock);
90 /* --------------------------------------------------------------------------
91 Boot-time Configuration
92 -------------------------------------------------------------------------- */
95 * The default interrupt routing model is PIC (8259). This gets
96 * overridden if IOAPICs are enumerated (below).
98 enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
102 * ISA irqs by default are the first 16 gsis but can be
103 * any gsi as specified by an interrupt source override.
105 static u32 isa_irq_to_gsi[NR_IRQS_LEGACY] __read_mostly = {
106 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
110 * This is just a simple wrapper around early_memremap(),
111 * with sanity checks for phys == 0 and size == 0.
113 void __init __iomem *__acpi_map_table(unsigned long phys, unsigned long size)
119 return early_memremap(phys, size);
122 void __init __acpi_unmap_table(void __iomem *map, unsigned long size)
127 early_memunmap(map, size);
130 #ifdef CONFIG_X86_LOCAL_APIC
131 static int __init acpi_parse_madt(struct acpi_table_header *table)
133 struct acpi_table_madt *madt = NULL;
135 if (!boot_cpu_has(X86_FEATURE_APIC))
138 madt = (struct acpi_table_madt *)table;
140 pr_warn("Unable to map MADT\n");
145 acpi_lapic_addr = (u64) madt->address;
147 pr_debug("Local APIC address 0x%08x\n", madt->address);
150 if (madt->flags & ACPI_MADT_PCAT_COMPAT)
151 legacy_pic_pcat_compat();
153 /* ACPI 6.3 and newer support the online capable bit. */
154 if (acpi_gbl_FADT.header.revision > 6 ||
155 (acpi_gbl_FADT.header.revision == 6 &&
156 acpi_gbl_FADT.minor_revision >= 3))
157 acpi_support_online_capable = true;
159 default_acpi_madt_oem_check(madt->header.oem_id,
160 madt->header.oem_table_id);
166 * acpi_register_lapic - register a local apic and generates a logic cpu number
167 * @id: local apic id to register
168 * @acpiid: ACPI id to register
169 * @enabled: this cpu is enabled or not
171 * Returns the logic cpu number which maps to the local apic
173 static int acpi_register_lapic(int id, u32 acpiid, u8 enabled)
175 unsigned int ver = 0;
178 if (id >= MAX_LOCAL_APIC) {
179 pr_info("skipped apicid that is too big\n");
188 if (boot_cpu_physical_apicid != -1U)
189 ver = boot_cpu_apic_version;
191 cpu = generic_processor_info(id, ver);
193 early_per_cpu(x86_cpu_to_acpiid, cpu) = acpiid;
198 static bool __init acpi_is_processor_usable(u32 lapic_flags)
200 if (lapic_flags & ACPI_MADT_ENABLED)
203 if (!acpi_support_online_capable ||
204 (lapic_flags & ACPI_MADT_ONLINE_CAPABLE))
211 acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end)
213 struct acpi_madt_local_x2apic *processor = NULL;
214 #ifdef CONFIG_X86_X2APIC
219 processor = (struct acpi_madt_local_x2apic *)header;
221 if (BAD_MADT_ENTRY(processor, end))
224 acpi_table_print_madt_entry(&header->common);
226 #ifdef CONFIG_X86_X2APIC
227 apic_id = processor->local_apic_id;
228 enabled = processor->lapic_flags & ACPI_MADT_ENABLED;
230 /* Ignore invalid ID */
231 if (apic_id == 0xffffffff)
234 /* don't register processors that cannot be onlined */
235 if (!acpi_is_processor_usable(processor->lapic_flags))
239 * We need to register disabled CPU as well to permit
240 * counting disabled CPUs. This allows us to size
241 * cpus_possible_map more accurately, to permit
242 * to not preallocating memory for all NR_CPUS
243 * when we use CPU hotplug.
245 if (!apic->apic_id_valid(apic_id)) {
247 pr_warn("x2apic entry ignored\n");
251 acpi_register_lapic(apic_id, processor->uid, enabled);
253 pr_warn("x2apic entry ignored\n");
260 acpi_parse_lapic(union acpi_subtable_headers * header, const unsigned long end)
262 struct acpi_madt_local_apic *processor = NULL;
264 processor = (struct acpi_madt_local_apic *)header;
266 if (BAD_MADT_ENTRY(processor, end))
269 acpi_table_print_madt_entry(&header->common);
271 /* Ignore invalid ID */
272 if (processor->id == 0xff)
275 /* don't register processors that can not be onlined */
276 if (!acpi_is_processor_usable(processor->lapic_flags))
280 * We need to register disabled CPU as well to permit
281 * counting disabled CPUs. This allows us to size
282 * cpus_possible_map more accurately, to permit
283 * to not preallocating memory for all NR_CPUS
284 * when we use CPU hotplug.
286 acpi_register_lapic(processor->id, /* APIC ID */
287 processor->processor_id, /* ACPI ID */
288 processor->lapic_flags & ACPI_MADT_ENABLED);
294 acpi_parse_sapic(union acpi_subtable_headers *header, const unsigned long end)
296 struct acpi_madt_local_sapic *processor = NULL;
298 processor = (struct acpi_madt_local_sapic *)header;
300 if (BAD_MADT_ENTRY(processor, end))
303 acpi_table_print_madt_entry(&header->common);
305 acpi_register_lapic((processor->id << 8) | processor->eid,/* APIC ID */
306 processor->processor_id, /* ACPI ID */
307 processor->lapic_flags & ACPI_MADT_ENABLED);
313 acpi_parse_lapic_addr_ovr(union acpi_subtable_headers * header,
314 const unsigned long end)
316 struct acpi_madt_local_apic_override *lapic_addr_ovr = NULL;
318 lapic_addr_ovr = (struct acpi_madt_local_apic_override *)header;
320 if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
323 acpi_table_print_madt_entry(&header->common);
325 acpi_lapic_addr = lapic_addr_ovr->address;
331 acpi_parse_x2apic_nmi(union acpi_subtable_headers *header,
332 const unsigned long end)
334 struct acpi_madt_local_x2apic_nmi *x2apic_nmi = NULL;
336 x2apic_nmi = (struct acpi_madt_local_x2apic_nmi *)header;
338 if (BAD_MADT_ENTRY(x2apic_nmi, end))
341 acpi_table_print_madt_entry(&header->common);
343 if (x2apic_nmi->lint != 1)
344 pr_warn("NMI not connected to LINT 1!\n");
350 acpi_parse_lapic_nmi(union acpi_subtable_headers * header, const unsigned long end)
352 struct acpi_madt_local_apic_nmi *lapic_nmi = NULL;
354 lapic_nmi = (struct acpi_madt_local_apic_nmi *)header;
356 if (BAD_MADT_ENTRY(lapic_nmi, end))
359 acpi_table_print_madt_entry(&header->common);
361 if (lapic_nmi->lint != 1)
362 pr_warn("NMI not connected to LINT 1!\n");
368 static int acpi_wakeup_cpu(int apicid, unsigned long start_ip)
371 * Remap mailbox memory only for the first call to acpi_wakeup_cpu().
373 * Wakeup of secondary CPUs is fully serialized in the core code.
374 * No need to protect acpi_mp_wake_mailbox from concurrent accesses.
376 if (!acpi_mp_wake_mailbox) {
377 acpi_mp_wake_mailbox = memremap(acpi_mp_wake_mailbox_paddr,
378 sizeof(*acpi_mp_wake_mailbox),
383 * Mailbox memory is shared between the firmware and OS. Firmware will
384 * listen on mailbox command address, and once it receives the wakeup
385 * command, the CPU associated with the given apicid will be booted.
387 * The value of 'apic_id' and 'wakeup_vector' must be visible to the
388 * firmware before the wakeup command is visible. smp_store_release()
389 * ensures ordering and visibility.
391 acpi_mp_wake_mailbox->apic_id = apicid;
392 acpi_mp_wake_mailbox->wakeup_vector = start_ip;
393 smp_store_release(&acpi_mp_wake_mailbox->command,
394 ACPI_MP_WAKE_COMMAND_WAKEUP);
397 * Wait for the CPU to wake up.
399 * The CPU being woken up is essentially in a spin loop waiting to be
400 * woken up. It should not take long for it wake up and acknowledge by
401 * zeroing out ->command.
403 * ACPI specification doesn't provide any guidance on how long kernel
404 * has to wait for a wake up acknowledgement. It also doesn't provide
405 * a way to cancel a wake up request if it takes too long.
407 * In TDX environment, the VMM has control over how long it takes to
408 * wake up secondary. It can postpone scheduling secondary vCPU
409 * indefinitely. Giving up on wake up request and reporting error opens
410 * possible attack vector for VMM: it can wake up a secondary CPU when
411 * kernel doesn't expect it. Wait until positive result of the wake up
414 while (READ_ONCE(acpi_mp_wake_mailbox->command))
419 #endif /* CONFIG_X86_64 */
420 #endif /* CONFIG_X86_LOCAL_APIC */
422 #ifdef CONFIG_X86_IO_APIC
425 static int __init mp_register_ioapic_irq(u8 bus_irq, u8 polarity,
426 u8 trigger, u32 gsi);
428 static void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger,
432 * Check bus_irq boundary.
434 if (bus_irq >= NR_IRQS_LEGACY) {
435 pr_warn("Invalid bus_irq %u for legacy override\n", bus_irq);
440 * TBD: This check is for faulty timer entries, where the override
441 * erroneously sets the trigger to level, resulting in a HUGE
442 * increase of timer interrupts!
444 if ((bus_irq == 0) && (trigger == 3))
447 if (mp_register_ioapic_irq(bus_irq, polarity, trigger, gsi) < 0)
450 * Reset default identity mapping if gsi is also an legacy IRQ,
451 * otherwise there will be more than one entry with the same GSI
452 * and acpi_isa_irq_to_gsi() may give wrong result.
454 if (gsi < nr_legacy_irqs() && isa_irq_to_gsi[gsi] == gsi)
455 isa_irq_to_gsi[gsi] = INVALID_ACPI_IRQ;
456 isa_irq_to_gsi[bus_irq] = gsi;
459 static void mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
462 #ifdef CONFIG_X86_MPPARSE
463 struct mpc_intsrc mp_irq;
464 struct pci_dev *pdev;
465 unsigned char number;
472 if (!dev || !dev_is_pci(dev))
475 pdev = to_pci_dev(dev);
476 number = pdev->bus->number;
479 /* print the entry should happen on mptable identically */
480 mp_irq.type = MP_INTSRC;
481 mp_irq.irqtype = mp_INT;
482 mp_irq.irqflag = (trigger == ACPI_EDGE_SENSITIVE ? 4 : 0x0c) |
483 (polarity == ACPI_ACTIVE_HIGH ? 1 : 3);
484 mp_irq.srcbus = number;
485 mp_irq.srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3);
486 ioapic = mp_find_ioapic(gsi);
487 mp_irq.dstapic = mpc_ioapic_id(ioapic);
488 mp_irq.dstirq = mp_find_ioapic_pin(ioapic, gsi);
490 mp_save_irq(&mp_irq);
494 static int __init mp_register_ioapic_irq(u8 bus_irq, u8 polarity,
497 struct mpc_intsrc mp_irq;
500 /* Convert 'gsi' to 'ioapic.pin'(INTIN#) */
501 ioapic = mp_find_ioapic(gsi);
503 pr_warn("Failed to find ioapic for gsi : %u\n", gsi);
507 pin = mp_find_ioapic_pin(ioapic, gsi);
509 mp_irq.type = MP_INTSRC;
510 mp_irq.irqtype = mp_INT;
511 mp_irq.irqflag = (trigger << 2) | polarity;
512 mp_irq.srcbus = MP_ISA_BUS;
513 mp_irq.srcbusirq = bus_irq;
514 mp_irq.dstapic = mpc_ioapic_id(ioapic);
517 mp_save_irq(&mp_irq);
523 acpi_parse_ioapic(union acpi_subtable_headers * header, const unsigned long end)
525 struct acpi_madt_io_apic *ioapic = NULL;
526 struct ioapic_domain_cfg cfg = {
527 .type = IOAPIC_DOMAIN_DYNAMIC,
528 .ops = &mp_ioapic_irqdomain_ops,
531 ioapic = (struct acpi_madt_io_apic *)header;
533 if (BAD_MADT_ENTRY(ioapic, end))
536 acpi_table_print_madt_entry(&header->common);
538 /* Statically assign IRQ numbers for IOAPICs hosting legacy IRQs */
539 if (ioapic->global_irq_base < nr_legacy_irqs())
540 cfg.type = IOAPIC_DOMAIN_LEGACY;
542 mp_register_ioapic(ioapic->id, ioapic->address, ioapic->global_irq_base,
549 * Parse Interrupt Source Override for the ACPI SCI
551 static void __init acpi_sci_ioapic_setup(u8 bus_irq, u16 polarity, u16 trigger, u32 gsi)
553 if (trigger == 0) /* compatible SCI trigger is level */
556 if (polarity == 0) /* compatible SCI polarity is low */
559 /* Command-line over-ride via acpi_sci= */
560 if (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK)
561 trigger = (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) >> 2;
563 if (acpi_sci_flags & ACPI_MADT_POLARITY_MASK)
564 polarity = acpi_sci_flags & ACPI_MADT_POLARITY_MASK;
566 if (bus_irq < NR_IRQS_LEGACY)
567 mp_override_legacy_irq(bus_irq, polarity, trigger, gsi);
569 mp_register_ioapic_irq(bus_irq, polarity, trigger, gsi);
571 acpi_penalize_sci_irq(bus_irq, trigger, polarity);
574 * stash over-ride to indicate we've been here
575 * and for later update of acpi_gbl_FADT
577 acpi_sci_override_gsi = gsi;
582 acpi_parse_int_src_ovr(union acpi_subtable_headers * header,
583 const unsigned long end)
585 struct acpi_madt_interrupt_override *intsrc = NULL;
587 intsrc = (struct acpi_madt_interrupt_override *)header;
589 if (BAD_MADT_ENTRY(intsrc, end))
592 acpi_table_print_madt_entry(&header->common);
594 if (intsrc->source_irq == acpi_gbl_FADT.sci_interrupt) {
595 acpi_sci_ioapic_setup(intsrc->source_irq,
596 intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
597 (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2,
602 if (intsrc->source_irq == 0) {
603 if (acpi_skip_timer_override) {
604 pr_warn("BIOS IRQ0 override ignored.\n");
608 if ((intsrc->global_irq == 2) && acpi_fix_pin2_polarity
609 && (intsrc->inti_flags & ACPI_MADT_POLARITY_MASK)) {
610 intsrc->inti_flags &= ~ACPI_MADT_POLARITY_MASK;
611 pr_warn("BIOS IRQ0 pin2 override: forcing polarity to high active.\n");
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,
624 acpi_parse_nmi_src(union acpi_subtable_headers * header, const unsigned long end)
626 struct acpi_madt_nmi_source *nmi_src = NULL;
628 nmi_src = (struct acpi_madt_nmi_source *)header;
630 if (BAD_MADT_ENTRY(nmi_src, end))
633 acpi_table_print_madt_entry(&header->common);
635 /* TBD: Support nimsrc entries? */
640 #endif /* CONFIG_X86_IO_APIC */
643 * acpi_pic_sci_set_trigger()
645 * use ELCR to set PIC-mode trigger type for SCI
647 * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
648 * it may require Edge Trigger -- use "acpi_sci=edge"
650 * Port 0x4d0-4d1 are ELCR1 and ELCR2, the Edge/Level Control Registers
651 * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
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)
656 void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
658 unsigned int mask = 1 << irq;
659 unsigned int old, new;
661 /* Real old ELCR mask */
662 old = inb(PIC_ELCR1) | (inb(PIC_ELCR2) << 8);
665 * If we use ACPI to set PCI IRQs, then we should clear ELCR
666 * since we will set it correctly as we enable the PCI irq
669 new = acpi_noirq ? old : 0;
672 * Update SCI information in the ELCR, it isn't in the PCI
676 case 1: /* Edge - clear */
679 case 3: /* Level - set */
687 pr_warn("setting ELCR to %04x (from %04x)\n", new, old);
688 outb(new, PIC_ELCR1);
689 outb(new >> 8, PIC_ELCR2);
692 int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp)
694 int rc, irq, trigger, polarity;
696 if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
701 rc = acpi_get_override_irq(gsi, &trigger, &polarity);
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);
714 EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);
716 int acpi_isa_irq_to_gsi(unsigned isa_irq, u32 *gsi)
718 if (isa_irq < nr_legacy_irqs() &&
719 isa_irq_to_gsi[isa_irq] != INVALID_ACPI_IRQ) {
720 *gsi = isa_irq_to_gsi[isa_irq];
727 static int acpi_register_gsi_pic(struct device *dev, u32 gsi,
728 int trigger, int polarity)
732 * Make sure all (legacy) PCI IRQs are set as level-triggered.
734 if (trigger == ACPI_LEVEL_SENSITIVE)
735 elcr_set_level_irq(gsi);
741 #ifdef CONFIG_X86_LOCAL_APIC
742 static int acpi_register_gsi_ioapic(struct device *dev, u32 gsi,
743 int trigger, int polarity)
746 #ifdef CONFIG_X86_IO_APIC
748 struct irq_alloc_info info;
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);
755 mutex_lock(&acpi_ioapic_lock);
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 */
758 if (irq >= 0 && enable_update_mptable && gsi != acpi_gbl_FADT.sci_interrupt)
759 mp_config_acpi_gsi(dev, gsi, trigger, polarity);
760 mutex_unlock(&acpi_ioapic_lock);
766 static void acpi_unregister_gsi_ioapic(u32 gsi)
768 #ifdef CONFIG_X86_IO_APIC
771 mutex_lock(&acpi_ioapic_lock);
772 irq = mp_map_gsi_to_irq(gsi, 0, NULL);
775 mutex_unlock(&acpi_ioapic_lock);
780 int (*__acpi_register_gsi)(struct device *dev, u32 gsi,
781 int trigger, int polarity) = acpi_register_gsi_pic;
782 void (*__acpi_unregister_gsi)(u32 gsi) = NULL;
784 #ifdef CONFIG_ACPI_SLEEP
785 int (*acpi_suspend_lowlevel)(void) = x86_acpi_suspend_lowlevel;
787 int (*acpi_suspend_lowlevel)(void);
791 * success: return IRQ number (>=0)
792 * failure: return < 0
794 int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
796 return __acpi_register_gsi(dev, gsi, trigger, polarity);
798 EXPORT_SYMBOL_GPL(acpi_register_gsi);
800 void acpi_unregister_gsi(u32 gsi)
802 if (__acpi_unregister_gsi)
803 __acpi_unregister_gsi(gsi);
805 EXPORT_SYMBOL_GPL(acpi_unregister_gsi);
807 #ifdef CONFIG_X86_LOCAL_APIC
808 static void __init acpi_set_irq_model_ioapic(void)
810 acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
811 __acpi_register_gsi = acpi_register_gsi_ioapic;
812 __acpi_unregister_gsi = acpi_unregister_gsi_ioapic;
818 * ACPI based hotplug support for CPU
820 #ifdef CONFIG_ACPI_HOTPLUG_CPU
821 #include <acpi/processor.h>
823 static int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
825 #ifdef CONFIG_ACPI_NUMA
828 nid = acpi_get_node(handle);
829 if (nid != NUMA_NO_NODE) {
830 set_apicid_to_node(physid, nid);
831 numa_set_node(cpu, nid);
837 int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id,
842 cpu = acpi_register_lapic(physid, acpi_id, ACPI_MADT_ENABLED);
844 pr_info("Unable to map lapic to logical cpu number\n");
848 acpi_processor_set_pdc(handle);
849 acpi_map_cpu2node(handle, cpu, physid);
854 EXPORT_SYMBOL(acpi_map_cpu);
856 int acpi_unmap_cpu(int cpu)
858 #ifdef CONFIG_ACPI_NUMA
859 set_apicid_to_node(per_cpu(x86_cpu_to_apicid, cpu), NUMA_NO_NODE);
862 per_cpu(x86_cpu_to_apicid, cpu) = -1;
863 set_cpu_present(cpu, false);
868 EXPORT_SYMBOL(acpi_unmap_cpu);
869 #endif /* CONFIG_ACPI_HOTPLUG_CPU */
871 int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
874 #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
877 struct ioapic_domain_cfg cfg = {
878 .type = IOAPIC_DOMAIN_DYNAMIC,
879 .ops = &mp_ioapic_irqdomain_ops,
882 ioapic_id = acpi_get_ioapic_id(handle, gsi_base, &addr);
884 unsigned long long uid;
887 status = acpi_evaluate_integer(handle, METHOD_NAME__UID,
889 if (ACPI_FAILURE(status)) {
890 acpi_handle_warn(handle, "failed to get IOAPIC ID.\n");
893 ioapic_id = (int)uid;
896 mutex_lock(&acpi_ioapic_lock);
897 ret = mp_register_ioapic(ioapic_id, phys_addr, gsi_base, &cfg);
898 mutex_unlock(&acpi_ioapic_lock);
903 EXPORT_SYMBOL(acpi_register_ioapic);
905 int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
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);
917 EXPORT_SYMBOL(acpi_unregister_ioapic);
920 * acpi_ioapic_registered - Check whether IOAPIC associated with @gsi_base
921 * has been registered
922 * @handle: ACPI handle of the IOAPIC device
923 * @gsi_base: GSI base associated with the IOAPIC
925 * Assume caller holds some type of lock to serialize acpi_ioapic_registered()
926 * with acpi_register_ioapic()/acpi_unregister_ioapic().
928 int acpi_ioapic_registered(acpi_handle handle, u32 gsi_base)
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);
941 static int __init acpi_parse_sbf(struct acpi_table_header *table)
943 struct acpi_table_boot *sb = (struct acpi_table_boot *)table;
945 sbf_port = sb->cmos_index; /* Save CMOS port */
950 #ifdef CONFIG_HPET_TIMER
951 #include <asm/hpet.h>
953 static struct resource *hpet_res __initdata;
955 static int __init acpi_parse_hpet(struct acpi_table_header *table)
957 struct acpi_table_hpet *hpet_tbl = (struct acpi_table_hpet *)table;
959 if (hpet_tbl->address.space_id != ACPI_SPACE_MEM) {
960 pr_warn("HPET timers must be located in memory.\n");
964 hpet_address = hpet_tbl->address.address;
965 hpet_blockid = hpet_tbl->sequence;
968 * Some broken BIOSes advertise HPET at 0x0. We really do not
969 * want to allocate a resource there.
972 pr_warn("HPET id: %#x base: %#lx is invalid\n", hpet_tbl->id, hpet_address);
977 * Some even more broken BIOSes advertise HPET at
978 * 0xfed0000000000000 instead of 0xfed00000. Fix it up and add
981 if (hpet_address == 0xfed0000000000000UL) {
982 if (!hpet_force_user) {
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",
988 pr_warn("HPET id: %#x base: 0xfed0000000000000 fixed up to 0xfed00000.\n",
993 pr_info("HPET id: %#x base: %#lx\n", hpet_tbl->id, hpet_address);
996 * Allocate and initialize the HPET firmware resource for adding into
997 * the resource tree during the lateinit timeframe.
999 #define HPET_RESOURCE_NAME_SIZE 9
1000 hpet_res = memblock_alloc(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE,
1003 panic("%s: Failed to allocate %zu bytes\n", __func__,
1004 sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE);
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);
1011 hpet_res->start = hpet_address;
1012 hpet_res->end = hpet_address + (1 * 1024) - 1;
1018 * hpet_insert_resource inserts the HPET resources used into the resource
1021 static __init int hpet_insert_resource(void)
1026 return insert_resource(&iomem_resource, hpet_res);
1029 late_initcall(hpet_insert_resource);
1032 #define acpi_parse_hpet NULL
1035 static int __init acpi_parse_fadt(struct acpi_table_header *table)
1037 if (!(acpi_gbl_FADT.boot_flags & ACPI_FADT_LEGACY_DEVICES)) {
1038 pr_debug("no legacy devices present\n");
1039 x86_platform.legacy.devices.pnpbios = 0;
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) {
1045 pr_debug("i8042 controller is absent\n");
1046 x86_platform.legacy.i8042 = X86_LEGACY_I8042_FIRMWARE_ABSENT;
1049 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) {
1050 pr_debug("not registering RTC platform device\n");
1051 x86_platform.legacy.rtc = 0;
1054 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_VGA) {
1055 pr_debug("probing for VGA not safe\n");
1056 x86_platform.legacy.no_vga = 1;
1059 #ifdef CONFIG_X86_PM_TIMER
1060 /* detect the location of the ACPI PM Timer */
1061 if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) {
1063 if (acpi_gbl_FADT.xpm_timer_block.space_id !=
1064 ACPI_ADR_SPACE_SYSTEM_IO)
1067 pmtmr_ioport = acpi_gbl_FADT.xpm_timer_block.address;
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.
1074 pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
1077 pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
1080 pr_info("PM-Timer IO Port: %#x\n", pmtmr_ioport);
1085 #ifdef CONFIG_X86_LOCAL_APIC
1087 * Parse LAPIC entries in MADT
1088 * returns 0 on success, < 0 on error
1091 static int __init early_acpi_parse_madt_lapic_addr_ovr(void)
1095 if (!boot_cpu_has(X86_FEATURE_APIC))
1099 * Note that the LAPIC address is obtained from the MADT (32-bit value)
1100 * and (optionally) overridden by a LAPIC_ADDR_OVR entry (64-bit value).
1103 count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
1104 acpi_parse_lapic_addr_ovr, 0);
1106 pr_err("Error parsing LAPIC address override entry\n");
1110 register_lapic_address(acpi_lapic_addr);
1115 static int __init acpi_parse_madt_lapic_entries(void)
1120 struct acpi_subtable_proc madt_proc[2];
1122 if (!boot_cpu_has(X86_FEATURE_APIC))
1125 count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_SAPIC,
1126 acpi_parse_sapic, MAX_LOCAL_APIC);
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);
1138 pr_err("Error parsing LAPIC/X2APIC entries\n");
1142 count = madt_proc[0].count;
1143 x2count = madt_proc[1].count;
1145 if (!count && !x2count) {
1146 pr_err("No LAPIC entries present\n");
1147 /* TBD: Cleanup to allow fallback to MPS */
1149 } else if (count < 0 || x2count < 0) {
1150 pr_err("Error parsing LAPIC entry\n");
1151 /* TBD: Cleanup to allow fallback to MPS */
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);
1159 if (count < 0 || x2count < 0) {
1160 pr_err("Error parsing LAPIC NMI entry\n");
1161 /* TBD: Cleanup to allow fallback to MPS */
1167 #ifdef CONFIG_X86_64
1168 static int __init acpi_parse_mp_wake(union acpi_subtable_headers *header,
1169 const unsigned long end)
1171 struct acpi_madt_multiproc_wakeup *mp_wake;
1173 if (!IS_ENABLED(CONFIG_SMP))
1176 mp_wake = (struct acpi_madt_multiproc_wakeup *)header;
1177 if (BAD_MADT_ENTRY(mp_wake, end))
1180 acpi_table_print_madt_entry(&header->common);
1182 acpi_mp_wake_mailbox_paddr = mp_wake->base_address;
1184 acpi_wake_cpu_handler_update(acpi_wakeup_cpu);
1188 #endif /* CONFIG_X86_64 */
1189 #endif /* CONFIG_X86_LOCAL_APIC */
1191 #ifdef CONFIG_X86_IO_APIC
1192 static void __init mp_config_acpi_legacy_irqs(void)
1195 struct mpc_intsrc mp_irq;
1199 * Fabricate the legacy ISA bus (bus #31).
1201 mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA;
1203 set_bit(MP_ISA_BUS, mp_bus_not_pci);
1204 pr_debug("Bus #%d is ISA (nIRQs: %d)\n", MP_ISA_BUS, nr_legacy_irqs());
1207 * Use the default configuration for the IRQs 0-15. Unless
1208 * overridden by (MADT) interrupt source override entries.
1210 for (i = 0; i < nr_legacy_irqs(); i++) {
1212 unsigned int dstapic;
1216 /* Locate the gsi that irq i maps to. */
1217 if (acpi_isa_irq_to_gsi(i, &gsi))
1221 * Locate the IOAPIC that manages the ISA IRQ.
1223 ioapic = mp_find_ioapic(gsi);
1226 pin = mp_find_ioapic_pin(ioapic, gsi);
1227 dstapic = mpc_ioapic_id(ioapic);
1229 for (idx = 0; idx < mp_irq_entries; idx++) {
1230 struct mpc_intsrc *irq = mp_irqs + idx;
1232 /* Do we already have a mapping for this ISA IRQ? */
1233 if (irq->srcbus == MP_ISA_BUS && irq->srcbusirq == i)
1236 /* Do we already have a mapping for this IOAPIC pin */
1237 if (irq->dstapic == dstapic && irq->dstirq == pin)
1241 if (idx != mp_irq_entries) {
1242 pr_debug("ACPI: IRQ%d used by override.\n", i);
1243 continue; /* IRQ already used */
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 */
1252 mp_irq.dstirq = pin;
1254 mp_save_irq(&mp_irq);
1259 * Parse IOAPIC related entries in MADT
1260 * returns 0 on success, < 0 on error
1262 static int __init acpi_parse_madt_ioapic_entries(void)
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
1272 if (acpi_disabled || acpi_noirq)
1275 if (!boot_cpu_has(X86_FEATURE_APIC))
1279 * if "noapic" boot option, don't look for IO-APICs
1281 if (skip_ioapic_setup) {
1282 pr_info("Skipping IOAPIC probe due to 'noapic' option.\n");
1286 count = acpi_table_parse_madt(ACPI_MADT_TYPE_IO_APIC, acpi_parse_ioapic,
1289 pr_err("No IOAPIC entries present\n");
1291 } else if (count < 0) {
1292 pr_err("Error parsing IOAPIC entry\n");
1296 count = acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE,
1297 acpi_parse_int_src_ovr, nr_irqs);
1299 pr_err("Error parsing interrupt source overrides entry\n");
1300 /* TBD: Cleanup to allow fallback to MPS */
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.
1307 * But ignore setting up SCI on hardware reduced platforms.
1309 if (acpi_sci_override_gsi == INVALID_ACPI_IRQ && !acpi_gbl_reduced_hardware)
1310 acpi_sci_ioapic_setup(acpi_gbl_FADT.sci_interrupt, 0, 0,
1311 acpi_gbl_FADT.sci_interrupt);
1313 /* Fill in identity legacy mappings where no override */
1314 mp_config_acpi_legacy_irqs();
1316 count = acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE,
1317 acpi_parse_nmi_src, nr_irqs);
1319 pr_err("Error parsing NMI SRC entry\n");
1320 /* TBD: Cleanup to allow fallback to MPS */
1327 static inline int acpi_parse_madt_ioapic_entries(void)
1331 #endif /* !CONFIG_X86_IO_APIC */
1333 static void __init early_acpi_process_madt(void)
1335 #ifdef CONFIG_X86_LOCAL_APIC
1338 if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
1341 * Parse MADT LAPIC entries
1343 error = early_acpi_parse_madt_lapic_addr_ovr();
1346 smp_found_config = 1;
1348 if (error == -EINVAL) {
1350 * Dell Precision Workstation 410, 610 come here.
1352 pr_err("Invalid BIOS MADT, disabling ACPI\n");
1359 static void __init acpi_process_madt(void)
1361 #ifdef CONFIG_X86_LOCAL_APIC
1364 if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
1367 * Parse MADT LAPIC entries
1369 error = acpi_parse_madt_lapic_entries();
1374 * Parse MADT IO-APIC entries
1376 mutex_lock(&acpi_ioapic_lock);
1377 error = acpi_parse_madt_ioapic_entries();
1378 mutex_unlock(&acpi_ioapic_lock);
1380 acpi_set_irq_model_ioapic();
1382 smp_found_config = 1;
1385 #ifdef CONFIG_X86_64
1387 * Parse MADT MP Wake entry.
1389 acpi_table_parse_madt(ACPI_MADT_TYPE_MULTIPROC_WAKEUP,
1390 acpi_parse_mp_wake, 1);
1393 if (error == -EINVAL) {
1395 * Dell Precision Workstation 410, 610 come here.
1397 pr_err("Invalid BIOS MADT, disabling ACPI\n");
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.
1406 if (smp_found_config) {
1407 pr_warn("No APIC-table, disabling MPS\n");
1408 smp_found_config = 0;
1413 * ACPI supports both logical (e.g. Hyper-Threading) and physical
1414 * processors, where MPS only supports physical.
1416 if (acpi_lapic && acpi_ioapic)
1417 pr_info("Using ACPI (MADT) for SMP configuration information\n");
1418 else if (acpi_lapic)
1419 pr_info("Using ACPI for processor (LAPIC) configuration information\n");
1424 static int __init disable_acpi_irq(const struct dmi_system_id *d)
1427 pr_notice("%s detected: force use of acpi=noirq\n", d->ident);
1433 static int __init disable_acpi_pci(const struct dmi_system_id *d)
1436 pr_notice("%s detected: force use of pci=noacpi\n", d->ident);
1442 static int __init disable_acpi_xsdt(const struct dmi_system_id *d)
1445 pr_notice("%s detected: force use of acpi=rsdt\n", d->ident);
1446 acpi_gbl_do_not_use_xsdt = TRUE;
1448 pr_notice("Warning: DMI blacklist says broken, but acpi XSDT forced\n");
1453 static int __init dmi_disable_acpi(const struct dmi_system_id *d)
1456 pr_notice("%s detected: acpi off\n", d->ident);
1459 pr_notice("Warning: DMI blacklist says broken, but acpi forced\n");
1465 * Force ignoring BIOS IRQ0 override
1467 static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
1469 if (!acpi_skip_timer_override) {
1470 pr_notice("%s detected: Ignoring BIOS IRQ0 override\n",
1472 acpi_skip_timer_override = 1;
1478 * ACPI offers an alternative platform interface model that removes
1479 * ACPI hardware requirements for platforms that do not implement
1480 * the PC Architecture.
1482 * We initialize the Hardware-reduced ACPI model here:
1484 void __init acpi_generic_reduced_hw_init(void)
1487 * Override x86_init functions and bypass legacy PIC in
1488 * hardware reduced ACPI mode.
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;
1495 static void __init acpi_reduced_hw_init(void)
1497 if (acpi_gbl_reduced_hardware)
1498 x86_init.acpi.reduced_hw_early_init();
1502 * If your system is blacklisted here, but you find that acpi=force
1503 * works for you, please contact linux-acpi@vger.kernel.org
1505 static const struct dmi_system_id acpi_dmi_table[] __initconst = {
1507 * Boxes that need ACPI disabled
1510 .callback = dmi_disable_acpi,
1511 .ident = "IBM Thinkpad",
1513 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1514 DMI_MATCH(DMI_BOARD_NAME, "2629H1G"),
1519 * Boxes that need ACPI PCI IRQ routing disabled
1522 .callback = disable_acpi_irq,
1523 .ident = "ASUS A7V",
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"),
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
1539 .callback = disable_acpi_irq,
1540 .ident = "IBM Thinkpad 600 Series 2645",
1542 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1543 DMI_MATCH(DMI_BOARD_NAME, "2645"),
1547 .callback = disable_acpi_irq,
1548 .ident = "IBM Thinkpad 600 Series 2646",
1550 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1551 DMI_MATCH(DMI_BOARD_NAME, "2646"),
1555 * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
1558 .callback = disable_acpi_pci,
1559 .ident = "ASUS PR-DLS",
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")
1569 .callback = disable_acpi_pci,
1570 .ident = "Acer TravelMate 36x Laptop",
1572 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
1573 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
1577 * Boxes that need ACPI XSDT use disabled due to corrupted tables
1580 .callback = disable_acpi_xsdt,
1581 .ident = "Advantech DAC-BJ01",
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"),
1592 /* second table for DMI checks that should run after early-quirks */
1593 static const struct dmi_system_id acpi_dmi_table_late[] __initconst = {
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
1601 * is not connected at all. Force ignoring BIOS IRQ0
1602 * override in that cases.
1605 .callback = dmi_ignore_irq0_timer_override,
1606 .ident = "HP nx6115 laptop",
1608 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1609 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6115"),
1613 .callback = dmi_ignore_irq0_timer_override,
1614 .ident = "HP NX6125 laptop",
1616 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1617 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6125"),
1621 .callback = dmi_ignore_irq0_timer_override,
1622 .ident = "HP NX6325 laptop",
1624 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1625 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6325"),
1629 .callback = dmi_ignore_irq0_timer_override,
1630 .ident = "HP 6715b laptop",
1632 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1633 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq 6715b"),
1637 .callback = dmi_ignore_irq0_timer_override,
1638 .ident = "FUJITSU SIEMENS",
1640 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
1641 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO PRO V2030"),
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
1654 * acpi_table_init() is separate to allow reading SRAT without
1655 * other side effects.
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=...
1666 void __init acpi_boot_table_init(void)
1668 dmi_check_system(acpi_dmi_table);
1671 * If acpi_disabled, bail out
1677 * Initialize the ACPI boot-time table parser.
1679 if (acpi_locate_initial_tables())
1682 acpi_reserve_initial_tables();
1685 int __init early_acpi_boot_init(void)
1690 acpi_table_init_complete();
1692 acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
1695 * blacklist may disable ACPI entirely
1697 if (acpi_blacklisted()) {
1699 pr_warn("acpi=force override\n");
1701 pr_warn("Disabling ACPI support\n");
1708 * Process the Multiple APIC Description Table (MADT), if present
1710 early_acpi_process_madt();
1713 * Hardware-reduced ACPI mode initialization:
1715 acpi_reduced_hw_init();
1720 int __init acpi_boot_init(void)
1722 /* those are executed after early-quirks are executed */
1723 dmi_check_system(acpi_dmi_table_late);
1726 * If acpi_disabled, bail out
1731 acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
1734 * set sci_int and PM timer address
1736 acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt);
1739 * Process the Multiple APIC Description Table (MADT), if present
1741 acpi_process_madt();
1743 acpi_table_parse(ACPI_SIG_HPET, acpi_parse_hpet);
1744 if (IS_ENABLED(CONFIG_ACPI_BGRT) && !acpi_nobgrt)
1745 acpi_table_parse(ACPI_SIG_BGRT, acpi_parse_bgrt);
1748 x86_init.pci.init = pci_acpi_init;
1750 /* Do not enable ACPI SPCR console by default */
1751 acpi_parse_spcr(earlycon_acpi_spcr_enable, false);
1755 static int __init parse_acpi(char *arg)
1760 /* "acpi=off" disables both ACPI table parsing and interpreter */
1761 if (strcmp(arg, "off") == 0) {
1764 /* acpi=force to over-ride black-list */
1765 else if (strcmp(arg, "force") == 0) {
1769 /* acpi=strict disables out-of-spec workarounds */
1770 else if (strcmp(arg, "strict") == 0) {
1773 /* acpi=rsdt use RSDT instead of XSDT */
1774 else if (strcmp(arg, "rsdt") == 0) {
1775 acpi_gbl_do_not_use_xsdt = TRUE;
1777 /* "acpi=noirq" disables ACPI interrupt routing */
1778 else if (strcmp(arg, "noirq") == 0) {
1781 /* "acpi=copy_dsdt" copies DSDT */
1782 else if (strcmp(arg, "copy_dsdt") == 0) {
1783 acpi_gbl_copy_dsdt_locally = 1;
1785 /* "acpi=nocmcff" disables FF mode for corrected errors */
1786 else if (strcmp(arg, "nocmcff") == 0) {
1787 acpi_disable_cmcff = 1;
1789 /* Core will printk when we return error. */
1794 early_param("acpi", parse_acpi);
1796 static int __init parse_acpi_bgrt(char *arg)
1801 early_param("bgrt_disable", parse_acpi_bgrt);
1803 /* FIXME: Using pci= for an ACPI parameter is a travesty. */
1804 static int __init parse_pci(char *arg)
1806 if (arg && strcmp(arg, "noacpi") == 0)
1810 early_param("pci", parse_pci);
1812 int __init acpi_mps_check(void)
1814 #if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_X86_MPPARSE)
1815 /* mptable code is not built-in*/
1816 if (acpi_disabled || acpi_noirq) {
1817 pr_warn("MPS support code is not built-in, using acpi=off or acpi=noirq or pci=noacpi may have problem\n");
1824 #ifdef CONFIG_X86_IO_APIC
1825 static int __init parse_acpi_skip_timer_override(char *arg)
1827 acpi_skip_timer_override = 1;
1830 early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override);
1832 static int __init parse_acpi_use_timer_override(char *arg)
1834 acpi_use_timer_override = 1;
1837 early_param("acpi_use_timer_override", parse_acpi_use_timer_override);
1838 #endif /* CONFIG_X86_IO_APIC */
1840 static int __init setup_acpi_sci(char *s)
1844 if (!strcmp(s, "edge"))
1845 acpi_sci_flags = ACPI_MADT_TRIGGER_EDGE |
1846 (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
1847 else if (!strcmp(s, "level"))
1848 acpi_sci_flags = ACPI_MADT_TRIGGER_LEVEL |
1849 (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
1850 else if (!strcmp(s, "high"))
1851 acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_HIGH |
1852 (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
1853 else if (!strcmp(s, "low"))
1854 acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_LOW |
1855 (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
1860 early_param("acpi_sci", setup_acpi_sci);
1862 int __acpi_acquire_global_lock(unsigned int *lock)
1864 unsigned int old, new, val;
1867 new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
1868 val = cmpxchg(lock, old, new);
1869 } while (unlikely (val != old));
1870 return ((new & 0x3) < 3) ? -1 : 0;
1873 int __acpi_release_global_lock(unsigned int *lock)
1875 unsigned int old, new, val;
1879 val = cmpxchg(lock, old, new);
1880 } while (unlikely (val != old));
1884 void __init arch_reserve_mem_area(acpi_physical_address addr, size_t size)
1886 e820__range_add(addr, size, E820_TYPE_NVS);
1887 e820__update_table_print();
1890 void x86_default_set_root_pointer(u64 addr)
1892 boot_params.acpi_rsdp_addr = addr;
1895 u64 x86_default_get_root_pointer(void)
1897 return boot_params.acpi_rsdp_addr;