diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/swiotlb.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/swiotlb.c b/lib/swiotlb.c index 10c13ad0d82d..a7381d55663a 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c | |||
@@ -357,7 +357,8 @@ map_single(struct device *hwdev, char *buffer, size_t size, int dir) | |||
357 | * This is needed when we sync the memory. Then we sync the buffer if | 357 | * This is needed when we sync the memory. Then we sync the buffer if |
358 | * needed. | 358 | * needed. |
359 | */ | 359 | */ |
360 | io_tlb_orig_addr[index] = buffer; | 360 | for (i = 0; i < nslots; i++) |
361 | io_tlb_orig_addr[index+i] = buffer + (i << IO_TLB_SHIFT); | ||
361 | if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL) | 362 | if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL) |
362 | memcpy(dma_addr, buffer, size); | 363 | memcpy(dma_addr, buffer, size); |
363 | 364 | ||
@@ -418,6 +419,8 @@ sync_single(struct device *hwdev, char *dma_addr, size_t size, | |||
418 | int index = (dma_addr - io_tlb_start) >> IO_TLB_SHIFT; | 419 | int index = (dma_addr - io_tlb_start) >> IO_TLB_SHIFT; |
419 | char *buffer = io_tlb_orig_addr[index]; | 420 | char *buffer = io_tlb_orig_addr[index]; |
420 | 421 | ||
422 | buffer += ((unsigned long)dma_addr & ((1 << IO_TLB_SHIFT) - 1)); | ||
423 | |||
421 | switch (target) { | 424 | switch (target) { |
422 | case SYNC_FOR_CPU: | 425 | case SYNC_FOR_CPU: |
423 | if (likely(dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL)) | 426 | if (likely(dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL)) |