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