ia64/xen-unstable

view xen/drivers/acpi/numa.c @ 18887:3db54d2aa8bd

powernow: implement struct cpufreq_driver.verify

Without this, under rare conditions hypervisor crashes are possible
due to this method being called without checking against NULL.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Dec 05 15:22:21 2008 +0000 (2008-12-05)
parents 9af7a535225f
children 89e50c449307
line source
1 /*
2 * acpi_numa.c - ACPI NUMA support
3 *
4 * Copyright (C) 2002 Takayoshi Kochi <t-kochi@bq.jp.nec.com>
5 *
6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 *
24 */
25 #include <xen/config.h>
26 #include <xen/init.h>
27 #include <xen/types.h>
28 #include <xen/errno.h>
29 #include <xen/acpi.h>
30 #include <xen/numa.h>
31 #include <acpi/acpi_bus.h>
32 #include <acpi/acmacros.h>
34 #define ACPI_NUMA 0x80000000
35 #define _COMPONENT ACPI_NUMA
36 ACPI_MODULE_NAME("numa")
38 void __init acpi_table_print_srat_entry(struct acpi_subtable_header * header)
39 {
41 ACPI_FUNCTION_NAME("acpi_table_print_srat_entry");
43 if (!header)
44 return;
46 switch (header->type) {
48 case ACPI_SRAT_PROCESSOR_AFFINITY:
49 #ifdef ACPI_DEBUG_OUTPUT
50 {
51 struct acpi_table_processor_affinity *p =
52 (struct acpi_table_processor_affinity *)header;
53 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
54 "SRAT Processor (id[0x%02x] eid[0x%02x]) in proximity domain %d %s\n",
55 p->apic_id, p->lsapic_eid,
56 p->proximity_domain,
57 p->flags.
58 enabled ? "enabled" : "disabled"));
59 }
60 #endif /* ACPI_DEBUG_OUTPUT */
61 break;
63 case ACPI_SRAT_MEMORY_AFFINITY:
64 #ifdef ACPI_DEBUG_OUTPUT
65 {
66 struct acpi_table_memory_affinity *p =
67 (struct acpi_table_memory_affinity *)header;
68 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
69 "SRAT Memory (0x%08x%08x length 0x%08x%08x type 0x%x) in proximity domain %d %s%s\n",
70 p->base_addr_hi, p->base_addr_lo,
71 p->length_hi, p->length_lo,
72 p->memory_type, p->proximity_domain,
73 p->flags.
74 enabled ? "enabled" : "disabled",
75 p->flags.
76 hot_pluggable ? " hot-pluggable" :
77 ""));
78 }
79 #endif /* ACPI_DEBUG_OUTPUT */
80 break;
82 default:
83 printk(KERN_WARNING PREFIX
84 "Found unsupported SRAT entry (type = 0x%x)\n",
85 header->type);
86 break;
87 }
88 }
90 static int __init acpi_parse_slit(struct acpi_table_header *table)
91 {
92 acpi_numa_slit_init((struct acpi_table_slit *)table);
94 return 0;
95 }
97 static int __init
98 acpi_parse_processor_affinity(struct acpi_subtable_header * header,
99 const unsigned long end)
100 {
101 struct acpi_table_processor_affinity *processor_affinity;
103 processor_affinity = (struct acpi_table_processor_affinity *)header;
104 if (!processor_affinity)
105 return -EINVAL;
107 acpi_table_print_srat_entry(header);
109 /* let architecture-dependent part to do it */
110 acpi_numa_processor_affinity_init(processor_affinity);
112 return 0;
113 }
115 static int __init
116 acpi_parse_memory_affinity(struct acpi_subtable_header * header,
117 const unsigned long end)
118 {
119 struct acpi_table_memory_affinity *memory_affinity;
121 memory_affinity = (struct acpi_table_memory_affinity *)header;
122 if (!memory_affinity)
123 return -EINVAL;
125 acpi_table_print_srat_entry(header);
127 /* let architecture-dependent part to do it */
128 acpi_numa_memory_affinity_init(memory_affinity);
130 return 0;
131 }
133 static int __init acpi_parse_srat(struct acpi_table_header *table)
134 {
135 return 0;
136 }
138 int __init
139 acpi_table_parse_srat(enum acpi_srat_entry_id id,
140 acpi_madt_entry_handler handler, unsigned int max_entries)
141 {
142 return acpi_table_parse_entries(ACPI_SIG_SRAT,
143 sizeof(struct acpi_table_srat), id,
144 handler, max_entries);
145 }
147 int __init acpi_numa_init(void)
148 {
149 /* SRAT: Static Resource Affinity Table */
150 if (!acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat)) {
151 acpi_table_parse_srat(ACPI_SRAT_PROCESSOR_AFFINITY,
152 acpi_parse_processor_affinity,
153 NR_CPUS);
154 acpi_table_parse_srat(ACPI_SRAT_MEMORY_AFFINITY, acpi_parse_memory_affinity, NR_NODE_MEMBLKS); // IA64 specific
155 }
157 /* SLIT: System Locality Information Table */
158 acpi_table_parse(ACPI_SIG_SLIT, acpi_parse_slit);
160 acpi_numa_arch_fixup();
161 return 0;
162 }
164 #if 0
165 int acpi_get_pxm(acpi_handle h)
166 {
167 unsigned long pxm;
168 acpi_status status;
169 acpi_handle handle;
170 acpi_handle phandle = h;
172 do {
173 handle = phandle;
174 status = acpi_evaluate_integer(handle, "_PXM", NULL, &pxm);
175 if (ACPI_SUCCESS(status))
176 return (int)pxm;
177 status = acpi_get_parent(handle, &phandle);
178 } while (ACPI_SUCCESS(status));
179 return -1;
180 }
182 EXPORT_SYMBOL(acpi_get_pxm);
183 #endif