diff options
-rw-r--r-- | include/asm-x86_64/swiotlb.h | 8 | ||||
-rw-r--r-- | lib/swiotlb.c | 33 |
2 files changed, 41 insertions, 0 deletions
diff --git a/include/asm-x86_64/swiotlb.h b/include/asm-x86_64/swiotlb.h index 36293061f4ed..9b011dd8d19d 100644 --- a/include/asm-x86_64/swiotlb.h +++ b/include/asm-x86_64/swiotlb.h | |||
@@ -15,6 +15,14 @@ extern void swiotlb_sync_single_for_cpu(struct device *hwdev, | |||
15 | extern void swiotlb_sync_single_for_device(struct device *hwdev, | 15 | extern void swiotlb_sync_single_for_device(struct device *hwdev, |
16 | dma_addr_t dev_addr, | 16 | dma_addr_t dev_addr, |
17 | size_t size, int dir); | 17 | size_t size, int dir); |
18 | extern void swiotlb_sync_single_range_for_cpu(struct device *hwdev, | ||
19 | dma_addr_t dev_addr, | ||
20 | unsigned long offset, | ||
21 | size_t size, int dir); | ||
22 | extern void swiotlb_sync_single_range_for_device(struct device *hwdev, | ||
23 | dma_addr_t dev_addr, | ||
24 | unsigned long offset, | ||
25 | size_t size, int dir); | ||
18 | extern void swiotlb_sync_sg_for_cpu(struct device *hwdev, | 26 | extern void swiotlb_sync_sg_for_cpu(struct device *hwdev, |
19 | struct scatterlist *sg, int nelems, | 27 | struct scatterlist *sg, int nelems, |
20 | int dir); | 28 | int dir); |
diff --git a/lib/swiotlb.c b/lib/swiotlb.c index 9719a14649e7..566791b3f583 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c | |||
@@ -623,6 +623,37 @@ swiotlb_sync_single_for_device(struct device *hwdev, dma_addr_t dev_addr, | |||
623 | } | 623 | } |
624 | 624 | ||
625 | /* | 625 | /* |
626 | * Same as above, but for a sub-range of the mapping. | ||
627 | */ | ||
628 | static inline void | ||
629 | swiotlb_sync_single_range(struct device *hwdev, dma_addr_t dev_addr, | ||
630 | unsigned long offset, size_t size, int dir) | ||
631 | { | ||
632 | char *dma_addr = phys_to_virt(dev_addr) + offset; | ||
633 | |||
634 | if (dir == DMA_NONE) | ||
635 | BUG(); | ||
636 | if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end) | ||
637 | sync_single(hwdev, dma_addr, size, dir); | ||
638 | else if (dir == DMA_FROM_DEVICE) | ||
639 | mark_clean(dma_addr, size); | ||
640 | } | ||
641 | |||
642 | void | ||
643 | swiotlb_sync_single_range_for_cpu(struct device *hwdev, dma_addr_t dev_addr, | ||
644 | unsigned long offset, size_t size, int dir) | ||
645 | { | ||
646 | swiotlb_sync_single_range(hwdev, dev_addr, offset, size, dir); | ||
647 | } | ||
648 | |||
649 | void | ||
650 | swiotlb_sync_single_range_for_device(struct device *hwdev, dma_addr_t dev_addr, | ||
651 | unsigned long offset, size_t size, int dir) | ||
652 | { | ||
653 | swiotlb_sync_single_range(hwdev, dev_addr, offset, size, dir); | ||
654 | } | ||
655 | |||
656 | /* | ||
626 | * Map a set of buffers described by scatterlist in streaming mode for DMA. | 657 | * Map a set of buffers described by scatterlist in streaming mode for DMA. |
627 | * This is the scatter-gather version of the above swiotlb_map_single | 658 | * This is the scatter-gather version of the above swiotlb_map_single |
628 | * interface. Here the scatter gather list elements are each tagged with the | 659 | * interface. Here the scatter gather list elements are each tagged with the |
@@ -750,6 +781,8 @@ EXPORT_SYMBOL(swiotlb_map_sg); | |||
750 | EXPORT_SYMBOL(swiotlb_unmap_sg); | 781 | EXPORT_SYMBOL(swiotlb_unmap_sg); |
751 | EXPORT_SYMBOL(swiotlb_sync_single_for_cpu); | 782 | EXPORT_SYMBOL(swiotlb_sync_single_for_cpu); |
752 | EXPORT_SYMBOL(swiotlb_sync_single_for_device); | 783 | EXPORT_SYMBOL(swiotlb_sync_single_for_device); |
784 | EXPORT_SYMBOL_GPL(swiotlb_sync_single_range_for_cpu); | ||
785 | EXPORT_SYMBOL_GPL(swiotlb_sync_single_range_for_device); | ||
753 | EXPORT_SYMBOL(swiotlb_sync_sg_for_cpu); | 786 | EXPORT_SYMBOL(swiotlb_sync_sg_for_cpu); |
754 | EXPORT_SYMBOL(swiotlb_sync_sg_for_device); | 787 | EXPORT_SYMBOL(swiotlb_sync_sg_for_device); |
755 | EXPORT_SYMBOL(swiotlb_dma_mapping_error); | 788 | EXPORT_SYMBOL(swiotlb_dma_mapping_error); |