public inbox for linux-integrity@vger.kernel.org
 help / color / mirror / Atom feed
From: "Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>
To: Lino Sanfilippo <LinoSanfilippo@gmx.de>,
	peterhuewe@gmx.de, jarkko@kernel.org, jgg@ziepe.ca
Cc: jsnitsel@redhat.com, hdegoede@redhat.com, oe-lkp@lists.linux.dev,
	lkp@intel.com, peterz@infradead.org, linux@mniewoehner.de,
	linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org,
	l.sanfilippo@kunbus.com, lukas@wunner.de,
	p.rosenberger@kunbus.com
Subject: Re: [PATCH 2/2] tpm, tpm_tis: reuse code in disable_interrupts()
Date: Tue, 23 May 2023 10:08:40 +0300	[thread overview]
Message-ID: <d753c02d-38ab-3061-c410-9ef979fe09f1@linux.intel.com> (raw)
In-Reply-To: <20230522143105.8617-2-LinoSanfilippo@gmx.de>



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,

-- 
Péter

  parent reply	other threads:[~2023-05-23  7:08 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-22 14:31 [PATCH 1/2] tpm, tpm_tis: Handle interrupt storm Lino Sanfilippo
2023-05-22 14:31 ` [PATCH 2/2] tpm, tpm_tis: reuse code in disable_interrupts() Lino Sanfilippo
2023-05-22 22:45   ` Jerry Snitselaar
2023-05-23  7:08   ` Péter Ujfalusi [this message]
2023-05-23 19:07   ` Jarkko Sakkinen
2023-05-23 20:52     ` Lino Sanfilippo
2023-05-24  1:29       ` Jarkko Sakkinen
2023-05-22 22:44 ` [PATCH 1/2] tpm, tpm_tis: Handle interrupt storm Jerry Snitselaar
2023-05-23  6:48 ` Péter Ujfalusi
2023-05-23  7:07   ` Péter Ujfalusi
2023-05-23  7:44   ` Lukas Wunner
2023-05-23  9:14     ` Péter Ujfalusi
2023-05-23  9:20       ` Hans de Goede
2023-05-23  9:35       ` Péter Ujfalusi
2023-05-23 10:35         ` Lino Sanfilippo
2023-05-23 15:19         ` Lukas Wunner
2023-05-23 10:41       ` Lino Sanfilippo
2023-05-23 15:16       ` Lukas Wunner
2023-05-24  9:08         ` Hans de Goede
2023-05-29 10:44         ` Michael Niewöhner
2023-05-23 19:35   ` Jarkko Sakkinen
2023-05-23 18:53 ` Jarkko Sakkinen
2023-05-23 19:00   ` Jarkko Sakkinen
2023-05-23 19:46     ` Lukas Wunner
2023-05-24  1:44       ` Jarkko Sakkinen
2023-05-23 20:50     ` Lino Sanfilippo
2023-05-23 19:12   ` Jarkko Sakkinen
2023-05-23 22:32     ` Jerry Snitselaar
2023-05-24  1:21       ` Jarkko Sakkinen
2023-05-23 19:37   ` Lukas Wunner
2023-05-24  1:46     ` Jarkko Sakkinen
2023-05-23 20:46   ` Lino Sanfilippo
2023-05-29  6:46     ` Péter Ujfalusi
2023-05-29 13:15       ` Lino Sanfilippo
2023-06-06 16:42         ` Jarkko Sakkinen
2023-05-30 17:56       ` Jerry Snitselaar
2023-06-06 16:35         ` Jarkko Sakkinen
2023-06-06 16:45       ` Jarkko Sakkinen
2023-05-24  3:58 ` Jarkko Sakkinen
2023-05-24  3:59   ` Jarkko Sakkinen
2023-05-24  7:29   ` Lukas Wunner
2023-05-24 15:30   ` Jarkko Sakkinen
2023-05-26  0:37     ` Lino Sanfilippo
2023-05-30 10:31     ` Lino Sanfilippo
2023-05-25 23:45   ` Lino Sanfilippo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d753c02d-38ab-3061-c410-9ef979fe09f1@linux.intel.com \
    --to=peter.ujfalusi@linux.intel.com \
    --cc=LinoSanfilippo@gmx.de \
    --cc=hdegoede@redhat.com \
    --cc=jarkko@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=jsnitsel@redhat.com \
    --cc=l.sanfilippo@kunbus.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@mniewoehner.de \
    --cc=lkp@intel.com \
    --cc=lukas@wunner.de \
    --cc=oe-lkp@lists.linux.dev \
    --cc=p.rosenberger@kunbus.com \
    --cc=peterhuewe@gmx.de \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox