Thomas Gleixner | 1a59d1b8 | 2019-05-27 08:55:05 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * acpi.c - Architecture-Specific Low-Level ACPI Support |
| 4 | * |
| 5 | * Copyright (C) 1999 VA Linux Systems |
| 6 | * Copyright (C) 1999,2000 Walt Drummond <drummond@valinux.com> |
| 7 | * Copyright (C) 2000, 2002-2003 Hewlett-Packard Co. |
| 8 | * David Mosberger-Tang <davidm@hpl.hp.com> |
| 9 | * Copyright (C) 2000 Intel Corp. |
| 10 | * Copyright (C) 2000,2001 J.I. Lee <jung-ik.lee@intel.com> |
| 11 | * Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> |
| 12 | * Copyright (C) 2001 Jenna Hall <jenna.s.hall@intel.com> |
| 13 | * Copyright (C) 2001 Takayoshi Kochi <t-kochi@bq.jp.nec.com> |
| 14 | * Copyright (C) 2002 Erich Focht <efocht@ess.nec.de> |
Ashok Raj | 55e59c5 | 2005-03-31 22:51:10 -0500 | [diff] [blame] | 15 | * Copyright (C) 2004 Ashok Raj <ashok.raj@intel.com> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | */ |
| 17 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <linux/module.h> |
| 19 | #include <linux/init.h> |
| 20 | #include <linux/kernel.h> |
| 21 | #include <linux/sched.h> |
| 22 | #include <linux/smp.h> |
| 23 | #include <linux/string.h> |
| 24 | #include <linux/types.h> |
| 25 | #include <linux/irq.h> |
| 26 | #include <linux/acpi.h> |
| 27 | #include <linux/efi.h> |
| 28 | #include <linux/mmzone.h> |
| 29 | #include <linux/nodemask.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 30 | #include <linux/slab.h> |
Alex Chiang | d8191fa | 2010-02-22 12:11:39 -0700 | [diff] [blame] | 31 | #include <acpi/processor.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <asm/io.h> |
| 33 | #include <asm/iosapic.h> |
| 34 | #include <asm/machvec.h> |
| 35 | #include <asm/page.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #include <asm/numa.h> |
| 37 | #include <asm/sal.h> |
| 38 | #include <asm/cyclone.h> |
| 39 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | #define PREFIX "ACPI: " |
| 41 | |
Baoquan He | 247dba5 | 2014-05-05 12:48:25 +0800 | [diff] [blame] | 42 | int acpi_lapic; |
Ashok Raj | 55e59c5 | 2005-03-31 22:51:10 -0500 | [diff] [blame] | 43 | unsigned int acpi_cpei_override; |
| 44 | unsigned int acpi_cpei_phys_cpuid; |
| 45 | |
Len Brown | e8b2fd0 | 2007-07-24 22:26:33 -0400 | [diff] [blame] | 46 | unsigned long acpi_wakeup_address = 0; |
| 47 | |
Len Brown | 239665a | 2007-11-23 20:08:02 -0500 | [diff] [blame] | 48 | #ifdef CONFIG_IA64_GENERIC |
| 49 | static unsigned long __init acpi_find_rsdp(void) |
| 50 | { |
| 51 | unsigned long rsdp_phys = 0; |
| 52 | |
| 53 | if (efi.acpi20 != EFI_INVALID_TABLE_ADDR) |
| 54 | rsdp_phys = efi.acpi20; |
| 55 | else if (efi.acpi != EFI_INVALID_TABLE_ADDR) |
| 56 | printk(KERN_WARNING PREFIX |
| 57 | "v1.0/r0.71 tables no longer supported\n"); |
| 58 | return rsdp_phys; |
| 59 | } |
Len Brown | 239665a | 2007-11-23 20:08:02 -0500 | [diff] [blame] | 60 | |
Tony Luck | d57c4a3 | 2007-05-24 10:59:44 -0700 | [diff] [blame] | 61 | const char __init * |
| 62 | acpi_get_sysname(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | unsigned long rsdp_phys; |
Alexey Starikovskiy | ad71860a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 65 | struct acpi_table_rsdp *rsdp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | struct acpi_table_xsdt *xsdt; |
| 67 | struct acpi_table_header *hdr; |
Suresh Siddha | d3f1381 | 2011-08-23 17:05:25 -0700 | [diff] [blame] | 68 | #ifdef CONFIG_INTEL_IOMMU |
Fenghua Yu | 62fdd76 | 2008-10-17 12:14:13 -0700 | [diff] [blame] | 69 | u64 i, nentries; |
| 70 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | |
| 72 | rsdp_phys = acpi_find_rsdp(); |
| 73 | if (!rsdp_phys) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 74 | printk(KERN_ERR |
| 75 | "ACPI 2.0 RSDP not found, default to \"dig\"\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | return "dig"; |
| 77 | } |
| 78 | |
Alexey Starikovskiy | ad71860a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 79 | rsdp = (struct acpi_table_rsdp *)__va(rsdp_phys); |
| 80 | if (strncmp(rsdp->signature, ACPI_SIG_RSDP, sizeof(ACPI_SIG_RSDP) - 1)) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 81 | printk(KERN_ERR |
| 82 | "ACPI 2.0 RSDP signature incorrect, default to \"dig\"\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | return "dig"; |
| 84 | } |
| 85 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 86 | xsdt = (struct acpi_table_xsdt *)__va(rsdp->xsdt_physical_address); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | hdr = &xsdt->header; |
Alexey Starikovskiy | ad71860a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 88 | if (strncmp(hdr->signature, ACPI_SIG_XSDT, sizeof(ACPI_SIG_XSDT) - 1)) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 89 | printk(KERN_ERR |
| 90 | "ACPI 2.0 XSDT signature incorrect, default to \"dig\"\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | return "dig"; |
| 92 | } |
| 93 | |
| 94 | if (!strcmp(hdr->oem_id, "HP")) { |
| 95 | return "hpzx1"; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 96 | } else if (!strcmp(hdr->oem_id, "SGI")) { |
Jack Steiner | 2224661 | 2008-05-06 15:18:57 -0500 | [diff] [blame] | 97 | if (!strcmp(hdr->oem_table_id + 4, "UV")) |
| 98 | return "uv"; |
| 99 | else |
| 100 | return "sn2"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | } |
| 102 | |
Suresh Siddha | d3f1381 | 2011-08-23 17:05:25 -0700 | [diff] [blame] | 103 | #ifdef CONFIG_INTEL_IOMMU |
Fenghua Yu | 62fdd76 | 2008-10-17 12:14:13 -0700 | [diff] [blame] | 104 | /* Look for Intel IOMMU */ |
| 105 | nentries = (hdr->length - sizeof(*hdr)) / |
| 106 | sizeof(xsdt->table_offset_entry[0]); |
| 107 | for (i = 0; i < nentries; i++) { |
| 108 | hdr = __va(xsdt->table_offset_entry[i]); |
| 109 | if (strncmp(hdr->signature, ACPI_SIG_DMAR, |
| 110 | sizeof(ACPI_SIG_DMAR) - 1) == 0) |
| 111 | return "dig_vtd"; |
| 112 | } |
| 113 | #endif |
| 114 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | return "dig"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | } |
Alex Chiang | d868080 | 2010-02-25 14:09:52 -0700 | [diff] [blame] | 117 | #endif /* CONFIG_IA64_GENERIC */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | |
| 119 | #define ACPI_MAX_PLATFORM_INTERRUPTS 256 |
| 120 | |
| 121 | /* Array to record platform interrupt vectors for generic interrupt routing. */ |
| 122 | int platform_intr_list[ACPI_MAX_PLATFORM_INTERRUPTS] = { |
| 123 | [0 ... ACPI_MAX_PLATFORM_INTERRUPTS - 1] = -1 |
| 124 | }; |
| 125 | |
| 126 | enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_IOSAPIC; |
| 127 | |
| 128 | /* |
| 129 | * Interrupt routing API for device drivers. Provides interrupt vector for |
| 130 | * a generic platform event. Currently only CPEI is implemented. |
| 131 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 132 | int acpi_request_vector(u32 int_type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | { |
| 134 | int vector = -1; |
| 135 | |
| 136 | if (int_type < ACPI_MAX_PLATFORM_INTERRUPTS) { |
| 137 | /* corrected platform error interrupt */ |
| 138 | vector = platform_intr_list[int_type]; |
| 139 | } else |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 140 | printk(KERN_ERR |
| 141 | "acpi_request_vector(): invalid interrupt type\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | return vector; |
| 143 | } |
| 144 | |
Andy Shevchenko | 6c9a58e | 2017-07-18 18:04:17 +0300 | [diff] [blame] | 145 | void __init __iomem *__acpi_map_table(unsigned long phys, unsigned long size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | { |
Andy Shevchenko | 6c9a58e | 2017-07-18 18:04:17 +0300 | [diff] [blame] | 147 | return __va(phys); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | } |
| 149 | |
Andy Shevchenko | 6c9a58e | 2017-07-18 18:04:17 +0300 | [diff] [blame] | 150 | void __init __acpi_unmap_table(void __iomem *map, unsigned long size) |
Yinghai Lu | 7d97277 | 2009-02-07 15:39:41 -0800 | [diff] [blame] | 151 | { |
| 152 | } |
| 153 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | /* -------------------------------------------------------------------------- |
| 155 | Boot-time Table Parsing |
| 156 | -------------------------------------------------------------------------- */ |
| 157 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 158 | static int available_cpus __initdata; |
| 159 | struct acpi_table_madt *acpi_madt __initdata; |
| 160 | static u8 has_8259; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | |
| 162 | static int __init |
Keith Busch | 60574d1 | 2019-03-11 14:55:57 -0600 | [diff] [blame] | 163 | acpi_parse_lapic_addr_ovr(union acpi_subtable_headers * header, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 164 | const unsigned long end) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | { |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 166 | struct acpi_madt_local_apic_override *lapic; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 168 | lapic = (struct acpi_madt_local_apic_override *)header; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | |
| 170 | if (BAD_MADT_ENTRY(lapic, end)) |
| 171 | return -EINVAL; |
| 172 | |
| 173 | if (lapic->address) { |
| 174 | iounmap(ipi_base_addr); |
| 175 | ipi_base_addr = ioremap(lapic->address, 0); |
| 176 | } |
| 177 | return 0; |
| 178 | } |
| 179 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | static int __init |
Keith Busch | 60574d1 | 2019-03-11 14:55:57 -0600 | [diff] [blame] | 181 | acpi_parse_lsapic(union acpi_subtable_headers *header, const unsigned long end) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | { |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 183 | struct acpi_madt_local_sapic *lsapic; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 185 | lsapic = (struct acpi_madt_local_sapic *)header; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 187 | /*Skip BAD_MADT_ENTRY check, as lsapic size could vary */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 189 | if (lsapic->lapic_flags & ACPI_MADT_ENABLED) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | #ifdef CONFIG_SMP |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 191 | smp_boot_data.cpu_phys_id[available_cpus] = |
| 192 | (lsapic->id << 8) | lsapic->eid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | ++available_cpus; |
| 195 | } |
| 196 | |
| 197 | total_cpus++; |
| 198 | return 0; |
| 199 | } |
| 200 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | static int __init |
Keith Busch | 60574d1 | 2019-03-11 14:55:57 -0600 | [diff] [blame] | 202 | acpi_parse_lapic_nmi(union acpi_subtable_headers * header, const unsigned long end) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | { |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 204 | struct acpi_madt_local_apic_nmi *lacpi_nmi; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 206 | lacpi_nmi = (struct acpi_madt_local_apic_nmi *)header; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | |
| 208 | if (BAD_MADT_ENTRY(lacpi_nmi, end)) |
| 209 | return -EINVAL; |
| 210 | |
| 211 | /* TBD: Support lapic_nmi entries */ |
| 212 | return 0; |
| 213 | } |
| 214 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | static int __init |
Keith Busch | 60574d1 | 2019-03-11 14:55:57 -0600 | [diff] [blame] | 216 | acpi_parse_iosapic(union acpi_subtable_headers * header, const unsigned long end) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | { |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 218 | struct acpi_madt_io_sapic *iosapic; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 220 | iosapic = (struct acpi_madt_io_sapic *)header; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | |
| 222 | if (BAD_MADT_ENTRY(iosapic, end)) |
| 223 | return -EINVAL; |
| 224 | |
Kenji Kaneshige | 0e888ad | 2005-04-28 00:25:58 -0700 | [diff] [blame] | 225 | return iosapic_init(iosapic->address, iosapic->global_irq_base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | } |
| 227 | |
Len Brown | 5810452 | 2006-05-13 01:12:15 -0400 | [diff] [blame] | 228 | static unsigned int __initdata acpi_madt_rev; |
| 229 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | static int __init |
Keith Busch | 60574d1 | 2019-03-11 14:55:57 -0600 | [diff] [blame] | 231 | acpi_parse_plat_int_src(union acpi_subtable_headers * header, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 232 | const unsigned long end) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | { |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 234 | struct acpi_madt_interrupt_source *plintsrc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | int vector; |
| 236 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 237 | plintsrc = (struct acpi_madt_interrupt_source *)header; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | |
| 239 | if (BAD_MADT_ENTRY(plintsrc, end)) |
| 240 | return -EINVAL; |
| 241 | |
| 242 | /* |
| 243 | * Get vector assignment for this interrupt, set attributes, |
| 244 | * and program the IOSAPIC routing table. |
| 245 | */ |
| 246 | vector = iosapic_register_platform_intr(plintsrc->type, |
| 247 | plintsrc->global_irq, |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 248 | plintsrc->io_sapic_vector, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | plintsrc->eid, |
| 250 | plintsrc->id, |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 251 | ((plintsrc->inti_flags & ACPI_MADT_POLARITY_MASK) == |
| 252 | ACPI_MADT_POLARITY_ACTIVE_HIGH) ? |
| 253 | IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW, |
| 254 | ((plintsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) == |
| 255 | ACPI_MADT_TRIGGER_EDGE) ? |
| 256 | IOSAPIC_EDGE : IOSAPIC_LEVEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | |
| 258 | platform_intr_list[plintsrc->type] = vector; |
Ashok Raj | 55e59c5 | 2005-03-31 22:51:10 -0500 | [diff] [blame] | 259 | if (acpi_madt_rev > 1) { |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 260 | acpi_cpei_override = plintsrc->flags & ACPI_MADT_CPEI_OVERRIDE; |
Ashok Raj | 55e59c5 | 2005-03-31 22:51:10 -0500 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | /* |
| 264 | * Save the physical id, so we can check when its being removed |
| 265 | */ |
| 266 | acpi_cpei_phys_cpuid = ((plintsrc->id << 8) | (plintsrc->eid)) & 0xffff; |
| 267 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | return 0; |
| 269 | } |
| 270 | |
Ashok Raj | b88e926 | 2006-01-19 16:18:47 -0800 | [diff] [blame] | 271 | #ifdef CONFIG_HOTPLUG_CPU |
Ashok Raj | 55e59c5 | 2005-03-31 22:51:10 -0500 | [diff] [blame] | 272 | unsigned int can_cpei_retarget(void) |
| 273 | { |
| 274 | extern int cpe_vector; |
Ashok Raj | ff74190 | 2005-11-11 14:32:40 -0800 | [diff] [blame] | 275 | extern unsigned int force_cpei_retarget; |
Ashok Raj | 55e59c5 | 2005-03-31 22:51:10 -0500 | [diff] [blame] | 276 | |
| 277 | /* |
| 278 | * Only if CPEI is supported and the override flag |
| 279 | * is present, otherwise return that its re-targettable |
| 280 | * if we are in polling mode. |
| 281 | */ |
Ashok Raj | ff74190 | 2005-11-11 14:32:40 -0800 | [diff] [blame] | 282 | if (cpe_vector > 0) { |
| 283 | if (acpi_cpei_override || force_cpei_retarget) |
| 284 | return 1; |
| 285 | else |
| 286 | return 0; |
| 287 | } |
| 288 | return 1; |
Ashok Raj | 55e59c5 | 2005-03-31 22:51:10 -0500 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | unsigned int is_cpu_cpei_target(unsigned int cpu) |
| 292 | { |
| 293 | unsigned int logical_id; |
| 294 | |
| 295 | logical_id = cpu_logical_id(acpi_cpei_phys_cpuid); |
| 296 | |
| 297 | if (logical_id == cpu) |
| 298 | return 1; |
| 299 | else |
| 300 | return 0; |
| 301 | } |
| 302 | |
| 303 | void set_cpei_target_cpu(unsigned int cpu) |
| 304 | { |
| 305 | acpi_cpei_phys_cpuid = cpu_physical_id(cpu); |
| 306 | } |
Ashok Raj | b88e926 | 2006-01-19 16:18:47 -0800 | [diff] [blame] | 307 | #endif |
Ashok Raj | 55e59c5 | 2005-03-31 22:51:10 -0500 | [diff] [blame] | 308 | |
| 309 | unsigned int get_cpei_target_cpu(void) |
| 310 | { |
| 311 | return acpi_cpei_phys_cpuid; |
| 312 | } |
| 313 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | static int __init |
Keith Busch | 60574d1 | 2019-03-11 14:55:57 -0600 | [diff] [blame] | 315 | acpi_parse_int_src_ovr(union acpi_subtable_headers * header, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 316 | const unsigned long end) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | { |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 318 | struct acpi_madt_interrupt_override *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 320 | p = (struct acpi_madt_interrupt_override *)header; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | |
| 322 | if (BAD_MADT_ENTRY(p, end)) |
| 323 | return -EINVAL; |
| 324 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 325 | iosapic_override_isa_irq(p->source_irq, p->global_irq, |
| 326 | ((p->inti_flags & ACPI_MADT_POLARITY_MASK) == |
Liu Jiang | 0577bb6 | 2012-03-13 22:07:09 +0800 | [diff] [blame] | 327 | ACPI_MADT_POLARITY_ACTIVE_LOW) ? |
| 328 | IOSAPIC_POL_LOW : IOSAPIC_POL_HIGH, |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 329 | ((p->inti_flags & ACPI_MADT_TRIGGER_MASK) == |
Liu Jiang | 0577bb6 | 2012-03-13 22:07:09 +0800 | [diff] [blame] | 330 | ACPI_MADT_TRIGGER_LEVEL) ? |
| 331 | IOSAPIC_LEVEL : IOSAPIC_EDGE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | return 0; |
| 333 | } |
| 334 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | static int __init |
Keith Busch | 60574d1 | 2019-03-11 14:55:57 -0600 | [diff] [blame] | 336 | acpi_parse_nmi_src(union acpi_subtable_headers * header, const unsigned long end) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | { |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 338 | struct acpi_madt_nmi_source *nmi_src; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 340 | nmi_src = (struct acpi_madt_nmi_source *)header; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | |
| 342 | if (BAD_MADT_ENTRY(nmi_src, end)) |
| 343 | return -EINVAL; |
| 344 | |
| 345 | /* TBD: Support nimsrc entries */ |
| 346 | return 0; |
| 347 | } |
| 348 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 349 | static void __init acpi_madt_oem_check(char *oem_id, char *oem_table_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 351 | if (!strncmp(oem_id, "IBM", 3) && (!strncmp(oem_table_id, "SERMOW", 6))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | |
| 353 | /* |
| 354 | * Unfortunately ITC_DRIFT is not yet part of the |
| 355 | * official SAL spec, so the ITC_DRIFT bit is not |
| 356 | * set by the BIOS on this hardware. |
| 357 | */ |
| 358 | sal_platform_features |= IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT; |
| 359 | |
| 360 | cyclone_setup(); |
| 361 | } |
| 362 | } |
| 363 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 364 | static int __init acpi_parse_madt(struct acpi_table_header *table) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | { |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 366 | acpi_madt = (struct acpi_table_madt *)table; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | |
Ashok Raj | 55e59c5 | 2005-03-31 22:51:10 -0500 | [diff] [blame] | 368 | acpi_madt_rev = acpi_madt->header.revision; |
| 369 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | /* remember the value for reference after free_initmem() */ |
| 371 | #ifdef CONFIG_ITANIUM |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 372 | has_8259 = 1; /* Firmware on old Itanium systems is broken */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | #else |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 374 | has_8259 = acpi_madt->flags & ACPI_MADT_PCAT_COMPAT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | #endif |
| 376 | iosapic_system_init(has_8259); |
| 377 | |
| 378 | /* Get base address of IPI Message Block */ |
| 379 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 380 | if (acpi_madt->address) |
| 381 | ipi_base_addr = ioremap(acpi_madt->address, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 382 | |
| 383 | printk(KERN_INFO PREFIX "Local APIC address %p\n", ipi_base_addr); |
| 384 | |
| 385 | acpi_madt_oem_check(acpi_madt->header.oem_id, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 386 | acpi_madt->header.oem_table_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | |
| 388 | return 0; |
| 389 | } |
| 390 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | #ifdef CONFIG_ACPI_NUMA |
| 392 | |
| 393 | #undef SLIT_DEBUG |
| 394 | |
| 395 | #define PXM_FLAG_LEN ((MAX_PXM_DOMAINS + 1)/32) |
| 396 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 397 | static int __initdata srat_num_cpus; /* number of cpus */ |
Greg Kroah-Hartman | 5b5e76e | 2012-12-21 14:05:13 -0800 | [diff] [blame] | 398 | static u32 pxm_flag[PXM_FLAG_LEN]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | #define pxm_bit_set(bit) (set_bit(bit,(void *)pxm_flag)) |
| 400 | #define pxm_bit_test(bit) (test_bit(bit,(void *)pxm_flag)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | static struct acpi_table_slit __initdata *slit_table; |
holt@sgi.com | 2c6e6db | 2008-04-03 15:17:13 -0500 | [diff] [blame] | 402 | cpumask_t early_cpu_possible_map = CPU_MASK_NONE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | |
Kurt Garloff | 9f10f6a | 2012-01-17 04:21:49 -0500 | [diff] [blame] | 404 | static int __init |
| 405 | get_processor_proximity_domain(struct acpi_srat_cpu_affinity *pa) |
Jack Steiner | 3ad5ef8 | 2006-03-02 16:02:25 -0600 | [diff] [blame] | 406 | { |
| 407 | int pxm; |
| 408 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 409 | pxm = pa->proximity_domain_lo; |
Kurt Garloff | 9f10f6a | 2012-01-17 04:21:49 -0500 | [diff] [blame] | 410 | if (ia64_platform_is("sn2") || acpi_srat_revision >= 2) |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 411 | pxm += pa->proximity_domain_hi[0] << 8; |
Jack Steiner | 3ad5ef8 | 2006-03-02 16:02:25 -0600 | [diff] [blame] | 412 | return pxm; |
| 413 | } |
| 414 | |
Kurt Garloff | 9f10f6a | 2012-01-17 04:21:49 -0500 | [diff] [blame] | 415 | static int __init |
| 416 | get_memory_proximity_domain(struct acpi_srat_mem_affinity *ma) |
Jack Steiner | 3ad5ef8 | 2006-03-02 16:02:25 -0600 | [diff] [blame] | 417 | { |
| 418 | int pxm; |
| 419 | |
| 420 | pxm = ma->proximity_domain; |
Kurt Garloff | 9f10f6a | 2012-01-17 04:21:49 -0500 | [diff] [blame] | 421 | if (!ia64_platform_is("sn2") && acpi_srat_revision <= 1) |
Alexey Starikovskiy | defad23 | 2007-02-02 22:02:55 -0500 | [diff] [blame] | 422 | pxm &= 0xff; |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 423 | |
Jack Steiner | 3ad5ef8 | 2006-03-02 16:02:25 -0600 | [diff] [blame] | 424 | return pxm; |
| 425 | } |
| 426 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | /* |
| 428 | * ACPI 2.0 SLIT (System Locality Information Table) |
| 429 | * http://devresource.hp.com/devresource/Docs/TechPapers/IA64/slit.pdf |
| 430 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 431 | void __init acpi_numa_slit_init(struct acpi_table_slit *slit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | { |
| 433 | u32 len; |
| 434 | |
| 435 | len = sizeof(struct acpi_table_header) + 8 |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 436 | + slit->locality_count * slit->locality_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | if (slit->header.length != len) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 438 | printk(KERN_ERR |
| 439 | "ACPI 2.0 SLIT: size mismatch: %d expected, %d actual\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | len, slit->header.length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | return; |
| 442 | } |
| 443 | slit_table = slit; |
| 444 | } |
| 445 | |
| 446 | void __init |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 447 | acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | { |
Jack Steiner | 3ad5ef8 | 2006-03-02 16:02:25 -0600 | [diff] [blame] | 449 | int pxm; |
| 450 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 451 | if (!(pa->flags & ACPI_SRAT_CPU_ENABLED)) |
Kenji Kaneshige | d903cea | 2006-03-15 14:45:11 +0900 | [diff] [blame] | 452 | return; |
| 453 | |
Tony Luck | 05f2f27 | 2011-01-07 09:11:55 -0800 | [diff] [blame] | 454 | if (srat_num_cpus >= ARRAY_SIZE(node_cpuid)) { |
| 455 | printk_once(KERN_WARNING |
Tony Luck | dff0092 | 2011-01-12 11:02:43 -0800 | [diff] [blame] | 456 | "node_cpuid[%ld] is too small, may not be able to use all cpus\n", |
Tony Luck | 05f2f27 | 2011-01-07 09:11:55 -0800 | [diff] [blame] | 457 | ARRAY_SIZE(node_cpuid)); |
| 458 | return; |
| 459 | } |
Jack Steiner | 3ad5ef8 | 2006-03-02 16:02:25 -0600 | [diff] [blame] | 460 | pxm = get_processor_proximity_domain(pa); |
| 461 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | /* record this node in proximity bitmap */ |
Jack Steiner | 3ad5ef8 | 2006-03-02 16:02:25 -0600 | [diff] [blame] | 463 | pxm_bit_set(pxm); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 465 | node_cpuid[srat_num_cpus].phys_id = |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 466 | (pa->apic_id << 8) | (pa->local_sapic_eid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | /* nid should be overridden as logical node id later */ |
Jack Steiner | 3ad5ef8 | 2006-03-02 16:02:25 -0600 | [diff] [blame] | 468 | node_cpuid[srat_num_cpus].nid = pxm; |
Rusty Russell | 5d2068d | 2015-03-05 10:49:16 +1030 | [diff] [blame] | 469 | cpumask_set_cpu(srat_num_cpus, &early_cpu_possible_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | srat_num_cpus++; |
| 471 | } |
| 472 | |
Thomas Renninger | 095adbb | 2012-07-31 17:41:09 +0200 | [diff] [blame] | 473 | int __init |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 474 | acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | { |
| 476 | unsigned long paddr, size; |
Jack Steiner | 3ad5ef8 | 2006-03-02 16:02:25 -0600 | [diff] [blame] | 477 | int pxm; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | struct node_memblk_s *p, *q, *pend; |
| 479 | |
Jack Steiner | 3ad5ef8 | 2006-03-02 16:02:25 -0600 | [diff] [blame] | 480 | pxm = get_memory_proximity_domain(ma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | |
| 482 | /* fill node memory chunk structure */ |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 483 | paddr = ma->base_address; |
| 484 | size = ma->length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | |
| 486 | /* Ignore disabled entries */ |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 487 | if (!(ma->flags & ACPI_SRAT_MEM_ENABLED)) |
Thomas Renninger | 095adbb | 2012-07-31 17:41:09 +0200 | [diff] [blame] | 488 | return -1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | |
Ganapatrao Kulkarni | fd3e454 | 2017-11-15 22:59:02 +0530 | [diff] [blame] | 490 | if (num_node_memblks >= NR_NODE_MEMBLKS) { |
| 491 | pr_err("NUMA: too many memblk ranges\n"); |
| 492 | return -EINVAL; |
| 493 | } |
| 494 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 495 | /* record this node in proximity bitmap */ |
| 496 | pxm_bit_set(pxm); |
| 497 | |
| 498 | /* Insertion sort based on base address */ |
| 499 | pend = &node_memblk[num_node_memblks]; |
| 500 | for (p = &node_memblk[0]; p < pend; p++) { |
| 501 | if (paddr < p->start_paddr) |
| 502 | break; |
| 503 | } |
| 504 | if (p < pend) { |
| 505 | for (q = pend - 1; q >= p; q--) |
| 506 | *(q + 1) = *q; |
| 507 | } |
| 508 | p->start_paddr = paddr; |
| 509 | p->size = size; |
| 510 | p->nid = pxm; |
| 511 | num_node_memblks++; |
Thomas Renninger | 095adbb | 2012-07-31 17:41:09 +0200 | [diff] [blame] | 512 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | } |
| 514 | |
Robert Richter | 312521d | 2016-05-24 15:35:34 -0700 | [diff] [blame] | 515 | void __init acpi_numa_fixup(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | { |
| 517 | int i, j, node_from, node_to; |
| 518 | |
| 519 | /* If there's no SRAT, fix the phys_id and mark node 0 online */ |
| 520 | if (srat_num_cpus == 0) { |
| 521 | node_set_online(0); |
| 522 | node_cpuid[0].phys_id = hard_smp_processor_id(); |
| 523 | return; |
| 524 | } |
| 525 | |
| 526 | /* |
| 527 | * MCD - This can probably be dropped now. No need for pxm ID to node ID |
| 528 | * mapping with sparse node numbering iff MAX_PXM_DOMAINS <= MAX_NUMNODES. |
| 529 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 530 | nodes_clear(node_online_map); |
| 531 | for (i = 0; i < MAX_PXM_DOMAINS; i++) { |
| 532 | if (pxm_bit_test(i)) { |
Yasunori Goto | 762834e | 2006-06-23 02:03:19 -0700 | [diff] [blame] | 533 | int nid = acpi_map_pxm_to_node(i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | node_set_online(nid); |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | /* set logical node id in memory chunk structure */ |
| 539 | for (i = 0; i < num_node_memblks; i++) |
Yasunori Goto | 762834e | 2006-06-23 02:03:19 -0700 | [diff] [blame] | 540 | node_memblk[i].nid = pxm_to_node(node_memblk[i].nid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | |
| 542 | /* assign memory bank numbers for each chunk on each node */ |
| 543 | for_each_online_node(i) { |
| 544 | int bank; |
| 545 | |
| 546 | bank = 0; |
| 547 | for (j = 0; j < num_node_memblks; j++) |
| 548 | if (node_memblk[j].nid == i) |
| 549 | node_memblk[j].bank = bank++; |
| 550 | } |
| 551 | |
| 552 | /* set logical node id in cpu structure */ |
holt@sgi.com | 2c6e6db | 2008-04-03 15:17:13 -0500 | [diff] [blame] | 553 | for_each_possible_early_cpu(i) |
Yasunori Goto | 762834e | 2006-06-23 02:03:19 -0700 | [diff] [blame] | 554 | node_cpuid[i].nid = pxm_to_node(node_cpuid[i].nid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 556 | printk(KERN_INFO "Number of logical nodes in system = %d\n", |
| 557 | num_online_nodes()); |
| 558 | printk(KERN_INFO "Number of memory chunks in system = %d\n", |
| 559 | num_node_memblks); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | |
Fenghua Yu | 39b8931 | 2008-06-09 16:48:18 -0700 | [diff] [blame] | 561 | if (!slit_table) { |
| 562 | for (i = 0; i < MAX_NUMNODES; i++) |
| 563 | for (j = 0; j < MAX_NUMNODES; j++) |
Matias Bjørling | ef78e5e | 2018-11-26 11:27:03 -0800 | [diff] [blame] | 564 | slit_distance(i, j) = i == j ? |
| 565 | LOCAL_DISTANCE : REMOTE_DISTANCE; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 566 | return; |
Fenghua Yu | 39b8931 | 2008-06-09 16:48:18 -0700 | [diff] [blame] | 567 | } |
| 568 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | memset(numa_slit, -1, sizeof(numa_slit)); |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 570 | for (i = 0; i < slit_table->locality_count; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | if (!pxm_bit_test(i)) |
| 572 | continue; |
Yasunori Goto | 762834e | 2006-06-23 02:03:19 -0700 | [diff] [blame] | 573 | node_from = pxm_to_node(i); |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 574 | for (j = 0; j < slit_table->locality_count; j++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | if (!pxm_bit_test(j)) |
| 576 | continue; |
Yasunori Goto | 762834e | 2006-06-23 02:03:19 -0700 | [diff] [blame] | 577 | node_to = pxm_to_node(j); |
Matias Bjørling | ef78e5e | 2018-11-26 11:27:03 -0800 | [diff] [blame] | 578 | slit_distance(node_from, node_to) = |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 579 | slit_table->entry[i * slit_table->locality_count + j]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | } |
| 581 | } |
| 582 | |
| 583 | #ifdef SLIT_DEBUG |
| 584 | printk("ACPI 2.0 SLIT locality table:\n"); |
| 585 | for_each_online_node(i) { |
| 586 | for_each_online_node(j) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 587 | printk("%03d ", node_distance(i, j)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | printk("\n"); |
| 589 | } |
| 590 | #endif |
| 591 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 592 | #endif /* CONFIG_ACPI_NUMA */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | |
Kenji Kaneshige | 1f3a6a1 | 2005-07-28 14:42:00 -0400 | [diff] [blame] | 594 | /* |
| 595 | * success: return IRQ number (>=0) |
| 596 | * failure: return < 0 |
| 597 | */ |
Yinghai Lu | a2f809b | 2009-04-27 18:01:20 -0700 | [diff] [blame] | 598 | int acpi_register_gsi(struct device *dev, u32 gsi, int triggering, int polarity) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | { |
John Keller | 3948ec9 | 2006-12-22 11:50:04 -0600 | [diff] [blame] | 600 | if (acpi_irq_model == ACPI_IRQ_MODEL_PLATFORM) |
| 601 | return gsi; |
| 602 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | if (has_8259 && gsi < 16) |
| 604 | return isa_irq_to_vector(gsi); |
| 605 | |
| 606 | return iosapic_register_intr(gsi, |
Len Brown | cb65469 | 2005-12-28 02:43:51 -0500 | [diff] [blame] | 607 | (polarity == |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 608 | ACPI_ACTIVE_HIGH) ? IOSAPIC_POL_HIGH : |
| 609 | IOSAPIC_POL_LOW, |
Len Brown | cb65469 | 2005-12-28 02:43:51 -0500 | [diff] [blame] | 610 | (triggering == |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 611 | ACPI_EDGE_SENSITIVE) ? IOSAPIC_EDGE : |
| 612 | IOSAPIC_LEVEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | } |
Mika Westerberg | a42b9bf | 2012-10-31 22:44:55 +0100 | [diff] [blame] | 614 | EXPORT_SYMBOL_GPL(acpi_register_gsi); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 615 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 616 | void acpi_unregister_gsi(u32 gsi) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | { |
John Keller | 7225394 | 2007-02-03 01:14:02 -0800 | [diff] [blame] | 618 | if (acpi_irq_model == ACPI_IRQ_MODEL_PLATFORM) |
| 619 | return; |
| 620 | |
Prarit Bhargava | 3fb2c74 | 2008-05-14 12:00:24 -0400 | [diff] [blame] | 621 | if (has_8259 && gsi < 16) |
| 622 | return; |
| 623 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | iosapic_unregister_intr(gsi); |
| 625 | } |
Mika Westerberg | a42b9bf | 2012-10-31 22:44:55 +0100 | [diff] [blame] | 626 | EXPORT_SYMBOL_GPL(acpi_unregister_gsi); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 628 | static int __init acpi_parse_fadt(struct acpi_table_header *table) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | { |
| 630 | struct acpi_table_header *fadt_header; |
Alexey Starikovskiy | cee324b | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 631 | struct acpi_table_fadt *fadt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 633 | fadt_header = (struct acpi_table_header *)table; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | if (fadt_header->revision != 3) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 635 | return -ENODEV; /* Only deal with ACPI 2.0 FADT */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | |
Alexey Starikovskiy | cee324b | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 637 | fadt = (struct acpi_table_fadt *)fadt_header; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | |
Yinghai Lu | a2f809b | 2009-04-27 18:01:20 -0700 | [diff] [blame] | 639 | acpi_register_gsi(NULL, fadt->sci_interrupt, ACPI_LEVEL_SENSITIVE, |
| 640 | ACPI_ACTIVE_LOW); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | return 0; |
| 642 | } |
| 643 | |
Doug Chapman | 62ee054 | 2008-11-05 17:57:52 -0500 | [diff] [blame] | 644 | int __init early_acpi_boot_init(void) |
| 645 | { |
| 646 | int ret; |
| 647 | |
| 648 | /* |
| 649 | * do a partial walk of MADT to determine how many CPUs |
| 650 | * we have including offline CPUs |
| 651 | */ |
| 652 | if (acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) { |
| 653 | printk(KERN_ERR PREFIX "Can't find MADT\n"); |
| 654 | return 0; |
| 655 | } |
| 656 | |
| 657 | ret = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_SAPIC, |
| 658 | acpi_parse_lsapic, NR_CPUS); |
| 659 | if (ret < 1) |
| 660 | printk(KERN_ERR PREFIX |
| 661 | "Error parsing MADT - no LAPIC entries\n"); |
Baoquan He | 247dba5 | 2014-05-05 12:48:25 +0800 | [diff] [blame] | 662 | else |
| 663 | acpi_lapic = 1; |
Doug Chapman | 62ee054 | 2008-11-05 17:57:52 -0500 | [diff] [blame] | 664 | |
Tejun Heo | 12cda81 | 2009-10-02 13:28:56 +0900 | [diff] [blame] | 665 | #ifdef CONFIG_SMP |
| 666 | if (available_cpus == 0) { |
| 667 | printk(KERN_INFO "ACPI: Found 0 CPUS; assuming 1\n"); |
| 668 | printk(KERN_INFO "CPU 0 (0x%04x)", hard_smp_processor_id()); |
| 669 | smp_boot_data.cpu_phys_id[available_cpus] = |
| 670 | hard_smp_processor_id(); |
| 671 | available_cpus = 1; /* We've got at least one of these, no? */ |
| 672 | } |
| 673 | smp_boot_data.cpu_count = available_cpus; |
| 674 | #endif |
| 675 | /* Make boot-up look pretty */ |
| 676 | printk(KERN_INFO "%d CPUs available, %d CPUs total\n", available_cpus, |
| 677 | total_cpus); |
| 678 | |
Doug Chapman | 62ee054 | 2008-11-05 17:57:52 -0500 | [diff] [blame] | 679 | return 0; |
| 680 | } |
| 681 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 682 | int __init acpi_boot_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | { |
| 684 | |
| 685 | /* |
| 686 | * MADT |
| 687 | * ---- |
| 688 | * Parse the Multiple APIC Description Table (MADT), if exists. |
| 689 | * Note that this table provides platform SMP configuration |
| 690 | * information -- the successor to MPS tables. |
| 691 | */ |
| 692 | |
John Keller | db2d4cc | 2007-02-16 15:07:27 -0600 | [diff] [blame] | 693 | if (acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 694 | printk(KERN_ERR PREFIX "Can't find MADT\n"); |
| 695 | goto skip_madt; |
| 696 | } |
| 697 | |
| 698 | /* Local APIC */ |
| 699 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 700 | if (acpi_table_parse_madt |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 701 | (ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE, acpi_parse_lapic_addr_ovr, 0) < 0) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 702 | printk(KERN_ERR PREFIX |
| 703 | "Error parsing LAPIC address override entry\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 704 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 705 | if (acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_NMI, acpi_parse_lapic_nmi, 0) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 706 | < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n"); |
| 708 | |
| 709 | /* I/O APIC */ |
| 710 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 711 | if (acpi_table_parse_madt |
George Beshers | 7f6ff62 | 2007-10-11 15:33:55 -0400 | [diff] [blame] | 712 | (ACPI_MADT_TYPE_IO_SAPIC, acpi_parse_iosapic, NR_IOSAPICS) < 1) { |
| 713 | if (!ia64_platform_is("sn2")) |
| 714 | printk(KERN_ERR PREFIX |
| 715 | "Error parsing MADT - no IOSAPIC entries\n"); |
| 716 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | |
| 718 | /* System-Level Interrupt Routing */ |
| 719 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 720 | if (acpi_table_parse_madt |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 721 | (ACPI_MADT_TYPE_INTERRUPT_SOURCE, acpi_parse_plat_int_src, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 722 | ACPI_MAX_PLATFORM_INTERRUPTS) < 0) |
| 723 | printk(KERN_ERR PREFIX |
| 724 | "Error parsing platform interrupt source entry\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 725 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 726 | if (acpi_table_parse_madt |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 727 | (ACPI_MADT_TYPE_INTERRUPT_OVERRIDE, acpi_parse_int_src_ovr, 0) < 0) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 728 | printk(KERN_ERR PREFIX |
| 729 | "Error parsing interrupt source overrides entry\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 730 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 731 | if (acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE, acpi_parse_nmi_src, 0) < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 732 | printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n"); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 733 | skip_madt: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 734 | |
| 735 | /* |
| 736 | * FADT says whether a legacy keyboard controller is present. |
| 737 | * The FADT also contains an SCI_INT line, by which the system |
| 738 | * gets interrupts such as power and sleep buttons. If it's not |
| 739 | * on a Legacy interrupt, it needs to be setup. |
| 740 | */ |
John Keller | db2d4cc | 2007-02-16 15:07:27 -0600 | [diff] [blame] | 741 | if (acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 742 | printk(KERN_ERR PREFIX "Can't find FADT\n"); |
| 743 | |
Tejun Heo | 12cda81 | 2009-10-02 13:28:56 +0900 | [diff] [blame] | 744 | #ifdef CONFIG_ACPI_NUMA |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 745 | #ifdef CONFIG_SMP |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 746 | if (srat_num_cpus == 0) { |
| 747 | int cpu, i = 1; |
| 748 | for (cpu = 0; cpu < smp_boot_data.cpu_count; cpu++) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 749 | if (smp_boot_data.cpu_phys_id[cpu] != |
| 750 | hard_smp_processor_id()) |
| 751 | node_cpuid[i++].phys_id = |
| 752 | smp_boot_data.cpu_phys_id[cpu]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 753 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 754 | #endif |
Tony Luck | 8d7e351 | 2005-07-06 18:18:10 -0700 | [diff] [blame] | 755 | build_cpu_to_node_map(); |
| 756 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | return 0; |
| 758 | } |
| 759 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 760 | int acpi_gsi_to_irq(u32 gsi, unsigned int *irq) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | { |
Kenji Kaneshige | 3c3738c | 2007-07-26 15:31:34 +0900 | [diff] [blame] | 762 | int tmp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 763 | |
| 764 | if (has_8259 && gsi < 16) |
| 765 | *irq = isa_irq_to_vector(gsi); |
| 766 | else { |
Kenji Kaneshige | 3c3738c | 2007-07-26 15:31:34 +0900 | [diff] [blame] | 767 | tmp = gsi_to_irq(gsi); |
| 768 | if (tmp == -1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 769 | return -1; |
Kenji Kaneshige | 3c3738c | 2007-07-26 15:31:34 +0900 | [diff] [blame] | 770 | *irq = tmp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 771 | } |
| 772 | return 0; |
| 773 | } |
| 774 | |
Eric W. Biederman | 2c2df84 | 2010-03-30 01:07:02 -0700 | [diff] [blame] | 775 | int acpi_isa_irq_to_gsi(unsigned isa_irq, u32 *gsi) |
| 776 | { |
| 777 | if (isa_irq >= 16) |
| 778 | return -1; |
| 779 | *gsi = isa_irq; |
| 780 | return 0; |
| 781 | } |
| 782 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 783 | /* |
| 784 | * ACPI based hotplug CPU support |
| 785 | */ |
| 786 | #ifdef CONFIG_ACPI_HOTPLUG_CPU |
Gu Zheng | dc6db24 | 2016-08-25 16:35:18 +0800 | [diff] [blame] | 787 | int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 788 | { |
| 789 | #ifdef CONFIG_ACPI_NUMA |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 790 | /* |
KAMEZAWA Hiroyuki | 0899298 | 2006-09-25 16:25:21 -0700 | [diff] [blame] | 791 | * We don't have cpu-only-node hotadd. But if the system equips |
| 792 | * SRAT table, pxm is already found and node is ready. |
| 793 | * So, just pxm_to_nid(pxm) is OK. |
| 794 | * This code here is for the system which doesn't have full SRAT |
| 795 | * table for possible cpus. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 796 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 797 | node_cpuid[cpu].phys_id = physid; |
Bjorn Helgaas | b1e9cee | 2014-01-24 15:28:42 -0700 | [diff] [blame] | 798 | node_cpuid[cpu].nid = acpi_get_node(handle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 799 | #endif |
Bjorn Helgaas | b1e9cee | 2014-01-24 15:28:42 -0700 | [diff] [blame] | 800 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 801 | } |
| 802 | |
Ashok Raj | a6b14fa | 2006-02-14 15:01:12 -0800 | [diff] [blame] | 803 | int additional_cpus __initdata = -1; |
| 804 | |
| 805 | static __init int setup_additional_cpus(char *s) |
| 806 | { |
| 807 | if (s) |
| 808 | additional_cpus = simple_strtol(s, NULL, 0); |
| 809 | |
| 810 | return 0; |
| 811 | } |
| 812 | |
| 813 | early_param("additional_cpus", setup_additional_cpus); |
| 814 | |
| 815 | /* |
Rusty Russell | 5f054e3 | 2012-03-29 15:38:31 +1030 | [diff] [blame] | 816 | * cpu_possible_mask should be static, it cannot change as CPUs |
Ashok Raj | a6b14fa | 2006-02-14 15:01:12 -0800 | [diff] [blame] | 817 | * are onlined, or offlined. The reason is per-cpu data-structures |
| 818 | * are allocated by some modules at init time, and dont expect to |
| 819 | * do this dynamically on cpu arrival/departure. |
Srivatsa S. Bhat | 7d7f984 | 2012-03-28 14:42:46 -0700 | [diff] [blame] | 820 | * cpu_present_mask on the other hand can change dynamically. |
Ashok Raj | a6b14fa | 2006-02-14 15:01:12 -0800 | [diff] [blame] | 821 | * In case when cpu_hotplug is not compiled, then we resort to current |
| 822 | * behaviour, which is cpu_possible == cpu_present. |
| 823 | * - Ashok Raj |
| 824 | * |
| 825 | * Three ways to find out the number of additional hotplug CPUs: |
| 826 | * - If the BIOS specified disabled CPUs in ACPI/mptables use that. |
| 827 | * - The user can overwrite it with additional_cpus=NUM |
| 828 | * - Otherwise don't reserve additional CPUs. |
| 829 | */ |
| 830 | __init void prefill_possible_map(void) |
| 831 | { |
| 832 | int i; |
| 833 | int possible, disabled_cpus; |
| 834 | |
| 835 | disabled_cpus = total_cpus - available_cpus; |
Ashok Raj | 8f8b1138 | 2006-02-16 14:01:48 -0800 | [diff] [blame] | 836 | |
Ashok Raj | a6b14fa | 2006-02-14 15:01:12 -0800 | [diff] [blame] | 837 | if (additional_cpus == -1) { |
Ashok Raj | 8f8b1138 | 2006-02-16 14:01:48 -0800 | [diff] [blame] | 838 | if (disabled_cpus > 0) |
Ashok Raj | a6b14fa | 2006-02-14 15:01:12 -0800 | [diff] [blame] | 839 | additional_cpus = disabled_cpus; |
Ashok Raj | 8f8b1138 | 2006-02-16 14:01:48 -0800 | [diff] [blame] | 840 | else |
Ashok Raj | a6b14fa | 2006-02-14 15:01:12 -0800 | [diff] [blame] | 841 | additional_cpus = 0; |
Ashok Raj | 8f8b1138 | 2006-02-16 14:01:48 -0800 | [diff] [blame] | 842 | } |
| 843 | |
| 844 | possible = available_cpus + additional_cpus; |
| 845 | |
Yinghai Lu | 2b633e3 | 2010-02-10 01:20:37 -0800 | [diff] [blame] | 846 | if (possible > nr_cpu_ids) |
| 847 | possible = nr_cpu_ids; |
Ashok Raj | a6b14fa | 2006-02-14 15:01:12 -0800 | [diff] [blame] | 848 | |
| 849 | printk(KERN_INFO "SMP: Allowing %d CPUs, %d hotplug CPUs\n", |
Ashok Raj | 8f8b1138 | 2006-02-16 14:01:48 -0800 | [diff] [blame] | 850 | possible, max((possible - available_cpus), 0)); |
Ashok Raj | a6b14fa | 2006-02-14 15:01:12 -0800 | [diff] [blame] | 851 | |
| 852 | for (i = 0; i < possible; i++) |
Rusty Russell | 2af51a3 | 2009-03-16 14:12:43 +1030 | [diff] [blame] | 853 | set_cpu_possible(i, true); |
Ashok Raj | a6b14fa | 2006-02-14 15:01:12 -0800 | [diff] [blame] | 854 | } |
| 855 | |
Jiang Liu | d536bf3 | 2013-09-02 11:57:35 +0800 | [diff] [blame] | 856 | static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 857 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 858 | cpumask_t tmp_map; |
Jiang Liu | d536bf3 | 2013-09-02 11:57:35 +0800 | [diff] [blame] | 859 | int cpu; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 860 | |
Rusty Russell | 5dd3c99 | 2009-03-16 14:12:42 +1030 | [diff] [blame] | 861 | cpumask_complement(&tmp_map, cpu_present_mask); |
| 862 | cpu = cpumask_first(&tmp_map); |
| 863 | if (cpu >= nr_cpu_ids) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 864 | return -EINVAL; |
| 865 | |
| 866 | acpi_map_cpu2node(handle, cpu, physid); |
| 867 | |
Srivatsa S. Bhat | 7d7f984 | 2012-03-28 14:42:46 -0700 | [diff] [blame] | 868 | set_cpu_present(cpu, true); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 869 | ia64_cpu_to_sapicid[cpu] = physid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 870 | |
Alex Chiang | d8191fa | 2010-02-22 12:11:39 -0700 | [diff] [blame] | 871 | acpi_processor_set_pdc(handle); |
| 872 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 873 | *pcpu = cpu; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 874 | return (0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 875 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 876 | |
Jan Beulich | af10f94 | 2011-02-17 16:36:24 +0000 | [diff] [blame] | 877 | /* wrapper to silence section mismatch warning */ |
Vitaly Kuznetsov | febf240 | 2017-02-06 18:01:51 +0100 | [diff] [blame] | 878 | int __ref acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id, |
| 879 | int *pcpu) |
Jan Beulich | af10f94 | 2011-02-17 16:36:24 +0000 | [diff] [blame] | 880 | { |
Jiang Liu | d536bf3 | 2013-09-02 11:57:35 +0800 | [diff] [blame] | 881 | return _acpi_map_lsapic(handle, physid, pcpu); |
Jan Beulich | af10f94 | 2011-02-17 16:36:24 +0000 | [diff] [blame] | 882 | } |
Hanjun Guo | d02dc27 | 2015-01-04 18:55:03 +0800 | [diff] [blame] | 883 | EXPORT_SYMBOL(acpi_map_cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 884 | |
Hanjun Guo | d02dc27 | 2015-01-04 18:55:03 +0800 | [diff] [blame] | 885 | int acpi_unmap_cpu(int cpu) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 886 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 887 | ia64_cpu_to_sapicid[cpu] = -1; |
Srivatsa S. Bhat | 7d7f984 | 2012-03-28 14:42:46 -0700 | [diff] [blame] | 888 | set_cpu_present(cpu, false); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 889 | |
| 890 | #ifdef CONFIG_ACPI_NUMA |
| 891 | /* NUMA specific cleanup's */ |
| 892 | #endif |
| 893 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 894 | return (0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 895 | } |
Hanjun Guo | d02dc27 | 2015-01-04 18:55:03 +0800 | [diff] [blame] | 896 | EXPORT_SYMBOL(acpi_unmap_cpu); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 897 | #endif /* CONFIG_ACPI_HOTPLUG_CPU */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 898 | |
| 899 | #ifdef CONFIG_ACPI_NUMA |
Greg Kroah-Hartman | 5b5e76e | 2012-12-21 14:05:13 -0800 | [diff] [blame] | 900 | static acpi_status acpi_map_iosapic(acpi_handle handle, u32 depth, |
| 901 | void *context, void **ret) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 902 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 903 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 904 | union acpi_object *obj; |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 905 | struct acpi_madt_io_sapic *iosapic; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 906 | unsigned int gsi_base; |
Bjorn Helgaas | b1e9cee | 2014-01-24 15:28:42 -0700 | [diff] [blame] | 907 | int node; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 908 | |
| 909 | /* Only care about objects w/ a method that returns the MADT */ |
| 910 | if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer))) |
| 911 | return AE_OK; |
| 912 | |
| 913 | if (!buffer.length || !buffer.pointer) |
| 914 | return AE_OK; |
| 915 | |
| 916 | obj = buffer.pointer; |
| 917 | if (obj->type != ACPI_TYPE_BUFFER || |
| 918 | obj->buffer.length < sizeof(*iosapic)) { |
Len Brown | 02438d8 | 2006-06-30 03:19:10 -0400 | [diff] [blame] | 919 | kfree(buffer.pointer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 920 | return AE_OK; |
| 921 | } |
| 922 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 923 | iosapic = (struct acpi_madt_io_sapic *)obj->buffer.pointer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 924 | |
Alexey Starikovskiy | 5f3b1a8 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 925 | if (iosapic->header.type != ACPI_MADT_TYPE_IO_SAPIC) { |
Len Brown | 02438d8 | 2006-06-30 03:19:10 -0400 | [diff] [blame] | 926 | kfree(buffer.pointer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 927 | return AE_OK; |
| 928 | } |
| 929 | |
| 930 | gsi_base = iosapic->global_irq_base; |
| 931 | |
Len Brown | 02438d8 | 2006-06-30 03:19:10 -0400 | [diff] [blame] | 932 | kfree(buffer.pointer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 933 | |
Bjorn Helgaas | b1e9cee | 2014-01-24 15:28:42 -0700 | [diff] [blame] | 934 | /* OK, it's an IOSAPIC MADT entry; associate it with a node */ |
| 935 | node = acpi_get_node(handle); |
| 936 | if (node == NUMA_NO_NODE || !node_online(node) || |
Rusty Russell | fbb776c | 2008-12-26 22:23:40 +1030 | [diff] [blame] | 937 | cpumask_empty(cpumask_of_node(node))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 938 | return AE_OK; |
| 939 | |
| 940 | /* We know a gsi to node mapping! */ |
| 941 | map_iosapic_to_node(gsi_base, node); |
| 942 | return AE_OK; |
| 943 | } |
Bjorn Helgaas | 650316f | 2005-09-16 11:43:45 -0600 | [diff] [blame] | 944 | |
| 945 | static int __init |
| 946 | acpi_map_iosapics (void) |
| 947 | { |
| 948 | acpi_get_devices(NULL, acpi_map_iosapic, NULL, NULL); |
| 949 | return 0; |
| 950 | } |
| 951 | |
| 952 | fs_initcall(acpi_map_iosapics); |
| 953 | #endif /* CONFIG_ACPI_NUMA */ |
Kenji Kaneshige | b1bb248 | 2005-04-28 00:25:58 -0700 | [diff] [blame] | 954 | |
Hidetoshi Seto | c5b5a59 | 2008-04-30 16:51:06 +0900 | [diff] [blame] | 955 | int __ref acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base) |
Kenji Kaneshige | b1bb248 | 2005-04-28 00:25:58 -0700 | [diff] [blame] | 956 | { |
Kenji Kaneshige | 0e888ad | 2005-04-28 00:25:58 -0700 | [diff] [blame] | 957 | int err; |
| 958 | |
| 959 | if ((err = iosapic_init(phys_addr, gsi_base))) |
| 960 | return err; |
| 961 | |
Peter Chubb | 24b8e0c | 2005-09-15 15:36:35 +1000 | [diff] [blame] | 962 | #ifdef CONFIG_ACPI_NUMA |
Kenji Kaneshige | 0e888ad | 2005-04-28 00:25:58 -0700 | [diff] [blame] | 963 | acpi_map_iosapic(handle, 0, NULL, NULL); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 964 | #endif /* CONFIG_ACPI_NUMA */ |
Kenji Kaneshige | 0e888ad | 2005-04-28 00:25:58 -0700 | [diff] [blame] | 965 | |
| 966 | return 0; |
Kenji Kaneshige | b1bb248 | 2005-04-28 00:25:58 -0700 | [diff] [blame] | 967 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 968 | |
Kenji Kaneshige | b1bb248 | 2005-04-28 00:25:58 -0700 | [diff] [blame] | 969 | EXPORT_SYMBOL(acpi_register_ioapic); |
| 970 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 971 | int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base) |
Kenji Kaneshige | b1bb248 | 2005-04-28 00:25:58 -0700 | [diff] [blame] | 972 | { |
Kenji Kaneshige | 0e888ad | 2005-04-28 00:25:58 -0700 | [diff] [blame] | 973 | return iosapic_remove(gsi_base); |
Kenji Kaneshige | b1bb248 | 2005-04-28 00:25:58 -0700 | [diff] [blame] | 974 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 975 | |
Kenji Kaneshige | b1bb248 | 2005-04-28 00:25:58 -0700 | [diff] [blame] | 976 | EXPORT_SYMBOL(acpi_unregister_ioapic); |
| 977 | |
Len Brown | e8b2fd0 | 2007-07-24 22:26:33 -0400 | [diff] [blame] | 978 | /* |
Rafael J. Wysocki | f1a2003 | 2011-02-08 23:42:22 +0100 | [diff] [blame] | 979 | * acpi_suspend_lowlevel() - save kernel state and suspend. |
Len Brown | e8b2fd0 | 2007-07-24 22:26:33 -0400 | [diff] [blame] | 980 | * |
| 981 | * TBD when when IA64 starts to support suspend... |
| 982 | */ |
Rafael J. Wysocki | f1a2003 | 2011-02-08 23:42:22 +0100 | [diff] [blame] | 983 | int acpi_suspend_lowlevel(void) { return 0; } |