aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/nvdimm/e820.c15
-rw-r--r--drivers/nvdimm/pmem.c15
2 files changed, 16 insertions, 14 deletions
diff --git a/drivers/nvdimm/e820.c b/drivers/nvdimm/e820.c
index 8282db2ef99e..b0045a505dc8 100644
--- a/drivers/nvdimm/e820.c
+++ b/drivers/nvdimm/e820.c
@@ -3,6 +3,7 @@
3 * Copyright (c) 2015, Intel Corporation. 3 * Copyright (c) 2015, Intel Corporation.
4 */ 4 */
5#include <linux/platform_device.h> 5#include <linux/platform_device.h>
6#include <linux/memory_hotplug.h>
6#include <linux/libnvdimm.h> 7#include <linux/libnvdimm.h>
7#include <linux/module.h> 8#include <linux/module.h>
8 9
@@ -25,6 +26,18 @@ static int e820_pmem_remove(struct platform_device *pdev)
25 return 0; 26 return 0;
26} 27}
27 28
29#ifdef CONFIG_MEMORY_HOTPLUG
30static int e820_range_to_nid(resource_size_t addr)
31{
32 return memory_add_physaddr_to_nid(addr);
33}
34#else
35static int e820_range_to_nid(resource_size_t addr)
36{
37 return NUMA_NO_NODE;
38}
39#endif
40
28static int e820_pmem_probe(struct platform_device *pdev) 41static int e820_pmem_probe(struct platform_device *pdev)
29{ 42{
30 static struct nvdimm_bus_descriptor nd_desc; 43 static struct nvdimm_bus_descriptor nd_desc;
@@ -48,7 +61,7 @@ static int e820_pmem_probe(struct platform_device *pdev)
48 memset(&ndr_desc, 0, sizeof(ndr_desc)); 61 memset(&ndr_desc, 0, sizeof(ndr_desc));
49 ndr_desc.res = p; 62 ndr_desc.res = p;
50 ndr_desc.attr_groups = e820_pmem_region_attribute_groups; 63 ndr_desc.attr_groups = e820_pmem_region_attribute_groups;
51 ndr_desc.numa_node = NUMA_NO_NODE; 64 ndr_desc.numa_node = e820_range_to_nid(p->start);
52 set_bit(ND_REGION_PAGEMAP, &ndr_desc.flags); 65 set_bit(ND_REGION_PAGEMAP, &ndr_desc.flags);
53 if (!nvdimm_pmem_region_create(nvdimm_bus, &ndr_desc)) 66 if (!nvdimm_pmem_region_create(nvdimm_bus, &ndr_desc))
54 goto err; 67 goto err;
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index 012e0649f1ac..8ee79893d2f5 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -105,22 +105,11 @@ static long pmem_direct_access(struct block_device *bdev, sector_t sector,
105{ 105{
106 struct pmem_device *pmem = bdev->bd_disk->private_data; 106 struct pmem_device *pmem = bdev->bd_disk->private_data;
107 resource_size_t offset = sector * 512 + pmem->data_offset; 107 resource_size_t offset = sector * 512 + pmem->data_offset;
108 resource_size_t size; 108
109
110 if (pmem->data_offset) {
111 /*
112 * Limit the direct_access() size to what is covered by
113 * the memmap
114 */
115 size = (pmem->size - offset) & ~ND_PFN_MASK;
116 } else
117 size = pmem->size - offset;
118
119 /* FIXME convert DAX to comprehend that this mapping has a lifetime */
120 *kaddr = pmem->virt_addr + offset; 109 *kaddr = pmem->virt_addr + offset;
121 *pfn = (pmem->phys_addr + offset) >> PAGE_SHIFT; 110 *pfn = (pmem->phys_addr + offset) >> PAGE_SHIFT;
122 111
123 return size; 112 return pmem->size - offset;
124} 113}
125 114
126static const struct block_device_operations pmem_fops = { 115static const struct block_device_operations pmem_fops = {