Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Dan Williams | f295e53 | 2016-06-17 11:08:06 -0700 | [diff] [blame] | 2 | #ifndef __NVDIMM_PMEM_H__ |
| 3 | #define __NVDIMM_PMEM_H__ |
Dan Williams | c953cc9 | 2018-07-13 21:50:37 -0700 | [diff] [blame] | 4 | #include <linux/page-flags.h> |
Dan Williams | f295e53 | 2016-06-17 11:08:06 -0700 | [diff] [blame] | 5 | #include <linux/badblocks.h> |
| 6 | #include <linux/types.h> |
| 7 | #include <linux/pfn_t.h> |
| 8 | #include <linux/fs.h> |
| 9 | |
Dan Williams | f295e53 | 2016-06-17 11:08:06 -0700 | [diff] [blame] | 10 | /* this definition is in it's own header for tools/testing/nvdimm to consume */ |
| 11 | struct 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; |
Dan Williams | 7a9eb20 | 2016-06-03 18:06:47 -0700 | [diff] [blame] | 17 | void *virt_addr; |
Dan Williams | f295e53 | 2016-06-17 11:08:06 -0700 | [diff] [blame] | 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; |
Toshi Kani | 975750a | 2017-06-12 16:25:11 -0600 | [diff] [blame] | 22 | struct kernfs_node *bb_state; |
Dan Williams | f295e53 | 2016-06-17 11:08:06 -0700 | [diff] [blame] | 23 | struct badblocks bb; |
Dan Williams | c1d6e82 | 2017-01-24 23:02:09 -0800 | [diff] [blame] | 24 | struct dax_device *dax_dev; |
| 25 | struct gendisk *disk; |
Christoph Hellwig | e8d5134 | 2017-12-29 08:54:05 +0100 | [diff] [blame] | 26 | struct dev_pagemap pgmap; |
Dan Williams | f295e53 | 2016-06-17 11:08:06 -0700 | [diff] [blame] | 27 | }; |
Dan Williams | c1d6e82 | 2017-01-24 23:02:09 -0800 | [diff] [blame] | 28 | |
| 29 | long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, |
| 30 | long nr_pages, void **kaddr, pfn_t *pfn); |
Dan Williams | c953cc9 | 2018-07-13 21:50:37 -0700 | [diff] [blame] | 31 | |
| 32 | #ifdef CONFIG_MEMORY_FAILURE |
| 33 | static inline bool test_and_clear_pmem_poison(struct page *page) |
| 34 | { |
| 35 | return TestClearPageHWPoison(page); |
| 36 | } |
| 37 | #else |
| 38 | static inline bool test_and_clear_pmem_poison(struct page *page) |
| 39 | { |
| 40 | return false; |
| 41 | } |
| 42 | #endif |
Dan Williams | f295e53 | 2016-06-17 11:08:06 -0700 | [diff] [blame] | 43 | #endif /* __NVDIMM_PMEM_H__ */ |