pmem.h 1.1 KB

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