* [PATCH] tpm: tpm_i2c_nuvoton: disable IRQ on wait timeout
@ 2026-06-26 9:16 Myeonghun Pak
2026-06-26 16:31 ` Jarkko Sakkinen
0 siblings, 1 reply; 2+ messages in thread
From: Myeonghun Pak @ 2026-06-26 9:16 UTC (permalink / raw)
To: Peter Huewe, Jarkko Sakkinen
Cc: Jason Gunthorpe, linux-integrity, linux-kernel, Myeonghun Pak,
Ijae Kim
i2c_nuvoton_wait_for_stat() enables the IRQ before waiting for the
interrupt handler to report a status change. If the wait times out, or is
interrupted before the handler runs, the function returns without
balancing the enable_irq() call.
Disable the IRQ before leaving the failed wait path. Also preserve an
interrupted wait's original error code instead of converting it to
-ETIMEDOUT inside the helper.
Fixes: 4c336e4b1556 ("tpm: Add support for the Nuvoton NPCT501 I2C TPM")
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
drivers/char/tpm/tpm_i2c_nuvoton.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c
index d44903b..aa36730 100644
--- a/drivers/char/tpm/tpm_i2c_nuvoton.c
+++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
@@ -182,8 +182,10 @@ static int i2c_nuvoton_wait_for_stat(struct tpm_chip *chip, u8 mask, u8 value,
timeout);
if (rc > 0)
return 0;
- /* At this point we know that the SINT pin is asserted, so we
- * do not need to do i2c_nuvoton_check_status */
+
+ disable_irq(priv->irq);
+ if (rc < 0)
+ return rc;
} else {
unsigned long ten_msec, stop;
bool status_valid;
--
2.47.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] tpm: tpm_i2c_nuvoton: disable IRQ on wait timeout
2026-06-26 9:16 [PATCH] tpm: tpm_i2c_nuvoton: disable IRQ on wait timeout Myeonghun Pak
@ 2026-06-26 16:31 ` Jarkko Sakkinen
0 siblings, 0 replies; 2+ messages in thread
From: Jarkko Sakkinen @ 2026-06-26 16:31 UTC (permalink / raw)
To: Myeonghun Pak
Cc: Peter Huewe, Jason Gunthorpe, linux-integrity, linux-kernel,
Ijae Kim
On Fri, Jun 26, 2026 at 06:16:53PM +0900, Myeonghun Pak wrote:
> i2c_nuvoton_wait_for_stat() enables the IRQ before waiting for the
> interrupt handler to report a status change. If the wait times out, or is
> interrupted before the handler runs, the function returns without
> balancing the enable_irq() call.
>
> Disable the IRQ before leaving the failed wait path. Also preserve an
> interrupted wait's original error code instead of converting it to
> -ETIMEDOUT inside the helper.
>
> Fixes: 4c336e4b1556 ("tpm: Add support for the Nuvoton NPCT501 I2C TPM")
> Co-developed-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
> ---
> drivers/char/tpm/tpm_i2c_nuvoton.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c
> index d44903b..aa36730 100644
> --- a/drivers/char/tpm/tpm_i2c_nuvoton.c
> +++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
> @@ -182,8 +182,10 @@ static int i2c_nuvoton_wait_for_stat(struct tpm_chip *chip, u8 mask, u8 value,
> timeout);
> if (rc > 0)
> return 0;
> - /* At this point we know that the SINT pin is asserted, so we
> - * do not need to do i2c_nuvoton_check_status */
> +
> + disable_irq(priv->irq);
> + if (rc < 0)
> + return rc;
> } else {
> unsigned long ten_msec, stop;
> bool status_valid;
> --
> 2.47.1
LGTM
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
BR, Jarkko
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-26 16:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-26 9:16 [PATCH] tpm: tpm_i2c_nuvoton: disable IRQ on wait timeout Myeonghun Pak
2026-06-26 16:31 ` Jarkko Sakkinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox