From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (NAM02-BN1-obe.outbound.protection.outlook.com [40.107.212.119]) by mx.groups.io with SMTP id smtpd.web11.53488.1683791537928025073 for ; Thu, 11 May 2023 00:52:19 -0700 Authentication-Results: mx.groups.io; dkim=fail, err=malformed MIME header line: Subject: [edk2-platforms][PATCH 3/3] AmpereAltraPkg: Add retry logic when PCIe card is present; spf=pass (domain: os.amperecomputing.com, ip: 40.107.212.119, mailfrom: minhnguyen1@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HBmCTOck7EkZA7lXZRCkY0VuDTNrUyWl6AuM0dkHE6KT5II7akq4ygxWJMMqffh8VScIihhjwQpkuNM2qea3XvbkWqlkMj+YSS1OJAQBXqAJCicuZY1GhbABOo9jAGmOBptlV/HJq5ws6l+uQZAQYgrQll4u2sfRF+EvUXyUx2RW9Aw35YEA1cs3BKQ5wq4FR/aHKSzNTS1rWj6tmYLNZaKEOOu/Qkcnj/WEpOmu1OTJ3HneQusXJlXhsfa3BbNMpqTWT9sFtUEjrHak6axRHFy5i8/qhnqIWfZ3pz0ps7lHPItXLWDUFJZgaTFp7k25UdEZoJmgzb5apIoSuwUdQw== 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=Fj4PEnnUohv8TECn+0OjmfPzKnEiNUzXhDP898dweEA=; b=R+JFlcZVwaVb2z6icZgYi7IbgVFkSTqijXXbWvE3mqUF7lCehuSQeG6PY1G4KnU1XmBUvrSpFKy6dYnBFM8vXckJl8DLpg96pa4UZ+gVvMU8G7vGAAkYPLS03FdOFoUXKHDPsbyyD0cr+zNadejxt/WHLrueXYFMLEc5rb/dA/8vbZrBlWNu48+1J+P3J99FJ2jBz2D0F+5VNS6uFywQQHppVMc8mSmn22fE97nS2mH2cikSABih1uQZ1ZUxm9fqgYMbPvugDRU+y/dZyWdBvkiff3j2OfY1a6jz4Lr5wIKjOI/4AvBgRxS/W+BsaE+Bfpp0EIeRRm9/R/5enozKRg== 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=Fj4PEnnUohv8TECn+0OjmfPzKnEiNUzXhDP898dweEA=; b=jh9s2aKXLBK+gvEBAD0qxclUvlj2WVuRfemUOUf4BbelnN3D2axuM4zUKxjlbPOrGcq9JGzd17BKfE+GGHvqpkIeLbTaQeo0DbrMA4SFFhphXPaIJqetAOg8F7YcZBmvUrWbXGXoUgUBulAaJ1Z6eNioQpdzLOm4SoSgA8VkZZg= 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 PH7PR01MB7959.prod.exchangelabs.com (2603:10b6:510:277::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.32; Thu, 11 May 2023 07:52:11 +0000 Received: from PH0PR01MB8048.prod.exchangelabs.com ([fe80::bbdb:b58c:140e:c4e1]) by PH0PR01MB8048.prod.exchangelabs.com ([fe80::bbdb:b58c:140e:c4e1%6]) with mapi id 15.20.6387.019; Thu, 11 May 2023 07:52:11 +0000 From: Minh Nguyen To: devel@edk2.groups.io CC: patches@amperecomputing.com, quic_llindhol@quicinc.com, ardb+tianocore@kernel.org, nhi@os.amperecomputing.com, tinhnguyen@os.amperecomputing.com, Minh Nguyen Subject: [edk2-platforms][PATCH 3/3] AmpereAltraPkg: Add retry logic when PCIe card is present Date: Thu, 11 May 2023 14:51:43 +0700 Message-ID: <20230511075143.2690207-4-minhnguyen1@os.amperecomputing.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230511075143.2690207-1-minhnguyen1@os.amperecomputing.com> References: <20230511075143.2690207-1-minhnguyen1@os.amperecomputing.com> X-ClientProxiedBy: SI1PR02CA0008.apcprd02.prod.outlook.com (2603:1096:4:1f7::14) 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_|PH7PR01MB7959:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e76efca-ffd1-455c-abab-08db51f4a07b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /mG8kK+Fe7joUmJTQepEkeZiC1ZarE8n84mb5WUA+shOgxb5F1ZXFA8wZ76VlJCW39Xu+iYDXwhcAX8aVTVaL3qAyMOT8y7HmVzp+43ZHmcz03iGPl61yP+VPmNKfg1CRlTUzkS7aprSIRy5CSGq8bZ3fmBOGzfTDghdPmxIs1ADryDHCO3N66610sWlSSNa8FlhY0BpPaTenn7YPOdcWLylLuJr7W4iOyd82nmkL0DBo2D+7ZT5GfY9bE+iK7oz0OZIzFaZ1XWcFpsDROZosfLu+bOXOyCedvXJ/AxXrNiWDWAfLNqEKHtu/DtONKtVMpHZ+F8sBpOhKCtyM+cHzG09caqxqmkjywRKYwgI0PD6FsfmFy57ylfMvnkKaO5bVS+jNAiYI4QM6HaKHhbV9wkVeCk9tZvg+F/+zxRfv3mMYRtrrWQ8we/bdIV4luQZF/R14xD+9Ow1fTlDSogo61CV3omYg0rh7s1uQqJ4co3k59CAtNzcGNWDtACa37wDFoBcZUIUr1k1ZyJTesr0thhQA91zJQa0k2sPV2BBKR8UDuOgtY+SwS5u/wpAcGAUqDQXG77yovDxsi4wyPowCBjX8NHiqFVUi2bViBRW1vL4UalutxaNPEN7gm4LgT3a 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)(39860400002)(366004)(346002)(396003)(376002)(136003)(451199021)(2906002)(186003)(1076003)(6666004)(8936002)(8676002)(4326008)(52116002)(6486002)(41300700001)(5660300002)(316002)(66476007)(6916009)(66556008)(66946007)(19627235002)(86362001)(83380400001)(478600001)(38350700002)(38100700002)(26005)(6512007)(6506007)(107886003)(2616005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?O5N3BEO/G6QGX9tLAJGNC3YZCmW0n+5xz6xy+ns7DhlEoLbscnsaIzFP+Cr6?= =?us-ascii?Q?KrTova88nEJ+1N0lD5hNglcNARYDxBhLwlxT4sKvNlHLyVL5UROGltFTRvg9?= =?us-ascii?Q?j92GF6yOOyzF414l9UMePtqNx2ZK04o0DDKs67ICQplxNMeLvFrwjd+VQGka?= =?us-ascii?Q?vuKGJo0h73aC1/WZSXacZF61VDzF/JaWrRBrA+GxIPujK3aKnPE87aipIDc5?= =?us-ascii?Q?daa32qDpHfpT9AP8bJz5LjpGhDMlJz0pq/lSmyFeUVwehS1pWhq+cy4Wrvlr?= =?us-ascii?Q?DbOChgLOyaVjO8quVOhcQHLUCWwBT5mjek1H83aTubvmqwoB42KUDy4O4eWl?= =?us-ascii?Q?guGV2eT9ryWRcsilyxBqGiZRgtBi7RVt9s5Smp74iwfuRU5DC0597+Ot4108?= =?us-ascii?Q?Wab0dK1IpuWlBzHsA7nYzd0zhd/isf1CyTe1F0U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Q?OeTH1BCTHn0ige6yZ+fmRb63za7epqp4FWEmsVGs7cAut7jGejbZvrxLgQil?= =?us-ascii?Q?qrD9+ao2x+SXK9V/gEAQndT8eGh/TyTy/3ozx452TduhViGkhPwCFrArjqDN?= =?us-ascii?Q?t1LJT2/I+kvY3y/4DMuYD3U9+Uzvc0djMvAGp4ZF/2hx8B+uuR9x4Q9FDOZM?= =?us-ascii?Q?9I6Rc6TFxsFORxX2mwy18tF3+hw5QZd30J1HOGVY3NXjTE0log/XoojcxRDt?= =?us-ascii?Q?dLQlKK1vqHt+jbtd1RN5rYY1uF3Tj6Qt4hHit1e7egrPG28yYSglYlarXmdu?= =?us-ascii?Q?EpLUWinpItpr6YddMbYYwYR16OyejyNT//HLuVj3OAL7?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e76efca-ffd1-455c-abab-08db51f4a07b X-MS-Exchange-CrossTenant-AuthSource: PH0PR01MB8048.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2023 07:52:11.3141 (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: 0hpwxeqTi6nypNbwHVCszcP9rENC+R3Q97xW7HHG2bKaz/JQ0ldLZEFKORekswtMR+EFiJ7L1/MRbFq9AAP59PyRg8oNfEYpOom6o/fcE7yp0espHJArmFcT4laitVcK X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR01MB7959 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Tinh Nguyen Add PCIe link retry logic. If the card is detected to be present, allow a retry for 3 times. When the link is down, check if the LTSSMEN bit is cleared. Based on Altra PCIe IP, the LTSSMEN bit is cleared from 1 to 0 if there is a surprising link down. This indicates that a card is present. Signed-off-by: Minh Nguyen --- Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c b= /Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c index d797442d9fbc..9cc059788581 100644 --- a/Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c +++ b/Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c @@ -1769,7 +1769,11 @@ Ac01PcieCoreUpdateLink ( } else { FailedPciePtr[*FailedPcieCount] =3D PcieIndex; *FailedPcieCount +=3D 1; - *IsNextRoundNeeded =3D !(*IsNextRoundNeeded) ? Ac01PcieCoreCheckCa= rdPresent (Pcie) : TRUE; + + if (Ac01PcieCoreCheckCardPresent (Pcie)) { + *IsNextRoundNeeded =3D TRUE; + DEBUG ((DEBUG_INFO, "PCIE%d.%d Link retry\n", RootComplex->ID, P= cieIndex)); + } } } } --=20 2.39.0