diff options
author | Alexander Duyck <alexander.h.duyck@intel.com> | 2012-10-15 13:19:49 -0400 |
---|---|---|
committer | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2012-10-30 09:32:07 -0400 |
commit | fbfda893eb570bbe9e9ad9128b6e9cf2a1e48c87 (patch) | |
tree | c79485f1cec2861db3f86852629c19d32fda30bd | |
parent | 61ca08c3220032dd88815b3465d56cb779258168 (diff) |
swiotlb: Use physical addresses instead of virtual in swiotlb_tbl_sync_single
This change makes it so that the sync functionality also uses physical
addresses. This helps to further reduce the use of virt_to_phys and
phys_to_virt functions.
In order to clarify things since we now have 2 physical addresses in use
inside of swiotlb_tbl_sync_single I am renaming phys to orig_addr, and
dma_addr to tlb_addr. This way is should be clear that orig_addr is
contained within io_orig_addr and tlb_addr is an address within the
io_tlb_addr buffer.
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
-rw-r--r-- | drivers/xen/swiotlb-xen.c | 3 | ||||
-rw-r--r-- | include/linux/swiotlb.h | 3 | ||||
-rw-r--r-- | lib/swiotlb.c | 22 |
3 files changed, 14 insertions, 14 deletions
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c index 4cedc284b5df..af47e7594460 100644 --- a/drivers/xen/swiotlb-xen.c +++ b/drivers/xen/swiotlb-xen.c | |||
@@ -433,8 +433,7 @@ xen_swiotlb_sync_single(struct device *hwdev, dma_addr_t dev_addr, | |||
433 | 433 | ||
434 | /* NOTE: We use dev_addr here, not paddr! */ | 434 | /* NOTE: We use dev_addr here, not paddr! */ |
435 | if (is_xen_swiotlb_buffer(dev_addr)) { | 435 | if (is_xen_swiotlb_buffer(dev_addr)) { |
436 | swiotlb_tbl_sync_single(hwdev, phys_to_virt(paddr), size, dir, | 436 | swiotlb_tbl_sync_single(hwdev, paddr, size, dir, target); |
437 | target); | ||
438 | return; | 437 | return; |
439 | } | 438 | } |
440 | 439 | ||
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h index 291643c6b88b..e0ac98fd81a9 100644 --- a/include/linux/swiotlb.h +++ b/include/linux/swiotlb.h | |||
@@ -47,7 +47,8 @@ extern void swiotlb_tbl_unmap_single(struct device *hwdev, | |||
47 | phys_addr_t tlb_addr, | 47 | phys_addr_t tlb_addr, |
48 | size_t size, enum dma_data_direction dir); | 48 | size_t size, enum dma_data_direction dir); |
49 | 49 | ||
50 | extern void swiotlb_tbl_sync_single(struct device *hwdev, char *dma_addr, | 50 | extern void swiotlb_tbl_sync_single(struct device *hwdev, |
51 | phys_addr_t tlb_addr, | ||
51 | size_t size, enum dma_data_direction dir, | 52 | size_t size, enum dma_data_direction dir, |
52 | enum dma_sync_target target); | 53 | enum dma_sync_target target); |
53 | 54 | ||
diff --git a/lib/swiotlb.c b/lib/swiotlb.c index d7701dcf407f..16a548dc91ac 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c | |||
@@ -557,26 +557,27 @@ void swiotlb_tbl_unmap_single(struct device *hwdev, phys_addr_t tlb_addr, | |||
557 | } | 557 | } |
558 | EXPORT_SYMBOL_GPL(swiotlb_tbl_unmap_single); | 558 | EXPORT_SYMBOL_GPL(swiotlb_tbl_unmap_single); |
559 | 559 | ||
560 | void | 560 | void swiotlb_tbl_sync_single(struct device *hwdev, phys_addr_t tlb_addr, |
561 | swiotlb_tbl_sync_single(struct device *hwdev, char *dma_addr, size_t size, | 561 | size_t size, enum dma_data_direction dir, |
562 | enum dma_data_direction dir, | 562 | enum dma_sync_target target) |
563 | enum dma_sync_target target) | ||
564 | { | 563 | { |
565 | int index = (dma_addr - (char *)phys_to_virt(io_tlb_start)) >> IO_TLB_SHIFT; | 564 | int index = (tlb_addr - io_tlb_start) >> IO_TLB_SHIFT; |
566 | phys_addr_t phys = io_tlb_orig_addr[index]; | 565 | phys_addr_t orig_addr = io_tlb_orig_addr[index]; |
567 | 566 | ||
568 | phys += ((unsigned long)dma_addr & ((1 << IO_TLB_SHIFT) - 1)); | 567 | orig_addr += (unsigned long)tlb_addr & ((1 << IO_TLB_SHIFT) - 1); |
569 | 568 | ||
570 | switch (target) { | 569 | switch (target) { |
571 | case SYNC_FOR_CPU: | 570 | case SYNC_FOR_CPU: |
572 | if (likely(dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL)) | 571 | if (likely(dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL)) |
573 | swiotlb_bounce(phys, dma_addr, size, DMA_FROM_DEVICE); | 572 | swiotlb_bounce(orig_addr, phys_to_virt(tlb_addr), |
573 | size, DMA_FROM_DEVICE); | ||
574 | else | 574 | else |
575 | BUG_ON(dir != DMA_TO_DEVICE); | 575 | BUG_ON(dir != DMA_TO_DEVICE); |
576 | break; | 576 | break; |
577 | case SYNC_FOR_DEVICE: | 577 | case SYNC_FOR_DEVICE: |
578 | if (likely(dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL)) | 578 | if (likely(dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL)) |
579 | swiotlb_bounce(phys, dma_addr, size, DMA_TO_DEVICE); | 579 | swiotlb_bounce(orig_addr, phys_to_virt(tlb_addr), |
580 | size, DMA_TO_DEVICE); | ||
580 | else | 581 | else |
581 | BUG_ON(dir != DMA_FROM_DEVICE); | 582 | BUG_ON(dir != DMA_FROM_DEVICE); |
582 | break; | 583 | break; |
@@ -785,8 +786,7 @@ swiotlb_sync_single(struct device *hwdev, dma_addr_t dev_addr, | |||
785 | BUG_ON(dir == DMA_NONE); | 786 | BUG_ON(dir == DMA_NONE); |
786 | 787 | ||
787 | if (is_swiotlb_buffer(paddr)) { | 788 | if (is_swiotlb_buffer(paddr)) { |
788 | swiotlb_tbl_sync_single(hwdev, phys_to_virt(paddr), size, dir, | 789 | swiotlb_tbl_sync_single(hwdev, paddr, size, dir, target); |
789 | target); | ||
790 | return; | 790 | return; |
791 | } | 791 | } |
792 | 792 | ||