1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __NVDIMM_PMEM_H__ 3 #define __NVDIMM_PMEM_H__ 4 #include <linux/page-flags.h> 5 #include <linux/badblocks.h> 6 #include <linux/memremap.h> 7 #include <linux/types.h> 8 #include <linux/pfn_t.h> 9 #include <linux/fs.h> 10 11 /* this definition is in it's own header for tools/testing/nvdimm to consume */ 12 struct pmem_device { 13 /* One contiguous memory region per device */ 14 phys_addr_t phys_addr; 15 /* when non-zero this device is hosting a 'pfn' instance */ 16 phys_addr_t data_offset; 17 u64 pfn_flags; 18 void *virt_addr; 19 /* immutable base size of the namespace */ 20 size_t size; 21 /* trim size when namespace capacity has been section aligned */ 22 u32 pfn_pad; 23 struct kernfs_node *bb_state; 24 struct badblocks bb; 25 struct dax_device *dax_dev; 26 struct gendisk *disk; 27 struct dev_pagemap pgmap; 28 }; 29 30 long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, 31 long nr_pages, void **kaddr, pfn_t *pfn); 32 33 #ifdef CONFIG_MEMORY_FAILURE 34 static inline bool test_and_clear_pmem_poison(struct page *page) 35 { 36 return TestClearPageHWPoison(page); 37 } 38 #else 39 static inline bool test_and_clear_pmem_poison(struct page *page) 40 { 41 return false; 42 } 43 #endif 44 #endif /* __NVDIMM_PMEM_H__ */ 45