tpm, tpm_tis: Do not skip reset of original interrupt vector
[ Upstream commit ed9be0e6c892a783800d77a41ca4c7255c6af8c5 ]
If in tpm_tis_probe_irq_single() an error occurs after the original
interrupt vector has been read, restore the interrupts before the error is
returned.
Since the caller does not check the error value, return -1 in any case that
the TPM_CHIP_FLAG_IRQ flag is not set. Since the return value of function
tpm_tis_gen_interrupt() is not longer used, make it a void function.
Fixes: 1107d065fd
("tpm_tis: Introduce intermediate layer for TPM access")
Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com>
Tested-by: Jarkko Sakkinen <jarkko@kernel.org>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
784c206c66
commit
12839c326a
@ -732,7 +732,7 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id)
|
|||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tpm_tis_gen_interrupt(struct tpm_chip *chip)
|
static void tpm_tis_gen_interrupt(struct tpm_chip *chip)
|
||||||
{
|
{
|
||||||
const char *desc = "attempting to generate an interrupt";
|
const char *desc = "attempting to generate an interrupt";
|
||||||
u32 cap2;
|
u32 cap2;
|
||||||
@ -741,7 +741,7 @@ static int tpm_tis_gen_interrupt(struct tpm_chip *chip)
|
|||||||
|
|
||||||
ret = request_locality(chip, 0);
|
ret = request_locality(chip, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return;
|
||||||
|
|
||||||
if (chip->flags & TPM_CHIP_FLAG_TPM2)
|
if (chip->flags & TPM_CHIP_FLAG_TPM2)
|
||||||
ret = tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
|
ret = tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
|
||||||
@ -749,8 +749,6 @@ static int tpm_tis_gen_interrupt(struct tpm_chip *chip)
|
|||||||
ret = tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc, 0);
|
ret = tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc, 0);
|
||||||
|
|
||||||
release_locality(chip, 0);
|
release_locality(chip, 0);
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register the IRQ and issue a command that will cause an interrupt. If an
|
/* Register the IRQ and issue a command that will cause an interrupt. If an
|
||||||
@ -780,42 +778,37 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
|
|||||||
|
|
||||||
rc = tpm_tis_write8(priv, TPM_INT_VECTOR(priv->locality), irq);
|
rc = tpm_tis_write8(priv, TPM_INT_VECTOR(priv->locality), irq);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return rc;
|
goto restore_irqs;
|
||||||
|
|
||||||
rc = tpm_tis_read32(priv, TPM_INT_STATUS(priv->locality), &int_status);
|
rc = tpm_tis_read32(priv, TPM_INT_STATUS(priv->locality), &int_status);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return rc;
|
goto restore_irqs;
|
||||||
|
|
||||||
/* Clear all existing */
|
/* Clear all existing */
|
||||||
rc = tpm_tis_write32(priv, TPM_INT_STATUS(priv->locality), int_status);
|
rc = tpm_tis_write32(priv, TPM_INT_STATUS(priv->locality), int_status);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return rc;
|
goto restore_irqs;
|
||||||
|
|
||||||
/* Turn on */
|
/* Turn on */
|
||||||
rc = tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality),
|
rc = tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality),
|
||||||
intmask | TPM_GLOBAL_INT_ENABLE);
|
intmask | TPM_GLOBAL_INT_ENABLE);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return rc;
|
goto restore_irqs;
|
||||||
|
|
||||||
priv->irq_tested = false;
|
priv->irq_tested = false;
|
||||||
|
|
||||||
/* Generate an interrupt by having the core call through to
|
/* Generate an interrupt by having the core call through to
|
||||||
* tpm_tis_send
|
* tpm_tis_send
|
||||||
*/
|
*/
|
||||||
rc = tpm_tis_gen_interrupt(chip);
|
tpm_tis_gen_interrupt(chip);
|
||||||
if (rc < 0)
|
|
||||||
return rc;
|
|
||||||
|
|
||||||
|
restore_irqs:
|
||||||
/* tpm_tis_send will either confirm the interrupt is working or it
|
/* tpm_tis_send will either confirm the interrupt is working or it
|
||||||
* will call disable_irq which undoes all of the above.
|
* will call disable_irq which undoes all of the above.
|
||||||
*/
|
*/
|
||||||
if (!(chip->flags & TPM_CHIP_FLAG_IRQ)) {
|
if (!(chip->flags & TPM_CHIP_FLAG_IRQ)) {
|
||||||
rc = tpm_tis_write8(priv, original_int_vec,
|
tpm_tis_write8(priv, original_int_vec,
|
||||||
TPM_INT_VECTOR(priv->locality));
|
TPM_INT_VECTOR(priv->locality));
|
||||||
if (rc < 0)
|
return -1;
|
||||||
return rc;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user