|
5 | 5 | #define __LINUX_IOMMU_PRIV_H |
6 | 6 |
|
7 | 7 | #include <linux/iommu.h> |
| 8 | +#include <linux/iommu-debug-pagealloc.h> |
8 | 9 | #include <linux/msi.h> |
9 | 10 |
|
10 | 11 | static inline const struct iommu_ops *dev_iommu_ops(struct device *dev) |
@@ -65,4 +66,61 @@ static inline int iommufd_sw_msi(struct iommu_domain *domain, |
65 | 66 | int iommu_replace_device_pasid(struct iommu_domain *domain, |
66 | 67 | struct device *dev, ioasid_t pasid, |
67 | 68 | struct iommu_attach_handle *handle); |
| 69 | + |
| 70 | +#ifdef CONFIG_IOMMU_DEBUG_PAGEALLOC |
| 71 | + |
| 72 | +void __iommu_debug_map(struct iommu_domain *domain, phys_addr_t phys, |
| 73 | + size_t size); |
| 74 | +void __iommu_debug_unmap_begin(struct iommu_domain *domain, |
| 75 | + unsigned long iova, size_t size); |
| 76 | +void __iommu_debug_unmap_end(struct iommu_domain *domain, |
| 77 | + unsigned long iova, size_t size, size_t unmapped); |
| 78 | + |
| 79 | +static inline void iommu_debug_map(struct iommu_domain *domain, |
| 80 | + phys_addr_t phys, size_t size) |
| 81 | +{ |
| 82 | + if (static_branch_unlikely(&iommu_debug_initialized)) |
| 83 | + __iommu_debug_map(domain, phys, size); |
| 84 | +} |
| 85 | + |
| 86 | +static inline void iommu_debug_unmap_begin(struct iommu_domain *domain, |
| 87 | + unsigned long iova, size_t size) |
| 88 | +{ |
| 89 | + if (static_branch_unlikely(&iommu_debug_initialized)) |
| 90 | + __iommu_debug_unmap_begin(domain, iova, size); |
| 91 | +} |
| 92 | + |
| 93 | +static inline void iommu_debug_unmap_end(struct iommu_domain *domain, |
| 94 | + unsigned long iova, size_t size, |
| 95 | + size_t unmapped) |
| 96 | +{ |
| 97 | + if (static_branch_unlikely(&iommu_debug_initialized)) |
| 98 | + __iommu_debug_unmap_end(domain, iova, size, unmapped); |
| 99 | +} |
| 100 | + |
| 101 | +void iommu_debug_init(void); |
| 102 | + |
| 103 | +#else |
| 104 | +static inline void iommu_debug_map(struct iommu_domain *domain, |
| 105 | + phys_addr_t phys, size_t size) |
| 106 | +{ |
| 107 | +} |
| 108 | + |
| 109 | +static inline void iommu_debug_unmap_begin(struct iommu_domain *domain, |
| 110 | + unsigned long iova, size_t size) |
| 111 | +{ |
| 112 | +} |
| 113 | + |
| 114 | +static inline void iommu_debug_unmap_end(struct iommu_domain *domain, |
| 115 | + unsigned long iova, size_t size, |
| 116 | + size_t unmapped) |
| 117 | +{ |
| 118 | +} |
| 119 | + |
| 120 | +static inline void iommu_debug_init(void) |
| 121 | +{ |
| 122 | +} |
| 123 | + |
| 124 | +#endif /* CONFIG_IOMMU_DEBUG_PAGEALLOC */ |
| 125 | + |
68 | 126 | #endif /* __LINUX_IOMMU_PRIV_H */ |
0 commit comments