aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2009-07-09 21:05:02 -0400
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2009-07-28 01:19:20 -0400
commit862d196b27bd30a5ab8109d5cdb37980d81b1fe9 (patch)
tree4fe582aeb7ef93fe769b63150f983fbb8eae918f
parent8d4f5339d1ee4027c07e6b2a1cfa9dc41b0d383b (diff)
swiotlb: use phys_to_dma and dma_to_phys
This converts swiotlb to use phys_to_dma and dma_to_phys instead of swiotlb_phys_to_bus() and swiotlb_bus_to_phys(). swiotlb_phys_to_bus() and swiotlb_bus_to_phys() are not necessary so this patch also removes them. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Acked-by: Becky Bruce <beckyb@kernel.crashing.org>
-rw-r--r--include/linux/swiotlb.h5
-rw-r--r--lib/swiotlb.c22
2 files changed, 6 insertions, 21 deletions
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index a977da24f17c..73b1f1cec423 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -23,11 +23,6 @@ struct scatterlist;
23extern void 23extern void
24swiotlb_init(void); 24swiotlb_init(void);
25 25
26extern dma_addr_t swiotlb_phys_to_bus(struct device *hwdev,
27 phys_addr_t address);
28extern phys_addr_t swiotlb_bus_to_phys(struct device *hwdev,
29 dma_addr_t address);
30
31extern void 26extern void
32*swiotlb_alloc_coherent(struct device *hwdev, size_t size, 27*swiotlb_alloc_coherent(struct device *hwdev, size_t size,
33 dma_addr_t *dma_handle, gfp_t flags); 28 dma_addr_t *dma_handle, gfp_t flags);
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index a012d93792b7..9e2fe3e1804c 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -114,21 +114,11 @@ setup_io_tlb_npages(char *str)
114__setup("swiotlb=", setup_io_tlb_npages); 114__setup("swiotlb=", setup_io_tlb_npages);
115/* make io_tlb_overflow tunable too? */ 115/* make io_tlb_overflow tunable too? */
116 116
117dma_addr_t __weak swiotlb_phys_to_bus(struct device *hwdev, phys_addr_t paddr)
118{
119 return paddr;
120}
121
122phys_addr_t __weak swiotlb_bus_to_phys(struct device *hwdev, dma_addr_t baddr)
123{
124 return baddr;
125}
126
127/* Note that this doesn't work with highmem page */ 117/* Note that this doesn't work with highmem page */
128static dma_addr_t swiotlb_virt_to_bus(struct device *hwdev, 118static dma_addr_t swiotlb_virt_to_bus(struct device *hwdev,
129 volatile void *address) 119 volatile void *address)
130{ 120{
131 return swiotlb_phys_to_bus(hwdev, virt_to_phys(address)); 121 return phys_to_dma(hwdev, virt_to_phys(address));
132} 122}
133 123
134static void swiotlb_print_info(unsigned long bytes) 124static void swiotlb_print_info(unsigned long bytes)
@@ -567,7 +557,7 @@ void
567swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr, 557swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
568 dma_addr_t dev_addr) 558 dma_addr_t dev_addr)
569{ 559{
570 phys_addr_t paddr = swiotlb_bus_to_phys(hwdev, dev_addr); 560 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
571 561
572 WARN_ON(irqs_disabled()); 562 WARN_ON(irqs_disabled());
573 if (!is_swiotlb_buffer(paddr)) 563 if (!is_swiotlb_buffer(paddr))
@@ -612,7 +602,7 @@ dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
612 struct dma_attrs *attrs) 602 struct dma_attrs *attrs)
613{ 603{
614 phys_addr_t phys = page_to_phys(page) + offset; 604 phys_addr_t phys = page_to_phys(page) + offset;
615 dma_addr_t dev_addr = swiotlb_phys_to_bus(dev, phys); 605 dma_addr_t dev_addr = phys_to_dma(dev, phys);
616 void *map; 606 void *map;
617 607
618 BUG_ON(dir == DMA_NONE); 608 BUG_ON(dir == DMA_NONE);
@@ -656,7 +646,7 @@ EXPORT_SYMBOL_GPL(swiotlb_map_page);
656static void unmap_single(struct device *hwdev, dma_addr_t dev_addr, 646static void unmap_single(struct device *hwdev, dma_addr_t dev_addr,
657 size_t size, int dir) 647 size_t size, int dir)
658{ 648{
659 phys_addr_t paddr = swiotlb_bus_to_phys(hwdev, dev_addr); 649 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
660 650
661 BUG_ON(dir == DMA_NONE); 651 BUG_ON(dir == DMA_NONE);
662 652
@@ -699,7 +689,7 @@ static void
699swiotlb_sync_single(struct device *hwdev, dma_addr_t dev_addr, 689swiotlb_sync_single(struct device *hwdev, dma_addr_t dev_addr,
700 size_t size, int dir, int target) 690 size_t size, int dir, int target)
701{ 691{
702 phys_addr_t paddr = swiotlb_bus_to_phys(hwdev, dev_addr); 692 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
703 693
704 BUG_ON(dir == DMA_NONE); 694 BUG_ON(dir == DMA_NONE);
705 695
@@ -788,7 +778,7 @@ swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, int nelems,
788 778
789 for_each_sg(sgl, sg, nelems, i) { 779 for_each_sg(sgl, sg, nelems, i) {
790 phys_addr_t paddr = sg_phys(sg); 780 phys_addr_t paddr = sg_phys(sg);
791 dma_addr_t dev_addr = swiotlb_phys_to_bus(hwdev, paddr); 781 dma_addr_t dev_addr = phys_to_dma(hwdev, paddr);
792 782
793 if (swiotlb_force || 783 if (swiotlb_force ||
794 !dma_capable(hwdev, dev_addr, sg->length)) { 784 !dma_capable(hwdev, dev_addr, sg->length)) {