From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (EUR03-VE1-obe.outbound.protection.outlook.com [40.107.5.87]) by mx.groups.io with SMTP id smtpd.web12.9828.1586866495588002605 for ; Tue, 14 Apr 2020 05:14:55 -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=JmWqdXB0; spf=pass (domain: oss.nxp.com, ip: 40.107.5.87, mailfrom: pankaj.bansal@oss.nxp.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ElHDsoK4Xk+s2juF+fErDZGkyvxglDYm9L4zcGvNVLGmYd9GUuAgkqpPVgbQ8FpDaTqJ8oOir01BjqzzMfT7OQdOI5AUC9UMROKYV7borJFHmEdvk34u0sf4nEkQjw7GdIdAIHKofeLNIt0EX214DA/RdAh0BZgqh5BOqrbtBIxjnIPmq0OFEqC7sHNCuo45vHlaxEw5OHZWUniBpk4/axGjJH+4hHbec9/htqSi5+UI9Wtp75ZxpzOmYQZfkT//4YjiA0TqoAOxU7U5OcZeoa/aVbxgPdgXB/B73U98pYXZYVyvU5KUtYdqjwkPNQOJGNiQxmCGXSrwk32GTT1LwA== 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=eHW2HeRW4i7I/bGV9/4h2iPGdMykFCd+5fWYzsCmVzQ=; b=WWWz7OGp2XXxWctS1jfh2ubSKC240f4t78jF7U0DUb/o2RUe9ZPfGHT8i0MD7RGBteXpFBSBCge5phcaKdkBe1w2xZhqbI8/myeLtxq/dfmTn2iNu/M2UMS9vCNAl6ZRZdXFuvX+4skfewxai81VelCh83eL+YnEMGCSRkeLs6SZHiS/oAcJOz2Gww5TMYIfqqx8ZSDg01aed6X7xvmqH4dg5Eb3FaGPjiavuwg6I5//v1jo5gHFHDNL3jttOY3vP75GpDZjDsWJoM3XuCJ4WqBswiu0N7bP2zr+wv6mRXq+dYouSE+uVSygMhGqedV9jLi/iLDxdB3uGBw7Hf4p1g== 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=eHW2HeRW4i7I/bGV9/4h2iPGdMykFCd+5fWYzsCmVzQ=; b=JmWqdXB0JIgYicaal1gUzT5RjbFrf/mxE2kIiPDx7JIQw1FPZtUdoeQHxVBnhj1XZDmBUGaMI1BsD/4RjJRDj4JuRMGa+ppBspiZPHYt2nVJLyHtWJ21AR7Zy9EiokTMt6mMNc5m+a6PQxItZUNsC01cF72oRHvj0qKbWkai6GE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=pankaj.bansal@oss.nxp.com; Received: from VI1PR04MB5933.eurprd04.prod.outlook.com (2603:10a6:803:ec::16) by VI1PR04MB4461.eurprd04.prod.outlook.com (2603:10a6:803:70::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.28; Tue, 14 Apr 2020 12:14:53 +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.2900.028; Tue, 14 Apr 2020 12:14:53 +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 v3 03/24] Silicon/NXP/I2cDxe: Fix I2c Timeout with RTC Date: Wed, 15 Apr 2020 17:43:21 +0530 Message-ID: <20200415121342.9246-4-pankaj.bansal@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200415121342.9246-1-pankaj.bansal@oss.nxp.com> References: <20200415121342.9246-1-pankaj.bansal@oss.nxp.com> X-ClientProxiedBy: SG2PR01CA0092.apcprd01.prod.exchangelabs.com (2603:1096:3:15::18) 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 SG2PR01CA0092.apcprd01.prod.exchangelabs.com (2603:1096:3:15::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.15 via Frontend Transport; Tue, 14 Apr 2020 12:14:50 +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: c07ab6e3-9f2b-490d-e5df-08d7e06d6fef X-MS-TrafficTypeDiagnostic: VI1PR04MB4461:|VI1PR04MB4461: 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: 0373D94D15 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:(10009020)(4636009)(376002)(366004)(346002)(136003)(39850400004)(396003)(1076003)(186003)(8936002)(16526019)(86362001)(110136005)(26005)(478600001)(81156014)(8676002)(6512007)(66946007)(316002)(44832011)(66476007)(66556008)(52116002)(5660300002)(6666004)(2906002)(6486002)(6506007)(956004)(19627235002)(2616005);DIR:OUT;SFP:1101; Received-SPF: None (protection.outlook.com: oss.nxp.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tXEXByVFSEUJ4m3uSa9DqguXaY9NqDZEOZSpsOz7cwA5X/ijPTyDpuy6oW/EhGQhI8Bwos9N559B/Vf0VMeCuGxzOJ2WKBy5PhEK0ILUtETBnviOSDa12uLDQxd+woY6EmK8msyaY4xLPnNkrja4wI1XpwNh+Cytwl/Bh2N49XF7cyEfKMsamedMwpk9UUwwOqX+GqkWJAwCHPDw+bAbcHTtAgwsnn2plICoBbIRv2pb+a8v48h0w+7G1BI+xdMsejqWLk2J1E7tUC7Hzgi8r8yI/WGmXzpM6CAcczMIyYuWvowr560wACOQuqHj23BY3842ek0rylkEUImhzILEAsfIOVb+JkwjKq3xhEUXnczNlH+AAO1fOF5oc8Dq3wPbGtu8UDsJpmVow7bOW99Lq/lD8tUIjMVlASyfWFRFKD9eX2f3hcYT9WfDgcwJLDF/ X-MS-Exchange-AntiSpam-MessageData: FdhOtl8nkjB3Dm8tkH9aQxUYA9UsTqGlmyobvoidiNBsopLKC4r3SJakh34U4YX7DpbxbNjSJKWnn1o5DfMa+/nyV96sq+e6C/ed6J36qdlMwf41W4Dh2vbNiAjpmR9IgabMXMcK0tCyooCXgHCE4Q== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c07ab6e3-9f2b-490d-e5df-08d7e06d6fef X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2020 12:14:53.2893 (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: OPlCqtYiU4U815zJ0YOgUHVUt/T2UDhsbXfqq1sCYznrgATeP2mmcx2igGi4m02opsxrLlgL/gjYQdGhazh9Zw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4461 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 unrecovered 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 preempt this. with this solution no timeout has been observed so far. Signed-off-by: Pankaj Bansal Reviewed-by: Leif Lindholm --- Notes: - 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