Skip to content

Commit 21df4a8

Browse files
snitsJarkko Sakkinen
authored andcommitted
tpm_tis: reserve chip for duration of tpm_tis_core_init
Instead of repeatedly calling tpm_chip_start/tpm_chip_stop when issuing commands to the tpm during initialization, just reserve the chip after wait_startup, and release it when we are ready to call tpm_chip_register. Cc: Christian Bundy <[email protected]> Cc: Dan Williams <[email protected]> Cc: Peter Huewe <[email protected]> Cc: Jarkko Sakkinen <[email protected]> Cc: Jason Gunthorpe <[email protected]> Cc: Stefan Berger <[email protected]> Cc: [email protected] Cc: [email protected] Fixes: a3fbfae ("tpm: take TPM chip power gating out of tpm_transmit()") Fixes: 5b359c7 ("tpm_tis_core: Turn on the TPM before probing IRQ's") Suggested-by: Jarkko Sakkinen <[email protected]> Reviewed-by: Jarkko Sakkinen <[email protected]> Signed-off-by: Jerry Snitselaar <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]>
1 parent bea3741 commit 21df4a8

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

drivers/char/tpm/tpm_tis_core.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -978,13 +978,13 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
978978

979979
if (wait_startup(chip, 0) != 0) {
980980
rc = -ENODEV;
981-
goto out_err;
981+
goto err_start;
982982
}
983983

984984
/* Take control of the TPM's interrupt hardware and shut it off */
985985
rc = tpm_tis_read32(priv, TPM_INT_ENABLE(priv->locality), &intmask);
986986
if (rc < 0)
987-
goto out_err;
987+
goto err_start;
988988

989989
intmask |= TPM_INTF_CMD_READY_INT | TPM_INTF_LOCALITY_CHANGE_INT |
990990
TPM_INTF_DATA_AVAIL_INT | TPM_INTF_STS_VALID_INT;
@@ -993,21 +993,21 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
993993

994994
rc = tpm_chip_start(chip);
995995
if (rc)
996-
goto out_err;
996+
goto err_start;
997+
997998
rc = tpm2_probe(chip);
998-
tpm_chip_stop(chip);
999999
if (rc)
1000-
goto out_err;
1000+
goto err_probe;
10011001

10021002
rc = tpm_tis_read32(priv, TPM_DID_VID(0), &vendor);
10031003
if (rc < 0)
1004-
goto out_err;
1004+
goto err_probe;
10051005

10061006
priv->manufacturer_id = vendor;
10071007

10081008
rc = tpm_tis_read8(priv, TPM_RID(0), &rid);
10091009
if (rc < 0)
1010-
goto out_err;
1010+
goto err_probe;
10111011

10121012
dev_info(dev, "%s TPM (device-id 0x%X, rev-id %d)\n",
10131013
(chip->flags & TPM_CHIP_FLAG_TPM2) ? "2.0" : "1.2",
@@ -1016,13 +1016,13 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
10161016
probe = probe_itpm(chip);
10171017
if (probe < 0) {
10181018
rc = -ENODEV;
1019-
goto out_err;
1019+
goto err_probe;
10201020
}
10211021

10221022
/* Figure out the capabilities */
10231023
rc = tpm_tis_read32(priv, TPM_INTF_CAPS(priv->locality), &intfcaps);
10241024
if (rc < 0)
1025-
goto out_err;
1025+
goto err_probe;
10261026

10271027
dev_dbg(dev, "TPM interface capabilities (0x%x):\n",
10281028
intfcaps);
@@ -1056,10 +1056,9 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
10561056
if (tpm_get_timeouts(chip)) {
10571057
dev_err(dev, "Could not get TPM timeouts and durations\n");
10581058
rc = -ENODEV;
1059-
goto out_err;
1059+
goto err_probe;
10601060
}
10611061

1062-
tpm_chip_start(chip);
10631062
chip->flags |= TPM_CHIP_FLAG_IRQ;
10641063
if (irq) {
10651064
tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED,
@@ -1070,18 +1069,20 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
10701069
} else {
10711070
tpm_tis_probe_irq(chip, intmask);
10721071
}
1073-
tpm_chip_stop(chip);
10741072
}
10751073

1074+
tpm_chip_stop(chip);
1075+
10761076
rc = tpm_chip_register(chip);
10771077
if (rc)
1078-
goto out_err;
1079-
1080-
if (chip->ops->clk_enable != NULL)
1081-
chip->ops->clk_enable(chip, false);
1078+
goto err_start;
10821079

10831080
return 0;
1084-
out_err:
1081+
1082+
err_probe:
1083+
tpm_chip_stop(chip);
1084+
1085+
err_start:
10851086
if ((chip->ops != NULL) && (chip->ops->clk_enable != NULL))
10861087
chip->ops->clk_enable(chip, false);
10871088

0 commit comments

Comments
 (0)