From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (EUR05-DB8-obe.outbound.protection.outlook.com [40.107.20.75]) by mx.groups.io with SMTP id smtpd.web11.2053.1588225871768981922 for ; Wed, 29 Apr 2020 22:51:12 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@nxp1.onmicrosoft.com header.s=selector2-nxp1-onmicrosoft-com header.b=lXq1hfQO; spf=pass (domain: oss.nxp.com, ip: 40.107.20.75, mailfrom: pankaj.bansal@oss.nxp.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SYxe8ooWvqL6RZDIR9jKQQVblCC5UpS7wli3vyeE5iqhbplMu1h/KDEUPTeuOn2l+gbHqS0NO1D34f5WksAcCJggQEa3DfI45Yp2mwUpkI4+rqXgzcVRR3soN8BxY2zK6MEy65jFZlUPbwcH0sucf/wAeZj1nv1QjMWI4Mfz7h2myFly11QcCJfjlCC6zm1VRBoLRXHddF27ep0kRpfLljZP+iUXVq68oxXpgDNGXWxAkumoOWlz8FOr6U7NUP5azNMWF3VtRTOFn5513AWqtDFiVcpL7TLNfwwQtxHUAsOCB69MBafutu2muzXvtShpJYvaiYt+ph1NSUMwwAmg8Q== 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-SenderADCheck; bh=Er+8d9wwOouPNqH8UmXE8Uv7IEZHFbZ9BT8wyAj/FiI=; b=Jfjxe1rY15jNwpnE7o2HSEzIdrXVHFm7W/A9Y8bg8F1Ond/m9fEhtQaEujB3LaOpscLGyAUuVtTuu1c5MgLGYAFoENKKIS1csg5aETeRjjo6Jq2rB7oW2ldBGo7G4nsjood+s0NibSO9nfr5EwxcA/gUjOTmZLZQRMpT4lBjf3C+tp17l+w6W3MpyT4H3FxuSgl6cHhx85yH4DFAcY85kTMFum6UQYA+49jz67HxGPKBoy8J1kC4Wf2ySXxgOFWbLOd9NO3fwgh5SAqh+YhxdIIIZsu/O9dLTCpOJwmpF/wYOCRlUwkYd0J8MMKFt+D3ARQ19kgWJCP2RGZxDUDF1g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Er+8d9wwOouPNqH8UmXE8Uv7IEZHFbZ9BT8wyAj/FiI=; b=lXq1hfQOTyRplu5YcuAvXHHmd2Z1BcnOnVQhvzAJSYqCGsiZBj6sZ4A3pbgAFOrC9/M0DD5/Xhjk/8MPW34lt6WwR3QDnX+/C1mozA8JJfkN9rJ1uS2lc85vVu92HRNesyeXdl1H5hYb9c0PWKJ0Vr5fsXaWrJS/Cs9PyguHe9k= Authentication-Results: nuviainc.com; dkim=none (message not signed) header.d=none;nuviainc.com; dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5933.eurprd04.prod.outlook.com (2603:10a6:803:ec::16) by VI1PR04MB4429.eurprd04.prod.outlook.com (2603:10a6:803:6e::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.13; Thu, 30 Apr 2020 05:51:09 +0000 Received: from VI1PR04MB5933.eurprd04.prod.outlook.com ([fe80::45c4:8846:5327:9513]) by VI1PR04MB5933.eurprd04.prod.outlook.com ([fe80::45c4:8846:5327:9513%7]) with mapi id 15.20.2958.020; Thu, 30 Apr 2020 05:51:09 +0000 From: "Pankaj Bansal" To: Leif Lindholm , Meenakshi Aggarwal , Michael D Kinney , devel@edk2.groups.io, Varun Sethi , Samer El-Haj-Mahmoud , Jon Nettleton , Ard Biesheuvel Subject: [PATCH edk2-platforms v4 03/24] Silicon/NXP/I2cDxe: Fix I2c Timeout with RTC Date: Fri, 1 May 2020 11:19:34 +0530 Message-ID: <20200501054955.13025-4-pankaj.bansal@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501054955.13025-1-pankaj.bansal@oss.nxp.com> References: <20200501054955.13025-1-pankaj.bansal@oss.nxp.com> X-ClientProxiedBy: SG2PR03CA0131.apcprd03.prod.outlook.com (2603:1096:4:91::35) To VI1PR04MB5933.eurprd04.prod.outlook.com (2603:10a6:803:ec::16) Return-Path: pankaj.bansal@oss.nxp.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from uefi-workstation.ap.freescale.net (92.120.0.69) by SG2PR03CA0131.apcprd03.prod.outlook.com (2603:1096:4:91::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.14 via Frontend Transport; Thu, 30 Apr 2020 05:51:07 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [92.120.0.69] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 9b0b346f-142d-4480-30e3-08d7ecca7b74 X-MS-TrafficTypeDiagnostic: VI1PR04MB4429:|VI1PR04MB4429: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-Forefront-PRVS: 0389EDA07F X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5933.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(376002)(39860400002)(346002)(366004)(396003)(6512007)(26005)(16526019)(5660300002)(6666004)(478600001)(186003)(2906002)(110136005)(52116002)(6486002)(316002)(8676002)(6506007)(66476007)(19627235002)(86362001)(2616005)(66946007)(44832011)(956004)(66556008)(1076003)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BXLHxEhGuLfrwV+D+FQJOQKJQ2+eFa7FY/KvTHcKkVipqP7M3LSJymEV3WpyyYvGmFZU7J6h1Bhgc6lfPGmkuh58XeAEr73AfWpEDJoXkfCWHVqj/BYnBpaZ9fYzqoQaSu/PguIsA8g8I9ip7mg8jGOJQlUPSlaFKr1PIT+QBRBjtz55g67T9nKX6Rquj4bIWn0RTxuKpCNytYfzQEZMFwldfw8ShzLRx5KTFCBzq82xD8We0L36sI/G6nMcOUv3XCz8f9pl6opHTljFTvhUT4kb5SRbfsBmEtgfgLqw25K3yMXQ3JrXn+Va4zE3CF4JeKgB/TQZQs4aGZ4oE6XE9V3FGx3DZ+dife2EdglZEyjVajVLGABBbY0p1h0PDD1dKzXKxVbEPRUhxfUsVY4QBwubjd3BkjNYsOnmVuG16sl0gYX2MfHcbntOd0ZPRbDf X-MS-Exchange-AntiSpam-MessageData: UYxTNRfIEtQp58haokaaQH20c7I3xYvYcMRjl4aaINr0hBAz3+8Znwng7xcIjxPx6XRGvBR2KES7tmNnzym3OpgLg5ZN7/lZzruDdCs7QxC7ZxsaL9vxD47ZDTNZZEczJBAKUudEe9Vob5jsBZlQPfeKw0zO/nq/k5J1ElMOrP2Zk30YoSBD8ldXhHyPdA9M3kYg8D+0XsrSa6FYSMVsgxJ0bCGaOdBQd4z7Ko/qI7nvrJzxOkXirxqwoFlhzYwfNydaKcfHkEU8ydA6tkUa1eFrU88UxXa9eTyseEMR6jDR+BZ+MRxadqiEQ4fafdcd7HksnWYJ9m39LEQf3bf+lcpIGBTbOcpzyb5BW0FXi0kVq288Cfz7TnwRsl1qcRkfYAhpgsp9PjVpZkBk/Q/cDDGtxGkWzzviXhKuzivLPqqd7F5SFXT1FPzPuXE+IaftfCnmoQaJIRCWqw1SphsP98pSPz7NB3iVG77kDe3++pF5TGHlhRjcnagttFhhZHjIjLpJ3jNiDPvtuyQONU/C0LOR6Yc21I9dnCwEsmvL33LBUTkZY2TdgYm/nKignX2mrXL1RHoiiIoNGcfxQ1d4INSoDl7FvkpG0N7o0IAm5360stPJVNORiPKM80nQbBnKJr95LmvlnynBwzRKI23ayxqjguxSvi0xW98g+K5E6NRzw7daq8Lk1BG59bokR3YXveGNVkuuZzBjrR9IFxhoHvA4CR28rSq1RkAws62b+/r2bfXsk8ggHwRz/TKQnyqR28bFBUUnilFe7cJQhjTbEMh692+P+iRmDrUW/DpxV0c= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b0b346f-142d-4480-30e3-08d7ecca7b74 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2020 05:51:09.6814 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 45gXT3KRJHKt1x0igz64zi1dVZWfXDS/R6nn6ql1KjgOtuNC12U9LaQTpnSuRSOX/DzwanJ1gLje76v724jzog== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4429 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Pankaj Bansal With latest edk2 codebase, sometimes i2c timeout is observed when Network devices are being probed. This is happening when gRT->GetTime request is ongoing. gRT->GetTime triggers a read request to Real Time Clock which is connected to I2c bus. In between read request, if an event occurs, which also triggers gRT->GetTime (i.e. RTC read), the I2c bus goes into unrecoverable state. This state is not even recovered, when rebooting the board. We need to power off the board completely to recover i2c bus. To prevent this, TPL level of I2c read is being raised to high, so that no other event can pre-empt this. with this solution no timeout has been observed so far. Signed-off-by: Pankaj Bansal Reviewed-by: Leif Lindholm --- Notes: V4: - No change =20 V3: - No change Silicon/NXP/Drivers/I2cDxe/I2cDxe.inf | 3 ++- Silicon/NXP/Drivers/I2cDxe/I2cDxe.c | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Silicon/NXP/Drivers/I2cDxe/I2cDxe.inf b/Silicon/NXP/Drivers/I2= cDxe/I2cDxe.inf index 84adb837c249..867376044656 100644 --- a/Silicon/NXP/Drivers/I2cDxe/I2cDxe.inf +++ b/Silicon/NXP/Drivers/I2cDxe/I2cDxe.inf @@ -13,7 +13,7 @@ INF_VERSION =3D 0x0001001A BASE_NAME =3D I2cDxe FILE_GUID =3D 5f2927ba-1b04-4d5f-8bef-2b50c635d1e7 - MODULE_TYPE =3D DXE_DRIVER + MODULE_TYPE =3D DXE_RUNTIME_DRIVER VERSION_STRING =3D 1.0 ENTRY_POINT =3D I2cDxeEntryPoint UNLOAD =3D I2cDxeUnload @@ -36,6 +36,7 @@ UefiBootServicesTableLib UefiDriverEntryPoint UefiLib + UefiRuntimeLib =20 [Guids] gNxpNonDiscoverableI2cMasterGuid diff --git a/Silicon/NXP/Drivers/I2cDxe/I2cDxe.c b/Silicon/NXP/Drivers/I2cD= xe/I2cDxe.c index 848e707c1673..a5aba47b3ed4 100644 --- a/Silicon/NXP/Drivers/I2cDxe/I2cDxe.c +++ b/Silicon/NXP/Drivers/I2cDxe/I2cDxe.c @@ -16,6 +16,7 @@ #include #include #include +#include =20 #include "I2cDxe.h" =20 @@ -88,6 +89,13 @@ StartRequest ( NXP_I2C_MASTER *I2c; UINTN I2cBase; EFI_STATUS Status; + EFI_TPL Tpl; + BOOLEAN AtRuntime; + + AtRuntime =3D EfiAtRuntime (); + if (!AtRuntime) { + Tpl =3D gBS->RaiseTPL (TPL_HIGH_LEVEL); + } =20 I2c =3D NXP_I2C_FROM_THIS (This); =20 @@ -95,6 +103,10 @@ StartRequest ( =20 Status =3D I2cBusXfer (I2cBase, SlaveAddress, RequestPacket); =20 + if (!AtRuntime) { + gBS->RestoreTPL (Tpl); + } + return Status; } =20 --=20 2.17.1