aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nvdimm
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2016-06-17 14:08:06 -0400
committerDan Williams <dan.j.williams@intel.com>2016-06-24 14:39:29 -0400
commitf295e53b60eb93ee53ed5ac610374ed293caa57b (patch)
tree93f09f9113c4efa1704833671557c0230dab9b75 /drivers/nvdimm
parente02fb7264d8a31dddb9a80fbde603feb502d6478 (diff)
libnvdimm, pmem: allow nfit_test to override pmem_direct_access()
Currently phys_to_pfn_t() is an exported symbol to allow nfit_test to override it and indicate that nfit_test-pmem is not device-mapped. Now, we want to enable nfit_test to operate without DMA_CMA and the pmem it provides will no longer be physically contiguous, i.e. won't be capable of supporting direct_access requests larger than a page. Make pmem_direct_access() a weak symbol so that it can be replaced by the tools/testing/nvdimm/ version, and move phys_to_pfn_t() to a static inline now that it no longer needs to be overridden. Acked-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/nvdimm')
-rw-r--r--drivers/nvdimm/pmem.c18
-rw-r--r--drivers/nvdimm/pmem.h24
2 files changed, 27 insertions, 15 deletions
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index ba253df6233f..b6fcb97a601c 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -29,23 +29,10 @@
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/pmem.h> 30#include <linux/pmem.h>
31#include <linux/nd.h> 31#include <linux/nd.h>
32#include "pmem.h"
32#include "pfn.h" 33#include "pfn.h"
33#include "nd.h" 34#include "nd.h"
34 35
35struct pmem_device {
36 /* One contiguous memory region per device */
37 phys_addr_t phys_addr;
38 /* when non-zero this device is hosting a 'pfn' instance */
39 phys_addr_t data_offset;
40 u64 pfn_flags;
41 void __pmem *virt_addr;
42 /* immutable base size of the namespace */
43 size_t size;
44 /* trim size when namespace capacity has been section aligned */
45 u32 pfn_pad;
46 struct badblocks bb;
47};
48
49static void pmem_clear_poison(struct pmem_device *pmem, phys_addr_t offset, 36static void pmem_clear_poison(struct pmem_device *pmem, phys_addr_t offset,
50 unsigned int len) 37 unsigned int len)
51{ 38{
@@ -163,7 +150,8 @@ static int pmem_rw_page(struct block_device *bdev, sector_t sector,
163 return rc; 150 return rc;
164} 151}
165 152
166static long pmem_direct_access(struct block_device *bdev, sector_t sector, 153/* see "strong" declaration in tools/testing/nvdimm/pmem-dax.c */
154__weak long pmem_direct_access(struct block_device *bdev, sector_t sector,
167 void __pmem **kaddr, pfn_t *pfn, long size) 155 void __pmem **kaddr, pfn_t *pfn, long size)
168{ 156{
169 struct pmem_device *pmem = bdev->bd_queue->queuedata; 157 struct pmem_device *pmem = bdev->bd_queue->queuedata;
diff --git a/drivers/nvdimm/pmem.h b/drivers/nvdimm/pmem.h
new file mode 100644
index 000000000000..c48d4e3aa346
--- /dev/null
+++ b/drivers/nvdimm/pmem.h
@@ -0,0 +1,24 @@
1#ifndef __NVDIMM_PMEM_H__
2#define __NVDIMM_PMEM_H__
3#include <linux/badblocks.h>
4#include <linux/types.h>
5#include <linux/pfn_t.h>
6#include <linux/fs.h>
7
8long pmem_direct_access(struct block_device *bdev, sector_t sector,
9 void __pmem **kaddr, pfn_t *pfn, long size);
10/* this definition is in it's own header for tools/testing/nvdimm to consume */
11struct pmem_device {
12 /* One contiguous memory region per device */
13 phys_addr_t phys_addr;
14 /* when non-zero this device is hosting a 'pfn' instance */
15 phys_addr_t data_offset;
16 u64 pfn_flags;
17 void __pmem *virt_addr;
18 /* immutable base size of the namespace */
19 size_t size;
20 /* trim size when namespace capacity has been section aligned */
21 u32 pfn_pad;
22 struct badblocks bb;
23};
24#endif /* __NVDIMM_PMEM_H__ */