aboutsummaryrefslogtreecommitdiffstats
path: root/lib/swiotlb.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-03-18 03:37:55 -0400
committerDavid S. Miller <davem@davemloft.net>2008-03-18 03:37:55 -0400
commit577f99c1d08cf9cbdafd4e858dd13ff04d855090 (patch)
tree0f726bbda9b18d311d4c95198bbd96cb7ac01db0 /lib/swiotlb.c
parent26c0f03f6b77c513cb7bc37b73a06819bdbb791b (diff)
parent2f633928cbba8a5858bb39b11e7219a41b0fbef5 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
Conflicts: drivers/net/wireless/rt2x00/rt2x00dev.c net/8021q/vlan_dev.c
Diffstat (limited to 'lib/swiotlb.c')
-rw-r--r--lib/swiotlb.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 4bb5a11e18a2..025922807e6e 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -310,7 +310,9 @@ map_single(struct device *hwdev, char *buffer, size_t size, int dir)
310 start_dma_addr = virt_to_bus(io_tlb_start) & mask; 310 start_dma_addr = virt_to_bus(io_tlb_start) & mask;
311 311
312 offset_slots = ALIGN(start_dma_addr, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT; 312 offset_slots = ALIGN(start_dma_addr, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT;
313 max_slots = ALIGN(mask + 1, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT; 313 max_slots = mask + 1
314 ? ALIGN(mask + 1, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT
315 : 1UL << (BITS_PER_LONG - IO_TLB_SHIFT);
314 316
315 /* 317 /*
316 * For mappings greater than a page, we limit the stride (and 318 * For mappings greater than a page, we limit the stride (and
@@ -333,16 +335,18 @@ map_single(struct device *hwdev, char *buffer, size_t size, int dir)
333 index = ALIGN(io_tlb_index, stride); 335 index = ALIGN(io_tlb_index, stride);
334 if (index >= io_tlb_nslabs) 336 if (index >= io_tlb_nslabs)
335 index = 0; 337 index = 0;
336
337 while (is_span_boundary(index, nslots, offset_slots,
338 max_slots)) {
339 index += stride;
340 if (index >= io_tlb_nslabs)
341 index = 0;
342 }
343 wrap = index; 338 wrap = index;
344 339
345 do { 340 do {
341 while (is_span_boundary(index, nslots, offset_slots,
342 max_slots)) {
343 index += stride;
344 if (index >= io_tlb_nslabs)
345 index = 0;
346 if (index == wrap)
347 goto not_found;
348 }
349
346 /* 350 /*
347 * If we find a slot that indicates we have 'nslots' 351 * If we find a slot that indicates we have 'nslots'
348 * number of contiguous buffers, we allocate the 352 * number of contiguous buffers, we allocate the
@@ -367,14 +371,12 @@ map_single(struct device *hwdev, char *buffer, size_t size, int dir)
367 371
368 goto found; 372 goto found;
369 } 373 }
370 do { 374 index += stride;
371 index += stride; 375 if (index >= io_tlb_nslabs)
372 if (index >= io_tlb_nslabs) 376 index = 0;
373 index = 0;
374 } while (is_span_boundary(index, nslots, offset_slots,
375 max_slots));
376 } while (index != wrap); 377 } while (index != wrap);
377 378
379 not_found:
378 spin_unlock_irqrestore(&io_tlb_lock, flags); 380 spin_unlock_irqrestore(&io_tlb_lock, flags);
379 return NULL; 381 return NULL;
380 } 382 }