X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ArmPkg%2FLibrary%2FArmDmaLib%2FArmDmaLib.c;h=7fef208c78c1867122275960bb912c4c7d011503;hb=3ea3ff88e3fb91dd63da29718bdc454f0d043cee;hp=9467fa5b474ea9cda23bcf157f2c109fe5314c8b;hpb=d34689b44a1ca9f159a8ad981574acc3d85488d9;p=mirror_edk2.git 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;