Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 123208
b: refs/heads/master
c: 1b548f6
h: refs/heads/master
v: v3
  • Loading branch information
Jeremy Fitzhardinge authored and Ingo Molnar committed Dec 17, 2008
1 parent 06490ce commit 4517642
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b81ea27b2329bf44b30c427800954f845896d476
refs/heads/master: 1b548f667c1487d92e794a9f7a67788f49b952d8
17 changes: 13 additions & 4 deletions trunk/lib/swiotlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,15 @@ static int is_swiotlb_buffer(char *addr)
return addr >= io_tlb_start && addr < io_tlb_end;
}

static void
__sync_single(char *buffer, char *dma_addr, size_t size, int dir)
{
if (dir == DMA_TO_DEVICE)
memcpy(dma_addr, buffer, size);
else
memcpy(buffer, dma_addr, size);
}

/*
* Allocates bounce buffer and returns its kernel virtual address.
*/
Expand Down Expand Up @@ -413,7 +422,7 @@ map_single(struct device *hwdev, char *buffer, size_t size, int dir)
for (i = 0; i < nslots; i++)
io_tlb_orig_addr[index+i] = buffer + (i << IO_TLB_SHIFT);
if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL)
memcpy(dma_addr, buffer, size);
__sync_single(buffer, dma_addr, size, DMA_TO_DEVICE);

return dma_addr;
}
Expand All @@ -437,7 +446,7 @@ unmap_single(struct device *hwdev, char *dma_addr, size_t size, int dir)
* bounce... copy the data back into the original buffer * and
* delete the bounce buffer.
*/
memcpy(buffer, dma_addr, size);
__sync_single(buffer, dma_addr, size, DMA_FROM_DEVICE);

/*
* Return the buffer to the free list by setting the corresponding
Expand Down Expand Up @@ -477,13 +486,13 @@ sync_single(struct device *hwdev, char *dma_addr, size_t size,
switch (target) {
case SYNC_FOR_CPU:
if (likely(dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL))
memcpy(buffer, dma_addr, size);
__sync_single(buffer, dma_addr, size, DMA_FROM_DEVICE);
else
BUG_ON(dir != DMA_TO_DEVICE);
break;
case SYNC_FOR_DEVICE:
if (likely(dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL))
memcpy(dma_addr, buffer, size);
__sync_single(buffer, dma_addr, size, DMA_TO_DEVICE);
else
BUG_ON(dir != DMA_FROM_DEVICE);
break;
Expand Down

0 comments on commit 4517642

Please sign in to comment.