diff options
-rw-r--r-- | lib/swiotlb.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/lib/swiotlb.c b/lib/swiotlb.c index 2bde54a40d86..d912f068145c 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c | |||
@@ -731,10 +731,16 @@ swiotlb_sync_single(struct device *hwdev, dma_addr_t dev_addr, | |||
731 | char *dma_addr = swiotlb_bus_to_virt(dev_addr); | 731 | char *dma_addr = swiotlb_bus_to_virt(dev_addr); |
732 | 732 | ||
733 | BUG_ON(dir == DMA_NONE); | 733 | BUG_ON(dir == DMA_NONE); |
734 | if (is_swiotlb_buffer(dma_addr)) | 734 | |
735 | if (is_swiotlb_buffer(dma_addr)) { | ||
735 | sync_single(hwdev, dma_addr, size, dir, target); | 736 | sync_single(hwdev, dma_addr, size, dir, target); |
736 | else if (dir == DMA_FROM_DEVICE) | 737 | return; |
737 | dma_mark_clean(dma_addr, size); | 738 | } |
739 | |||
740 | if (dir != DMA_FROM_DEVICE) | ||
741 | return; | ||
742 | |||
743 | dma_mark_clean(dma_addr, size); | ||
738 | } | 744 | } |
739 | 745 | ||
740 | void | 746 | void |
@@ -761,13 +767,7 @@ swiotlb_sync_single_range(struct device *hwdev, dma_addr_t dev_addr, | |||
761 | unsigned long offset, size_t size, | 767 | unsigned long offset, size_t size, |
762 | int dir, int target) | 768 | int dir, int target) |
763 | { | 769 | { |
764 | char *dma_addr = swiotlb_bus_to_virt(dev_addr) + offset; | 770 | swiotlb_sync_single(hwdev, dev_addr + offset, size, dir, target); |
765 | |||
766 | BUG_ON(dir == DMA_NONE); | ||
767 | if (is_swiotlb_buffer(dma_addr)) | ||
768 | sync_single(hwdev, dma_addr, size, dir, target); | ||
769 | else if (dir == DMA_FROM_DEVICE) | ||
770 | dma_mark_clean(dma_addr, size); | ||
771 | } | 771 | } |
772 | 772 | ||
773 | void | 773 | void |
@@ -890,15 +890,9 @@ swiotlb_sync_sg(struct device *hwdev, struct scatterlist *sgl, | |||
890 | struct scatterlist *sg; | 890 | struct scatterlist *sg; |
891 | int i; | 891 | int i; |
892 | 892 | ||
893 | BUG_ON(dir == DMA_NONE); | 893 | for_each_sg(sgl, sg, nelems, i) |
894 | 894 | swiotlb_sync_single(hwdev, sg->dma_address, | |
895 | for_each_sg(sgl, sg, nelems, i) { | ||
896 | if (sg->dma_address != swiotlb_phys_to_bus(hwdev, sg_phys(sg))) | ||
897 | sync_single(hwdev, swiotlb_bus_to_virt(sg->dma_address), | ||
898 | sg->dma_length, dir, target); | 895 | sg->dma_length, dir, target); |
899 | else if (dir == DMA_FROM_DEVICE) | ||
900 | dma_mark_clean(swiotlb_bus_to_virt(sg->dma_address), sg->dma_length); | ||
901 | } | ||
902 | } | 896 | } |
903 | 897 | ||
904 | void | 898 | void |