diff mbox series

[v10,12/14] tpm, tpm_tis: Claim locality when interrupts are reenabled on resume

Message ID 20221120133134.28926-13-LinoSanfilippo@gmx.de (mailing list archive)
State New
Headers show
Series TPM IRQ fixes | expand

Commit Message

Lino Sanfilippo Nov. 20, 2022, 1:31 p.m. UTC
From: Lino Sanfilippo <l.sanfilippo@kunbus.com>

In tpm_tis_resume() make sure that the locality has been claimed when
tpm_tis_reenable_interrupts() is called. Otherwise the writings to the
register might not have any effect.

Fixes: 45baa1d1fa39 ("tpm_tis: Re-enable interrupts upon (S3) resume")
Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com>
---
 drivers/char/tpm/tpm_tis_core.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

Comments

Jarkko Sakkinen Nov. 24, 2022, 12:32 a.m. UTC | #1
On Sun, Nov 20, 2022 at 02:31:32PM +0100, Lino Sanfilippo wrote:
> From: Lino Sanfilippo <l.sanfilippo@kunbus.com>
> 
> In tpm_tis_resume() make sure that the locality has been claimed when
> tpm_tis_reenable_interrupts() is called. Otherwise the writings to the
> register might not have any effect.
> 
> Fixes: 45baa1d1fa39 ("tpm_tis: Re-enable interrupts upon (S3) resume")
> Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com>
> ---
>  drivers/char/tpm/tpm_tis_core.c | 19 +++++++++----------
>  1 file changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> index 4312c5cc13da..2514e60f6778 100644
> --- a/drivers/char/tpm/tpm_tis_core.c
> +++ b/drivers/char/tpm/tpm_tis_core.c
> @@ -1220,28 +1220,27 @@ int tpm_tis_resume(struct device *dev)
>  	struct tpm_chip *chip = dev_get_drvdata(dev);
>  	int ret;
>  
> +	ret = tpm_tis_request_locality(chip, 0);
> +	if (ret < 0)
> +		return ret;
> +
>  	if (chip->flags & TPM_CHIP_FLAG_IRQ)
>  		tpm_tis_reenable_interrupts(chip);
>  
>  	ret = tpm_pm_resume(dev);
>  	if (ret)
> -		return ret;
> +		goto out;
>  
>  	/*
>  	 * TPM 1.2 requires self-test on resume. This function actually returns
>  	 * an error code but for unknown reason it isn't handled.
>  	 */
> -	if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) {
> -		ret = tpm_tis_request_locality(chip, 0);
> -		if (ret < 0)
> -			return ret;
> -
> +	if (!(chip->flags & TPM_CHIP_FLAG_TPM2))
>  		tpm1_do_selftest(chip);
> +out:
> +	tpm_tis_relinquish_locality(chip, 0);
>  
> -		tpm_tis_relinquish_locality(chip, 0);
> -	}
> -
> -	return 0;
> +	return ret;
>  }
>  EXPORT_SYMBOL_GPL(tpm_tis_resume);
>  #endif
> -- 
> 2.36.1
> 


Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>

BR, Jarkko
diff mbox series

Patch

diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index 4312c5cc13da..2514e60f6778 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -1220,28 +1220,27 @@  int tpm_tis_resume(struct device *dev)
 	struct tpm_chip *chip = dev_get_drvdata(dev);
 	int ret;
 
+	ret = tpm_tis_request_locality(chip, 0);
+	if (ret < 0)
+		return ret;
+
 	if (chip->flags & TPM_CHIP_FLAG_IRQ)
 		tpm_tis_reenable_interrupts(chip);
 
 	ret = tpm_pm_resume(dev);
 	if (ret)
-		return ret;
+		goto out;
 
 	/*
 	 * TPM 1.2 requires self-test on resume. This function actually returns
 	 * an error code but for unknown reason it isn't handled.
 	 */
-	if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) {
-		ret = tpm_tis_request_locality(chip, 0);
-		if (ret < 0)
-			return ret;
-
+	if (!(chip->flags & TPM_CHIP_FLAG_TPM2))
 		tpm1_do_selftest(chip);
+out:
+	tpm_tis_relinquish_locality(chip, 0);
 
-		tpm_tis_relinquish_locality(chip, 0);
-	}
-
-	return 0;
+	return ret;
 }
 EXPORT_SYMBOL_GPL(tpm_tis_resume);
 #endif