From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.119]) by mx.groups.io with SMTP id smtpd.web11.4692.1634883648163726151 for ; Thu, 21 Oct 2021 23:20:48 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@os.amperecomputing.com header.s=selector2 header.b=v5xUOCTd; spf=pass (domain: os.amperecomputing.com, ip: 40.107.237.119, mailfrom: nhi@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NXMmbSlhJVOLgKcsjz1aXp35yr6BC1TelF8+LMKr4Op07wmWg0CPcLfmETza0AY211XMCuoS/+BW7wf7vS5tw7BAO556wt+i6vp+26/5vHmaDugDxXkyw/R4vrggI+UIXXSNgA/vG1e59Fqp6fDf0fYNDA8tNa7BmAOKmX5+vk02IpDdhfJwuw1V2bsOELT1lZNkBU9Fbt4/eekDWDNnIfnl6KbSUxBRvMX3VGPqTcoYIxQbDGH9u1U8z53CcjHe9NGs3TaMkhoS0AUcNSn+pBzcw2w0tYubX/m/ad6nABkPkuCEM+VU96/hTgjNrteXAjx5u/vz7HiNNdjMKnvKsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JurtxvLmM93TSLMBaXOybPLuNc4jSgX6OQTHgqWvGXk=; b=BbaNOikMdH1LQQFTVH41uirk6RYpyfvuX8CGl7v/dMGOQrvmMHGcsUk4AMIvONGmqTAsbFzlPhBEYl0HpSyQCctvLYKO4nHR92mCHfbReLZl3eA46LC1XKOv5SjngDE0chau3AOZPCGO+tR5lXkTISZjdNrfL8gjxAOiyE/SDf4Ne4ldH8YpLJ5PzfIDD6A+/AEk4NS4V2PGxXz6ZVOyK6sUPG4n5YYtzXmreUqmrBKFQH/c6T4KZDNFH0okDVzNsWa2vW+ENJxLjdbA+5pckfSBC0WeJybnTi9mMSkK5XiST5iKAVOBe+fGc6O6A6tKaLY3ZpOKTFzM7so4f3VuxA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JurtxvLmM93TSLMBaXOybPLuNc4jSgX6OQTHgqWvGXk=; b=v5xUOCTdfYrcQCHS43fXU/7wA5doQ+a26lS+Kmv/pa1FModFUHx2A5Hx3KClaHxjXbMdl3ui0CkvNu52cH8Cpw76qCG314/rlJIIJMpMt5gGmcT2hhb0Y4eISvQlwXjnh2OWR+HZ623N5RKcXNMPkbkzLHPyL4GHLq7dfCvYqFE= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=os.amperecomputing.com; Received: from PH0PR01MB7287.prod.exchangelabs.com (2603:10b6:510:10a::21) by PH0PR01MB6213.prod.exchangelabs.com (2603:10b6:510:9::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15; Fri, 22 Oct 2021 06:20:46 +0000 Received: from PH0PR01MB7287.prod.exchangelabs.com ([fe80::254c:9533:7f35:aee]) by PH0PR01MB7287.prod.exchangelabs.com ([fe80::254c:9533:7f35:aee%4]) with mapi id 15.20.4628.016; Fri, 22 Oct 2021 06:20:46 +0000 From: "Nhi Pham" To: devel@edk2.groups.io CC: patches@amperecomputing.com, nhi@os.amperecomputing.com, vunguyen@os.amperecomputing.com, Thang Nguyen , Chuong Tran , Phong Vo , Leif Lindholm , Michael D Kinney , Ard Biesheuvel , Nate DeSimone Subject: [edk2-platforms][PATCH v4 25/31] Ampere: Utilize the PCIe User setting Date: Fri, 22 Oct 2021 13:18:03 +0700 Message-ID: <20211022061809.31087-26-nhi@os.amperecomputing.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211022061809.31087-1-nhi@os.amperecomputing.com> References: <20211022061809.31087-1-nhi@os.amperecomputing.com> X-ClientProxiedBy: HK2PR02CA0168.apcprd02.prod.outlook.com (2603:1096:201:1f::28) To PH0PR01MB7287.prod.exchangelabs.com (2603:10b6:510:10a::21) Return-Path: nhi@os.amperecomputing.com MIME-Version: 1.0 Received: from sw004.amperecomputing.com (118.69.219.201) by HK2PR02CA0168.apcprd02.prod.outlook.com (2603:1096:201:1f::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Fri, 22 Oct 2021 06:20:43 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cfb59a5d-ef27-43c5-359b-08d9952415a0 X-MS-TrafficTypeDiagnostic: PH0PR01MB6213: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WUChbChT1pZbES0TxDVL6PHEW6aMab0Zx+KrkLpN6rre01b8D0gSLb1U2fsc+iSPSnzwaMBsJ0qPYfAoGML9JdGas3cizmmCc7aZfBVYK6arOxZou3XA9XiF4BZvJBFF9Q+49ro17C8XrUHcTLoS0AhTCWOT7Iotc0tyu3utNkVenzYCELLKYnocDsz43OCnXO7DsgNmlbOc0GH40UpxGf8Qh2eexruO7TKj+vQUfquH4oEdgNzRSkUfZmxRB30lnEMFqUPhUuhnCaxuze2nL7AFumBx+ryPBaHY0wnMbg5NCkq7kScAFJZSbEGptkYV+3nqHNAz6KXoPe/iKA43kunEufd5RjaFWG98KXpW6OV2fOsGVvkgMuRSoRH+jZxPWRFL+DNXQVEIwkyMIST1jkA0B1cfMICtmzLa8rk//pmOKBI6jWQGEOa3AkVe3pvB4NshuDC8nviAeNnbK7y4AB6gonXxaxBpcZaWJ8FaZJXc1+EFdGxU1EiQ5omOJ85Eh40TeytxUAWMlniChoO+Gcosu+LWsfIzGl4m4uAnXO2RRq4zm20nGYesnbm6/fuNxQ8UU3qIuIb3e5teD/hLc9IlP7w2b0Clu9S/tYOG1Y1K7DQiQGKRTw7N5Dr+K1EE+arDMoHxpiVGV4KdJbRdxDU12a0pgUQiUM55b7q8rhKVZaOFwajdJOU5amBj5UwRu8+AYyzm820NO4giO7YMFg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR01MB7287.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(52116002)(186003)(2906002)(26005)(2616005)(86362001)(5660300002)(316002)(6916009)(6666004)(83380400001)(19627235002)(38100700002)(508600001)(6506007)(956004)(1076003)(8936002)(6486002)(4326008)(8676002)(66556008)(66946007)(66476007)(6512007)(54906003)(38350700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?JMJdg+q5k8fmL/U3A0axCsAOlHBH85p89F4uefkcvKga5nYYijelFvyIYrFz?= =?us-ascii?Q?9MlcgHLiHhHH7IEEWovse4pvSICNBo3aq7GfeJCWfammOY9jKvkHaPNCODEf?= =?us-ascii?Q?tdGSN7BJzoNhjmrtvNOSjXWLz/5Oahj5Q898+5MilyFvwx6ueaJPItzvp5qb?= =?us-ascii?Q?l0E/nepM//7UbOsUeadSZXXnEt9YB9ndSMq2j1awEZk0NeJ90Q3BolLd44yB?= =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fbByLIGyWeBi0VRRogvG3R6oNq5wphQP?= =?us-ascii?Q?6kxLMi9kRDK/z215ITxDm15Kp9sUNsUxxBoSzI1iw1Ifc+r5L7ZKU4qjZtsd?= =?us-ascii?Q?yKlrZiFTI9BPtpKyeeb4PvFalXmcUA0aG6IOQ+H8pA0ipKxuPxqJXdfXxkmT?= =?us-ascii?Q?38BjS4sYKrwiGz3wDrWGDWkLMs2u1G44BES5JXXZ3cxjxYJB5XkODzjffbIu?= =?us-ascii?Q?r+pl9EtMfGtxJvjY3SOJfdvz?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: cfb59a5d-ef27-43c5-359b-08d9952415a0 X-MS-Exchange-CrossTenant-AuthSource: PH0PR01MB7287.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2021 06:20:46.6436 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nhi@amperemail.onmicrosoft.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR01MB6213 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Vu Nguyen This change allows to configure the PCIe bifurcation mode and update the ACPI IORT tables based on the PCIe User setting. Cc: Thang Nguyen Cc: Chuong Tran Cc: Phong Vo Cc: Leif Lindholm Cc: Michael D Kinney Cc: Ard Biesheuvel Cc: Nate DeSimone Signed-off-by: Nhi Pham --- Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf | 2 + Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.inf | 5 += ++ Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiIort.c | 32 += +++++++++++---- Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.c | 40 += +++++++++++++++++-- 4 files changed, 69 insertions(+), 10 deletions(-) diff --git a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDx= e.inf b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf index 415f795d2a54..804e761a1524 100644 --- a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf +++ b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf @@ -52,6 +52,7 @@ [LibraryClasses] UefiBootServicesTableLib UefiDriverEntryPoint UefiLib + UefiRuntimeServicesTableLib =20 [Pcd] gArmPlatformTokenSpaceGuid.PcdCoreCount @@ -70,6 +71,7 @@ [Guids] gEfiEventReadyToBootGuid gPlatformInfoHobGuid gRootComplexInfoHobGuid + gRootComplexConfigFormSetGuid =20 [Protocols] gEfiAcpiTableProtocolGuid ## ALWAYS_CONSUMED diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.= inf b/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.inf index 17ac1672dac8..32d60bec1440 100644 --- a/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.inf +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.inf @@ -31,9 +31,14 @@ [LibraryClasses] DebugLib HobLib PeimEntryPoint + PeiServicesLib + +[Ppis] + gEfiPeiReadOnlyVariable2PpiGuid =20 [Guids] gRootComplexInfoHobGuid + gRootComplexConfigFormSetGuid gPlatformInfoHobGuid =20 [Depex] diff --git a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiIort.c b/P= latform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiIort.c index b8f8cfa356af..97be85c51f25 100644 --- a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiIort.c +++ b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiIort.c @@ -7,6 +7,7 @@ **/ =20 #include +#include #include #include #include @@ -17,6 +18,7 @@ #include #include #include +#include #include #include =20 @@ -282,8 +284,10 @@ AcpiInstallIort ( EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol; EFI_STATUS Status; INT32 EnabledRCs[AC01_PCIE_MAX_ROOT_COMPLEX]= ; + ROOT_COMPLEX_CONFIG_VARSTORE_DATA VarStoreConfig; UINT32 RcCount, SmmuPmuAgentCount, TotalCount= ; UINT8 Idx; + UINTN BufferSize; UINTN TableKey; VOID *Hob; VOID *IortBuffer; @@ -313,14 +317,28 @@ AcpiInstallIort ( } =20 SmmuPmuAgentCount =3D 0; - for (Idx =3D 0; Idx < RcCount; Idx++) { - if (mRootComplexList[EnabledRCs[Idx]].Type =3D=3D RootComplexTypeA) { - SmmuPmuAgentCount +=3D AC01_RCA_MAX_TBU_PMU; - } else { - SmmuPmuAgentCount +=3D AC01_RCB_MAX_TBU_PMU; + + // + // Check SMMU setting + // + BufferSize =3D sizeof (VarStoreConfig); + Status =3D gRT->GetVariable ( + ROOT_COMPLEX_CONFIG_VARSTORE_NAME, + &gRootComplexConfigFormSetGuid, + NULL, + &BufferSize, + &VarStoreConfig + ); + if (!EFI_ERROR (Status) && VarStoreConfig.SmmuPmu) { + for (Idx =3D 0; Idx < RcCount; Idx++) { + if (mRootComplexList[EnabledRCs[Idx]].Type =3D=3D RootComplexTypeA) = { + SmmuPmuAgentCount +=3D AC01_RCA_MAX_TBU_PMU; + } else { + SmmuPmuAgentCount +=3D AC01_RCB_MAX_TBU_PMU; + } + // Plus 1 TCU + SmmuPmuAgentCount +=3D 1; } - // Plus 1 TCU - SmmuPmuAgentCount +=3D 1; } =20 TotalCount =3D sizeof (EFI_ACPI_6_0_IO_REMAPPING_TABLE) + diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.= c b/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.c index 76cbb76f38f0..3e873a669332 100644 --- a/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.c +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.c @@ -8,6 +8,7 @@ =20 #include =20 +#include #include #include #include @@ -15,7 +16,9 @@ #include #include #include +#include #include +#include =20 #include "RootComplexNVParam.h" =20 @@ -43,8 +46,39 @@ BuildRootComplexData ( ) { AC01_ROOT_COMPLEX *RootComplex; + BOOLEAN ConfigFound; + EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariablePpi; + EFI_STATUS Status; + ROOT_COMPLEX_CONFIG_VARSTORE_DATA RootComplexConfig; UINT8 RCIndex; UINT8 PcieIndex; + UINTN DataSize; + + ConfigFound =3D FALSE; + + // + // Get the Root Complex config from NVRAM + // + Status =3D PeiServicesLocatePpi ( + &gEfiPeiReadOnlyVariable2PpiGuid, + 0, + NULL, + (VOID **)&VariablePpi + ); + if (!EFI_ERROR (Status)) { + DataSize =3D sizeof (RootComplexConfig); + Status =3D VariablePpi->GetVariable ( + VariablePpi, + ROOT_COMPLEX_CONFIG_VARSTORE_NAME, + &gRootComplexConfigFormSetGuid, + NULL, + &DataSize, + &RootComplexConfig + ); + if (!EFI_ERROR (Status)) { + ConfigFound =3D TRUE; + } + } =20 ZeroMem (&mRootComplexList, sizeof (AC01_ROOT_COMPLEX) * AC01_PCIE_MAX_R= OOT_COMPLEX); =20 @@ -58,9 +92,9 @@ BuildRootComplexData ( =20 for (RCIndex =3D 0; RCIndex < AC01_PCIE_MAX_ROOT_COMPLEX; RCIndex++) { RootComplex =3D &mRootComplexList[RCIndex]; - RootComplex->Active =3D TRUE; - RootComplex->DevMapLow =3D 0; - RootComplex->DevMapHigh =3D 0; + RootComplex->Active =3D ConfigFound ? RootComplexConfig.RCStatus[RCInd= ex] : TRUE; + RootComplex->DevMapLow =3D ConfigFound ? RootComplexConfig.RCBifurcati= onLow[RCIndex] : 0; + RootComplex->DevMapHigh =3D ConfigFound ? RootComplexConfig.RCBifurcat= ionLow[RCIndex] : 0; RootComplex->Socket =3D RCIndex / AC01_PCIE_MAX_RCS_PER_SOCKET; RootComplex->ID =3D RCIndex % AC01_PCIE_MAX_RCS_PER_SOCKET; RootComplex->CsrBase =3D mCsrBase[RCIndex]; --=20 2.17.1