The non-coherent version of DmaAllocateBuffer () returns uncached memory, to ensure that the CPU and the device see the same data, even we they are accessing the buffer at the same time.
This is not really necessary for our RX ring: the CPU never accesses the buffer while it is mapped for writing by the device, and so we can simply use the streaming DMA model, which uses ordinary cached buffers, but issues a cache invalidate at DMA unmap time. Signed-off-by: Ard Biesheuvel <[email protected]> --- Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf | 4 ++++ Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.c | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf index e74fa02ad209..3cabc5936562 100644 --- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf +++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf @@ -49,3 +49,7 @@ [Protocols] gBcmGenetPlatformDeviceProtocolGuid ## TO_START gEfiDevicePathProtocolGuid ## BY_START gEfiSimpleNetworkProtocolGuid ## BY_START + +[Pcd] + gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset + gEmbeddedTokenSpaceGuid.PcdDmaDeviceLimit diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.c b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.c index 746fbfe51b1d..23bd1c1d2baa 100644 --- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.c +++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.c @@ -19,6 +19,10 @@ #define GENET_PHY_RETRY 1000 +STATIC CONST +EFI_PHYSICAL_ADDRESS mDmaAddressLimit = FixedPcdGet64 (PcdDmaDeviceLimit) - + FixedPcdGet64 (PcdDmaDeviceOffset); + /** Read a memory-mapped device CSR. @@ -605,16 +609,20 @@ GenetDmaAlloc ( IN GENET_PRIVATE_DATA *Genet ) { - EFI_STATUS Status; - UINTN Idx; + EFI_PHYSICAL_ADDRESS Address; + EFI_STATUS Status; + UINTN Idx; for (Idx = 0; Idx < GENET_DMA_DESC_COUNT; Idx++) { - Status = DmaAllocateBuffer (EfiBootServicesData, EFI_SIZE_TO_PAGES (GENET_MAX_PACKET_SIZE), (VOID **)&Genet->RxBuffer[Idx]); + Address = mDmaAddressLimit; + Status = gBS->AllocatePages (AllocateMaxAddress, EfiBootServicesData, + EFI_SIZE_TO_PAGES (GENET_MAX_PACKET_SIZE), &Address); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "GenetDmaAlloc: Failed to allocate RX buffer: %r\n", Status)); GenetDmaFree (Genet); return Status; } + Genet->RxBuffer[Idx] = (UINT8 *)(UINTN)Address; } return EFI_SUCCESS; @@ -699,8 +707,8 @@ GenetDmaFree ( GenetDmaUnmapRxDescriptor (Genet, Idx); if (Genet->RxBuffer[Idx] != NULL) { - DmaFreeBuffer (EFI_SIZE_TO_PAGES (GENET_MAX_PACKET_SIZE), - Genet->RxBuffer[Idx]); + gBS->FreePages ((UINTN)Genet->RxBuffer[Idx], + EFI_SIZE_TO_PAGES (GENET_MAX_PACKET_SIZE)); Genet->RxBuffer[Idx] = NULL; } } -- 2.17.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#59054): https://edk2.groups.io/g/devel/message/59054 Mute This Topic: https://groups.io/mt/74130978/21656 Group Owner: [email protected] Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
