pmem.h 1.2 KB

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