Skip to content

Commit 15d7aa4

Browse files
linosanfilippo-kunbusjarkkojs
authored andcommitted
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 <[email protected]> Tested-by: Jarkko Sakkinen <[email protected]> Reviewed-by: Jarkko Sakkinen <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]>
1 parent ed9be0e commit 15d7aa4

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
@@ -740,16 +740,10 @@ static void tpm_tis_gen_interrupt(struct tpm_chip *chip)
740740
cap_t cap;
741741
int ret;
742742

743-
ret = request_locality(chip, 0);
744-
if (ret < 0)
745-
return;
746-
747743
if (chip->flags & TPM_CHIP_FLAG_TPM2)
748744
ret = tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
749745
else
750746
ret = tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc, 0);
751-
752-
release_locality(chip, 0);
753747
}
754748

755749
/* Register the IRQ and issue a command that will cause an interrupt. If an
@@ -772,10 +766,16 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
772766
}
773767
priv->irq = irq;
774768

769+
rc = request_locality(chip, 0);
770+
if (rc < 0)
771+
return rc;
772+
775773
rc = tpm_tis_read8(priv, TPM_INT_VECTOR(priv->locality),
776774
&original_int_vec);
777-
if (rc < 0)
775+
if (rc < 0) {
776+
release_locality(chip, priv->locality);
778777
return rc;
778+
}
779779

780780
rc = tpm_tis_write8(priv, TPM_INT_VECTOR(priv->locality), irq);
781781
if (rc < 0)
@@ -809,10 +809,12 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
809809
if (!(chip->flags & TPM_CHIP_FLAG_IRQ)) {
810810
tpm_tis_write8(priv, original_int_vec,
811811
TPM_INT_VECTOR(priv->locality));
812-
return -1;
812+
rc = -1;
813813
}
814814

815-
return 0;
815+
release_locality(chip, priv->locality);
816+
817+
return rc;
816818
}
817819

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

0 commit comments

Comments
 (0)