aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAlexander Duyck <alexander.h.duyck@intel.com>2012-10-15 13:19:22 -0400
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2012-10-30 09:32:05 -0400
commitc40dba06e9a27d673197a2083828f13eff16b2ab (patch)
tree2bea1f9eaf85ef76aaed04b291f45bbeb7090e15 /lib
parent8f0d8163b50e01f398b14bcd4dc039ac5ab18d64 (diff)
swiotlb: Make io_tlb_end a physical address instead of a virtual one
This change replaces all references to the virtual address for io_tlb_end with references to the physical address io_tlb_end. The main advantage of replacing the virtual address with a physical address is that we can avoid having to do multiple translations from the virtual address to the physical one needed for testing an existing DMA address. Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/swiotlb.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index f114bf6a8e13..c0cbfa1116c0 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -57,7 +57,8 @@ int swiotlb_force;
57 * swiotlb_tbl_sync_single_*, to see if the memory was in fact allocated by this 57 * swiotlb_tbl_sync_single_*, to see if the memory was in fact allocated by this
58 * API. 58 * API.
59 */ 59 */
60static char *io_tlb_start, *io_tlb_end; 60static char *io_tlb_start;
61static phys_addr_t io_tlb_end;
61 62
62/* 63/*
63 * The number of IO TLB blocks (in groups of 64) between io_tlb_start and 64 * The number of IO TLB blocks (in groups of 64) between io_tlb_start and
@@ -125,14 +126,16 @@ static dma_addr_t swiotlb_virt_to_bus(struct device *hwdev,
125void swiotlb_print_info(void) 126void swiotlb_print_info(void)
126{ 127{
127 unsigned long bytes = io_tlb_nslabs << IO_TLB_SHIFT; 128 unsigned long bytes = io_tlb_nslabs << IO_TLB_SHIFT;
128 phys_addr_t pstart, pend; 129 phys_addr_t pstart;
130 unsigned char *vend;
129 131
130 pstart = virt_to_phys(io_tlb_start); 132 pstart = virt_to_phys(io_tlb_start);
131 pend = virt_to_phys(io_tlb_end); 133 vend = phys_to_virt(io_tlb_end);
132 134
133 printk(KERN_INFO "software IO TLB [mem %#010llx-%#010llx] (%luMB) mapped at [%p-%p]\n", 135 printk(KERN_INFO "software IO TLB [mem %#010llx-%#010llx] (%luMB) mapped at [%p-%p]\n",
134 (unsigned long long)pstart, (unsigned long long)pend - 1, 136 (unsigned long long)pstart,
135 bytes >> 20, io_tlb_start, io_tlb_end - 1); 137 (unsigned long long)io_tlb_end,
138 bytes >> 20, io_tlb_start, vend - 1);
136} 139}
137 140
138void __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose) 141void __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
@@ -143,7 +146,7 @@ void __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
143 146
144 io_tlb_nslabs = nslabs; 147 io_tlb_nslabs = nslabs;
145 io_tlb_start = tlb; 148 io_tlb_start = tlb;
146 io_tlb_end = io_tlb_start + bytes; 149 io_tlb_end = __pa(io_tlb_start) + bytes;
147 150
148 /* 151 /*
149 * Allocate and initialize the free list array. This array is used 152 * Allocate and initialize the free list array. This array is used
@@ -254,7 +257,7 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs)
254 257
255 io_tlb_nslabs = nslabs; 258 io_tlb_nslabs = nslabs;
256 io_tlb_start = tlb; 259 io_tlb_start = tlb;
257 io_tlb_end = io_tlb_start + bytes; 260 io_tlb_end = virt_to_phys(io_tlb_start) + bytes;
258 261
259 memset(io_tlb_start, 0, bytes); 262 memset(io_tlb_start, 0, bytes);
260 263
@@ -304,7 +307,7 @@ cleanup3:
304 sizeof(int))); 307 sizeof(int)));
305 io_tlb_list = NULL; 308 io_tlb_list = NULL;
306cleanup2: 309cleanup2:
307 io_tlb_end = NULL; 310 io_tlb_end = 0;
308 io_tlb_start = NULL; 311 io_tlb_start = NULL;
309 io_tlb_nslabs = 0; 312 io_tlb_nslabs = 0;
310 return -ENOMEM; 313 return -ENOMEM;
@@ -339,8 +342,7 @@ void __init swiotlb_free(void)
339 342
340static int is_swiotlb_buffer(phys_addr_t paddr) 343static int is_swiotlb_buffer(phys_addr_t paddr)
341{ 344{
342 return paddr >= virt_to_phys(io_tlb_start) && 345 return paddr >= virt_to_phys(io_tlb_start) && paddr < io_tlb_end;
343 paddr < virt_to_phys(io_tlb_end);
344} 346}
345 347
346/* 348/*
@@ -938,6 +940,6 @@ EXPORT_SYMBOL(swiotlb_dma_mapping_error);
938int 940int
939swiotlb_dma_supported(struct device *hwdev, u64 mask) 941swiotlb_dma_supported(struct device *hwdev, u64 mask)
940{ 942{
941 return swiotlb_virt_to_bus(hwdev, io_tlb_end - 1) <= mask; 943 return phys_to_dma(hwdev, io_tlb_end - 1) <= mask;
942} 944}
943EXPORT_SYMBOL(swiotlb_dma_supported); 945EXPORT_SYMBOL(swiotlb_dma_supported);