From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::241; helo=mail-wr0-x241.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 170B4223C1765 for ; Wed, 21 Feb 2018 03:05:29 -0800 (PST) Received: by mail-wr0-x241.google.com with SMTP id u49so3309214wrc.10 for ; Wed, 21 Feb 2018 03:11:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=gCeXVIWFctIvCEPZGyTNrz+VE/hm5JQBOiTiGRPVazE=; b=DYj3pRG/cX5A1QP0r7yDQtltDkYM5tjk5rWMtylrLFlwVwq3EBpfl7hgyiBjVMnIs6 5Tt9Mu2woyDStAGbDbts+NSfrQiNBEA0aaeFKVq21WQLv5w5Xr0AsdF5jK+v9dJuJQiu hE2YwbN/x81L8O3XpZ7sxfSu/E3egVrnlO0Gw= 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=gCeXVIWFctIvCEPZGyTNrz+VE/hm5JQBOiTiGRPVazE=; b=mOnCh2+w9lOXKbxQUz7RQ/wZA+RGDRVUARPNxOUonJTQTMz9HQ4SUt3oNz3u1Onen1 gu7/8DFzzL+UtO6yQLTh5hiTzGBApQ+fK2+A9BrPbbHFnnYtkD5++sVW/cyFLmViBFij TmavDSJxzik/xGxeoPm0UNlm5JxypOfesOSIKVF0x1Vw52uhN78Ytip+kapSE8Ls+waj aSMMI6s6wGCxfMdg154XpYHwXkanMSwQLW86pN9EPF6JAJ7dwz3cJI9nS8TzHAoy9gO6 a5lJkEPCrRUaIPFxmhAgM5UwgY0niHkhXKxhW63AjsX617uSbFp0eklvIWCsst/IMFK5 ASBQ== X-Gm-Message-State: APf1xPCcrBrdIJZthyJg8G/2B6O26wPNwgObcrg3NbIaURDqBJ8kYki1 qn3eeYLJI7HGRxmiuQWnwqd5eg== X-Google-Smtp-Source: AH8x225r1d4kCJftRfGg5yrZ4gQcFArd8YQOAedYFdKrm+5g1D5R6JlT//3ogaNEIyXSga2yH9VzHA== X-Received: by 10.28.129.198 with SMTP id c189mr1815416wmd.65.1519211487947; Wed, 21 Feb 2018 03:11:27 -0800 (PST) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id m55sm5235099wrf.38.2018.02.21.03.11.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Feb 2018 03:11:26 -0800 (PST) Date: Wed, 21 Feb 2018 11:11:25 +0000 From: Leif Lindholm To: Ard Biesheuvel Cc: edk2-devel@lists.01.org Message-ID: <20180221111125.c5uf5jki5bp3u556@bivouac.eciton.net> References: <20180221110421.18435-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 In-Reply-To: <20180221110421.18435-1-ard.biesheuvel@linaro.org> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [PATCH edk2-platforms v2] Silicon/Socionext/SynQuacerI2cDxe: fix TPL handling bug X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Feb 2018 11:05:30 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Feb 21, 2018 at 11:04:21AM +0000, Ard Biesheuvel wrote: > Currently, SynQuacerI2cStartRequest() increases the TPL to TPL_HIGH_LEVEL > while accessing the I2C controller hardware, but fails to restore the TPL > to the original level if the call to SynQuacerI2cMasterStart() fails, and > returns right away. Given the TPL_HIGH_LEVEL implies that interrupts are > disabled, this results in a complete system hang. So instead, break out > of the loop, so that the TPL restore will occur before leaving the > function. > > Note that this will result in the bus control bits to be de-asserted in > case of a failure to send the START condition, which is an appropriate > cleanup action to take after SynQuacerI2cMasterStart() fails. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm > --- > v2: clarify comment and commit log to explain that releasing the bus controls > is an appropriate action for this failure mode > > Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.c b/Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.c > index 46c512a20151..5e70f9d921c3 100644 > --- a/Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.c > +++ b/Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.c > @@ -324,7 +324,7 @@ SynQuacerI2cStartRequest ( > > Status = SynQuacerI2cMasterStart (I2c, SlaveAddress, Op); > if (EFI_ERROR (Status)) { > - return Status; > + break; > } > > Status = WaitForInterrupt (I2c); > @@ -397,7 +397,7 @@ SynQuacerI2cStartRequest ( > } while (BufIdx < Op->LengthInBytes); > } > > - // Stop the transfer > + // Force bus state to idle, terminating any ongoing transfer > MmioWrite8 (I2c->MmioBase + F_I2C_REG_BCR, 0); > > if (!AtRuntime) { > -- > 2.11.0 >