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