Message ID | 20230522143105.8617-2-LinoSanfilippo@gmx.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1500694vqo; Mon, 22 May 2023 07:42:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5tJAVBMkiCYpuWjnItNxlKhRbc1dPHuCMJfDiH/Vp8BHVS0GWdzmBD3UD6lOZOIsMrfCbC X-Received: by 2002:a05:6a00:23c7:b0:63d:2f13:200 with SMTP id g7-20020a056a0023c700b0063d2f130200mr14968067pfc.16.1684766557916; Mon, 22 May 2023 07:42:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684766557; cv=none; d=google.com; s=arc-20160816; b=zhz61yMeYDlZ7x8M0se70GFkepcBfYq5O7Le8tb0qK/V97VvKMdENWTZspTSnCN/gd 0TSUX82Cq26XGDwb4BS8wT31LoXRjBWGqosbrUcH07hTwxBa83dbNlY6wGCXJYOe2cpV HOmOTsv0V1053V0j2tMNEIqkvt0Fje7HbvvuO/ZMe6tz4gCAtMsvYCT3d2z/6U0X0iJl xwY9yLu7Kj4QGV6BnFChJ90HpNBVKCaKcuYLZbpF6CTdpHAvttFT5FFtN+x0MPK2UK30 bP2VTZ2qsk2aSy99ZwPUmogEWOJtjjusxEUWKtCgPcrb+cfwIyGZ+hJIfEzAov8jrFcJ DR7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=23KmM5Vjp/r+0CEVZoYhx1NZ0LhMxpN04GBEUCeHBaA=; b=Cp6Hqq4koMlFZHWVQnlI8ifBKDnT+tzMSdULZo81ROYbITO/BxzeXvmzy11d9I9/Kv Tl4N1uPAn6BGtpSywbGqLeHTJUjzWdhbbyqxGQuIuNSdbZGmBGRzJIA+CQpIV62Urb4/ A8bJTpJxTAE3vUV2Ix/GFk+OVfO60fhDcj4YtzW4beylkEa+gBkMcUlou6JXzAF7kCTl 5DQXvvOLs02zNppd7tdC2+1G64M8fCdpysVo0CwlmFqwEGvFKLV+ta4NJTAS23d2VBWY puTdeQMVB9G+BymMKND4Xrn2LgXXYXD5OcieMtx6XdlLxJpqpFuTNKcmNpejmBz17FWd 3tbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=Dotd6gRN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x24-20020a63db58000000b005303a26dbf8si4714721pgi.408.2023.05.22.07.42.23; Mon, 22 May 2023 07:42:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=Dotd6gRN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233641AbjEVOc2 (ORCPT <rfc822;wlfightup@gmail.com> + 99 others); Mon, 22 May 2023 10:32:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231609AbjEVOc1 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 22 May 2023 10:32:27 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D9E19E; Mon, 22 May 2023 07:32:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1684765902; i=linosanfilippo@gmx.de; bh=23KmM5Vjp/r+0CEVZoYhx1NZ0LhMxpN04GBEUCeHBaA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=Dotd6gRN0IZGqFv0g+0zOBKVgPxT9vZS7OwjQLeoqXusmJGOTOETnLkeT91QPpT3k 7/qLO6HpAoLMkkRogeeMO2zvQ1FglYnEUgQ5ZteuUvSTeJUa4LEtLG//U2qHsk2kHf F9ELFT3uoQIfTY5rJFpharCFXIkJsj9om3vlpFT4e5mQIAJdl28pYUKdfdW/tMuQ6l eyKFcDzJ7YSyngaCbWhD3+LgX/KOMSUFyRqS5+hWmvyqJbiiC4/jOLE/AmQgcDQisL /pEjFRcTh8MPiM/AQsDpUhCMjM716aBGKv4NFqFe4kPhPX5IbJLqdIk4MRr32i3FRa yYZouriZOBzHg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from Venus.speedport.ip ([84.162.2.106]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MQv8n-1po5rm4Akh-00Nxtb; Mon, 22 May 2023 16:31:42 +0200 From: Lino Sanfilippo <LinoSanfilippo@gmx.de> To: peterhuewe@gmx.de, jarkko@kernel.org, jgg@ziepe.ca Cc: jsnitsel@redhat.com, hdegoede@redhat.com, oe-lkp@lists.linux.dev, lkp@intel.com, peter.ujfalusi@linux.intel.com, peterz@infradead.org, linux@mniewoehner.de, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, l.sanfilippo@kunbus.com, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com Subject: [PATCH 2/2] tpm, tpm_tis: reuse code in disable_interrupts() Date: Mon, 22 May 2023 16:31:05 +0200 Message-Id: <20230522143105.8617-2-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230522143105.8617-1-LinoSanfilippo@gmx.de> References: <20230522143105.8617-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 Content-Transfer-Encoding: base64 X-Provags-ID: V03:K1:5nyh3VGLVlEBuWb2yLT46GgisZGdkKDMI/UWxmOTevTZoUkILFN 5DjVRTH5d5hzFJlQS1ULHkRfnneGFDdSoRfMOb9sjCydsrYvGujtZOf7CzvPzhA2Dsw7ClI tv/JxikT3Cc2tY4FE0yPx5A4RGHgOzn0BpRdvlsh2B2CDd27f6w8JP2uc0mW1qKWcL9l+VB gbNMTK1x9tr2Y43IxM3Aw== UI-OutboundReport: notjunk:1;M01:P0:PYvem97hXWc=;JEbL4U403GY4pF3llnOIcrIDa+1 eY9Xw3t0hyQtzqrQ0aeN028TNUfWO//NJBUDjgZwgYIllqk2ss0OGmUFKvGpOC+/5OXi18Bkp KFyfpTAaRrvvJj49qW4i9uCmYUx47xoSL0jIF4ZSXxUNSVdi5gBgj6GwGijSnEAyFMOq0WuvJ JkXMXyjBt5G2+Zx57TCHEFOFPDsyE+EJH4dHcUGCgKi5oN/rKMUzHiKs5jZDU4qwSFiMeFMjV mSUF+aWb7pzuyxSUpvKmnAjWF6JPqfzVrRVp/aU5tOuyHkSMYJrBthQ2hwEfaqHpyhrGv0lDa YPeX2fq6dqNcn8tnfIJRl+d/n5BzfHqqyHJ2Ks9g2rzKm1/BTeNaYvs+6elNC39HyJOVXiOcm ZNDwmbQaPMB1bI+36CpxeOKiVESlGkMK0kBfKp1r7KQDguZ4HTNIKusVr76svFarcREW+pOCi +M5BjY8A3RIyJ6ry3w3FwqI8i69sbMN4+EVzcBILasLEhOfwSEasqI4bXAQYFBlW4TyWCj9VB E+fPvk/cFxJvf0p6Qb9xrU5YoTkQwwO5zra2WWdd1VanFG4GHd53kprZtfPibpjgjvEfqsP+Q pYQTAi6COMA32lPhOOU43DtSeSNrGV5liSv+ds56D3XMlAhaC25lcQfs/nbM2lRMNAya+6lTP mYExtOafF0hKsSvpDWdMBQLS1Ee3TAmAtq4NBHNtJ1Ij29jeLAa/6KGEX5faVR7+JXASqqlPL ZHpMSbG+p8ZQ+Ask7wtue8iaqyCwFjf+W5U8q+Lfqtb0mtDnxRjWJTv6+CE300J7bJ2sAxVk7 AKyRB85fUGxikbuxWndZO3x5i41ACAPa6pn2MOheXHDCWix856MX13PtZ517FjaR9bISucqZo nEEDN/A3Sn2t6SMJdP4s1C+AFH2i46Ev3RUIhSU3tvEzhl0EUjY4rDTqkW29C2n3hMJ2lmR7+ tlAHQw== X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,MIME_BASE64_TEXT, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766605778523310668?= X-GMAIL-MSGID: =?utf-8?q?1766605778523310668?= |
Series |
[1/2] tpm, tpm_tis: Handle interrupt storm
|
|
Commit Message
Lino Sanfilippo
May 22, 2023, 2:31 p.m. UTC
From: Lino Sanfilippo <l.sanfilippo@kunbus.com> Avoid code redundancy by shifting part of the code in disable_interrupts() into a subfunction and reusing this function in tpm_tis_handle_irq_storm(). Make sure that in the subfunction the INT_ENABLE register is written with a claimed locality even if the caller did not claim it before. In the shifted code get rid of the variable "rc" by initializing the interrupt mask to zero at variable declaration. Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> --- drivers/char/tpm/tpm_tis_core.c | 36 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 19 deletions(-)
Comments
On Mon, May 22, 2023 at 04:31:05PM +0200, Lino Sanfilippo wrote: > From: Lino Sanfilippo <l.sanfilippo@kunbus.com> > > Avoid code redundancy by shifting part of the code in disable_interrupts() > into a subfunction and reusing this function in tpm_tis_handle_irq_storm(). > Make sure that in the subfunction the INT_ENABLE register is written with a > claimed locality even if the caller did not claim it before. > > In the shifted code get rid of the variable "rc" by initializing the > interrupt mask to zero at variable declaration. > > Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com> > --- > drivers/char/tpm/tpm_tis_core.c | 36 ++++++++++++++++----------------- > 1 file changed, 17 insertions(+), 19 deletions(-) > > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c > index 458ebf8c2f16..8f4f2cb5520f 100644 > --- a/drivers/char/tpm/tpm_tis_core.c > +++ b/drivers/char/tpm/tpm_tis_core.c > @@ -468,25 +468,32 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len) > return rc; > } > > +static void __tpm_tis_disable_interrupts(struct tpm_chip *chip) > +{ > + struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); > + u32 intmask = 0; > + > + tpm_tis_read32(priv, TPM_INT_ENABLE(priv->locality), &intmask); > + intmask &= ~TPM_GLOBAL_INT_ENABLE; > + > + tpm_tis_request_locality(chip, 0); > + tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask); > + tpm_tis_relinquish_locality(chip, 0); > + > + chip->flags &= ~TPM_CHIP_FLAG_IRQ; > +} > + > static void disable_interrupts(struct tpm_chip *chip) > { > struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); > - u32 intmask; > - int rc; > > if (priv->irq == 0) > return; > > - rc = tpm_tis_read32(priv, TPM_INT_ENABLE(priv->locality), &intmask); > - if (rc < 0) > - intmask = 0; > - > - intmask &= ~TPM_GLOBAL_INT_ENABLE; > - rc = tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask); > + __tpm_tis_disable_interrupts(chip); > > devm_free_irq(chip->dev.parent, priv->irq, chip); > priv->irq = 0; > - chip->flags &= ~TPM_CHIP_FLAG_IRQ; > } > > /* > @@ -755,20 +762,11 @@ static bool tpm_tis_req_canceled(struct tpm_chip *chip, u8 status) > static void tpm_tis_handle_irq_storm(struct tpm_chip *chip) > { > struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); > - int intmask = 0; > > dev_err(&chip->dev, HW_ERR > "TPM interrupt storm detected, polling instead\n"); > > - tpm_tis_read32(priv, TPM_INT_ENABLE(priv->locality), &intmask); > - > - intmask &= ~TPM_GLOBAL_INT_ENABLE; > - > - tpm_tis_request_locality(chip, 0); > - tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask); > - tpm_tis_relinquish_locality(chip, 0); > - > - chip->flags &= ~TPM_CHIP_FLAG_IRQ; > + __tpm_tis_disable_interrupts(chip); > > /* > * We must not call devm_free_irq() from within the interrupt handler, > -- > 2.40.1 >
On 22/05/2023 17:31, Lino Sanfilippo wrote: > From: Lino Sanfilippo <l.sanfilippo@kunbus.com> > > Avoid code redundancy by shifting part of the code in disable_interrupts() > into a subfunction and reusing this function in tpm_tis_handle_irq_storm(). > Make sure that in the subfunction the INT_ENABLE register is written with a > claimed locality even if the caller did not claim it before. > > In the shifted code get rid of the variable "rc" by initializing the > interrupt mask to zero at variable declaration. Reviewed-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> > Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> > --- > drivers/char/tpm/tpm_tis_core.c | 36 ++++++++++++++++----------------- > 1 file changed, 17 insertions(+), 19 deletions(-) > > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c > index 458ebf8c2f16..8f4f2cb5520f 100644 > --- a/drivers/char/tpm/tpm_tis_core.c > +++ b/drivers/char/tpm/tpm_tis_core.c > @@ -468,25 +468,32 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len) > return rc; > } > > +static void __tpm_tis_disable_interrupts(struct tpm_chip *chip) > +{ > + struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); > + u32 intmask = 0; > + > + tpm_tis_read32(priv, TPM_INT_ENABLE(priv->locality), &intmask); > + intmask &= ~TPM_GLOBAL_INT_ENABLE; > + > + tpm_tis_request_locality(chip, 0); > + tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask); > + tpm_tis_relinquish_locality(chip, 0); > + > + chip->flags &= ~TPM_CHIP_FLAG_IRQ; > +} > + > static void disable_interrupts(struct tpm_chip *chip) > { > struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); > - u32 intmask; > - int rc; > > if (priv->irq == 0) > return; > > - rc = tpm_tis_read32(priv, TPM_INT_ENABLE(priv->locality), &intmask); > - if (rc < 0) > - intmask = 0; > - > - intmask &= ~TPM_GLOBAL_INT_ENABLE; > - rc = tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask); > + __tpm_tis_disable_interrupts(chip); > > devm_free_irq(chip->dev.parent, priv->irq, chip); > priv->irq = 0; > - chip->flags &= ~TPM_CHIP_FLAG_IRQ; > } > > /* > @@ -755,20 +762,11 @@ static bool tpm_tis_req_canceled(struct tpm_chip *chip, u8 status) > static void tpm_tis_handle_irq_storm(struct tpm_chip *chip) > { > struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); > - int intmask = 0; > > dev_err(&chip->dev, HW_ERR > "TPM interrupt storm detected, polling instead\n"); > > - tpm_tis_read32(priv, TPM_INT_ENABLE(priv->locality), &intmask); > - > - intmask &= ~TPM_GLOBAL_INT_ENABLE; > - > - tpm_tis_request_locality(chip, 0); > - tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask); > - tpm_tis_relinquish_locality(chip, 0); > - > - chip->flags &= ~TPM_CHIP_FLAG_IRQ; > + __tpm_tis_disable_interrupts(chip); > > /* > * We must not call devm_free_irq() from within the interrupt handler,
On Mon May 22, 2023 at 5:31 PM EEST, Lino Sanfilippo wrote: > From: Lino Sanfilippo <l.sanfilippo@kunbus.com> > > Avoid code redundancy by shifting part of the code in disable_interrupts() > into a subfunction and reusing this function in tpm_tis_handle_irq_storm(). > Make sure that in the subfunction the INT_ENABLE register is written with a > claimed locality even if the caller did not claim it before. > > In the shifted code get rid of the variable "rc" by initializing the > interrupt mask to zero at variable declaration. > > Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> > --- > drivers/char/tpm/tpm_tis_core.c | 36 ++++++++++++++++----------------- > 1 file changed, 17 insertions(+), 19 deletions(-) > > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c > index 458ebf8c2f16..8f4f2cb5520f 100644 > --- a/drivers/char/tpm/tpm_tis_core.c > +++ b/drivers/char/tpm/tpm_tis_core.c > @@ -468,25 +468,32 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len) > return rc; > } > > +static void __tpm_tis_disable_interrupts(struct tpm_chip *chip) > +{ > + struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); > + u32 intmask = 0; > + > + tpm_tis_read32(priv, TPM_INT_ENABLE(priv->locality), &intmask); > + intmask &= ~TPM_GLOBAL_INT_ENABLE; > + > + tpm_tis_request_locality(chip, 0); > + tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask); > + tpm_tis_relinquish_locality(chip, 0); > + > + chip->flags &= ~TPM_CHIP_FLAG_IRQ; > +} > + > static void disable_interrupts(struct tpm_chip *chip) > { > struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); > - u32 intmask; > - int rc; > > if (priv->irq == 0) > return; > > - rc = tpm_tis_read32(priv, TPM_INT_ENABLE(priv->locality), &intmask); > - if (rc < 0) > - intmask = 0; > - > - intmask &= ~TPM_GLOBAL_INT_ENABLE; > - rc = tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask); > + __tpm_tis_disable_interrupts(chip); > > devm_free_irq(chip->dev.parent, priv->irq, chip); > priv->irq = 0; > - chip->flags &= ~TPM_CHIP_FLAG_IRQ; > } > > /* > @@ -755,20 +762,11 @@ static bool tpm_tis_req_canceled(struct tpm_chip *chip, u8 status) > static void tpm_tis_handle_irq_storm(struct tpm_chip *chip) > { > struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); > - int intmask = 0; > > dev_err(&chip->dev, HW_ERR > "TPM interrupt storm detected, polling instead\n"); > > - tpm_tis_read32(priv, TPM_INT_ENABLE(priv->locality), &intmask); > - > - intmask &= ~TPM_GLOBAL_INT_ENABLE; > - > - tpm_tis_request_locality(chip, 0); > - tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask); > - tpm_tis_relinquish_locality(chip, 0); > - > - chip->flags &= ~TPM_CHIP_FLAG_IRQ; > + __tpm_tis_disable_interrupts(chip); > > /* > * We must not call devm_free_irq() from within the interrupt handler, > -- > 2.40.1 NAK as invidual change w/o further discussion. Would need to be seen in context. This does not change kernel for better. If you want to wrap, please do it in 1/2 and then we can evaluate whether it makes sense or not. BR, Jarkko
On 23.05.23 21:07, Jarkko Sakkinen wrote: > > NAK as invidual change w/o further discussion. > > Would need to be seen in context. This does not change kernel for > better. > > If you want to wrap, please do it in 1/2 and then we can evaluate > whether it makes sense or not. > Ok, will do so. Regards, Lino
On Tue May 23, 2023 at 11:52 PM EEST, Lino Sanfilippo wrote: > > > On 23.05.23 21:07, Jarkko Sakkinen wrote: > > > > > NAK as invidual change w/o further discussion. > > > > Would need to be seen in context. This does not change kernel for > > better. > > > > If you want to wrap, please do it in 1/2 and then we can evaluate > > whether it makes sense or not. > > > > Ok, will do so. And generally: keep it *minimal* :-) We want to exactly fix the bug, and take absolutely no other action. BR, Jarkko
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index 458ebf8c2f16..8f4f2cb5520f 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -468,25 +468,32 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len) return rc; } +static void __tpm_tis_disable_interrupts(struct tpm_chip *chip) +{ + struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); + u32 intmask = 0; + + tpm_tis_read32(priv, TPM_INT_ENABLE(priv->locality), &intmask); + intmask &= ~TPM_GLOBAL_INT_ENABLE; + + tpm_tis_request_locality(chip, 0); + tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask); + tpm_tis_relinquish_locality(chip, 0); + + chip->flags &= ~TPM_CHIP_FLAG_IRQ; +} + static void disable_interrupts(struct tpm_chip *chip) { struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); - u32 intmask; - int rc; if (priv->irq == 0) return; - rc = tpm_tis_read32(priv, TPM_INT_ENABLE(priv->locality), &intmask); - if (rc < 0) - intmask = 0; - - intmask &= ~TPM_GLOBAL_INT_ENABLE; - rc = tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask); + __tpm_tis_disable_interrupts(chip); devm_free_irq(chip->dev.parent, priv->irq, chip); priv->irq = 0; - chip->flags &= ~TPM_CHIP_FLAG_IRQ; } /* @@ -755,20 +762,11 @@ static bool tpm_tis_req_canceled(struct tpm_chip *chip, u8 status) static void tpm_tis_handle_irq_storm(struct tpm_chip *chip) { struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); - int intmask = 0; dev_err(&chip->dev, HW_ERR "TPM interrupt storm detected, polling instead\n"); - tpm_tis_read32(priv, TPM_INT_ENABLE(priv->locality), &intmask); - - intmask &= ~TPM_GLOBAL_INT_ENABLE; - - tpm_tis_request_locality(chip, 0); - tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask); - tpm_tis_relinquish_locality(chip, 0); - - chip->flags &= ~TPM_CHIP_FLAG_IRQ; + __tpm_tis_disable_interrupts(chip); /* * We must not call devm_free_irq() from within the interrupt handler,