.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (c) 2015, Christoph Hellwig. |
---|
3 | 4 | * Copyright (c) 2015, Intel Corporation. |
---|
.. | .. |
---|
6 | 7 | #include <linux/memory_hotplug.h> |
---|
7 | 8 | #include <linux/libnvdimm.h> |
---|
8 | 9 | #include <linux/module.h> |
---|
9 | | - |
---|
10 | | -static const struct attribute_group *e820_pmem_attribute_groups[] = { |
---|
11 | | - &nvdimm_bus_attribute_group, |
---|
12 | | - NULL, |
---|
13 | | -}; |
---|
14 | | - |
---|
15 | | -static const struct attribute_group *e820_pmem_region_attribute_groups[] = { |
---|
16 | | - &nd_region_attribute_group, |
---|
17 | | - &nd_device_attribute_group, |
---|
18 | | - NULL, |
---|
19 | | -}; |
---|
| 10 | +#include <linux/numa.h> |
---|
20 | 11 | |
---|
21 | 12 | static int e820_pmem_remove(struct platform_device *pdev) |
---|
22 | 13 | { |
---|
.. | .. |
---|
26 | 17 | return 0; |
---|
27 | 18 | } |
---|
28 | 19 | |
---|
29 | | -#ifdef CONFIG_MEMORY_HOTPLUG |
---|
30 | | -static int e820_range_to_nid(resource_size_t addr) |
---|
31 | | -{ |
---|
32 | | - return memory_add_physaddr_to_nid(addr); |
---|
33 | | -} |
---|
34 | | -#else |
---|
35 | | -static int e820_range_to_nid(resource_size_t addr) |
---|
36 | | -{ |
---|
37 | | - return NUMA_NO_NODE; |
---|
38 | | -} |
---|
39 | | -#endif |
---|
40 | | - |
---|
41 | 20 | static int e820_register_one(struct resource *res, void *data) |
---|
42 | 21 | { |
---|
43 | 22 | struct nd_region_desc ndr_desc; |
---|
44 | 23 | struct nvdimm_bus *nvdimm_bus = data; |
---|
| 24 | + int nid = phys_to_target_node(res->start); |
---|
45 | 25 | |
---|
46 | 26 | memset(&ndr_desc, 0, sizeof(ndr_desc)); |
---|
47 | 27 | ndr_desc.res = res; |
---|
48 | | - ndr_desc.attr_groups = e820_pmem_region_attribute_groups; |
---|
49 | | - ndr_desc.numa_node = e820_range_to_nid(res->start); |
---|
| 28 | + ndr_desc.numa_node = numa_map_to_online_node(nid); |
---|
| 29 | + ndr_desc.target_node = nid; |
---|
50 | 30 | set_bit(ND_REGION_PAGEMAP, &ndr_desc.flags); |
---|
51 | 31 | if (!nvdimm_pmem_region_create(nvdimm_bus, &ndr_desc)) |
---|
52 | 32 | return -ENXIO; |
---|
.. | .. |
---|
60 | 40 | struct nvdimm_bus *nvdimm_bus; |
---|
61 | 41 | int rc = -ENXIO; |
---|
62 | 42 | |
---|
63 | | - nd_desc.attr_groups = e820_pmem_attribute_groups; |
---|
64 | 43 | nd_desc.provider_name = "e820"; |
---|
65 | 44 | nd_desc.module = THIS_MODULE; |
---|
66 | 45 | nvdimm_bus = nvdimm_bus_register(dev, &nd_desc); |
---|