From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4001:c0b::241; helo=mail-it0-x241.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-it0-x241.google.com (mail-it0-x241.google.com [IPv6:2607:f8b0:4001:c0b::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 CC6A9223C1775 for ; Wed, 21 Feb 2018 04:03:22 -0800 (PST) Received: by mail-it0-x241.google.com with SMTP id v194so2045366itb.0 for ; Wed, 21 Feb 2018 04:09:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=bn3p5rKvjxW3+ZeroA48gVDmxL+AGNHtuBGVeyYrToY=; b=N81jMckj+Op7MoqPGxedoWL36zj5vKPAzFADH2pVjyvSEl0a5VcMqYiqjAkHHbw1qL 5+f1iXtCDqWluwEnLEDAHZ8h1HHcZQRu5DkXxS7McpeEI482U9xU1NRpCPl4j/irpZ8+ 40z3Wd8eQNnSW23lQuUQeT/5DQ+rVGOrZv/8I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=bn3p5rKvjxW3+ZeroA48gVDmxL+AGNHtuBGVeyYrToY=; b=nLGQ6dgiaU7o4gGpdzhQ8JRb1SRIdgnFVhIRl0bjhI7pULuK73LdDC/QD4FqzTWzNV N/yeN5P8qNYjRrOzM3sotwaVOjr9ULt4NvXnnb8uxSMEHfRt6uaejyBVaT9cFG2dXVvF PY/H2LUz3/SDZubGojJI5egl7t76byc4hiQTwkb8yxSJweVfsXBZZ5/uTW3tikKLHMeK S59R+1ffRf/K9ZoBWPNpUk8ot/WxufRtb+s64ZQDmlx88AwCBxQo2G9Tgme1aYG32xm3 LIr6+WLUEwpOqROuuwZYVbunI3ON2+V+tmUUTjXTX5Fk5BEtwHxVSbKACORDrO3CueQL jtkw== X-Gm-Message-State: APf1xPA9ajfoO/s63yqx8vlW9B7qBDe7WrsZQa6MCXEps4E1+9zuzpQa APIeQ4a7cKSP4dxptauYpPfSPA1UhidnXHpPp5tcAkwNRDM= X-Google-Smtp-Source: AH8x225zwbVOnQ22dlbq+QYkPyvuuIduh425AfF6qMTvVewuWFs3JIzi2PByeLvo0k9w+nu3BcBGi1xePw1bNxHcFtA= X-Received: by 10.36.204.4 with SMTP id x4mr1482370itf.42.1519214961341; Wed, 21 Feb 2018 04:09:21 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.138.209 with HTTP; Wed, 21 Feb 2018 04:09:20 -0800 (PST) In-Reply-To: <20180221111125.c5uf5jki5bp3u556@bivouac.eciton.net> References: <20180221110421.18435-1-ard.biesheuvel@linaro.org> <20180221111125.c5uf5jki5bp3u556@bivouac.eciton.net> From: Ard Biesheuvel Date: Wed, 21 Feb 2018 12:09:20 +0000 Message-ID: To: Leif Lindholm Cc: "edk2-devel@lists.01.org" 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 12:03:23 -0000 Content-Type: text/plain; charset="UTF-8" On 21 February 2018 at 11:11, Leif Lindholm wrote: > 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 > Thanks Pushed as 33d1b85bae27 >> --- >> 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 >>