aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2015-09-15 02:14:03 -0400
committerDan Williams <dan.j.williams@intel.com>2015-10-09 17:00:32 -0400
commita639315d6c536c806724c9328941a2517507e3e3 (patch)
tree392e1082c2dcfe5ca0b2d8e4394c4be5ed0b403b
parentc9cdaeb2027e535b956ff69f215522d79f6b54e3 (diff)
pmem: kill memremap_pmem()
Now that the pmem-api is defined as "a set of apis that enables access to WB mapped pmem", the mapping type is implied. Remove the wrapper and push the functionality down into the pmem driver in preparation for adding support for direct-mapped pmem. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r--drivers/nvdimm/pmem.c9
-rw-r--r--include/linux/pmem.h26
2 files changed, 6 insertions, 29 deletions
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index 0ba6a978f227..0680affae04a 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -157,8 +157,9 @@ static struct pmem_device *pmem_alloc(struct device *dev,
157 return addr; 157 return addr;
158 pmem->virt_addr = (void __pmem *) addr; 158 pmem->virt_addr = (void __pmem *) addr;
159 } else { 159 } else {
160 pmem->virt_addr = memremap_pmem(dev, pmem->phys_addr, 160 pmem->virt_addr = (void __pmem *) devm_memremap(dev,
161 pmem->size); 161 pmem->phys_addr, pmem->size,
162 ARCH_MEMREMAP_PMEM);
162 if (!pmem->virt_addr) 163 if (!pmem->virt_addr)
163 return ERR_PTR(-ENXIO); 164 return ERR_PTR(-ENXIO);
164 } 165 }
@@ -363,8 +364,8 @@ static int nvdimm_namespace_attach_pfn(struct nd_namespace_common *ndns)
363 364
364 /* establish pfn range for lookup, and switch to direct map */ 365 /* establish pfn range for lookup, and switch to direct map */
365 pmem = dev_get_drvdata(dev); 366 pmem = dev_get_drvdata(dev);
366 memunmap_pmem(dev, pmem->virt_addr); 367 devm_memunmap(dev, (void __force *) pmem->virt_addr);
367 pmem->virt_addr = (void __pmem *)devm_memremap_pages(dev, &nsio->res); 368 pmem->virt_addr = (void __pmem *) devm_memremap_pages(dev, &nsio->res);
368 if (IS_ERR(pmem->virt_addr)) { 369 if (IS_ERR(pmem->virt_addr)) {
369 rc = PTR_ERR(pmem->virt_addr); 370 rc = PTR_ERR(pmem->virt_addr);
370 goto err; 371 goto err;
diff --git a/include/linux/pmem.h b/include/linux/pmem.h
index 85f810b33917..acfea8ce4a07 100644
--- a/include/linux/pmem.h
+++ b/include/linux/pmem.h
@@ -65,11 +65,6 @@ static inline void memcpy_from_pmem(void *dst, void __pmem const *src, size_t si
65 memcpy(dst, (void __force const *) src, size); 65 memcpy(dst, (void __force const *) src, size);
66} 66}
67 67
68static inline void memunmap_pmem(struct device *dev, void __pmem *addr)
69{
70 devm_memunmap(dev, (void __force *) addr);
71}
72
73static inline bool arch_has_pmem_api(void) 68static inline bool arch_has_pmem_api(void)
74{ 69{
75 return IS_ENABLED(CONFIG_ARCH_HAS_PMEM_API); 70 return IS_ENABLED(CONFIG_ARCH_HAS_PMEM_API);
@@ -93,7 +88,7 @@ static inline bool arch_has_wmb_pmem(void)
93 * These defaults seek to offer decent performance and minimize the 88 * These defaults seek to offer decent performance and minimize the
94 * window between i/o completion and writes being durable on media. 89 * window between i/o completion and writes being durable on media.
95 * However, it is undefined / architecture specific whether 90 * However, it is undefined / architecture specific whether
96 * default_memremap_pmem + default_memcpy_to_pmem is sufficient for 91 * ARCH_MEMREMAP_PMEM + default_memcpy_to_pmem is sufficient for
97 * making data durable relative to i/o completion. 92 * making data durable relative to i/o completion.
98 */ 93 */
99static inline void default_memcpy_to_pmem(void __pmem *dst, const void *src, 94static inline void default_memcpy_to_pmem(void __pmem *dst, const void *src,
@@ -117,25 +112,6 @@ static inline void default_clear_pmem(void __pmem *addr, size_t size)
117} 112}
118 113
119/** 114/**
120 * memremap_pmem - map physical persistent memory for pmem api
121 * @offset: physical address of persistent memory
122 * @size: size of the mapping
123 *
124 * Establish a mapping of the architecture specific memory type expected
125 * by memcpy_to_pmem() and wmb_pmem(). For example, it may be
126 * the case that an uncacheable or writethrough mapping is sufficient,
127 * or a writeback mapping provided memcpy_to_pmem() and
128 * wmb_pmem() arrange for the data to be written through the
129 * cache to persistent media.
130 */
131static inline void __pmem *memremap_pmem(struct device *dev,
132 resource_size_t offset, unsigned long size)
133{
134 return (void __pmem *) devm_memremap(dev, offset, size,
135 ARCH_MEMREMAP_PMEM);
136}
137
138/**
139 * memcpy_to_pmem - copy data to persistent memory 115 * memcpy_to_pmem - copy data to persistent memory
140 * @dst: destination buffer for the copy 116 * @dst: destination buffer for the copy
141 * @src: source buffer for the copy 117 * @src: source buffer for the copy