mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-30 00:54:06 +02:00
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
This commit is contained in:
parent
d34689b44a
commit
3ea3ff88e3
@ -95,7 +95,12 @@ DmaMap (
|
|||||||
|
|
||||||
*Mapping = Map;
|
*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;
|
Map->DoubleBuffer = TRUE;
|
||||||
Status = DmaAllocateBuffer (EfiBootServicesData, EFI_SIZE_TO_PAGES (*NumberOfBytes), &Buffer);
|
Status = DmaAllocateBuffer (EfiBootServicesData, EFI_SIZE_TO_PAGES (*NumberOfBytes), &Buffer);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
@ -108,8 +113,6 @@ DmaMap (
|
|||||||
Map->DoubleBuffer = FALSE;
|
Map->DoubleBuffer = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
*NumberOfBytes &= *NumberOfBytes & ~(gCacheAlignment - 1); // Only do it on full cache lines
|
|
||||||
|
|
||||||
Map->HostAddress = (UINTN)HostAddress;
|
Map->HostAddress = (UINTN)HostAddress;
|
||||||
Map->DeviceAddress = *DeviceAddress;
|
Map->DeviceAddress = *DeviceAddress;
|
||||||
Map->NumberOfBytes = *NumberOfBytes;
|
Map->NumberOfBytes = *NumberOfBytes;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user