WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Xen

xen-devel

[Top] [All Lists]

[Xen-devel] [PATCH 08 of 14] swiotlb: factor out copy to/from device

To: Ingo Molnar <mingo@xxxxxxx>
Subject: [Xen-devel] [PATCH 08 of 14] swiotlb: factor out copy to/from device
From: Jeremy Fitzhardinge <jeremy@xxxxxxxx>
Date: 2008年12月16日 12:17:32 -0800
Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>, Ian Campbell <ian.campbell@xxxxxxxxxx>, the arch/x86 maintainers <x86@xxxxxxxxxx>, linux-kernel@xxxxxxxxxxxxxxx, FUJITA Tomonori <fujita.tomonori@xxxxxxxxxxxxx>
Delivery-date: 2008年12月16日 12:24:24 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1229458644@xxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>
---
 lib/swiotlb.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -312,6 +312,15 @@
 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.
 */
@@ -413,7 +422,7 @@
 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;
 }
@@ -437,7 +446,7 @@
 * 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
@@ -477,13 +486,13 @@
 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;
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
Previous by Date: [Xen-devel] [PATCH 07 of 14] swiotlb: add arch hook to force mapping , Jeremy Fitzhardinge
Next by Date: [Xen-devel] [PATCH 10 of 14] swiotlb: consolidate swiotlb info message printing , Jeremy Fitzhardinge
Previous by Thread: [Xen-devel] [PATCH 07 of 14] swiotlb: add arch hook to force mapping , Jeremy Fitzhardinge
Next by Thread: [Xen-devel] [PATCH 10 of 14] swiotlb: consolidate swiotlb info message printing , Jeremy Fitzhardinge
Indexes: [Date] [Thread] [Top] [All Lists]

Copyright ©, Citrix Systems Inc. All rights reserved. Legal and Privacy
Citrix This site is hosted by Citrix

AltStyle によって変換されたページ (->オリジナル) /