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