From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (EUR04-VI1-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web10.13794.1584628590249290719 for ; Thu, 19 Mar 2020 07:36:32 -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=cl/vSg7a; spf=fail (domain: oss.nxp.com, ip: , mailfrom: pankaj.bansal@oss.nxp.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mbdbo8LhIQbowhQCsxkzbIdmvnKEEg8foUqYmm4Mm8AAWG3u8iPo3X+MvWwVee+CEq6dBnXw/j3EtadSYZ8nAKOru09MXpegCqNG2SNzWxwqPXHKN7QsAV3m3uQJcUhpZvLPHimAAmPPqr+GnL4QcZiBK1feW22i4y7/JeTw2uo1ua6QbEvJK8PG3AzM0UyDHLvnsON3f/6EJKo50JXOHYGqPYdPzENQizOOlMy+Jov8xS5UNuogBS/y7FakdyyP9RYeds6CX/mC9AYAn9XZ9wnq23FvlxmeMyy1Ric1jdAv329rda00rmhnqrAPtLU1MDlJsS2SwaK3upsSg66Gjw== 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=vRmXiXOcwdRmOvEq/6qKrngyECjiZnk8jGELHK/lwDs=; b=oedfTCDXaM/gk0qe628YZ3fCMqWy8JEo4imjOjNNc8HbytYvdSdaJBD6MSXkUFlHSHHKNsX3CjcKNEFv6SOVsHvXouQbSP2DHHcwxIXuQx889OKO/I2q6xI8noRkN4v6iTAUu15s1hy13t5GGAw0RtaStj03aGCnBI6ooOW97A6UPPs7yEtnlmou9B69KSJlNfKyw49FQW3yGUxPGhYDyWkAPsI+x0zFP2V3t+Okeq6vOz8k5Yco/35DgeF703aQiuj3Hi7meyqAHJPmsLbULtpQVcEqKVbZca1raaBaWd8ffYknOrjeGm55Q6iWNxBPv0GKorLGkDnvHRi7DWNEYw== 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=vRmXiXOcwdRmOvEq/6qKrngyECjiZnk8jGELHK/lwDs=; b=cl/vSg7aySF1oLQRPmreMsHJKfGBn5q+rLtaeBnctNGJCt/A6Go9VU7UDn8pN6DsHQ210iuvw1EBSJTTkcaHi33QssCY/OzB6r/RBgscTU3uWXXOl1ZCjgpzUNLJVHK1wWduPRJvpLYyyUvTomPIsWesy6bjVWGi7tkxFrLeVyk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=pankaj.bansal@oss.nxp.com; Received: from VI1PR0401MB2496.eurprd04.prod.outlook.com (10.168.65.10) by VI1PR0401MB2382.eurprd04.prod.outlook.com (10.169.130.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.21; Thu, 19 Mar 2020 14:36:30 +0000 Received: from VI1PR0401MB2496.eurprd04.prod.outlook.com ([fe80::196a:28a9:bb9:2fae]) by VI1PR0401MB2496.eurprd04.prod.outlook.com ([fe80::196a:28a9:bb9:2fae%9]) with mapi id 15.20.2835.017; Thu, 19 Mar 2020 14:36:30 +0000 From: Pankaj Bansal To: Leif Lindholm , Meenakshi Aggarwal , Michael D Kinney , devel@edk2.groups.io, Varun Sethi , Samer El-Haj-Mahmoud , Jon Nettleton Subject: [PATCH v2 03/28] Silicon/NXP/I2cDxe: Fix I2c Timeout with RTC Date: Fri, 20 Mar 2020 20:05:18 +0530 Message-ID: <20200320143543.18615-4-pankaj.bansal@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200320143543.18615-1-pankaj.bansal@oss.nxp.com> References: <20200320143543.18615-1-pankaj.bansal@oss.nxp.com> X-ClientProxiedBy: SG2PR02CA0042.apcprd02.prod.outlook.com (2603:1096:3:18::30) To VI1PR0401MB2496.eurprd04.prod.outlook.com (2603:10a6:800:56::10) 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 SG2PR02CA0042.apcprd02.prod.outlook.com (2603:1096:3:18::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.19 via Frontend Transport; Thu, 19 Mar 2020 14:36:27 +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: 82648eb7-b5b2-45e1-d029-08d7cc12e9dd X-MS-TrafficTypeDiagnostic: VI1PR0401MB2382:|VI1PR0401MB2382: 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: 0347410860 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4636009)(376002)(396003)(346002)(136003)(366004)(39860400002)(199004)(6666004)(316002)(186003)(16526019)(6506007)(8676002)(81166006)(81156014)(478600001)(86362001)(44832011)(19627235002)(26005)(8936002)(6486002)(5660300002)(52116002)(6512007)(956004)(66946007)(110136005)(66476007)(2616005)(2906002)(66556008)(1076003);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0401MB2382;H:VI1PR0401MB2496.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:0; 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: 3PxR5WNfgP5u7pLYQ7mManFdmqj10HqKILhwz8pvgBUiZ88MV/LFAXiRq8u0MqlHQVCEetWFAbzIA1bf25ORG14EY9GmFWea+8s07jpEbAVYdmrMFUglk/jpPi8dm444q4C9ijbTzg/oHV68SRwesGiYN8ziMwXFM+ew/ev2a3wuN5er4hsVGny1ZVRBQkB10x8NLRA+irf4G20SuEDm785RT0efAMiKbTcF/ERzxq78b2RJA5l3l/Zd8MzKMccTJKDt/PDU8P/9+0FTSezwvFLeSOAmoZ8uh64SO/zmM6oN+ePyge92SGu5CaaXqeBEObQx6OG5rqrbTslV46dHeX71OPaYuen1FXItuz8kWhBUXwkukBdooxA8OSd1bofeMbvyzTgtSruiWzuAbVZqCn1arX0YgIPU+HWjnerMGBADBWcVOEkueTwVJ08/z3xf X-MS-Exchange-AntiSpam-MessageData: cgJm8W46RCEutS6j6WAlk8O8VaYywtcS81vWkxcLhopmuGM31erB/3wwko11FF4m8oNk26N6qVEwUjdgdK/2SA+pn0CqLejegzh5v7tjYU7qkaF1ASO5m7sOSjMJJLNadKnbBs+WaiR3/JDjzf9khw== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 82648eb7-b5b2-45e1-d029-08d7cc12e9dd X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Mar 2020 14:36:30.4858 (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: i+7GYi0xyG4hdDQ8Pvb6ouiQ6/6pHGcvUK9DFGX037ee76c0PlmJmfCTeY7HWKfZ+ABtQmIOPPpH29/HhM5g4A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2382 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 --- Silicon/NXP/Drivers/I2cDxe/I2cDxe.c | 12 ++++++++++++ Silicon/NXP/Drivers/I2cDxe/I2cDxe.inf | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) 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 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 @@ [Defines] 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 @@ [LibraryClasses] UefiBootServicesTableLib UefiDriverEntryPoint UefiLib + UefiRuntimeLib =20 [Guids] gNxpNonDiscoverableI2cMasterGuid --=20 2.17.1