diff options
Diffstat (limited to 'lib/swiotlb.c')
-rw-r--r-- | lib/swiotlb.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/lib/swiotlb.c b/lib/swiotlb.c index a009055140ec..783aff00024c 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c | |||
@@ -361,25 +361,22 @@ static void swiotlb_bounce(phys_addr_t phys, char *dma_addr, size_t size, | |||
361 | } | 361 | } |
362 | } | 362 | } |
363 | 363 | ||
364 | /* | 364 | void *swiotlb_tbl_map_single(struct device *hwdev, dma_addr_t tbl_dma_addr, |
365 | * Allocates bounce buffer and returns its kernel virtual address. | 365 | phys_addr_t phys, size_t size, int dir) |
366 | */ | ||
367 | static void * | ||
368 | map_single(struct device *hwdev, phys_addr_t phys, size_t size, int dir) | ||
369 | { | 366 | { |
370 | unsigned long flags; | 367 | unsigned long flags; |
371 | char *dma_addr; | 368 | char *dma_addr; |
372 | unsigned int nslots, stride, index, wrap; | 369 | unsigned int nslots, stride, index, wrap; |
373 | int i; | 370 | int i; |
374 | unsigned long start_dma_addr; | ||
375 | unsigned long mask; | 371 | unsigned long mask; |
376 | unsigned long offset_slots; | 372 | unsigned long offset_slots; |
377 | unsigned long max_slots; | 373 | unsigned long max_slots; |
378 | 374 | ||
379 | mask = dma_get_seg_boundary(hwdev); | 375 | mask = dma_get_seg_boundary(hwdev); |
380 | start_dma_addr = swiotlb_virt_to_bus(hwdev, io_tlb_start) & mask; | ||
381 | 376 | ||
382 | offset_slots = ALIGN(start_dma_addr, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT; | 377 | tbl_dma_addr &= mask; |
378 | |||
379 | offset_slots = ALIGN(tbl_dma_addr, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT; | ||
383 | 380 | ||
384 | /* | 381 | /* |
385 | * Carefully handle integer overflow which can occur when mask == ~0UL. | 382 | * Carefully handle integer overflow which can occur when mask == ~0UL. |
@@ -468,6 +465,18 @@ found: | |||
468 | } | 465 | } |
469 | 466 | ||
470 | /* | 467 | /* |
468 | * Allocates bounce buffer and returns its kernel virtual address. | ||
469 | */ | ||
470 | |||
471 | static void * | ||
472 | map_single(struct device *hwdev, phys_addr_t phys, size_t size, int dir) | ||
473 | { | ||
474 | dma_addr_t start_dma_addr = swiotlb_virt_to_bus(hwdev, io_tlb_start); | ||
475 | |||
476 | return swiotlb_tbl_map_single(hwdev, start_dma_addr, phys, size, dir); | ||
477 | } | ||
478 | |||
479 | /* | ||
471 | * dma_addr is the kernel virtual address of the bounce buffer to unmap. | 480 | * dma_addr is the kernel virtual address of the bounce buffer to unmap. |
472 | */ | 481 | */ |
473 | static void | 482 | static void |