blob: 59cfe13ea8a85c3bcccf9211409ae237196626d5 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Dan Williamsf295e532016-06-17 11:08:06 -07002#ifndef __NVDIMM_PMEM_H__
3#define __NVDIMM_PMEM_H__
Dan Williamsc953cc92018-07-13 21:50:37 -07004#include <linux/page-flags.h>
Dan Williamsf295e532016-06-17 11:08:06 -07005#include <linux/badblocks.h>
6#include <linux/types.h>
7#include <linux/pfn_t.h>
8#include <linux/fs.h>
9
Dan Williamsf295e532016-06-17 11:08:06 -070010/* this definition is in it's own header for tools/testing/nvdimm to consume */
11struct 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 Williams7a9eb202016-06-03 18:06:47 -070017 void *virt_addr;
Dan Williamsf295e532016-06-17 11:08:06 -070018 /* 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 Kani975750a2017-06-12 16:25:11 -060022 struct kernfs_node *bb_state;
Dan Williamsf295e532016-06-17 11:08:06 -070023 struct badblocks bb;
Dan Williamsc1d6e822017-01-24 23:02:09 -080024 struct dax_device *dax_dev;
25 struct gendisk *disk;
Christoph Hellwige8d51342017-12-29 08:54:05 +010026 struct dev_pagemap pgmap;
Dan Williamsf295e532016-06-17 11:08:06 -070027};
Dan Williamsc1d6e822017-01-24 23:02:09 -080028
29long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff,
30 long nr_pages, void **kaddr, pfn_t *pfn);
Dan Williamsc953cc92018-07-13 21:50:37 -070031
32#ifdef CONFIG_MEMORY_FAILURE
33static inline bool test_and_clear_pmem_poison(struct page *page)
34{
35 return TestClearPageHWPoison(page);
36}
37#else
38static inline bool test_and_clear_pmem_poison(struct page *page)
39{
40 return false;
41}
42#endif
Dan Williamsf295e532016-06-17 11:08:06 -070043#endif /* __NVDIMM_PMEM_H__ */