From nobody Fri May 3 00:26:30 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503663969241375.1345184491116; Fri, 25 Aug 2017 05:26:09 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 22BBA2095AE57; Fri, 25 Aug 2017 05:23:29 -0700 (PDT) Received: from mail-wr0-x22c.google.com (mail-wr0-x22c.google.com [IPv6:2a00:1450:400c:c0c::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CA96D21D1E2C5 for ; Fri, 25 Aug 2017 05:23:27 -0700 (PDT) Received: by mail-wr0-x22c.google.com with SMTP id k46so2603652wre.0 for ; Fri, 25 Aug 2017 05:26:03 -0700 (PDT) Received: from localhost.localdomain ([105.137.125.182]) by smtp.gmail.com with ESMTPSA id 6sm1264893wmf.0.2017.08.25.05.25.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Aug 2017 05:26:00 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=pGCSOJgaJa07bcLtrqyyl0m3NkXXaMuXbaa/rjmZ/cA=; b=NsEeXuCBceYnRHjPxL1NPLu8x+aNRveqyl8WPoftkXYM87r9dur02tveADrnFe2eNh YtLv1+/or0e3y8/l+65tmVjZagtpValgOOC4GdS2ScQqqOBcU9TVZTDa514zwmyXwlWM R5YQhP77O4rTnwnlaMo4gVW607g/TD/gQsNhQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=pGCSOJgaJa07bcLtrqyyl0m3NkXXaMuXbaa/rjmZ/cA=; b=eYqals/LJfTnbYFsK2TRW7KC8v3TmqiQ8VTk+GYvsBDDp0HzhtaT+3CBSsqLQYCzcu NSHSdPFsldvJDyEmrvhpURA+6xHTqCUu0ohPYfhedVUPV1FGSFp/02K/x+64jwdGzgGY P8hYunSI35jDlRxfdyyzbqFO1QdnByEr2VrjkobdiTJgCKbRjMlBOmTt4zx5xQYgU8Rd g+foxDl29FyZAuM/F57wV+dfbZ/BZxYTiqn2JvQFxEl9pSlzIsHLw4lu4GWXQ1cWTZPS gnW+T49Ty7BcGhxTrbBOvCJleO5QbkUueBO7fqZqGw2iA8ldRhZIgQTZWoRUeQiUxxlV x5/w== X-Gm-Message-State: AHYfb5h3dUSJyIPniLrlkq2c+VRYuBLUFnd9uMpvoTp5VVD32FltDhMt KOddwEte7sKKgnkQ1wvMlw== X-Received: by 10.223.145.40 with SMTP id j37mr6856309wrj.245.1503663962058; Fri, 25 Aug 2017 05:26:02 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 25 Aug 2017 13:25:54 +0100 Message-Id: <20170825122554.17819-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 Subject: [edk2] [PATCH] Platform/Armada/Pp2Dxe: switch to ArmDmaLib X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Instead of hardcoding the non-cache coherent nature of this device by invoking UncachedMemoryAllocationLib directly for allocating shared buffers, switch to DmaLib, which encapsulates this at a more abstract level. This allows the driver to be shared with platforms that are cache coherent (by simply switching to another DmaLib implementation), and removes the hardcoded dependency on UncachedMemoryAllocationLib, which will be removed from upstream EDK2. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm Tested-by: Marcin Wojtas --- This depends on patches #1 and #2 of https://lists.01.org/pipermail/edk2-devel/2017-August/013740.html Platform/Marvell/Armada/Armada.dsc.inc | 1 - Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c | 35 ++++++++++++++------ Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.h | 2 +- Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf | 4 +-- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/Platform/Marvell/Armada/Armada.dsc.inc b/Platform/Marvell/Arma= da/Armada.dsc.inc index 4e8f289fcbca..04b108619ac7 100644 --- a/Platform/Marvell/Armada/Armada.dsc.inc +++ b/Platform/Marvell/Armada/Armada.dsc.inc @@ -37,7 +37,6 @@ UtmiPhyLib|Platform/Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf =20 DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf - UncachedMemoryAllocationLib|ArmPkg/Library/UncachedMemoryAllocationLib/U= ncachedMemoryAllocationLib.inf DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseD= ebugPrintErrorLevelLib.inf =20 # Basic utility libraries diff --git a/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c b/Platform/Marvel= l/Drivers/Net/Pp2Dxe/Pp2Dxe.c index 8de2473d09f0..1e2ccd0dbe9d 100644 --- a/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c +++ b/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c @@ -175,9 +175,10 @@ Pp2DxeBmPoolInit ( VOID ) { - INTN Index; - UINT8 *PoolAddr; - UINT32 PoolSize =3D (sizeof(VOID *) * MVPP2_BM_SIZE) * 2 + MVPP2_BM_POOL= _PTR_ALIGN; + INTN Index; + UINT8 *PoolAddr; + UINT32 PoolSize; + EFI_STATUS Status; =20 ASSERT(MVPP2_BM_POOL_PTR_ALIGN >=3D sizeof(UINTN)); =20 @@ -194,11 +195,16 @@ Pp2DxeBmPoolInit ( return EFI_OUT_OF_RESOURCES; } =20 - PoolAddr =3D UncachedAllocateAlignedZeroPool (PoolSize, MVPP2_BM_POOL_PT= R_ALIGN); - if (PoolAddr =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; + Status =3D DmaAllocateAlignedBuffer (EfiBootServicesData, + EFI_SIZE_TO_PAGES (PoolSize), + MVPP2_BM_POOL_PTR_ALIGN, + (VOID **)&PoolAddr); + if (EFI_ERROR (Status)) { + goto FreePools; } =20 + ZeroMem (PoolAddr, PoolSize); + Mvpp2Shared->BmPools->Id =3D MVPP2_BM_POOL; Mvpp2Shared->BmPools->VirtAddr =3D (UINT32 *)PoolAddr; Mvpp2Shared->BmPools->PhysAddr =3D (UINTN)PoolAddr; @@ -206,6 +212,10 @@ Pp2DxeBmPoolInit ( Mvpp2BmPoolHwCreate(Mvpp2Shared, Mvpp2Shared->BmPools, MVPP2_BM_SIZE); =20 return EFI_SUCCESS; + +FreePools: + FreePool (Mvpp2Shared->BmPools); + return Status; } =20 /* Enable and fill BM pool */ @@ -1169,12 +1179,17 @@ Pp2DxeInitialise ( Mvpp2Shared->Tclk =3D PcdGet32 (PcdPp2ClockFrequency); =20 /* Prepare buffers */ - BufferSpace =3D UncachedAllocateAlignedZeroPool (BD_SPACE, MVPP2_BUFFER_= ALIGN_SIZE); - if (BufferSpace =3D=3D NULL) { - DEBUG((DEBUG_ERROR, "Failed to allocate buffer space\n")); - return EFI_OUT_OF_RESOURCES; + Status =3D DmaAllocateAlignedBuffer (EfiBootServicesData, + EFI_SIZE_TO_PAGES (BD_SPACE), + MVPP2_BUFFER_ALIGN_SIZE, + &BufferSpace); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to allocate buffer space\n")); + return Status; } =20 + ZeroMem (BufferSpace, BD_SPACE); + BufferLocation.TxDescs =3D BufferSpace; BufferLocation.AggrTxDescs =3D (MVPP2_TX_DESC *)((UINTN)BufferSpace + MV= PP2_MAX_TXD * sizeof(MVPP2_TX_DESC)); BufferLocation.RxDescs =3D (MVPP2_RX_DESC *)((UINTN)BufferSpace + diff --git a/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.h b/Platform/Marvel= l/Drivers/Net/Pp2Dxe/Pp2Dxe.h index 3bb0c4a65376..a179638fd609 100644 --- a/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.h +++ b/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.h @@ -46,13 +46,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DA= MAGE. #include #include #include +#include #include #include #include #include #include #include -#include =20 #include "Mvpp2LibHw.h" =20 diff --git a/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf b/Platform/Marv= ell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf index 87cc5e8ded74..9052fe27b7f3 100644 --- a/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf +++ b/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf @@ -43,13 +43,14 @@ Mvpp2Lib.c =20 [Packages] + EmbeddedPkg/EmbeddedPkg.dec MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec - ArmPlatformPkg/ArmPlatformPkg.dec ArmPkg/ArmPkg.dec Platform/Marvell/Marvell.dec =20 [LibraryClasses] + DmaLib IoLib PcdLib BaseLib @@ -60,7 +61,6 @@ UefiDriverEntryPoint UefiBootServicesTableLib MemoryAllocationLib - UncachedMemoryAllocationLib CacheMaintenanceLib =20 [Protocols] --=20 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel