blob: 5434321cad67f11d4f044a0a7152a8e5035aa97d [file] [log] [blame]
Dan Williamsf295e532016-06-17 11:08:06 -07001#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 Williams4e4f00a2017-05-29 22:40:44 -07008#ifdef CONFIG_ARCH_HAS_PMEM_API
Dan Williamsca6a4652017-01-13 20:36:58 -08009#define ARCH_MEMREMAP_PMEM MEMREMAP_WB
Dan Williams4e4f00a2017-05-29 22:40:44 -070010void arch_wb_cache_pmem(void *addr, size_t size);
Dan Williamsf2b61252017-05-29 23:00:34 -070011void arch_invalidate_pmem(void *addr, size_t size);
Dan Williams4e4f00a2017-05-29 22:40:44 -070012#else
Dan Williamsca6a4652017-01-13 20:36:58 -080013#define ARCH_MEMREMAP_PMEM MEMREMAP_WT
Dan Williams4e4f00a2017-05-29 22:40:44 -070014static inline void arch_wb_cache_pmem(void *addr, size_t size)
15{
16}
Dan Williamsf2b61252017-05-29 23:00:34 -070017static inline void arch_invalidate_pmem(void *addr, size_t size)
18{
19}
Dan Williams4e4f00a2017-05-29 22:40:44 -070020#endif
21
Dan Williamsf295e532016-06-17 11:08:06 -070022/* this definition is in it's own header for tools/testing/nvdimm to consume */
23struct 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 Williams7a9eb202016-06-03 18:06:47 -070029 void *virt_addr;
Dan Williamsf295e532016-06-17 11:08:06 -070030 /* 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 Kani975750a2017-06-12 16:25:11 -060034 struct kernfs_node *bb_state;
Dan Williamsf295e532016-06-17 11:08:06 -070035 struct badblocks bb;
Dan Williamsc1d6e822017-01-24 23:02:09 -080036 struct dax_device *dax_dev;
37 struct gendisk *disk;
Dan Williamsf295e532016-06-17 11:08:06 -070038};
Dan Williamsc1d6e822017-01-24 23:02:09 -080039
40long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff,
41 long nr_pages, void **kaddr, pfn_t *pfn);
Dan Williamsf295e532016-06-17 11:08:06 -070042#endif /* __NVDIMM_PMEM_H__ */