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.129]) by mx.groups.io with SMTP id smtpd.web11.18516.1683254992519267167 for ; Thu, 04 May 2023 19:49:53 -0700 Authentication-Results: mx.groups.io; dkim=fail, err=malformed MIME header line: Subject: [edk2-devel][edk2-platforms][PATCH 2/2] AmpereAltraPkg: Enable auto bifurcation via BoardSetting; spf=pass (domain: os.amperecomputing.com, ip: 40.107.237.129, mailfrom: minhnguyen1@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TYTRTOQAbUyLm6L74Ft4JerpZktp5PkIfuuWs2n4pr4xn/aLZ3I3ljQ73XT2SGcqUU/UJCbcbwmfkHkWaiYevT8SqCSZYq2L26Qn1IPEDV6EQ4jCRbtjECRxXa1lAVKFchm/8LAjx+UdbP2RGY0fuzXcIdhoB+j+TId3XzdxifxgKb4Ih8LIjyZIkTbq/htZPHwnw2lRCfBDWbia11Tt/9WGeP2LYfDEnMl/OqgUh8xVYkzM2w+MDjrdnJ+IpCjTn0MRZQSpnmQ5JKZAEww8vqrD49gXEDqfaiAkNvpq1+1eR5Y7LpannaMOrw5TOw24T/HQWwDbTON0M/Y1R2iP2A== 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=ONEfPXE9OffyfgtEbrvi317lzPNXLcGqbklB/6iU25A=; b=gRBa/W/n2z4tzuNZ7LFx4P9Xr0vVHWBhSD6lbrV7qCpS86e+bwQmw7wF+5NwLjKA/XZgwNa2JM2behhNf2OM5INFB5nv5LCeeeSMZslZTWRj/SXTv07VET6iYHECVZIt3ysOa7KvJvqjbJrDXyfhaQAWBrlqQAplYXFNu6ktm0TtNHZFMO3yA6yiKFTpLX5nvONkbR+h2FTtYaw6SbNBVzOhqWpYXB8ukafb5rKpBabttsmZ2SaVY10itPaRev3YnOR0buzAeJEiEEFEPeOEyFtOxCO0OKdEc5uFzVdDNpcDy0sxXtoS0atp2Y6k3H1vyFLb+lw+NyI40gDLq94Txw== 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=ONEfPXE9OffyfgtEbrvi317lzPNXLcGqbklB/6iU25A=; b=mwz/1t501at/XCZ1fuZKebj7LQUEw1vbqp50E2NkT1YRwHZFr3WIA4oji1og6iYem9xBYDpZhAofd2Ot624w+gNKp+3ej1mveQLcUR4Y2T0DpjUoVU14bTgLgAA8N4BkJLf9gXxuHW8HRgdIB/LdzMw/f/qQHe97RB8x0GejfIM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from PH0PR01MB8048.prod.exchangelabs.com (2603:10b6:510:280::7) by BL3PR01MB6948.prod.exchangelabs.com (2603:10b6:208:35b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.27; Fri, 5 May 2023 02:49:47 +0000 Received: from PH0PR01MB8048.prod.exchangelabs.com ([fe80::bbdb:b58c:140e:c4e1]) by PH0PR01MB8048.prod.exchangelabs.com ([fe80::bbdb:b58c:140e:c4e1%7]) with mapi id 15.20.6363.026; Fri, 5 May 2023 02:49:47 +0000 From: Minh Nguyen To: devel@edk2.groups.io CC: patches@amperecomputing.com, quic_llindhol@quicinc.com, ardb+tianocore@kernel.org, thang@os.amperecomputing.com, nhi@os.amperecomputing.com, tinhnguyen@os.amperecomputing.com Subject: [edk2-devel][edk2-platforms][PATCH 2/2] AmpereAltraPkg: Enable auto bifurcation via BoardSetting Date: Fri, 5 May 2023 09:49:18 +0700 Message-ID: <20230505024918.1447433-3-minhnguyen1@os.amperecomputing.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230505024918.1447433-1-minhnguyen1@os.amperecomputing.com> References: <20230505024918.1447433-1-minhnguyen1@os.amperecomputing.com> X-ClientProxiedBy: SG2PR01CA0167.apcprd01.prod.exchangelabs.com (2603:1096:4:28::23) To PH0PR01MB8048.prod.exchangelabs.com (2603:10b6:510:280::7) Return-Path: minhnguyen1@os.amperecomputing.com MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR01MB8048:EE_|BL3PR01MB6948:EE_ X-MS-Office365-Filtering-Correlation-Id: 268d2644-9ca6-46a5-2e14-08db4d1360d1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LCcuc1B8Kg2aRMmSYjqGzcL5/QHa9J7NMQKosATtLF1Id7YijgeA1pg4ItBabdMkkp6qDHtaU7L//lm1XDQdRmQnR9OA1Xy/SoaqUXT9uerQ8LoceKmZ3pxyH3uf2oOszoTOYWGZYGdngTkhyWrz6L41EIkm15OGoat+GzxRczXTc1p5RH1CSAlZy5MxIbnhv6U0pHCQnzYn0ATdtLUzsLt37gQNX6SQx+wiEt+XvIfKyxmt2Kax9zmpJswMyJah6pHWfZ9tjFp6Au4vqrvM9BQKVFsuBRU/LgiDf5PWkp2883BwThTrsuV8ncWW4ozLXuIsJC5Gq6zx/lZdNCSkNLGSAdTDfocD1Dt7bRmTLgqiiu5pIY22VQi/NbNM2TC4KK+UJWDpbsR844sPZXZRriLi2ByKj1yEziFCc9GMiRiBZMrVu+HLIuTwwXtR5G5LIdMCio/jEcJHijSPar9BsE3MvDhpueU41dmHn8QbyhWuFd6fVuPY156RXuNtU1PxieumeEigSaxenJk6BCqlx9slEPfl6ZbjFOMWiKDjjAHHSc0+4acPkvzfkjQtwtj0vgfOEVYpPQKYQe/JdguTLNF+id/gh9TtnUZtIG7eps7cathTLeWYG4nFVhY4kT+k X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR01MB8048.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(136003)(346002)(376002)(366004)(396003)(39850400004)(451199021)(86362001)(316002)(66946007)(66556008)(66476007)(6916009)(4326008)(52116002)(478600001)(6486002)(6666004)(41300700001)(8676002)(8936002)(5660300002)(2906002)(38350700002)(38100700002)(186003)(2616005)(6512007)(6506007)(1076003)(26005)(107886003)(83380400001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?VLoHwfcCQhutc+L1rvEpyV8HWplxa14SZ4LYVAdeDQ7BgINZExx23yjVQKZb?= =?us-ascii?Q?IhKNl8QCulHG2zOFt71eSi+O0gkccwlIIYCj3oYjuah+J7+3XWvHOpsIuJ32?= =?us-ascii?Q?mMb1p2w4nWn1b/2KxFubxCPJhagslKOT0Oe1cugaDCzrHyECtO7mZnzVYwF1?= =?us-ascii?Q?11zZ/+1sCHAE/gTiP7f52pCGdbRtaybkHktn9dw0ZgbIaTcrcHpHcCPHf4lP?= =?us-ascii?Q?d2YwVjj1fXmt1oWUM7cDXtDf5GewMm0xEYR07m6E680MOIf68VLVN4A7gl8h?= =?us-ascii?Q?RMARElQIIliO7REeqvT0b8oosL/X6ptGknDYK7H2LRJN+AX0AEs2FxZM4g9+?= =?us-ascii?Q?+WQN46X691G3hpRiLzefks1bf65p0Jw4ruASgR6+rBizVRGcsBgZRWV9Oimv?= =?us-ascii?Q?L8UGaHdsP8u/WsGP05rF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Q?HUwqIT4/wSpqZ5dLapeyXKNG3EyQpVgWZBia0bQ1kAN155YPFerWW2e/eFLO?= =?us-ascii?Q?AGqM0VktR+9pChcdZUInbb3J2CquAnXMbnrgmOL+XeSIiIYKQeg9iFOR0ddB?= =?us-ascii?Q?O9vmsM7JmYOBoNq7CQhH0GyG44TilnQHblrsc8ssisR6RuFwx0XaERvFEpPi?= =?us-ascii?Q?XqDfewpqnpgPizYmk0ZOyxR5Tv/4b+hSY0mCPzm1LGOgla7/Gtal53kVNRve?= =?us-ascii?Q?wb1uFnLZFjUChhSJg9au+wZVUvFB0K9lT0/APmWMt+yOpa+DlrNXs/Myls3Z?= =?us-ascii?Q?dm/PZzO3udFH02QnuEGl/3Dnrby7R+nIhduFI8wv9K9f?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 268d2644-9ca6-46a5-2e14-08db4d1360d1 X-MS-Exchange-CrossTenant-AuthSource: PH0PR01MB8048.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2023 02:49:42.9145 (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: fivIQFKhnbR6lusFcz4Ehd/zneXbJAcBPdyx35kst3SMqD3cbaYH12HcMH+dvmdryXGrjHPZmcFGLXwygI2GxFnHiVAOYyA0fO3EQsoMIe1ktdw+rd4FUVgqbOqKk27D X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR01MB6948 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Vu Nguyen Add support for new BoardSetting's config value (0x0000000A) to enable auto bifurcation mode per Root Complex: Example: NV_SI_RO_BOARD_S0_RCA2_CFG, 0x0098, 0x0000000A NV_SI_RO_BOARD_S0_RCA3_CFG, 0x00A0, 0x0000000A Signed-off-by: Minh Nguyen --- Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/RootComplexNVParam.h = | 4 +++- Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/RootComplexNVParam.c = | 12 +++++++++++- Silicon/Ampere/AmpereAltraPkg/Drivers/RootComplexConfigDxe/RootComplexConf= igDxe.c | 7 ++++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/RootComplexN= VParam.h b/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/RootComplexNVP= aram.h index 008a8db69f2c..8c07f086a58f 100644 --- a/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/RootComplexNVParam.= h +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/RootComplexNVParam.= h @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. + Copyright (c) 2020 - 2023, Ampere Computing LLC. All rights reserved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -13,6 +13,8 @@ #define BYTE_MASK 0xFF #define PCIE_ERRATA_SPEED1 0x0001 // Limited speed errata =20 +#define AUTO_BIFURCATION_SETTING_VALUE 0x0A + #ifndef BIT #define BIT(nr) (1 << (nr)) #endif diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/RootComplexN= VParam.c b/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/RootComplexNVP= aram.c index 08dff0f1311f..a8e23015b605 100644 --- a/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/RootComplexNVParam.= c +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/RootComplexNVParam.= c @@ -205,7 +205,9 @@ GetDevMap ( // // Get default Devmap low and configure Devmap low accordingly. // - RootComplex->DefaultDevMapLow =3D GetDefaultDevMap (RootComplex, TRUE); + if (RootComplex->DefaultDevMapLow !=3D DevMapModeAuto) { + RootComplex->DefaultDevMapLow =3D GetDefaultDevMap (RootComplex, TRUE)= ; + } if (RootComplex->DevMapLow =3D=3D 0) { RootComplex->DevMapLow =3D RootComplex->DefaultDevMapLow; } @@ -398,6 +400,14 @@ GetLaneAllocation ( } } =20 + // Update RootComplex data to handle auto bifurcation mode on RCA + if (Value =3D=3D AUTO_BIFURCATION_SETTING_VALUE) { + RootComplex->Pcie[PcieController0].MaxWidth =3D LINK_WIDTH_X4; + RootComplex->Pcie[PcieController0].MaxGen =3D LINK_SPEED_GEN3; + RootComplex->Pcie[PcieController0].Active =3D TRUE; + RootComplex->DefaultDevMapLow =3D DevMapModeAuto; + } + if (RootComplex->Type =3D=3D RootComplexTypeB) { NvParamOffset +=3D NV_PARAM_ENTRYSIZE; Status =3D NVParamGet (NvParamOffset, NV_PERM_ALL, &Value); diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/RootComplexConfigDxe/Roo= tComplexConfigDxe.c b/Silicon/Ampere/AmpereAltraPkg/Drivers/RootComplexConf= igDxe/RootComplexConfigDxe.c index 52a297ff085d..bc4812207f63 100644 --- a/Silicon/Ampere/AmpereAltraPkg/Drivers/RootComplexConfigDxe/RootComple= xConfigDxe.c +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/RootComplexConfigDxe/RootComple= xConfigDxe.c @@ -733,7 +733,8 @@ PcieRCScreenSetup ( // OptionsOpCodeHandle =3D CreateDevMapOptions (RootComplex); =20 - if (RootComplex->DefaultDevMapLow !=3D 0) { + if ((RootComplex->DefaultDevMapLow !=3D 0) + && (RootComplex->DefaultDevMapLow !=3D DevMapModeAuto)) { QuestionFlags |=3D EFI_IFR_FLAG_READ_ONLY; } =20 @@ -1202,8 +1203,8 @@ RootComplexDriverEntry ( RootComplex =3D GetRootComplex (RCIndex); =20 if (EFI_ERROR (Status)) { - VarStoreConfig->RCBifurcationLow[RCIndex] =3D RootComplex->DevMapLow= ; - VarStoreConfig->RCBifurcationHigh[RCIndex] =3D RootComplex->DevMapHi= gh; + VarStoreConfig->RCBifurcationLow[RCIndex] =3D RootComplex->DefaultDe= vMapLow; + VarStoreConfig->RCBifurcationHigh[RCIndex] =3D RootComplex->DefaultD= evMapHigh; VarStoreConfig->RCStatus[RCIndex] =3D RootComplex->Active; IsUpdated =3D TRUE; } --=20 2.39.0