summaryrefslogtreecommitdiff
path: root/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c
diff options
context:
space:
mode:
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>2010-07-15 17:27:13 +0000
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>2010-07-15 17:27:13 +0000
commit3ea3ff88e3fb91dd63da29718bdc454f0d043cee (patch)
treeb06219e167910e0e7eb5f8d671e072760bce64e1 /ArmPkg/Library/ArmDmaLib/ArmDmaLib.c
parentd34689b44a1ca9f159a8ad981574acc3d85488d9 (diff)
downloadedk2-platforms-3ea3ff88e3fb91dd63da29718bdc454f0d043cee.tar.xz
Fix issue in DmaMap with buffers that are smaller than a cache line. Also make any buffer that is not an even quanta of cache lines double buffer.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10654 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPkg/Library/ArmDmaLib/ArmDmaLib.c')
-rwxr-xr-xArmPkg/Library/ArmDmaLib/ArmDmaLib.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c b/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c
index 9467fa5b47..7fef208c78 100755
--- a/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c
+++ b/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c
@@ -95,7 +95,12 @@ DmaMap (
*Mapping = Map;
- if (((UINTN)HostAddress & (gCacheAlignment - 1)) != 0) {
+ if ((((UINTN)HostAddress & (gCacheAlignment - 1)) != 0) ||
+ ((*NumberOfBytes % gCacheAlignment) != 0)) {
+ //
+ // If the buffer does not fill entire cache lines we must double buffer into
+ // uncached memory. Device (PCI) address becomes uncached page.
+ //
Map->DoubleBuffer = TRUE;
Status = DmaAllocateBuffer (EfiBootServicesData, EFI_SIZE_TO_PAGES (*NumberOfBytes), &Buffer);
if (EFI_ERROR (Status)) {
@@ -108,8 +113,6 @@ DmaMap (
Map->DoubleBuffer = FALSE;
}
- *NumberOfBytes &= *NumberOfBytes & ~(gCacheAlignment - 1); // Only do it on full cache lines
-
Map->HostAddress = (UINTN)HostAddress;
Map->DeviceAddress = *DeviceAddress;
Map->NumberOfBytes = *NumberOfBytes;