aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nvdimm/namespace_devs.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/namespace_devs.c
parent32ab0a3f51701cb37ab960635254d5f84ec3de0a (diff)
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/namespace_devs.c')
-rw-r--r--drivers/nvdimm/namespace_devs.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 9303ca29be9b..0955b2cb10fe 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -13,6 +13,7 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/device.h> 14#include <linux/device.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/pmem.h>
16#include <linux/nd.h> 17#include <linux/nd.h>
17#include "nd-core.h" 18#include "nd-core.h"
18#include "nd.h" 19#include "nd.h"
@@ -76,11 +77,32 @@ static bool is_namespace_io(struct device *dev)
76 return dev ? dev->type == &namespace_io_device_type : false; 77 return dev ? dev->type == &namespace_io_device_type : false;
77} 78}
78 79
80bool pmem_should_map_pages(struct device *dev)
81{
82 struct nd_region *nd_region = to_nd_region(dev->parent);
83
84 if (!IS_ENABLED(CONFIG_ZONE_DEVICE))
85 return false;
86
87 if (!test_bit(ND_REGION_PAGEMAP, &nd_region->flags))
88 return false;
89
90 if (is_nd_pfn(dev) || is_nd_btt(dev))
91 return false;
92
93#ifdef ARCH_MEMREMAP_PMEM
94 return ARCH_MEMREMAP_PMEM == MEMREMAP_WB;
95#else
96 return false;
97#endif
98}
99EXPORT_SYMBOL(pmem_should_map_pages);
100
79const char *nvdimm_namespace_disk_name(struct nd_namespace_common *ndns, 101const char *nvdimm_namespace_disk_name(struct nd_namespace_common *ndns,
80 char *name) 102 char *name)
81{ 103{
82 struct nd_region *nd_region = to_nd_region(ndns->dev.parent); 104 struct nd_region *nd_region = to_nd_region(ndns->dev.parent);
83 const char *suffix = ""; 105 const char *suffix = NULL;
84 106
85 if (ndns->claim) { 107 if (ndns->claim) {
86 if (is_nd_btt(ndns->claim)) 108 if (is_nd_btt(ndns->claim))
@@ -93,13 +115,16 @@ const char *nvdimm_namespace_disk_name(struct nd_namespace_common *ndns,
93 dev_name(ndns->claim)); 115 dev_name(ndns->claim));
94 } 116 }
95 117
96 if (is_namespace_pmem(&ndns->dev) || is_namespace_io(&ndns->dev)) 118 if (is_namespace_pmem(&ndns->dev) || is_namespace_io(&ndns->dev)) {
97 sprintf(name, "pmem%d%s", nd_region->id, suffix); 119 if (!suffix && pmem_should_map_pages(&ndns->dev))
98 else if (is_namespace_blk(&ndns->dev)) { 120 suffix = "m";
121 sprintf(name, "pmem%d%s", nd_region->id, suffix ? suffix : "");
122 } else if (is_namespace_blk(&ndns->dev)) {
99 struct nd_namespace_blk *nsblk; 123 struct nd_namespace_blk *nsblk;
100 124
101 nsblk = to_nd_namespace_blk(&ndns->dev); 125 nsblk = to_nd_namespace_blk(&ndns->dev);
102 sprintf(name, "ndblk%d.%d%s", nd_region->id, nsblk->id, suffix); 126 sprintf(name, "ndblk%d.%d%s", nd_region->id, nsblk->id,
127 suffix ? suffix : "");
103 } else { 128 } else {
104 return NULL; 129 return NULL;
105 } 130 }