0001
0002
0003
0004
0005 #ifndef __DAX_PRIVATE_H__
0006 #define __DAX_PRIVATE_H__
0007
0008 #include <linux/device.h>
0009 #include <linux/cdev.h>
0010 #include <linux/idr.h>
0011
0012
0013 struct dax_device;
0014 struct dax_device *inode_dax(struct inode *inode);
0015 struct inode *dax_inode(struct dax_device *dax_dev);
0016 int dax_bus_init(void);
0017 void dax_bus_exit(void);
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 struct dax_region {
0032 int id;
0033 int target_node;
0034 struct kref kref;
0035 struct device *dev;
0036 unsigned int align;
0037 struct ida ida;
0038 struct resource res;
0039 struct device *seed;
0040 struct device *youngest;
0041 };
0042
0043 struct dax_mapping {
0044 struct device dev;
0045 int range_id;
0046 int id;
0047 };
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062 struct dev_dax {
0063 struct dax_region *region;
0064 struct dax_device *dax_dev;
0065 unsigned int align;
0066 int target_node;
0067 int id;
0068 struct ida ida;
0069 struct device dev;
0070 struct dev_pagemap *pgmap;
0071 int nr_range;
0072 struct dev_dax_range {
0073 unsigned long pgoff;
0074 struct range range;
0075 struct dax_mapping *mapping;
0076 } *ranges;
0077 };
0078
0079 static inline struct dev_dax *to_dev_dax(struct device *dev)
0080 {
0081 return container_of(dev, struct dev_dax, dev);
0082 }
0083
0084 static inline struct dax_mapping *to_dax_mapping(struct device *dev)
0085 {
0086 return container_of(dev, struct dax_mapping, dev);
0087 }
0088
0089 phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff, unsigned long size);
0090
0091 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
0092 static inline bool dax_align_valid(unsigned long align)
0093 {
0094 if (align == PUD_SIZE && IS_ENABLED(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD))
0095 return true;
0096 if (align == PMD_SIZE && has_transparent_hugepage())
0097 return true;
0098 if (align == PAGE_SIZE)
0099 return true;
0100 return false;
0101 }
0102 #else
0103 static inline bool dax_align_valid(unsigned long align)
0104 {
0105 return align == PAGE_SIZE;
0106 }
0107 #endif
0108 #endif