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;
55 bool acpi_int_src_ovr[NR_IRQS_LEGACY];
57 /* ACPI SCI override configuration */
58 u8 acpi_sci_flags __initdata;
59 u32 acpi_sci_override_gsi __initdata = INVALID_ACPI_IRQ;
60 int acpi_skip_timer_override __initdata;
61 int acpi_use_timer_override __initdata;
62 int acpi_fix_pin2_polarity __initdata;
64 #ifdef CONFIG_X86_LOCAL_APIC
65 static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
66 static bool acpi_support_online_capable;
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;
76 #ifdef CONFIG_X86_IO_APIC
78 * Locks related to IOAPIC hotplug
80 * ->device_hotplug_lock
83 * Interrupt mapping side:
88 static DEFINE_MUTEX(acpi_ioapic_lock);
91 /* --------------------------------------------------------------------------
92 Boot-time Configuration
93 -------------------------------------------------------------------------- */
96 * The default interrupt routing model is PIC (8259). This gets
97 * overridden if IOAPICs are enumerated (below).
99 enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
103 * ISA irqs by default are the first 16 gsis but can be
104 * any gsi as specified by an interrupt source override.
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
111 * This is just a simple wrapper around early_memremap(),
112 * with sanity checks for phys == 0 and size == 0.
114 void __init __iomem *__acpi_map_table(unsigned long phys, unsigned long size)
120 return early_memremap(phys, size);
123 void __init __acpi_unmap_table(void __iomem *map, unsigned long size)
128 early_memunmap(map, size);
131 #ifdef CONFIG_X86_LOCAL_APIC
132 static int __init acpi_parse_madt(struct acpi_table_header *table)
134 struct acpi_table_madt *madt = NULL;
136 if (!boot_cpu_has(X86_FEATURE_APIC))
139 madt = (struct acpi_table_madt *)table;
141 pr_warn("Unable to map MADT\n");
146 acpi_lapic_addr = (u64) madt->address;
148 pr_debug("Local APIC address 0x%08x\n", madt->address);
151 /* ACPI 6.3 and newer support the online capable bit. */
152 if (acpi_gbl_FADT.header.revision > 6 ||
153 (acpi_gbl_FADT.header.revision == 6 &&
154 acpi_gbl_FADT.minor_revision >= 3))
155 acpi_support_online_capable = true;
157 default_acpi_madt_oem_check(madt->header.oem_id,
158 madt->header.oem_table_id);
164 * acpi_register_lapic - register a local apic and generates a logic cpu number
165 * @id: local apic id to register
166 * @acpiid: ACPI id to register
167 * @enabled: this cpu is enabled or not
169 * Returns the logic cpu number which maps to the local apic
171 static int acpi_register_lapic(int id, u32 acpiid, u8 enabled)
173 unsigned int ver = 0;
176 if (id >= MAX_LOCAL_APIC) {
177 pr_info("skipped apicid that is too big\n");
186 if (boot_cpu_physical_apicid != -1U)
187 ver = boot_cpu_apic_version;
189 cpu = generic_processor_info(id, ver);
191 early_per_cpu(x86_cpu_to_acpiid, cpu) = acpiid;
196 static bool __init acpi_is_processor_usable(u32 lapic_flags)
198 if (lapic_flags & ACPI_MADT_ENABLED)
201 if (!acpi_support_online_capable ||
202 (lapic_flags & ACPI_MADT_ONLINE_CAPABLE))
209 acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end)
211 struct acpi_madt_local_x2apic *processor = NULL;
212 #ifdef CONFIG_X86_X2APIC
217 processor = (struct acpi_madt_local_x2apic *)header;
219 if (BAD_MADT_ENTRY(processor, end))
222 acpi_table_print_madt_entry(&header->common);
224 #ifdef CONFIG_X86_X2APIC
225 apic_id = processor->local_apic_id;
226 enabled = processor->lapic_flags & ACPI_MADT_ENABLED;
228 /* Ignore invalid ID */
229 if (apic_id == 0xffffffff)
232 /* don't register processors that cannot be onlined */
233 if (!acpi_is_processor_usable(processor->lapic_flags))
237 * We need to register disabled CPU as well to permit
238 * counting disabled CPUs. This allows us to size
239 * cpus_possible_map more accurately, to permit
240 * to not preallocating memory for all NR_CPUS
241 * when we use CPU hotplug.
243 if (!apic->apic_id_valid(apic_id)) {
245 pr_warn("x2apic entry ignored\n");
249 acpi_register_lapic(apic_id, processor->uid, enabled);
251 pr_warn("x2apic entry ignored\n");
258 acpi_parse_lapic(union acpi_subtable_headers * header, const unsigned long end)
260 struct acpi_madt_local_apic *processor = NULL;
262 processor = (struct acpi_madt_local_apic *)header;
264 if (BAD_MADT_ENTRY(processor, end))
267 acpi_table_print_madt_entry(&header->common);
269 /* Ignore invalid ID */
270 if (processor->id == 0xff)
273 /* don't register processors that can not be onlined */
274 if (!acpi_is_processor_usable(processor->lapic_flags))
278 * We need to register disabled CPU as well to permit
279 * counting disabled CPUs. This allows us to size
280 * cpus_possible_map more accurately, to permit
281 * to not preallocating memory for all NR_CPUS
282 * when we use CPU hotplug.
284 acpi_register_lapic(processor->id, /* APIC ID */
285 processor->processor_id, /* ACPI ID */
286 processor->lapic_flags & ACPI_MADT_ENABLED);
292 acpi_parse_sapic(union acpi_subtable_headers *header, const unsigned long end)
294 struct acpi_madt_local_sapic *processor = NULL;
296 processor = (struct acpi_madt_local_sapic *)header;
298 if (BAD_MADT_ENTRY(processor, end))
301 acpi_table_print_madt_entry(&header->common);
303 acpi_register_lapic((processor->id << 8) | processor->eid,/* APIC ID */
304 processor->processor_id, /* ACPI ID */
305 processor->lapic_flags & ACPI_MADT_ENABLED);
311 acpi_parse_lapic_addr_ovr(union acpi_subtable_headers * header,
312 const unsigned long end)
314 struct acpi_madt_local_apic_override *lapic_addr_ovr = NULL;
316 lapic_addr_ovr = (struct acpi_madt_local_apic_override *)header;
318 if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
321 acpi_table_print_madt_entry(&header->common);
323 acpi_lapic_addr = lapic_addr_ovr->address;
329 acpi_parse_x2apic_nmi(union acpi_subtable_headers *header,
330 const unsigned long end)
332 struct acpi_madt_local_x2apic_nmi *x2apic_nmi = NULL;
334 x2apic_nmi = (struct acpi_madt_local_x2apic_nmi *)header;
336 if (BAD_MADT_ENTRY(x2apic_nmi, end))
339 acpi_table_print_madt_entry(&header->common);
341 if (x2apic_nmi->lint != 1)
342 pr_warn("NMI not connected to LINT 1!\n");
348 acpi_parse_lapic_nmi(union acpi_subtable_headers * header, const unsigned long end)
350 struct acpi_madt_local_apic_nmi *lapic_nmi = NULL;
352 lapic_nmi = (struct acpi_madt_local_apic_nmi *)header;
354 if (BAD_MADT_ENTRY(lapic_nmi, end))
357 acpi_table_print_madt_entry(&header->common);
359 if (lapic_nmi->lint != 1)
360 pr_warn("NMI not connected to LINT 1!\n");
366 static int acpi_wakeup_cpu(int apicid, unsigned long start_ip)
369 * Remap mailbox memory only for the first call to acpi_wakeup_cpu().
371 * Wakeup of secondary CPUs is fully serialized in the core code.
372 * No need to protect acpi_mp_wake_mailbox from concurrent accesses.
374 if (!acpi_mp_wake_mailbox) {
375 acpi_mp_wake_mailbox = memremap(acpi_mp_wake_mailbox_paddr,
376 sizeof(*acpi_mp_wake_mailbox),
381 * Mailbox memory is shared between the firmware and OS. Firmware will
382 * listen on mailbox command address, and once it receives the wakeup
383 * command, the CPU associated with the given apicid will be booted.
385 * The value of 'apic_id' and 'wakeup_vector' must be visible to the
386 * firmware before the wakeup command is visible. smp_store_release()
387 * ensures ordering and visibility.
389 acpi_mp_wake_mailbox->apic_id = apicid;
390 acpi_mp_wake_mailbox->wakeup_vector = start_ip;
391 smp_store_release(&acpi_mp_wake_mailbox->command,
392 ACPI_MP_WAKE_COMMAND_WAKEUP);
395 * Wait for the CPU to wake up.
397 * The CPU being woken up is essentially in a spin loop waiting to be
398 * woken up. It should not take long for it wake up and acknowledge by
399 * zeroing out ->command.
401 * ACPI specification doesn't provide any guidance on how long kernel
402 * has to wait for a wake up acknowledgement. It also doesn't provide
403 * a way to cancel a wake up request if it takes too long.
405 * In TDX environment, the VMM has control over how long it takes to
406 * wake up secondary. It can postpone scheduling secondary vCPU
407 * indefinitely. Giving up on wake up request and reporting error opens
408 * possible attack vector for VMM: it can wake up a secondary CPU when
409 * kernel doesn't expect it. Wait until positive result of the wake up
412 while (READ_ONCE(acpi_mp_wake_mailbox->command))
417 #endif /* CONFIG_X86_64 */
418 #endif /* CONFIG_X86_LOCAL_APIC */
420 #ifdef CONFIG_X86_IO_APIC
423 static int __init mp_register_ioapic_irq(u8 bus_irq, u8 polarity,
424 u8 trigger, u32 gsi);
426 static void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger,
430 * Check bus_irq boundary.
432 if (bus_irq >= NR_IRQS_LEGACY) {
433 pr_warn("Invalid bus_irq %u for legacy override\n", bus_irq);
438 * TBD: This check is for faulty timer entries, where the override
439 * erroneously sets the trigger to level, resulting in a HUGE
440 * increase of timer interrupts!
442 if ((bus_irq == 0) && (trigger == 3))
445 if (mp_register_ioapic_irq(bus_irq, polarity, trigger, gsi) < 0)
448 * Reset default identity mapping if gsi is also an legacy IRQ,
449 * otherwise there will be more than one entry with the same GSI
450 * and acpi_isa_irq_to_gsi() may give wrong result.
452 if (gsi < nr_legacy_irqs() && isa_irq_to_gsi[gsi] == gsi)
453 isa_irq_to_gsi[gsi] = INVALID_ACPI_IRQ;
454 isa_irq_to_gsi[bus_irq] = gsi;
457 static void mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
460 #ifdef CONFIG_X86_MPPARSE
461 struct mpc_intsrc mp_irq;
462 struct pci_dev *pdev;
463 unsigned char number;
470 if (!dev || !dev_is_pci(dev))
473 pdev = to_pci_dev(dev);
474 number = pdev->bus->number;
477 /* print the entry should happen on mptable identically */
478 mp_irq.type = MP_INTSRC;
479 mp_irq.irqtype = mp_INT;
480 mp_irq.irqflag = (trigger == ACPI_EDGE_SENSITIVE ? 4 : 0x0c) |
481 (polarity == ACPI_ACTIVE_HIGH ? 1 : 3);
482 mp_irq.srcbus = number;
483 mp_irq.srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3);
484 ioapic = mp_find_ioapic(gsi);
485 mp_irq.dstapic = mpc_ioapic_id(ioapic);
486 mp_irq.dstirq = mp_find_ioapic_pin(ioapic, gsi);
488 mp_save_irq(&mp_irq);
492 static int __init mp_register_ioapic_irq(u8 bus_irq, u8 polarity,
495 struct mpc_intsrc mp_irq;
498 /* Convert 'gsi' to 'ioapic.pin'(INTIN#) */
499 ioapic = mp_find_ioapic(gsi);
501 pr_warn("Failed to find ioapic for gsi : %u\n", gsi);
505 pin = mp_find_ioapic_pin(ioapic, gsi);
507 mp_irq.type = MP_INTSRC;
508 mp_irq.irqtype = mp_INT;
509 mp_irq.irqflag = (trigger << 2) | polarity;
510 mp_irq.srcbus = MP_ISA_BUS;
511 mp_irq.srcbusirq = bus_irq;
512 mp_irq.dstapic = mpc_ioapic_id(ioapic);
515 mp_save_irq(&mp_irq);
521 acpi_parse_ioapic(union acpi_subtable_headers * header, const unsigned long end)
523 struct acpi_madt_io_apic *ioapic = NULL;
524 struct ioapic_domain_cfg cfg = {
525 .type = IOAPIC_DOMAIN_DYNAMIC,
526 .ops = &mp_ioapic_irqdomain_ops,
529 ioapic = (struct acpi_madt_io_apic *)header;
531 if (BAD_MADT_ENTRY(ioapic, end))
534 acpi_table_print_madt_entry(&header->common);
536 /* Statically assign IRQ numbers for IOAPICs hosting legacy IRQs */
537 if (ioapic->global_irq_base < nr_legacy_irqs())
538 cfg.type = IOAPIC_DOMAIN_LEGACY;
540 mp_register_ioapic(ioapic->id, ioapic->address, ioapic->global_irq_base,
547 * Parse Interrupt Source Override for the ACPI SCI
549 static void __init acpi_sci_ioapic_setup(u8 bus_irq, u16 polarity, u16 trigger, u32 gsi)
551 if (trigger == 0) /* compatible SCI trigger is level */
554 if (polarity == 0) /* compatible SCI polarity is low */
557 /* Command-line over-ride via acpi_sci= */
558 if (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK)
559 trigger = (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) >> 2;
561 if (acpi_sci_flags & ACPI_MADT_POLARITY_MASK)
562 polarity = acpi_sci_flags & ACPI_MADT_POLARITY_MASK;
564 if (bus_irq < NR_IRQS_LEGACY)
565 mp_override_legacy_irq(bus_irq, polarity, trigger, gsi);
567 mp_register_ioapic_irq(bus_irq, polarity, trigger, gsi);
569 acpi_penalize_sci_irq(bus_irq, trigger, polarity);
572 * stash over-ride to indicate we've been here
573 * and for later update of acpi_gbl_FADT
575 acpi_sci_override_gsi = gsi;
580 acpi_parse_int_src_ovr(union acpi_subtable_headers * header,
581 const unsigned long end)
583 struct acpi_madt_interrupt_override *intsrc = NULL;
585 intsrc = (struct acpi_madt_interrupt_override *)header;
587 if (BAD_MADT_ENTRY(intsrc, end))
590 acpi_table_print_madt_entry(&header->common);
592 if (intsrc->source_irq < NR_IRQS_LEGACY)
593 acpi_int_src_ovr[intsrc->source_irq] = true;
595 if (intsrc->source_irq == acpi_gbl_FADT.sci_interrupt) {
596 acpi_sci_ioapic_setup(intsrc->source_irq,
597 intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
598 (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2,
603 if (intsrc->source_irq == 0) {
604 if (acpi_skip_timer_override) {
605 pr_warn("BIOS IRQ0 override ignored.\n");
609 if ((intsrc->global_irq == 2) && acpi_fix_pin2_polarity
610 && (intsrc->inti_flags & ACPI_MADT_POLARITY_MASK)) {
611 intsrc->inti_flags &= ~ACPI_MADT_POLARITY_MASK;
612 pr_warn("BIOS IRQ0 pin2 override: forcing polarity to high active.\n");
616 mp_override_legacy_irq(intsrc->source_irq,
617 intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
618 (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2,
625 acpi_parse_nmi_src(union acpi_subtable_headers * header, const unsigned long end)
627 struct acpi_madt_nmi_source *nmi_src = NULL;
629 nmi_src = (struct acpi_madt_nmi_source *)header;
631 if (BAD_MADT_ENTRY(nmi_src, end))
634 acpi_table_print_madt_entry(&header->common);
636 /* TBD: Support nimsrc entries? */
641 #endif /* CONFIG_X86_IO_APIC */
644 * acpi_pic_sci_set_trigger()
646 * use ELCR to set PIC-mode trigger type for SCI
648 * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
649 * it may require Edge Trigger -- use "acpi_sci=edge"
651 * Port 0x4d0-4d1 are ELCR1 and ELCR2, the Edge/Level Control Registers
652 * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
653 * ELCR1 is IRQs 0-7 (IRQ 0, 1, 2 must be 0)
654 * ELCR2 is IRQs 8-15 (IRQ 8, 13 must be 0)
657 void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
659 unsigned int mask = 1 << irq;
660 unsigned int old, new;
662 /* Real old ELCR mask */
663 old = inb(PIC_ELCR1) | (inb(PIC_ELCR2) << 8);
666 * If we use ACPI to set PCI IRQs, then we should clear ELCR
667 * since we will set it correctly as we enable the PCI irq
670 new = acpi_noirq ? old : 0;
673 * Update SCI information in the ELCR, it isn't in the PCI
677 case 1: /* Edge - clear */
680 case 3: /* Level - set */
688 pr_warn("setting ELCR to %04x (from %04x)\n", new, old);
689 outb(new, PIC_ELCR1);
690 outb(new >> 8, PIC_ELCR2);
693 int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp)
695 int rc, irq, trigger, polarity;
697 if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
702 rc = acpi_get_override_irq(gsi, &trigger, &polarity);
706 trigger = trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE;
707 polarity = polarity ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH;
708 irq = acpi_register_gsi(NULL, gsi, trigger, polarity);
715 EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);
717 int acpi_isa_irq_to_gsi(unsigned isa_irq, u32 *gsi)
719 if (isa_irq < nr_legacy_irqs() &&
720 isa_irq_to_gsi[isa_irq] != INVALID_ACPI_IRQ) {
721 *gsi = isa_irq_to_gsi[isa_irq];
728 static int acpi_register_gsi_pic(struct device *dev, u32 gsi,
729 int trigger, int polarity)
733 * Make sure all (legacy) PCI IRQs are set as level-triggered.
735 if (trigger == ACPI_LEVEL_SENSITIVE)
736 elcr_set_level_irq(gsi);
742 #ifdef CONFIG_X86_LOCAL_APIC
743 static int acpi_register_gsi_ioapic(struct device *dev, u32 gsi,
744 int trigger, int polarity)
747 #ifdef CONFIG_X86_IO_APIC
749 struct irq_alloc_info info;
751 node = dev ? dev_to_node(dev) : NUMA_NO_NODE;
752 trigger = trigger == ACPI_EDGE_SENSITIVE ? 0 : 1;
753 polarity = polarity == ACPI_ACTIVE_HIGH ? 0 : 1;
754 ioapic_set_alloc_attr(&info, node, trigger, polarity);
756 mutex_lock(&acpi_ioapic_lock);
757 irq = mp_map_gsi_to_irq(gsi, IOAPIC_MAP_ALLOC, &info);
758 /* Don't set up the ACPI SCI because it's already set up */
759 if (irq >= 0 && enable_update_mptable && gsi != acpi_gbl_FADT.sci_interrupt)
760 mp_config_acpi_gsi(dev, gsi, trigger, polarity);
761 mutex_unlock(&acpi_ioapic_lock);
767 static void acpi_unregister_gsi_ioapic(u32 gsi)
769 #ifdef CONFIG_X86_IO_APIC
772 mutex_lock(&acpi_ioapic_lock);
773 irq = mp_map_gsi_to_irq(gsi, 0, NULL);
776 mutex_unlock(&acpi_ioapic_lock);
781 int (*__acpi_register_gsi)(struct device *dev, u32 gsi,
782 int trigger, int polarity) = acpi_register_gsi_pic;
783 void (*__acpi_unregister_gsi)(u32 gsi) = NULL;
785 #ifdef CONFIG_ACPI_SLEEP
786 int (*acpi_suspend_lowlevel)(void) = x86_acpi_suspend_lowlevel;
788 int (*acpi_suspend_lowlevel)(void);
792 * success: return IRQ number (>=0)
793 * failure: return < 0
795 int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
797 return __acpi_register_gsi(dev, gsi, trigger, polarity);
799 EXPORT_SYMBOL_GPL(acpi_register_gsi);
801 void acpi_unregister_gsi(u32 gsi)
803 if (__acpi_unregister_gsi)
804 __acpi_unregister_gsi(gsi);
806 EXPORT_SYMBOL_GPL(acpi_unregister_gsi);
808 #ifdef CONFIG_X86_LOCAL_APIC
809 static void __init acpi_set_irq_model_ioapic(void)
811 acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
812 __acpi_register_gsi = acpi_register_gsi_ioapic;
813 __acpi_unregister_gsi = acpi_unregister_gsi_ioapic;
819 * ACPI based hotplug support for CPU
821 #ifdef CONFIG_ACPI_HOTPLUG_CPU
822 #include <acpi/processor.h>
824 static int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
826 #ifdef CONFIG_ACPI_NUMA
829 nid = acpi_get_node(handle);
830 if (nid != NUMA_NO_NODE) {
831 set_apicid_to_node(physid, nid);
832 numa_set_node(cpu, nid);
838 int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id,
843 cpu = acpi_register_lapic(physid, acpi_id, ACPI_MADT_ENABLED);
845 pr_info("Unable to map lapic to logical cpu number\n");
849 acpi_processor_set_pdc(handle);
850 acpi_map_cpu2node(handle, cpu, physid);
855 EXPORT_SYMBOL(acpi_map_cpu);
857 int acpi_unmap_cpu(int cpu)
859 #ifdef CONFIG_ACPI_NUMA
860 set_apicid_to_node(per_cpu(x86_cpu_to_apicid, cpu), NUMA_NO_NODE);
863 per_cpu(x86_cpu_to_apicid, cpu) = -1;
864 set_cpu_present(cpu, false);
869 EXPORT_SYMBOL(acpi_unmap_cpu);
870 #endif /* CONFIG_ACPI_HOTPLUG_CPU */
872 int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
875 #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
878 struct ioapic_domain_cfg cfg = {
879 .type = IOAPIC_DOMAIN_DYNAMIC,
880 .ops = &mp_ioapic_irqdomain_ops,
883 ioapic_id = acpi_get_ioapic_id(handle, gsi_base, &addr);
885 unsigned long long uid;
888 status = acpi_evaluate_integer(handle, METHOD_NAME__UID,
890 if (ACPI_FAILURE(status)) {
891 acpi_handle_warn(handle, "failed to get IOAPIC ID.\n");
894 ioapic_id = (int)uid;
897 mutex_lock(&acpi_ioapic_lock);
898 ret = mp_register_ioapic(ioapic_id, phys_addr, gsi_base, &cfg);
899 mutex_unlock(&acpi_ioapic_lock);
904 EXPORT_SYMBOL(acpi_register_ioapic);
906 int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
910 #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
911 mutex_lock(&acpi_ioapic_lock);
912 ret = mp_unregister_ioapic(gsi_base);
913 mutex_unlock(&acpi_ioapic_lock);
918 EXPORT_SYMBOL(acpi_unregister_ioapic);
921 * acpi_ioapic_registered - Check whether IOAPIC associated with @gsi_base
922 * has been registered
923 * @handle: ACPI handle of the IOAPIC device
924 * @gsi_base: GSI base associated with the IOAPIC
926 * Assume caller holds some type of lock to serialize acpi_ioapic_registered()
927 * with acpi_register_ioapic()/acpi_unregister_ioapic().
929 int acpi_ioapic_registered(acpi_handle handle, u32 gsi_base)
933 #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
934 mutex_lock(&acpi_ioapic_lock);
935 ret = mp_ioapic_registered(gsi_base);
936 mutex_unlock(&acpi_ioapic_lock);
942 static int __init acpi_parse_sbf(struct acpi_table_header *table)
944 struct acpi_table_boot *sb = (struct acpi_table_boot *)table;
946 sbf_port = sb->cmos_index; /* Save CMOS port */
951 #ifdef CONFIG_HPET_TIMER
952 #include <asm/hpet.h>
954 static struct resource *hpet_res __initdata;
956 static int __init acpi_parse_hpet(struct acpi_table_header *table)
958 struct acpi_table_hpet *hpet_tbl = (struct acpi_table_hpet *)table;
960 if (hpet_tbl->address.space_id != ACPI_SPACE_MEM) {
961 pr_warn("HPET timers must be located in memory.\n");
965 hpet_address = hpet_tbl->address.address;
966 hpet_blockid = hpet_tbl->sequence;
969 * Some broken BIOSes advertise HPET at 0x0. We really do not
970 * want to allocate a resource there.
973 pr_warn("HPET id: %#x base: %#lx is invalid\n", hpet_tbl->id, hpet_address);
978 * Some even more broken BIOSes advertise HPET at
979 * 0xfed0000000000000 instead of 0xfed00000. Fix it up and add
982 if (hpet_address == 0xfed0000000000000UL) {
983 if (!hpet_force_user) {
984 pr_warn("HPET id: %#x base: 0xfed0000000000000 is bogus, try hpet=force on the kernel command line to fix it up to 0xfed00000.\n",
989 pr_warn("HPET id: %#x base: 0xfed0000000000000 fixed up to 0xfed00000.\n",
994 pr_info("HPET id: %#x base: %#lx\n", hpet_tbl->id, hpet_address);
997 * Allocate and initialize the HPET firmware resource for adding into
998 * the resource tree during the lateinit timeframe.
1000 #define HPET_RESOURCE_NAME_SIZE 9
1001 hpet_res = memblock_alloc(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE,
1004 panic("%s: Failed to allocate %zu bytes\n", __func__,
1005 sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE);
1007 hpet_res->name = (void *)&hpet_res[1];
1008 hpet_res->flags = IORESOURCE_MEM;
1009 snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE, "HPET %u",
1010 hpet_tbl->sequence);
1012 hpet_res->start = hpet_address;
1013 hpet_res->end = hpet_address + (1 * 1024) - 1;
1019 * hpet_insert_resource inserts the HPET resources used into the resource
1022 static __init int hpet_insert_resource(void)
1027 return insert_resource(&iomem_resource, hpet_res);
1030 late_initcall(hpet_insert_resource);
1033 #define acpi_parse_hpet NULL
1036 static int __init acpi_parse_fadt(struct acpi_table_header *table)
1038 if (!(acpi_gbl_FADT.boot_flags & ACPI_FADT_LEGACY_DEVICES)) {
1039 pr_debug("no legacy devices present\n");
1040 x86_platform.legacy.devices.pnpbios = 0;
1043 if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID &&
1044 !(acpi_gbl_FADT.boot_flags & ACPI_FADT_8042) &&
1045 x86_platform.legacy.i8042 != X86_LEGACY_I8042_PLATFORM_ABSENT) {
1046 pr_debug("i8042 controller is absent\n");
1047 x86_platform.legacy.i8042 = X86_LEGACY_I8042_FIRMWARE_ABSENT;
1050 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) {
1051 pr_debug("not registering RTC platform device\n");
1052 x86_platform.legacy.rtc = 0;
1055 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_VGA) {
1056 pr_debug("probing for VGA not safe\n");
1057 x86_platform.legacy.no_vga = 1;
1060 #ifdef CONFIG_X86_PM_TIMER
1061 /* detect the location of the ACPI PM Timer */
1062 if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) {
1064 if (acpi_gbl_FADT.xpm_timer_block.space_id !=
1065 ACPI_ADR_SPACE_SYSTEM_IO)
1068 pmtmr_ioport = acpi_gbl_FADT.xpm_timer_block.address;
1070 * "X" fields are optional extensions to the original V1.0
1071 * fields, so we must selectively expand V1.0 fields if the
1072 * corresponding X field is zero.
1075 pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
1078 pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
1081 pr_info("PM-Timer IO Port: %#x\n", pmtmr_ioport);
1086 #ifdef CONFIG_X86_LOCAL_APIC
1088 * Parse LAPIC entries in MADT
1089 * returns 0 on success, < 0 on error
1092 static int __init early_acpi_parse_madt_lapic_addr_ovr(void)
1096 if (!boot_cpu_has(X86_FEATURE_APIC))
1100 * Note that the LAPIC address is obtained from the MADT (32-bit value)
1101 * and (optionally) overridden by a LAPIC_ADDR_OVR entry (64-bit value).
1104 count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
1105 acpi_parse_lapic_addr_ovr, 0);
1107 pr_err("Error parsing LAPIC address override entry\n");
1111 register_lapic_address(acpi_lapic_addr);
1116 static int __init acpi_parse_madt_lapic_entries(void)
1121 struct acpi_subtable_proc madt_proc[2];
1123 if (!boot_cpu_has(X86_FEATURE_APIC))
1126 count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_SAPIC,
1127 acpi_parse_sapic, MAX_LOCAL_APIC);
1130 memset(madt_proc, 0, sizeof(madt_proc));
1131 madt_proc[0].id = ACPI_MADT_TYPE_LOCAL_APIC;
1132 madt_proc[0].handler = acpi_parse_lapic;
1133 madt_proc[1].id = ACPI_MADT_TYPE_LOCAL_X2APIC;
1134 madt_proc[1].handler = acpi_parse_x2apic;
1135 ret = acpi_table_parse_entries_array(ACPI_SIG_MADT,
1136 sizeof(struct acpi_table_madt),
1137 madt_proc, ARRAY_SIZE(madt_proc), MAX_LOCAL_APIC);
1139 pr_err("Error parsing LAPIC/X2APIC entries\n");
1143 count = madt_proc[0].count;
1144 x2count = madt_proc[1].count;
1146 if (!count && !x2count) {
1147 pr_err("No LAPIC entries present\n");
1148 /* TBD: Cleanup to allow fallback to MPS */
1150 } else if (count < 0 || x2count < 0) {
1151 pr_err("Error parsing LAPIC entry\n");
1152 /* TBD: Cleanup to allow fallback to MPS */
1156 x2count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_X2APIC_NMI,
1157 acpi_parse_x2apic_nmi, 0);
1158 count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_NMI,
1159 acpi_parse_lapic_nmi, 0);
1160 if (count < 0 || x2count < 0) {
1161 pr_err("Error parsing LAPIC NMI entry\n");
1162 /* TBD: Cleanup to allow fallback to MPS */
1168 #ifdef CONFIG_X86_64
1169 static int __init acpi_parse_mp_wake(union acpi_subtable_headers *header,
1170 const unsigned long end)
1172 struct acpi_madt_multiproc_wakeup *mp_wake;
1174 if (!IS_ENABLED(CONFIG_SMP))
1177 mp_wake = (struct acpi_madt_multiproc_wakeup *)header;
1178 if (BAD_MADT_ENTRY(mp_wake, end))
1181 acpi_table_print_madt_entry(&header->common);
1183 acpi_mp_wake_mailbox_paddr = mp_wake->base_address;
1185 acpi_wake_cpu_handler_update(acpi_wakeup_cpu);
1189 #endif /* CONFIG_X86_64 */
1190 #endif /* CONFIG_X86_LOCAL_APIC */
1192 #ifdef CONFIG_X86_IO_APIC
1193 static void __init mp_config_acpi_legacy_irqs(void)
1196 struct mpc_intsrc mp_irq;
1200 * Fabricate the legacy ISA bus (bus #31).
1202 mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA;
1204 set_bit(MP_ISA_BUS, mp_bus_not_pci);
1205 pr_debug("Bus #%d is ISA (nIRQs: %d)\n", MP_ISA_BUS, nr_legacy_irqs());
1208 * Use the default configuration for the IRQs 0-15. Unless
1209 * overridden by (MADT) interrupt source override entries.
1211 for (i = 0; i < nr_legacy_irqs(); i++) {
1213 unsigned int dstapic;
1217 /* Locate the gsi that irq i maps to. */
1218 if (acpi_isa_irq_to_gsi(i, &gsi))
1222 * Locate the IOAPIC that manages the ISA IRQ.
1224 ioapic = mp_find_ioapic(gsi);
1227 pin = mp_find_ioapic_pin(ioapic, gsi);
1228 dstapic = mpc_ioapic_id(ioapic);
1230 for (idx = 0; idx < mp_irq_entries; idx++) {
1231 struct mpc_intsrc *irq = mp_irqs + idx;
1233 /* Do we already have a mapping for this ISA IRQ? */
1234 if (irq->srcbus == MP_ISA_BUS && irq->srcbusirq == i)
1237 /* Do we already have a mapping for this IOAPIC pin */
1238 if (irq->dstapic == dstapic && irq->dstirq == pin)
1242 if (idx != mp_irq_entries) {
1243 pr_debug("ACPI: IRQ%d used by override.\n", i);
1244 continue; /* IRQ already used */
1247 mp_irq.type = MP_INTSRC;
1248 mp_irq.irqflag = 0; /* Conforming */
1249 mp_irq.srcbus = MP_ISA_BUS;
1250 mp_irq.dstapic = dstapic;
1251 mp_irq.irqtype = mp_INT;
1252 mp_irq.srcbusirq = i; /* Identity mapped */
1253 mp_irq.dstirq = pin;
1255 mp_save_irq(&mp_irq);
1260 * Parse IOAPIC related entries in MADT
1261 * returns 0 on success, < 0 on error
1263 static int __init acpi_parse_madt_ioapic_entries(void)
1268 * ACPI interpreter is required to complete interrupt setup,
1269 * so if it is off, don't enumerate the io-apics with ACPI.
1270 * If MPS is present, it will handle them,
1271 * otherwise the system will stay in PIC mode
1273 if (acpi_disabled || acpi_noirq)
1276 if (!boot_cpu_has(X86_FEATURE_APIC))
1280 * if "noapic" boot option, don't look for IO-APICs
1282 if (skip_ioapic_setup) {
1283 pr_info("Skipping IOAPIC probe due to 'noapic' option.\n");
1287 count = acpi_table_parse_madt(ACPI_MADT_TYPE_IO_APIC, acpi_parse_ioapic,
1290 pr_err("No IOAPIC entries present\n");
1292 } else if (count < 0) {
1293 pr_err("Error parsing IOAPIC entry\n");
1297 count = acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE,
1298 acpi_parse_int_src_ovr, nr_irqs);
1300 pr_err("Error parsing interrupt source overrides entry\n");
1301 /* TBD: Cleanup to allow fallback to MPS */
1306 * If BIOS did not supply an INT_SRC_OVR for the SCI
1307 * pretend we got one so we can set the SCI flags.
1308 * But ignore setting up SCI on hardware reduced platforms.
1310 if (acpi_sci_override_gsi == INVALID_ACPI_IRQ && !acpi_gbl_reduced_hardware)
1311 acpi_sci_ioapic_setup(acpi_gbl_FADT.sci_interrupt, 0, 0,
1312 acpi_gbl_FADT.sci_interrupt);
1314 /* Fill in identity legacy mappings where no override */
1315 mp_config_acpi_legacy_irqs();
1317 count = acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE,
1318 acpi_parse_nmi_src, nr_irqs);
1320 pr_err("Error parsing NMI SRC entry\n");
1321 /* TBD: Cleanup to allow fallback to MPS */
1328 static inline int acpi_parse_madt_ioapic_entries(void)
1332 #endif /* !CONFIG_X86_IO_APIC */
1334 static void __init early_acpi_process_madt(void)
1336 #ifdef CONFIG_X86_LOCAL_APIC
1339 if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
1342 * Parse MADT LAPIC entries
1344 error = early_acpi_parse_madt_lapic_addr_ovr();
1347 smp_found_config = 1;
1349 if (error == -EINVAL) {
1351 * Dell Precision Workstation 410, 610 come here.
1353 pr_err("Invalid BIOS MADT, disabling ACPI\n");
1360 static void __init acpi_process_madt(void)
1362 #ifdef CONFIG_X86_LOCAL_APIC
1365 if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
1368 * Parse MADT LAPIC entries
1370 error = acpi_parse_madt_lapic_entries();
1375 * Parse MADT IO-APIC entries
1377 mutex_lock(&acpi_ioapic_lock);
1378 error = acpi_parse_madt_ioapic_entries();
1379 mutex_unlock(&acpi_ioapic_lock);
1381 acpi_set_irq_model_ioapic();
1383 smp_found_config = 1;
1386 #ifdef CONFIG_X86_64
1388 * Parse MADT MP Wake entry.
1390 acpi_table_parse_madt(ACPI_MADT_TYPE_MULTIPROC_WAKEUP,
1391 acpi_parse_mp_wake, 1);
1394 if (error == -EINVAL) {
1396 * Dell Precision Workstation 410, 610 come here.
1398 pr_err("Invalid BIOS MADT, disabling ACPI\n");
1403 * ACPI found no MADT, and so ACPI wants UP PIC mode.
1404 * In the event an MPS table was found, forget it.
1405 * Boot with "acpi=off" to use MPS on such a system.
1407 if (smp_found_config) {
1408 pr_warn("No APIC-table, disabling MPS\n");
1409 smp_found_config = 0;
1414 * ACPI supports both logical (e.g. Hyper-Threading) and physical
1415 * processors, where MPS only supports physical.
1417 if (acpi_lapic && acpi_ioapic)
1418 pr_info("Using ACPI (MADT) for SMP configuration information\n");
1419 else if (acpi_lapic)
1420 pr_info("Using ACPI for processor (LAPIC) configuration information\n");
1425 static int __init disable_acpi_irq(const struct dmi_system_id *d)
1428 pr_notice("%s detected: force use of acpi=noirq\n", d->ident);
1434 static int __init disable_acpi_pci(const struct dmi_system_id *d)
1437 pr_notice("%s detected: force use of pci=noacpi\n", d->ident);
1443 static int __init disable_acpi_xsdt(const struct dmi_system_id *d)
1446 pr_notice("%s detected: force use of acpi=rsdt\n", d->ident);
1447 acpi_gbl_do_not_use_xsdt = TRUE;
1449 pr_notice("Warning: DMI blacklist says broken, but acpi XSDT forced\n");
1454 static int __init dmi_disable_acpi(const struct dmi_system_id *d)
1457 pr_notice("%s detected: acpi off\n", d->ident);
1460 pr_notice("Warning: DMI blacklist says broken, but acpi forced\n");
1466 * Force ignoring BIOS IRQ0 override
1468 static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
1470 if (!acpi_skip_timer_override) {
1471 pr_notice("%s detected: Ignoring BIOS IRQ0 override\n",
1473 acpi_skip_timer_override = 1;
1479 * ACPI offers an alternative platform interface model that removes
1480 * ACPI hardware requirements for platforms that do not implement
1481 * the PC Architecture.
1483 * We initialize the Hardware-reduced ACPI model here:
1485 void __init acpi_generic_reduced_hw_init(void)
1488 * Override x86_init functions and bypass legacy PIC in
1489 * hardware reduced ACPI mode.
1491 x86_init.timers.timer_init = x86_init_noop;
1492 x86_init.irqs.pre_vector_init = x86_init_noop;
1493 legacy_pic = &null_legacy_pic;
1496 static void __init acpi_reduced_hw_init(void)
1498 if (acpi_gbl_reduced_hardware)
1499 x86_init.acpi.reduced_hw_early_init();
1503 * If your system is blacklisted here, but you find that acpi=force
1504 * works for you, please contact linux-acpi@vger.kernel.org
1506 static const struct dmi_system_id acpi_dmi_table[] __initconst = {
1508 * Boxes that need ACPI disabled
1511 .callback = dmi_disable_acpi,
1512 .ident = "IBM Thinkpad",
1514 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1515 DMI_MATCH(DMI_BOARD_NAME, "2629H1G"),
1520 * Boxes that need ACPI PCI IRQ routing disabled
1523 .callback = disable_acpi_irq,
1524 .ident = "ASUS A7V",
1526 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
1527 DMI_MATCH(DMI_BOARD_NAME, "<A7V>"),
1528 /* newer BIOS, Revision 1011, does work */
1529 DMI_MATCH(DMI_BIOS_VERSION,
1530 "ASUS A7V ACPI BIOS Revision 1007"),
1535 * Latest BIOS for IBM 600E (1.16) has bad pcinum
1536 * for LPC bridge, which is needed for the PCI
1537 * interrupt links to work. DSDT fix is in bug 5966.
1538 * 2645, 2646 model numbers are shared with 600/600E/600X
1540 .callback = disable_acpi_irq,
1541 .ident = "IBM Thinkpad 600 Series 2645",
1543 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1544 DMI_MATCH(DMI_BOARD_NAME, "2645"),
1548 .callback = disable_acpi_irq,
1549 .ident = "IBM Thinkpad 600 Series 2646",
1551 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1552 DMI_MATCH(DMI_BOARD_NAME, "2646"),
1556 * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
1559 .callback = disable_acpi_pci,
1560 .ident = "ASUS PR-DLS",
1562 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
1563 DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"),
1564 DMI_MATCH(DMI_BIOS_VERSION,
1565 "ASUS PR-DLS ACPI BIOS Revision 1010"),
1566 DMI_MATCH(DMI_BIOS_DATE, "03/21/2003")
1570 .callback = disable_acpi_pci,
1571 .ident = "Acer TravelMate 36x Laptop",
1573 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
1574 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
1578 * Boxes that need ACPI XSDT use disabled due to corrupted tables
1581 .callback = disable_acpi_xsdt,
1582 .ident = "Advantech DAC-BJ01",
1584 DMI_MATCH(DMI_SYS_VENDOR, "NEC"),
1585 DMI_MATCH(DMI_PRODUCT_NAME, "Bearlake CRB Board"),
1586 DMI_MATCH(DMI_BIOS_VERSION, "V1.12"),
1587 DMI_MATCH(DMI_BIOS_DATE, "02/01/2011"),
1593 /* second table for DMI checks that should run after early-quirks */
1594 static const struct dmi_system_id acpi_dmi_table_late[] __initconst = {
1596 * HP laptops which use a DSDT reporting as HP/SB400/10000,
1597 * which includes some code which overrides all temperature
1598 * trip points to 16C if the INTIN2 input of the I/O APIC
1599 * is enabled. This input is incorrectly designated the
1600 * ISA IRQ 0 via an interrupt source override even though
1601 * it is wired to the output of the master 8259A and INTIN0
1602 * is not connected at all. Force ignoring BIOS IRQ0
1603 * override in that cases.
1606 .callback = dmi_ignore_irq0_timer_override,
1607 .ident = "HP nx6115 laptop",
1609 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1610 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6115"),
1614 .callback = dmi_ignore_irq0_timer_override,
1615 .ident = "HP NX6125 laptop",
1617 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1618 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6125"),
1622 .callback = dmi_ignore_irq0_timer_override,
1623 .ident = "HP NX6325 laptop",
1625 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1626 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6325"),
1630 .callback = dmi_ignore_irq0_timer_override,
1631 .ident = "HP 6715b laptop",
1633 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1634 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq 6715b"),
1638 .callback = dmi_ignore_irq0_timer_override,
1639 .ident = "FUJITSU SIEMENS",
1641 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
1642 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO PRO V2030"),
1649 * acpi_boot_table_init() and acpi_boot_init()
1650 * called from setup_arch(), always.
1651 * 1. checksums all tables
1652 * 2. enumerates lapics
1653 * 3. enumerates io-apics
1655 * acpi_table_init() is separate to allow reading SRAT without
1656 * other side effects.
1658 * side effects of acpi_boot_init:
1659 * acpi_lapic = 1 if LAPIC found
1660 * acpi_ioapic = 1 if IOAPIC found
1661 * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
1662 * if acpi_blacklisted() acpi_disabled = 1;
1663 * acpi_irq_model=...
1667 void __init acpi_boot_table_init(void)
1669 dmi_check_system(acpi_dmi_table);
1672 * If acpi_disabled, bail out
1678 * Initialize the ACPI boot-time table parser.
1680 if (acpi_locate_initial_tables())
1683 acpi_reserve_initial_tables();
1686 int __init early_acpi_boot_init(void)
1691 acpi_table_init_complete();
1693 acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
1696 * blacklist may disable ACPI entirely
1698 if (acpi_blacklisted()) {
1700 pr_warn("acpi=force override\n");
1702 pr_warn("Disabling ACPI support\n");
1709 * Process the Multiple APIC Description Table (MADT), if present
1711 early_acpi_process_madt();
1714 * Hardware-reduced ACPI mode initialization:
1716 acpi_reduced_hw_init();
1721 int __init acpi_boot_init(void)
1723 /* those are executed after early-quirks are executed */
1724 dmi_check_system(acpi_dmi_table_late);
1727 * If acpi_disabled, bail out
1732 acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
1735 * set sci_int and PM timer address
1737 acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt);
1740 * Process the Multiple APIC Description Table (MADT), if present
1742 acpi_process_madt();
1744 acpi_table_parse(ACPI_SIG_HPET, acpi_parse_hpet);
1745 if (IS_ENABLED(CONFIG_ACPI_BGRT) && !acpi_nobgrt)
1746 acpi_table_parse(ACPI_SIG_BGRT, acpi_parse_bgrt);
1749 x86_init.pci.init = pci_acpi_init;
1751 /* Do not enable ACPI SPCR console by default */
1752 acpi_parse_spcr(earlycon_acpi_spcr_enable, false);
1756 static int __init parse_acpi(char *arg)
1761 /* "acpi=off" disables both ACPI table parsing and interpreter */
1762 if (strcmp(arg, "off") == 0) {
1765 /* acpi=force to over-ride black-list */
1766 else if (strcmp(arg, "force") == 0) {
1770 /* acpi=strict disables out-of-spec workarounds */
1771 else if (strcmp(arg, "strict") == 0) {
1774 /* acpi=rsdt use RSDT instead of XSDT */
1775 else if (strcmp(arg, "rsdt") == 0) {
1776 acpi_gbl_do_not_use_xsdt = TRUE;
1778 /* "acpi=noirq" disables ACPI interrupt routing */
1779 else if (strcmp(arg, "noirq") == 0) {
1782 /* "acpi=copy_dsdt" copies DSDT */
1783 else if (strcmp(arg, "copy_dsdt") == 0) {
1784 acpi_gbl_copy_dsdt_locally = 1;
1786 /* "acpi=nocmcff" disables FF mode for corrected errors */
1787 else if (strcmp(arg, "nocmcff") == 0) {
1788 acpi_disable_cmcff = 1;
1790 /* Core will printk when we return error. */
1795 early_param("acpi", parse_acpi);
1797 static int __init parse_acpi_bgrt(char *arg)
1802 early_param("bgrt_disable", parse_acpi_bgrt);
1804 /* FIXME: Using pci= for an ACPI parameter is a travesty. */
1805 static int __init parse_pci(char *arg)
1807 if (arg && strcmp(arg, "noacpi") == 0)
1811 early_param("pci", parse_pci);
1813 int __init acpi_mps_check(void)
1815 #if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_X86_MPPARSE)
1816 /* mptable code is not built-in*/
1817 if (acpi_disabled || acpi_noirq) {
1818 pr_warn("MPS support code is not built-in, using acpi=off or acpi=noirq or pci=noacpi may have problem\n");
1825 #ifdef CONFIG_X86_IO_APIC
1826 static int __init parse_acpi_skip_timer_override(char *arg)
1828 acpi_skip_timer_override = 1;
1831 early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override);
1833 static int __init parse_acpi_use_timer_override(char *arg)
1835 acpi_use_timer_override = 1;
1838 early_param("acpi_use_timer_override", parse_acpi_use_timer_override);
1839 #endif /* CONFIG_X86_IO_APIC */
1841 static int __init setup_acpi_sci(char *s)
1845 if (!strcmp(s, "edge"))
1846 acpi_sci_flags = ACPI_MADT_TRIGGER_EDGE |
1847 (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
1848 else if (!strcmp(s, "level"))
1849 acpi_sci_flags = ACPI_MADT_TRIGGER_LEVEL |
1850 (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
1851 else if (!strcmp(s, "high"))
1852 acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_HIGH |
1853 (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
1854 else if (!strcmp(s, "low"))
1855 acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_LOW |
1856 (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
1861 early_param("acpi_sci", setup_acpi_sci);
1863 int __acpi_acquire_global_lock(unsigned int *lock)
1865 unsigned int old, new, val;
1867 old = READ_ONCE(*lock);
1869 val = (old >> 1) & 0x1;
1870 new = (old & ~0x3) + 2 + val;
1871 } while (!try_cmpxchg(lock, &old, new));
1879 int __acpi_release_global_lock(unsigned int *lock)
1881 unsigned int old, new;
1883 old = READ_ONCE(*lock);
1886 } while (!try_cmpxchg(lock, &old, new));
1890 void __init arch_reserve_mem_area(acpi_physical_address addr, size_t size)
1892 e820__range_add(addr, size, E820_TYPE_NVS);
1893 e820__update_table_print();
1896 void x86_default_set_root_pointer(u64 addr)
1898 boot_params.acpi_rsdp_addr = addr;
1901 u64 x86_default_get_root_pointer(void)
1903 return boot_params.acpi_rsdp_addr;