From patchwork Fri Aug 25 12:25:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 111018 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp930334qge; Fri, 25 Aug 2017 05:26:06 -0700 (PDT) X-Received: by 10.98.67.129 with SMTP id l1mr1967066pfi.76.1503663966367; Fri, 25 Aug 2017 05:26:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503663966; cv=none; d=google.com; s=arc-20160816; b=rVn8yoKWNiOgUTV8DaD0szuIMHUYpx+DyaMmwk/2o1McpA+eydaxSESKIR83JszuL6 Ab73U6H0OF05Sp8bD1Ycii/z/2wVlyTOZ701AblbBwwlrzkWYBE4pREsFlP7BTCDp9UO KAgbF1X/BXr5FfVzsr4vy1QvBS8Uhaf0n4n9dN3ODOzLbq2aJm8V2eDa2/F7+CWsw+tu zejkZ7eegH6MYiWipoczGMDTag+dAYA77s9ZJdxX4mKzbxKncxDQkBGrJbvtsTRr/cHU Ev5fElLEzizph+zYIscTbA8yysLbBfB5DMo9PpYJU662cmFiCYvP/bRr1MG+4OExunm1 AyJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=F6I1WPaJfbIaZ7ZJop9vgDEdvnS/ceTBOBTXJtp19GU=; b=b4AzGSmodzycOu3kWY1Y8TyhlLHEiJOe+QyeZYGo4FtuiYM/TORoL4TYQjdq1bReDe kiQT+CMZZJhfkGUMc+Ic+eNXC2SECA7YGretig8b6/XWzlRiaxdpNAp9jIWvuK0arhtI HCRcH1Mv38WsFoMxvE4MftUTipNXOkQ8PLZMCcr1joAuIJpHBSVYPV5hdJ6Af+j3n+mW hSq7nnK2WjEIx2Ak3oIghh9rdkr4f0JC7qH85pZvQOdyn4vqRsA44bjZbdz7Z2YyvtPU i7MsigacUL1W6VnNwmBoI7FkjnoMgQDI7r/ryALEodZinUB6NibbpxSYN6Mb80HV1hI1 //Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NsEeXuCB; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id z1si4606785pfd.320.2017.08.25.05.26.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Aug 2017 05:26:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NsEeXuCB; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org 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) 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) 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) 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 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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 --- 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(-) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Leif Lindholm Tested-by: Marcin Wojtas diff --git a/Platform/Marvell/Armada/Armada.dsc.inc b/Platform/Marvell/Armada/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 DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf - UncachedMemoryAllocationLib|ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.inf DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf # Basic utility libraries diff --git a/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c b/Platform/Marvell/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 = (sizeof(VOID *) * MVPP2_BM_SIZE) * 2 + MVPP2_BM_POOL_PTR_ALIGN; + INTN Index; + UINT8 *PoolAddr; + UINT32 PoolSize; + EFI_STATUS Status; ASSERT(MVPP2_BM_POOL_PTR_ALIGN >= sizeof(UINTN)); @@ -194,11 +195,16 @@ Pp2DxeBmPoolInit ( return EFI_OUT_OF_RESOURCES; } - PoolAddr = UncachedAllocateAlignedZeroPool (PoolSize, MVPP2_BM_POOL_PTR_ALIGN); - if (PoolAddr == NULL) { - return EFI_OUT_OF_RESOURCES; + Status = DmaAllocateAlignedBuffer (EfiBootServicesData, + EFI_SIZE_TO_PAGES (PoolSize), + MVPP2_BM_POOL_PTR_ALIGN, + (VOID **)&PoolAddr); + if (EFI_ERROR (Status)) { + goto FreePools; } + ZeroMem (PoolAddr, PoolSize); + Mvpp2Shared->BmPools->Id = MVPP2_BM_POOL; Mvpp2Shared->BmPools->VirtAddr = (UINT32 *)PoolAddr; Mvpp2Shared->BmPools->PhysAddr = (UINTN)PoolAddr; @@ -206,6 +212,10 @@ Pp2DxeBmPoolInit ( Mvpp2BmPoolHwCreate(Mvpp2Shared, Mvpp2Shared->BmPools, MVPP2_BM_SIZE); return EFI_SUCCESS; + +FreePools: + FreePool (Mvpp2Shared->BmPools); + return Status; } /* Enable and fill BM pool */ @@ -1169,12 +1179,17 @@ Pp2DxeInitialise ( Mvpp2Shared->Tclk = PcdGet32 (PcdPp2ClockFrequency); /* Prepare buffers */ - BufferSpace = UncachedAllocateAlignedZeroPool (BD_SPACE, MVPP2_BUFFER_ALIGN_SIZE); - if (BufferSpace == NULL) { - DEBUG((DEBUG_ERROR, "Failed to allocate buffer space\n")); - return EFI_OUT_OF_RESOURCES; + Status = 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; } + ZeroMem (BufferSpace, BD_SPACE); + BufferLocation.TxDescs = BufferSpace; BufferLocation.AggrTxDescs = (MVPP2_TX_DESC *)((UINTN)BufferSpace + MVPP2_MAX_TXD * sizeof(MVPP2_TX_DESC)); BufferLocation.RxDescs = (MVPP2_RX_DESC *)((UINTN)BufferSpace + diff --git a/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.h b/Platform/Marvell/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 DAMAGE. #include #include #include +#include #include #include #include #include #include #include -#include #include "Mvpp2LibHw.h" diff --git a/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf b/Platform/Marvell/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 [Packages] + EmbeddedPkg/EmbeddedPkg.dec MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec - ArmPlatformPkg/ArmPlatformPkg.dec ArmPkg/ArmPkg.dec Platform/Marvell/Marvell.dec [LibraryClasses] + DmaLib IoLib PcdLib BaseLib @@ -60,7 +61,6 @@ UefiDriverEntryPoint UefiBootServicesTableLib MemoryAllocationLib - UncachedMemoryAllocationLib CacheMaintenanceLib [Protocols]