Skip to content

Commit 3770442

Browse files
hanjun-guorafaeljw
authored andcommitted
ACPI / NUMA: Move acpi_numa_memory_affinity_init() to drivers/acpi/numa.c
acpi_numa_memory_affinity_init() will be reused by arm64. Move it to drivers/acpi/numa.c to facilitate reuse. No code change. Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org> Signed-off-by: Robert Richter <rrichter@cavium.com> Signed-off-by: David Daney <david.daney@cavium.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent fb1f418 commit 3770442

File tree

2 files changed

+60
-57
lines changed

2 files changed

+60
-57
lines changed

arch/x86/mm/srat.c

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
#include <linux/bitmap.h>
1616
#include <linux/module.h>
1717
#include <linux/topology.h>
18-
#include <linux/bootmem.h>
19-
#include <linux/memblock.h>
2018
#include <linux/mm.h>
2119
#include <asm/proto.h>
2220
#include <asm/numa.h>
@@ -104,61 +102,6 @@ acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa)
104102
pxm, apic_id, node);
105103
}
106104

107-
/* Callback for parsing of the Proximity Domain <-> Memory Area mappings */
108-
int __init
109-
acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
110-
{
111-
u64 start, end;
112-
u32 hotpluggable;
113-
int node, pxm;
114-
115-
if (srat_disabled())
116-
goto out_err;
117-
if (ma->header.length != sizeof(struct acpi_srat_mem_affinity))
118-
goto out_err_bad_srat;
119-
if ((ma->flags & ACPI_SRAT_MEM_ENABLED) == 0)
120-
goto out_err;
121-
hotpluggable = ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE;
122-
if (hotpluggable && !IS_ENABLED(CONFIG_MEMORY_HOTPLUG))
123-
goto out_err;
124-
125-
start = ma->base_address;
126-
end = start + ma->length;
127-
pxm = ma->proximity_domain;
128-
if (acpi_srat_revision <= 1)
129-
pxm &= 0xff;
130-
131-
node = acpi_map_pxm_to_node(pxm);
132-
if (node < 0) {
133-
printk(KERN_ERR "SRAT: Too many proximity domains.\n");
134-
goto out_err_bad_srat;
135-
}
136-
137-
if (numa_add_memblk(node, start, end) < 0)
138-
goto out_err_bad_srat;
139-
140-
node_set(node, numa_nodes_parsed);
141-
142-
pr_info("SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx]%s%s\n",
143-
node, pxm,
144-
(unsigned long long) start, (unsigned long long) end - 1,
145-
hotpluggable ? " hotplug" : "",
146-
ma->flags & ACPI_SRAT_MEM_NON_VOLATILE ? " non-volatile" : "");
147-
148-
/* Mark hotplug range in memblock. */
149-
if (hotpluggable && memblock_mark_hotplug(start, ma->length))
150-
pr_warn("SRAT: Failed to mark hotplug range [mem %#010Lx-%#010Lx] in memblock\n",
151-
(unsigned long long)start, (unsigned long long)end - 1);
152-
153-
max_possible_pfn = max(max_possible_pfn, PFN_UP(end - 1));
154-
155-
return 0;
156-
out_err_bad_srat:
157-
bad_srat();
158-
out_err:
159-
return -EINVAL;
160-
}
161-
162105
int __init x86_acpi_numa_init(void)
163106
{
164107
int ret;

drivers/acpi/numa.c

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include <linux/types.h>
2828
#include <linux/errno.h>
2929
#include <linux/acpi.h>
30+
#include <linux/bootmem.h>
31+
#include <linux/memblock.h>
3032
#include <linux/numa.h>
3133
#include <linux/nodemask.h>
3234
#include <linux/topology.h>
@@ -236,6 +238,64 @@ void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
236238
}
237239
}
238240
}
241+
242+
/*
243+
* Default callback for parsing of the Proximity Domain <-> Memory
244+
* Area mappings
245+
*/
246+
int __init
247+
acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
248+
{
249+
u64 start, end;
250+
u32 hotpluggable;
251+
int node, pxm;
252+
253+
if (srat_disabled())
254+
goto out_err;
255+
if (ma->header.length != sizeof(struct acpi_srat_mem_affinity))
256+
goto out_err_bad_srat;
257+
if ((ma->flags & ACPI_SRAT_MEM_ENABLED) == 0)
258+
goto out_err;
259+
hotpluggable = ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE;
260+
if (hotpluggable && !IS_ENABLED(CONFIG_MEMORY_HOTPLUG))
261+
goto out_err;
262+
263+
start = ma->base_address;
264+
end = start + ma->length;
265+
pxm = ma->proximity_domain;
266+
if (acpi_srat_revision <= 1)
267+
pxm &= 0xff;
268+
269+
node = acpi_map_pxm_to_node(pxm);
270+
if (node < 0) {
271+
printk(KERN_ERR "SRAT: Too many proximity domains.\n");
272+
goto out_err_bad_srat;
273+
}
274+
275+
if (numa_add_memblk(node, start, end) < 0)
276+
goto out_err_bad_srat;
277+
278+
node_set(node, numa_nodes_parsed);
279+
280+
pr_info("SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx]%s%s\n",
281+
node, pxm,
282+
(unsigned long long) start, (unsigned long long) end - 1,
283+
hotpluggable ? " hotplug" : "",
284+
ma->flags & ACPI_SRAT_MEM_NON_VOLATILE ? " non-volatile" : "");
285+
286+
/* Mark hotplug range in memblock. */
287+
if (hotpluggable && memblock_mark_hotplug(start, ma->length))
288+
pr_warn("SRAT: Failed to mark hotplug range [mem %#010Lx-%#010Lx] in memblock\n",
289+
(unsigned long long)start, (unsigned long long)end - 1);
290+
291+
max_possible_pfn = max(max_possible_pfn, PFN_UP(end - 1));
292+
293+
return 0;
294+
out_err_bad_srat:
295+
bad_srat();
296+
out_err:
297+
return -EINVAL;
298+
}
239299
#endif /* defined(CONFIG_X86) || defined (CONFIG_ARM64) */
240300

241301
static int __init acpi_parse_slit(struct acpi_table_header *table)

0 commit comments

Comments
 (0)