diff options
Diffstat (limited to 'lib/swiotlb.c')
-rw-r--r-- | lib/swiotlb.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/lib/swiotlb.c b/lib/swiotlb.c index 5f60157f31d8..34e3082632d8 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c | |||
@@ -50,14 +50,6 @@ | |||
50 | */ | 50 | */ |
51 | #define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT) | 51 | #define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT) |
52 | 52 | ||
53 | /* | ||
54 | * Enumeration for sync targets | ||
55 | */ | ||
56 | enum dma_sync_target { | ||
57 | SYNC_FOR_CPU = 0, | ||
58 | SYNC_FOR_DEVICE = 1, | ||
59 | }; | ||
60 | |||
61 | int swiotlb_force; | 53 | int swiotlb_force; |
62 | 54 | ||
63 | /* | 55 | /* |
@@ -335,8 +327,8 @@ static int is_swiotlb_buffer(phys_addr_t paddr) | |||
335 | /* | 327 | /* |
336 | * Bounce: copy the swiotlb buffer back to the original dma location | 328 | * Bounce: copy the swiotlb buffer back to the original dma location |
337 | */ | 329 | */ |
338 | static void swiotlb_bounce(phys_addr_t phys, char *dma_addr, size_t size, | 330 | void swiotlb_bounce(phys_addr_t phys, char *dma_addr, size_t size, |
339 | enum dma_data_direction dir) | 331 | enum dma_data_direction dir) |
340 | { | 332 | { |
341 | unsigned long pfn = PFN_DOWN(phys); | 333 | unsigned long pfn = PFN_DOWN(phys); |
342 | 334 | ||
@@ -372,6 +364,7 @@ static void swiotlb_bounce(phys_addr_t phys, char *dma_addr, size_t size, | |||
372 | memcpy(phys_to_virt(phys), dma_addr, size); | 364 | memcpy(phys_to_virt(phys), dma_addr, size); |
373 | } | 365 | } |
374 | } | 366 | } |
367 | EXPORT_SYMBOL_GPL(swiotlb_bounce); | ||
375 | 368 | ||
376 | void *swiotlb_tbl_map_single(struct device *hwdev, dma_addr_t tbl_dma_addr, | 369 | void *swiotlb_tbl_map_single(struct device *hwdev, dma_addr_t tbl_dma_addr, |
377 | phys_addr_t phys, size_t size, | 370 | phys_addr_t phys, size_t size, |
@@ -476,6 +469,7 @@ found: | |||
476 | 469 | ||
477 | return dma_addr; | 470 | return dma_addr; |
478 | } | 471 | } |
472 | EXPORT_SYMBOL_GPL(swiotlb_tbl_map_single); | ||
479 | 473 | ||
480 | /* | 474 | /* |
481 | * Allocates bounce buffer and returns its kernel virtual address. | 475 | * Allocates bounce buffer and returns its kernel virtual address. |
@@ -493,7 +487,7 @@ map_single(struct device *hwdev, phys_addr_t phys, size_t size, | |||
493 | /* | 487 | /* |
494 | * dma_addr is the kernel virtual address of the bounce buffer to unmap. | 488 | * dma_addr is the kernel virtual address of the bounce buffer to unmap. |
495 | */ | 489 | */ |
496 | static void | 490 | void |
497 | swiotlb_tbl_unmap_single(struct device *hwdev, char *dma_addr, size_t size, | 491 | swiotlb_tbl_unmap_single(struct device *hwdev, char *dma_addr, size_t size, |
498 | enum dma_data_direction dir) | 492 | enum dma_data_direction dir) |
499 | { | 493 | { |
@@ -533,10 +527,12 @@ swiotlb_tbl_unmap_single(struct device *hwdev, char *dma_addr, size_t size, | |||
533 | } | 527 | } |
534 | spin_unlock_irqrestore(&io_tlb_lock, flags); | 528 | spin_unlock_irqrestore(&io_tlb_lock, flags); |
535 | } | 529 | } |
530 | EXPORT_SYMBOL_GPL(swiotlb_tbl_unmap_single); | ||
536 | 531 | ||
537 | static void | 532 | void |
538 | swiotlb_tbl_sync_single(struct device *hwdev, char *dma_addr, size_t size, | 533 | swiotlb_tbl_sync_single(struct device *hwdev, char *dma_addr, size_t size, |
539 | enum dma_data_direction dir, int target) | 534 | enum dma_data_direction dir, |
535 | enum dma_sync_target target) | ||
540 | { | 536 | { |
541 | int index = (dma_addr - io_tlb_start) >> IO_TLB_SHIFT; | 537 | int index = (dma_addr - io_tlb_start) >> IO_TLB_SHIFT; |
542 | phys_addr_t phys = io_tlb_orig_addr[index]; | 538 | phys_addr_t phys = io_tlb_orig_addr[index]; |
@@ -560,6 +556,7 @@ swiotlb_tbl_sync_single(struct device *hwdev, char *dma_addr, size_t size, | |||
560 | BUG(); | 556 | BUG(); |
561 | } | 557 | } |
562 | } | 558 | } |
559 | EXPORT_SYMBOL_GPL(swiotlb_tbl_sync_single); | ||
563 | 560 | ||
564 | void * | 561 | void * |
565 | swiotlb_alloc_coherent(struct device *hwdev, size_t size, | 562 | swiotlb_alloc_coherent(struct device *hwdev, size_t size, |
@@ -748,7 +745,8 @@ EXPORT_SYMBOL_GPL(swiotlb_unmap_page); | |||
748 | */ | 745 | */ |
749 | static void | 746 | static void |
750 | swiotlb_sync_single(struct device *hwdev, dma_addr_t dev_addr, | 747 | swiotlb_sync_single(struct device *hwdev, dma_addr_t dev_addr, |
751 | size_t size, enum dma_data_direction dir, int target) | 748 | size_t size, enum dma_data_direction dir, |
749 | enum dma_sync_target target) | ||
752 | { | 750 | { |
753 | phys_addr_t paddr = dma_to_phys(hwdev, dev_addr); | 751 | phys_addr_t paddr = dma_to_phys(hwdev, dev_addr); |
754 | 752 | ||
@@ -877,7 +875,8 @@ EXPORT_SYMBOL(swiotlb_unmap_sg); | |||
877 | */ | 875 | */ |
878 | static void | 876 | static void |
879 | swiotlb_sync_sg(struct device *hwdev, struct scatterlist *sgl, | 877 | swiotlb_sync_sg(struct device *hwdev, struct scatterlist *sgl, |
880 | int nelems, enum dma_data_direction dir, int target) | 878 | int nelems, enum dma_data_direction dir, |
879 | enum dma_sync_target target) | ||
881 | { | 880 | { |
882 | struct scatterlist *sg; | 881 | struct scatterlist *sg; |
883 | int i; | 882 | int i; |