aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2017-03-20 15:11:28 -0400
committerJoerg Roedel <jroedel@suse.de>2017-03-22 10:54:07 -0400
commit21aff52ab2c831c2f07d48e2fa8d4bab26a66992 (patch)
tree40ba17bfdb2e5222a823e36b86dfe69243ca1c4c
parent82df0a4368c62e68d6622e19a8f4dca2c7eccd3a (diff)
iommu: Add dummy implementations for !IOMMU_IOVA
Currently, building code which uses the API guarded by the IOMMU_IOVA will fail to link if IOMMU_IOVA is not enabled. Often this code will be using the API provided by the IOMMU_API Kconfig symbol, but support for this can be optional, with code falling back to contiguous memory. This commit implements dummy functions for the IOVA API so that it can be compiled out. With both IOMMU_API and IOMMU_IOVA optional, code can now be built with or without support for IOMMU without having to resort to #ifdefs in the user code. Signed-off-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
-rw-r--r--include/linux/iova.h91
1 files changed, 91 insertions, 0 deletions
diff --git a/include/linux/iova.h b/include/linux/iova.h
index f27bb2c62fca..548982ad5f2f 100644
--- a/include/linux/iova.h
+++ b/include/linux/iova.h
@@ -82,6 +82,7 @@ static inline unsigned long iova_pfn(struct iova_domain *iovad, dma_addr_t iova)
82 return iova >> iova_shift(iovad); 82 return iova >> iova_shift(iovad);
83} 83}
84 84
85#ifdef CONFIG_IOMMU_IOVA
85int iova_cache_get(void); 86int iova_cache_get(void);
86void iova_cache_put(void); 87void iova_cache_put(void);
87 88
@@ -106,5 +107,95 @@ void put_iova_domain(struct iova_domain *iovad);
106struct iova *split_and_remove_iova(struct iova_domain *iovad, 107struct iova *split_and_remove_iova(struct iova_domain *iovad,
107 struct iova *iova, unsigned long pfn_lo, unsigned long pfn_hi); 108 struct iova *iova, unsigned long pfn_lo, unsigned long pfn_hi);
108void free_cpu_cached_iovas(unsigned int cpu, struct iova_domain *iovad); 109void free_cpu_cached_iovas(unsigned int cpu, struct iova_domain *iovad);
110#else
111static inline int iova_cache_get(void)
112{
113 return -ENOTSUPP;
114}
115
116static inline void iova_cache_put(void)
117{
118}
119
120static inline struct iova *alloc_iova_mem(void)
121{
122 return NULL;
123}
124
125static inline void free_iova_mem(struct iova *iova)
126{
127}
128
129static inline void free_iova(struct iova_domain *iovad, unsigned long pfn)
130{
131}
132
133static inline void __free_iova(struct iova_domain *iovad, struct iova *iova)
134{
135}
136
137static inline struct iova *alloc_iova(struct iova_domain *iovad,
138 unsigned long size,
139 unsigned long limit_pfn,
140 bool size_aligned)
141{
142 return NULL;
143}
144
145static inline void free_iova_fast(struct iova_domain *iovad,
146 unsigned long pfn,
147 unsigned long size)
148{
149}
150
151static inline unsigned long alloc_iova_fast(struct iova_domain *iovad,
152 unsigned long size,
153 unsigned long limit_pfn)
154{
155 return 0;
156}
157
158static inline struct iova *reserve_iova(struct iova_domain *iovad,
159 unsigned long pfn_lo,
160 unsigned long pfn_hi)
161{
162 return NULL;
163}
164
165static inline void copy_reserved_iova(struct iova_domain *from,
166 struct iova_domain *to)
167{
168}
169
170static inline void init_iova_domain(struct iova_domain *iovad,
171 unsigned long granule,
172 unsigned long start_pfn,
173 unsigned long pfn_32bit)
174{
175}
176
177static inline struct iova *find_iova(struct iova_domain *iovad,
178 unsigned long pfn)
179{
180 return NULL;
181}
182
183static inline void put_iova_domain(struct iova_domain *iovad)
184{
185}
186
187static inline struct iova *split_and_remove_iova(struct iova_domain *iovad,
188 struct iova *iova,
189 unsigned long pfn_lo,
190 unsigned long pfn_hi)
191{
192 return NULL;
193}
194
195static inline void free_cpu_cached_iovas(unsigned int cpu,
196 struct iova_domain *iovad)
197{
198}
199#endif
109 200
110#endif 201#endif