Dan Williams | f295e53 | 2016-06-17 11:08:06 -0700 | [diff] [blame] | 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 | |
Dan Williams | 4e4f00a | 2017-05-29 22:40:44 -0700 | [diff] [blame] | 8 | #ifdef CONFIG_ARCH_HAS_PMEM_API |
Dan Williams | ca6a465 | 2017-01-13 20:36:58 -0800 | [diff] [blame] | 9 | #define ARCH_MEMREMAP_PMEM MEMREMAP_WB |
Dan Williams | 4e4f00a | 2017-05-29 22:40:44 -0700 | [diff] [blame] | 10 | void arch_wb_cache_pmem(void *addr, size_t size); |
Dan Williams | f2b6125 | 2017-05-29 23:00:34 -0700 | [diff] [blame] | 11 | void arch_invalidate_pmem(void *addr, size_t size); |
Dan Williams | 4e4f00a | 2017-05-29 22:40:44 -0700 | [diff] [blame] | 12 | #else |
Dan Williams | ca6a465 | 2017-01-13 20:36:58 -0800 | [diff] [blame] | 13 | #define ARCH_MEMREMAP_PMEM MEMREMAP_WT |
Dan Williams | 4e4f00a | 2017-05-29 22:40:44 -0700 | [diff] [blame] | 14 | static inline void arch_wb_cache_pmem(void *addr, size_t size) |
| 15 | { |
| 16 | } |
Dan Williams | f2b6125 | 2017-05-29 23:00:34 -0700 | [diff] [blame] | 17 | static inline void arch_invalidate_pmem(void *addr, size_t size) |
| 18 | { |
| 19 | } |
Dan Williams | 4e4f00a | 2017-05-29 22:40:44 -0700 | [diff] [blame] | 20 | #endif |
| 21 | |
Dan Williams | f295e53 | 2016-06-17 11:08:06 -0700 | [diff] [blame] | 22 | /* this definition is in it's own header for tools/testing/nvdimm to consume */ |
| 23 | struct pmem_device { |
| 24 | /* One contiguous memory region per device */ |
| 25 | phys_addr_t phys_addr; |
| 26 | /* when non-zero this device is hosting a 'pfn' instance */ |
| 27 | phys_addr_t data_offset; |
| 28 | u64 pfn_flags; |
Dan Williams | 7a9eb20 | 2016-06-03 18:06:47 -0700 | [diff] [blame] | 29 | void *virt_addr; |
Dan Williams | f295e53 | 2016-06-17 11:08:06 -0700 | [diff] [blame] | 30 | /* immutable base size of the namespace */ |
| 31 | size_t size; |
| 32 | /* trim size when namespace capacity has been section aligned */ |
| 33 | u32 pfn_pad; |
Toshi Kani | 975750a | 2017-06-12 16:25:11 -0600 | [diff] [blame] | 34 | struct kernfs_node *bb_state; |
Dan Williams | f295e53 | 2016-06-17 11:08:06 -0700 | [diff] [blame] | 35 | struct badblocks bb; |
Dan Williams | c1d6e82 | 2017-01-24 23:02:09 -0800 | [diff] [blame] | 36 | struct dax_device *dax_dev; |
| 37 | struct gendisk *disk; |
Dan Williams | f295e53 | 2016-06-17 11:08:06 -0700 | [diff] [blame] | 38 | }; |
Dan Williams | c1d6e82 | 2017-01-24 23:02:09 -0800 | [diff] [blame] | 39 | |
| 40 | long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, |
| 41 | long nr_pages, void **kaddr, pfn_t *pfn); |
Dan Williams | f295e53 | 2016-06-17 11:08:06 -0700 | [diff] [blame] | 42 | #endif /* __NVDIMM_PMEM_H__ */ |