diff options
Diffstat (limited to 'lib/swiotlb.c')
-rw-r--r-- | lib/swiotlb.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/lib/swiotlb.c b/lib/swiotlb.c index 256c8445e54d..3c95922e51e7 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c | |||
@@ -31,6 +31,7 @@ | |||
31 | 31 | ||
32 | #include <linux/init.h> | 32 | #include <linux/init.h> |
33 | #include <linux/bootmem.h> | 33 | #include <linux/bootmem.h> |
34 | #include <linux/iommu-helper.h> | ||
34 | 35 | ||
35 | #define OFFSET(val,align) ((unsigned long) \ | 36 | #define OFFSET(val,align) ((unsigned long) \ |
36 | ( (val) & ( (align) - 1))) | 37 | ( (val) & ( (align) - 1))) |
@@ -282,15 +283,6 @@ address_needs_mapping(struct device *hwdev, dma_addr_t addr) | |||
282 | return (addr & ~mask) != 0; | 283 | return (addr & ~mask) != 0; |
283 | } | 284 | } |
284 | 285 | ||
285 | static inline unsigned int is_span_boundary(unsigned int index, | ||
286 | unsigned int nslots, | ||
287 | unsigned long offset_slots, | ||
288 | unsigned long max_slots) | ||
289 | { | ||
290 | unsigned long offset = (offset_slots + index) & (max_slots - 1); | ||
291 | return offset + nslots > max_slots; | ||
292 | } | ||
293 | |||
294 | /* | 286 | /* |
295 | * Allocates bounce buffer and returns its kernel virtual address. | 287 | * Allocates bounce buffer and returns its kernel virtual address. |
296 | */ | 288 | */ |
@@ -337,8 +329,8 @@ map_single(struct device *hwdev, char *buffer, size_t size, int dir) | |||
337 | wrap = index; | 329 | wrap = index; |
338 | 330 | ||
339 | do { | 331 | do { |
340 | while (is_span_boundary(index, nslots, offset_slots, | 332 | while (iommu_is_span_boundary(index, nslots, offset_slots, |
341 | max_slots)) { | 333 | max_slots)) { |
342 | index += stride; | 334 | index += stride; |
343 | if (index >= io_tlb_nslabs) | 335 | if (index >= io_tlb_nslabs) |
344 | index = 0; | 336 | index = 0; |