Commit 0c8862de authored by Jarkko Sakkinen's avatar Jarkko Sakkinen

tpm: Re-enable TPM chip boostrapping non-tpm_tis TPM drivers

TPM chip bootstrapping was removed from tpm_chip_register(), and it
was relocated to tpm_tis_core. This breaks all drivers which are not
based on tpm_tis because the chip will not get properly initialized.

Take the corrective steps:
1. Rename tpm_chip_startup() as tpm_chip_bootstrap() and make it one-shot.
2. Call tpm_chip_bootstrap() in tpm_chip_register(), which reverts the
   things  as tehy used to be.

Cc: Lino Sanfilippo <l.sanfilippo@kunbus.com>
Fixes: 548eb516 ("tpm, tpm_tis: startup chip before testing for interrupts")
Reported-by: default avatarPengfei Xu <pengfei.xu@intel.com>
Link: https://lore.kernel.org/all/ZEjqhwHWBnxcaRV5@xpf.sh.intel.com/Tested-by: default avatarPengfei Xu <pengfei.xu@intel.com>
Signed-off-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
parent 6e98b09d
......@@ -606,13 +606,19 @@ static int tpm_get_pcr_allocation(struct tpm_chip *chip)
}
/*
* tpm_chip_startup() - performs auto startup and allocates the PCRs
* tpm_chip_bootstrap() - Boostrap TPM chip after power on
* @chip: TPM chip to use.
*
* Initialize TPM chip after power on. This a one-shot function: subsequent
* calls will have no effect.
*/
int tpm_chip_startup(struct tpm_chip *chip)
int tpm_chip_bootstrap(struct tpm_chip *chip)
{
int rc;
if (chip->flags & TPM_CHIP_FLAG_BOOTSTRAPPED)
return 0;
rc = tpm_chip_start(chip);
if (rc)
return rc;
......@@ -625,9 +631,15 @@ int tpm_chip_startup(struct tpm_chip *chip)
stop:
tpm_chip_stop(chip);
/*
* Unconditionally set, as driver initialization should cease, when the
* boostrapping process fails.
*/
chip->flags |= TPM_CHIP_FLAG_BOOTSTRAPPED;
return rc;
}
EXPORT_SYMBOL_GPL(tpm_chip_startup);
EXPORT_SYMBOL_GPL(tpm_chip_bootstrap);
/*
* tpm_chip_register() - create a character device for the TPM chip
......@@ -644,6 +656,10 @@ int tpm_chip_register(struct tpm_chip *chip)
{
int rc;
rc = tpm_chip_bootstrap(chip);
if (rc)
return rc;
tpm_sysfs_add_device(chip);
tpm_bios_log_setup(chip);
......
......@@ -263,7 +263,7 @@ static inline void tpm_msleep(unsigned int delay_msec)
delay_msec * 1000);
};
int tpm_chip_startup(struct tpm_chip *chip);
int tpm_chip_bootstrap(struct tpm_chip *chip);
int tpm_chip_start(struct tpm_chip *chip);
void tpm_chip_stop(struct tpm_chip *chip);
struct tpm_chip *tpm_find_get_ops(struct tpm_chip *chip);
......
......@@ -1139,7 +1139,7 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
init_waitqueue_head(&priv->read_queue);
init_waitqueue_head(&priv->int_queue);
rc = tpm_chip_startup(chip);
rc = tpm_chip_bootstrap(chip);
if (rc)
goto out_err;
......
......@@ -274,6 +274,7 @@ enum tpm2_cc_attrs {
#define TPM_VID_ATML 0x1114
enum tpm_chip_flags {
TPM_CHIP_FLAG_BOOTSTRAPPED = BIT(0),
TPM_CHIP_FLAG_TPM2 = BIT(1),
TPM_CHIP_FLAG_IRQ = BIT(2),
TPM_CHIP_FLAG_VIRTUAL = BIT(3),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment