Commit d7ef1533a90f432615d25729c2477bac9e72051d
1 parent
22d4826998
Exists in
master
and in
7 other branches
swiotlb: Make swiotlb bookkeeping functions visible in the header file.
We put the functions dealing with the operations on the SWIOTLB buffer in the header and make those functions non-static. And also make the functions exported via EXPORT_SYMBOL_GPL. See "swiotlb: swiotlb: add swiotlb_tbl_map_single library function" for full description of patchset. [v2: swiotlb_sync_single_range_for_* no more. Remove usage.] Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Acked-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Tested-by: Albert Herranz <albert_herranz@yahoo.es>
Showing 2 changed files with 36 additions and 15 deletions Side-by-side Diff
include/linux/swiotlb.h
... | ... | @@ -25,6 +25,28 @@ |
25 | 25 | extern void swiotlb_init(int verbose); |
26 | 26 | extern void swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose); |
27 | 27 | |
28 | +/* | |
29 | + * Enumeration for sync targets | |
30 | + */ | |
31 | +enum dma_sync_target { | |
32 | + SYNC_FOR_CPU = 0, | |
33 | + SYNC_FOR_DEVICE = 1, | |
34 | +}; | |
35 | +extern void *swiotlb_tbl_map_single(struct device *hwdev, dma_addr_t tbl_dma_addr, | |
36 | + phys_addr_t phys, size_t size, | |
37 | + enum dma_data_direction dir); | |
38 | + | |
39 | +extern void swiotlb_tbl_unmap_single(struct device *hwdev, char *dma_addr, | |
40 | + size_t size, enum dma_data_direction dir); | |
41 | + | |
42 | +extern void swiotlb_tbl_sync_single(struct device *hwdev, char *dma_addr, | |
43 | + size_t size, enum dma_data_direction dir, | |
44 | + enum dma_sync_target target); | |
45 | + | |
46 | +/* Accessory functions. */ | |
47 | +extern void swiotlb_bounce(phys_addr_t phys, char *dma_addr, size_t size, | |
48 | + enum dma_data_direction dir); | |
49 | + | |
28 | 50 | extern void |
29 | 51 | *swiotlb_alloc_coherent(struct device *hwdev, size_t size, |
30 | 52 | dma_addr_t *dma_handle, gfp_t flags); |
lib/swiotlb.c
... | ... | @@ -50,14 +50,6 @@ |
50 | 50 | */ |
51 | 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 | 53 | int swiotlb_force; |
62 | 54 | |
63 | 55 | /* |
... | ... | @@ -335,8 +327,8 @@ |
335 | 327 | /* |
336 | 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, | |
339 | - enum dma_data_direction dir) | |
330 | +void swiotlb_bounce(phys_addr_t phys, char *dma_addr, size_t size, | |
331 | + enum dma_data_direction dir) | |
340 | 332 | { |
341 | 333 | unsigned long pfn = PFN_DOWN(phys); |
342 | 334 | |
... | ... | @@ -372,6 +364,7 @@ |
372 | 364 | memcpy(phys_to_virt(phys), dma_addr, size); |
373 | 365 | } |
374 | 366 | } |
367 | +EXPORT_SYMBOL_GPL(swiotlb_bounce); | |
375 | 368 | |
376 | 369 | void *swiotlb_tbl_map_single(struct device *hwdev, dma_addr_t tbl_dma_addr, |
377 | 370 | phys_addr_t phys, size_t size, |
... | ... | @@ -476,6 +469,7 @@ |
476 | 469 | |
477 | 470 | return dma_addr; |
478 | 471 | } |
472 | +EXPORT_SYMBOL_GPL(swiotlb_tbl_map_single); | |
479 | 473 | |
480 | 474 | /* |
481 | 475 | * Allocates bounce buffer and returns its kernel virtual address. |
... | ... | @@ -493,7 +487,7 @@ |
493 | 487 | /* |
494 | 488 | * dma_addr is the kernel virtual address of the bounce buffer to unmap. |
495 | 489 | */ |
496 | -static void | |
490 | +void | |
497 | 491 | swiotlb_tbl_unmap_single(struct device *hwdev, char *dma_addr, size_t size, |
498 | 492 | enum dma_data_direction dir) |
499 | 493 | { |
500 | 494 | |
501 | 495 | |
... | ... | @@ -533,10 +527,12 @@ |
533 | 527 | } |
534 | 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 | 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 | 537 | int index = (dma_addr - io_tlb_start) >> IO_TLB_SHIFT; |
542 | 538 | phys_addr_t phys = io_tlb_orig_addr[index]; |
... | ... | @@ -560,6 +556,7 @@ |
560 | 556 | BUG(); |
561 | 557 | } |
562 | 558 | } |
559 | +EXPORT_SYMBOL_GPL(swiotlb_tbl_sync_single); | |
563 | 560 | |
564 | 561 | void * |
565 | 562 | swiotlb_alloc_coherent(struct device *hwdev, size_t size, |
... | ... | @@ -748,7 +745,8 @@ |
748 | 745 | */ |
749 | 746 | static void |
750 | 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 | 751 | phys_addr_t paddr = dma_to_phys(hwdev, dev_addr); |
754 | 752 | |
... | ... | @@ -877,7 +875,8 @@ |
877 | 875 | */ |
878 | 876 | static void |
879 | 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 | 881 | struct scatterlist *sg; |
883 | 882 | int i; |