aboutsummaryrefslogtreecommitdiffstats
path: root/lib/swiotlb.c
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2008-09-08 05:53:50 -0400
committerIngo Molnar <mingo@elte.hu>2008-09-08 09:53:31 -0400
commit640aebfe014554ced9c38d2564e38862e488d0eb (patch)
tree64ce0e7ae61fd7707d2ea8f1c68661c92769197a /lib/swiotlb.c
parent21f6c4de4c25c4bdd88c75bc97a78e7fbeebac4d (diff)
swiotlb: add is_swiotlb_buffer helper function
This adds is_swiotlb_buffer() helper function to see whether a buffer belongs to the swiotlb buffer or not. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'lib/swiotlb.c')
-rw-r--r--lib/swiotlb.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index bf61c73a3418..b5f5d1133042 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -283,6 +283,11 @@ address_needs_mapping(struct device *hwdev, dma_addr_t addr)
283 return (addr & ~mask) != 0; 283 return (addr & ~mask) != 0;
284} 284}
285 285
286static int is_swiotlb_buffer(char *addr)
287{
288 return addr >= io_tlb_start && addr < io_tlb_end;
289}
290
286/* 291/*
287 * Allocates bounce buffer and returns its kernel virtual address. 292 * Allocates bounce buffer and returns its kernel virtual address.
288 */ 293 */
@@ -508,8 +513,7 @@ swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
508 dma_addr_t dma_handle) 513 dma_addr_t dma_handle)
509{ 514{
510 WARN_ON(irqs_disabled()); 515 WARN_ON(irqs_disabled());
511 if (!(vaddr >= (void *)io_tlb_start 516 if (!is_swiotlb_buffer(vaddr))
512 && vaddr < (void *)io_tlb_end))
513 free_pages((unsigned long) vaddr, get_order(size)); 517 free_pages((unsigned long) vaddr, get_order(size));
514 else 518 else
515 /* DMA_TO_DEVICE to avoid memcpy in unmap_single */ 519 /* DMA_TO_DEVICE to avoid memcpy in unmap_single */
@@ -602,7 +606,7 @@ swiotlb_unmap_single_attrs(struct device *hwdev, dma_addr_t dev_addr,
602 char *dma_addr = bus_to_virt(dev_addr); 606 char *dma_addr = bus_to_virt(dev_addr);
603 607
604 BUG_ON(dir == DMA_NONE); 608 BUG_ON(dir == DMA_NONE);
605 if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end) 609 if (is_swiotlb_buffer(dma_addr))
606 unmap_single(hwdev, dma_addr, size, dir); 610 unmap_single(hwdev, dma_addr, size, dir);
607 else if (dir == DMA_FROM_DEVICE) 611 else if (dir == DMA_FROM_DEVICE)
608 dma_mark_clean(dma_addr, size); 612 dma_mark_clean(dma_addr, size);
@@ -632,7 +636,7 @@ swiotlb_sync_single(struct device *hwdev, dma_addr_t dev_addr,
632 char *dma_addr = bus_to_virt(dev_addr); 636 char *dma_addr = bus_to_virt(dev_addr);
633 637
634 BUG_ON(dir == DMA_NONE); 638 BUG_ON(dir == DMA_NONE);
635 if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end) 639 if (is_swiotlb_buffer(dma_addr))
636 sync_single(hwdev, dma_addr, size, dir, target); 640 sync_single(hwdev, dma_addr, size, dir, target);
637 else if (dir == DMA_FROM_DEVICE) 641 else if (dir == DMA_FROM_DEVICE)
638 dma_mark_clean(dma_addr, size); 642 dma_mark_clean(dma_addr, size);
@@ -663,7 +667,7 @@ swiotlb_sync_single_range(struct device *hwdev, dma_addr_t dev_addr,
663 char *dma_addr = bus_to_virt(dev_addr) + offset; 667 char *dma_addr = bus_to_virt(dev_addr) + offset;
664 668
665 BUG_ON(dir == DMA_NONE); 669 BUG_ON(dir == DMA_NONE);
666 if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end) 670 if (is_swiotlb_buffer(dma_addr))
667 sync_single(hwdev, dma_addr, size, dir, target); 671 sync_single(hwdev, dma_addr, size, dir, target);
668 else if (dir == DMA_FROM_DEVICE) 672 else if (dir == DMA_FROM_DEVICE)
669 dma_mark_clean(dma_addr, size); 673 dma_mark_clean(dma_addr, size);