summaryrefslogtreecommitdiff
path: root/drivers/nvdimm/pmem.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2015-08-24 19:20:23 -0400
committerDan Williams <dan.j.williams@intel.com>2015-08-28 23:40:05 -0400
commit004f1afbe199e6ab20805b95aefd83ccd24bc5c7 (patch)
tree4c7df96fc10599da6f31639a1835a8ada97ef2d8 /drivers/nvdimm/pmem.c
parent32ab0a3f51701cb37ab960635254d5f84ec3de0a (diff)
downloadlwn-004f1afbe199e6ab20805b95aefd83ccd24bc5c7.tar.gz
lwn-004f1afbe199e6ab20805b95aefd83ccd24bc5c7.zip
libnvdimm, pmem: direct map legacy pmem by default
The expectation is that the legacy / non-standard pmem discovery method (e820 type-12) will only ever be used to describe small quantities of persistent memory. Larger capacities will be described via the ACPI NFIT. When "allocate struct page from pmem" support is added this default policy can be overridden by assigning a legacy pmem namespace to a pfn device, however this would be only be necessary if a platform used the legacy mechanism to define a very large range. Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/nvdimm/pmem.c')
-rw-r--r--drivers/nvdimm/pmem.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index 2f885e5d9c36..c5ae2e579288 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -148,9 +148,18 @@ static struct pmem_device *pmem_alloc(struct device *dev,
return ERR_PTR(-EBUSY);
}
- pmem->virt_addr = memremap_pmem(dev, pmem->phys_addr, pmem->size);
- if (!pmem->virt_addr)
- return ERR_PTR(-ENXIO);
+ if (pmem_should_map_pages(dev)) {
+ void *addr = devm_memremap_pages(dev, res);
+
+ if (IS_ERR(addr))
+ return addr;
+ pmem->virt_addr = (void __pmem *) addr;
+ } else {
+ pmem->virt_addr = memremap_pmem(dev, pmem->phys_addr,
+ pmem->size);
+ if (!pmem->virt_addr)
+ return ERR_PTR(-ENXIO);
+ }
return pmem;
}