~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm64/kernel/acpi_numa.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /*
  3  * ACPI 5.1 based NUMA setup for ARM64
  4  * Lots of code was borrowed from arch/x86/mm/srat.c
  5  *
  6  * Copyright 2004 Andi Kleen, SuSE Labs.
  7  * Copyright (C) 2013-2016, Linaro Ltd.
  8  *              Author: Hanjun Guo <hanjun.guo@linaro.org>
  9  *
 10  * Reads the ACPI SRAT table to figure out what memory belongs to which CPUs.
 11  *
 12  * Called from acpi_numa_init while reading the SRAT and SLIT tables.
 13  * Assumes all memory regions belonging to a single proximity domain
 14  * are in one chunk. Holes between them will be included in the node.
 15  */
 16 
 17 #define pr_fmt(fmt) "ACPI: NUMA: " fmt
 18 
 19 #include <linux/acpi.h>
 20 #include <linux/bitmap.h>
 21 #include <linux/kernel.h>
 22 #include <linux/mm.h>
 23 #include <linux/memblock.h>
 24 #include <linux/mmzone.h>
 25 #include <linux/module.h>
 26 #include <linux/topology.h>
 27 
 28 #include <asm/numa.h>
 29 
 30 static int acpi_early_node_map[NR_CPUS] __initdata = { [0 ... NR_CPUS - 1] = NUMA_NO_NODE };
 31 
 32 int __init acpi_numa_get_nid(unsigned int cpu)
 33 {
 34         return acpi_early_node_map[cpu];
 35 }
 36 
 37 static int __init acpi_parse_gicc_pxm(union acpi_subtable_headers *header,
 38                                       const unsigned long end)
 39 {
 40         struct acpi_srat_gicc_affinity *pa;
 41         int cpu, pxm, node;
 42 
 43         if (srat_disabled())
 44                 return -EINVAL;
 45 
 46         pa = (struct acpi_srat_gicc_affinity *)header;
 47         if (!pa)
 48                 return -EINVAL;
 49 
 50         if (!(pa->flags & ACPI_SRAT_GICC_ENABLED))
 51                 return 0;
 52 
 53         pxm = pa->proximity_domain;
 54         node = pxm_to_node(pxm);
 55 
 56         /*
 57          * If we can't map the UID to a logical cpu this
 58          * means that the UID is not part of possible cpus
 59          * so we do not need a NUMA mapping for it, skip
 60          * the SRAT entry and keep parsing.
 61          */
 62         cpu = get_cpu_for_acpi_id(pa->acpi_processor_uid);
 63         if (cpu < 0)
 64                 return 0;
 65 
 66         acpi_early_node_map[cpu] = node;
 67         pr_info("SRAT: PXM %d -> MPIDR 0x%llx -> Node %d\n", pxm,
 68                 cpu_logical_map(cpu), node);
 69 
 70         return 0;
 71 }
 72 
 73 void __init acpi_map_cpus_to_nodes(void)
 74 {
 75         acpi_table_parse_entries(ACPI_SIG_SRAT, sizeof(struct acpi_table_srat),
 76                                             ACPI_SRAT_TYPE_GICC_AFFINITY,
 77                                             acpi_parse_gicc_pxm, 0);
 78 }
 79 
 80 /* Callback for Proximity Domain -> ACPI processor UID mapping */
 81 void __init acpi_numa_gicc_affinity_init(struct acpi_srat_gicc_affinity *pa)
 82 {
 83         int pxm, node;
 84 
 85         if (srat_disabled())
 86                 return;
 87 
 88         if (pa->header.length < sizeof(struct acpi_srat_gicc_affinity)) {
 89                 pr_err("SRAT: Invalid SRAT header length: %d\n",
 90                         pa->header.length);
 91                 bad_srat();
 92                 return;
 93         }
 94 
 95         if (!(pa->flags & ACPI_SRAT_GICC_ENABLED))
 96                 return;
 97 
 98         pxm = pa->proximity_domain;
 99         node = acpi_map_pxm_to_node(pxm);
100 
101         if (node == NUMA_NO_NODE) {
102                 pr_err("SRAT: Too many proximity domains %d\n", pxm);
103                 bad_srat();
104                 return;
105         }
106 
107         node_set(node, numa_nodes_parsed);
108 }
109 
110 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php