Skip to content

Commit f5d7a01

Browse files
committed
tpm, tpm_tis: Claim locality before writing interrupt registers
JIRA: https://issues.redhat.com/browse/RHEL-72765 Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git commit 15d7aa4 Author: Lino Sanfilippo <l.sanfilippo@kunbus.com> Date: Thu Nov 24 14:55:29 2022 +0100 tpm, tpm_tis: Claim locality before writing interrupt registers In tpm_tis_probe_single_irq() interrupt registers TPM_INT_VECTOR, TPM_INT_STATUS and TPM_INT_ENABLE are modified to setup the interrupts. Currently these modifications are done without holding a locality thus they have no effect. Fix this by claiming the (default) locality before the registers are written. Since now tpm_tis_gen_interrupt() is called with the locality already claimed remove locality request and release from this function. 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: Štěpán Horáček <shoracek@redhat.com>
1 parent d62ad89 commit f5d7a01

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

drivers/char/tpm/tpm_tis_core.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -722,16 +722,10 @@ static void tpm_tis_gen_interrupt(struct tpm_chip *chip)
722722
cap_t cap;
723723
int ret;
724724

725-
ret = request_locality(chip, 0);
726-
if (ret < 0)
727-
return;
728-
729725
if (chip->flags & TPM_CHIP_FLAG_TPM2)
730726
ret = tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
731727
else
732728
ret = tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc, 0);
733-
734-
release_locality(chip, 0);
735729
}
736730

737731
/* Register the IRQ and issue a command that will cause an interrupt. If an
@@ -754,10 +748,16 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
754748
}
755749
priv->irq = irq;
756750

751+
rc = request_locality(chip, 0);
752+
if (rc < 0)
753+
return rc;
754+
757755
rc = tpm_tis_read8(priv, TPM_INT_VECTOR(priv->locality),
758756
&original_int_vec);
759-
if (rc < 0)
757+
if (rc < 0) {
758+
release_locality(chip, priv->locality);
760759
return rc;
760+
}
761761

762762
rc = tpm_tis_write8(priv, TPM_INT_VECTOR(priv->locality), irq);
763763
if (rc < 0)
@@ -791,10 +791,12 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
791791
if (!(chip->flags & TPM_CHIP_FLAG_IRQ)) {
792792
tpm_tis_write8(priv, original_int_vec,
793793
TPM_INT_VECTOR(priv->locality));
794-
return -1;
794+
rc = -1;
795795
}
796796

797-
return 0;
797+
release_locality(chip, priv->locality);
798+
799+
return rc;
798800
}
799801

800802
/* Try to find the IRQ the TPM is using. This is for legacy x86 systems that

0 commit comments

Comments
 (0)