From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mx.groups.io with SMTP id smtpd.web12.7141.1585655917901580107 for ; Tue, 31 Mar 2020 04:58:38 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=Wh2h4Af8; spf=pass (domain: nuviainc.com, ip: 209.85.221.68, mailfrom: leif@nuviainc.com) Received: by mail-wr1-f68.google.com with SMTP id j17so25469581wru.13 for ; Tue, 31 Mar 2020 04:58:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=t4SjnmEo+XPOuJ8NuMM3GoSUgov2IIvLuT/OlKi1VN0=; b=Wh2h4Af8eWzv+0O0JxUlKFdQR9IhipTQsyc0F0E+n0kf9n3iGUHEsvpWIncCRPFD49 v6ASyrcwrsjRYOHeACyu2p9MPBdVBqwXj0YGii2IWNyMsc08GJea8Vt4itlPbyEeuxQl /uXCFfFoUqd82G+3iXfsp5Y9z6VYdvddu6itE4I88+fcSndTBeatKtqGEb2RT1VkqRgT RQXKddoiXeALrtjzZzjuaMgat1BFJbte+m6gv6Fh/mRXOEwONbo4PC/v5pz8sQwipZOD ghOi4iAeFCAfs3qoyjeItAP772PLDMYpL6ha1NH+BVh3JJFt+wlpNZ/5Tb1ogy4VjYla 04FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=t4SjnmEo+XPOuJ8NuMM3GoSUgov2IIvLuT/OlKi1VN0=; b=QVwdlsHKUrHpHHgFTQ9nqkN1kqPe9vTswM66Bgo1LQD7fPGhOP7pOZ99X+U5LBK2je jmC/Oqntmyo6Cl1d1P4pNNPV1u52dekIBS+cw0Yz4VR+uGnpJZ4aA8mtSU6JfI6MkhgL H05A5l5W+p/S99Fum3VzXszovZmx/hBT2fKqQVjKKs8LkWzr54FpSP8Yggo0FrSSK1sl tMcFkAPTjVheK2bzUvgTPhmPmWk/5S4zmriRZ1cSVvU4A0eJt0e8ITycLm/r2Ysbda3C dnG0whoBXVmD35k8w2EBZIqyFiijyuu1hbRDuy5hxCULh22oFaIWsIwXIs90UI+q5cwB TVLQ== X-Gm-Message-State: ANhLgQ2W/2h1b2l7ziZjW08L2WiavlE/djEwjT10ehJ7dUxAyiigOY5M dkEwZBjpL5rzLPEbi9msaTMFsg== X-Google-Smtp-Source: ADFU+vvT29LAzSJe3dIDzjDHvNmks6UNI8iGE81CuNNPsqCtNWfCwe+rJU0ghZWvTk/0kqx3fwpX4w== X-Received: by 2002:adf:9526:: with SMTP id 35mr21338881wrs.164.1585655916450; Tue, 31 Mar 2020 04:58:36 -0700 (PDT) Return-Path: Received: from vanye ([2001:470:1f09:12f0:b26e:bfff:fea9:f1b8]) by smtp.gmail.com with ESMTPSA id k83sm3289660wma.3.2020.03.31.04.58.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2020 04:58:35 -0700 (PDT) Date: Tue, 31 Mar 2020 12:58:33 +0100 From: "Leif Lindholm" To: Pankaj Bansal Cc: Meenakshi Aggarwal , Michael D Kinney , devel@edk2.groups.io, Varun Sethi , Samer El-Haj-Mahmoud , Jon Nettleton Subject: Re: [PATCH v2 03/28] Silicon/NXP/I2cDxe: Fix I2c Timeout with RTC Message-ID: <20200331115833.GE7468@vanye> References: <20200320143543.18615-1-pankaj.bansal@oss.nxp.com> <20200320143543.18615-4-pankaj.bansal@oss.nxp.com> MIME-Version: 1.0 In-Reply-To: <20200320143543.18615-4-pankaj.bansal@oss.nxp.com> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Mar 20, 2020 at 20:05:18 +0530, Pankaj Bansal wrote: > 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 > --- > 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/I2cDxe/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 > > #include "I2cDxe.h" > > @@ -88,6 +89,13 @@ StartRequest ( > NXP_I2C_MASTER *I2c; > UINTN I2cBase; > EFI_STATUS Status; > + EFI_TPL Tpl; > + BOOLEAN AtRuntime; > + > + AtRuntime = EfiAtRuntime (); > + if (!AtRuntime) { > + Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL); > + } > > I2c = NXP_I2C_FROM_THIS (This); > > @@ -95,6 +103,10 @@ StartRequest ( > > Status = I2cBusXfer (I2cBase, SlaveAddress, RequestPacket); > > + if (!AtRuntime) { > + gBS->RestoreTPL (Tpl); > + } > + > return Status; > } > > diff --git a/Silicon/NXP/Drivers/I2cDxe/I2cDxe.inf b/Silicon/NXP/Drivers/I2cDxe/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 = 0x0001001A > BASE_NAME = I2cDxe > FILE_GUID = 5f2927ba-1b04-4d5f-8bef-2b50c635d1e7 > - MODULE_TYPE = DXE_DRIVER > + MODULE_TYPE = DXE_RUNTIME_DRIVER > VERSION_STRING = 1.0 > ENTRY_POINT = I2cDxeEntryPoint > UNLOAD = I2cDxeUnload > @@ -36,6 +36,7 @@ [LibraryClasses] > UefiBootServicesTableLib > UefiDriverEntryPoint > UefiLib > + UefiRuntimeLib > > [Guids] > gNxpNonDiscoverableI2cMasterGuid > -- > 2.17.1 >