Re: [PATCH v2 1/4] tpm: Cache TPM2 start method
From: Jarkko Sakkinen
Date: Sat Nov 14 2026 - 15:55:06 EST
On Sat, Nov 14, 2026 at 07:34:31PM +0000, Siddharth Chintamaneni wrote:
> From: Jarkko Sakkinen <jarkko@xxxxxxxxxx>
>
> Both tpm_tis and tpm_crb retrieve the start method from the ACPI TPM2
> table during device probe, and tpm_crb_ffa also needs it before chip
> allocation.
>
> Cache the start method in tpm2_acpi_start_method during tpm_init() and
> export it for the leaf drivers, defaulting to ACPI_TPM2_NOT_ALLOWED when
> the table is absent or invalid.
>
> Signed-off-by: Jarkko Sakkinen <jarkko@xxxxxxxxxx>
> Co-developed-by: Siddharth Chintamaneni <sidchintamaneni@xxxxxxxxx>
> Signed-off-by: Siddharth Chintamaneni <sidchintamaneni@xxxxxxxxx>
> ---
> drivers/char/tpm/tpm-interface.c | 21 +++++++++++++++++++++
> drivers/char/tpm/tpm.h | 1 +
> 2 files changed, 22 insertions(+)
>
> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
> index e0385b16616b..7b7da79bee7c 100644
> --- a/drivers/char/tpm/tpm-interface.c
> +++ b/drivers/char/tpm/tpm-interface.c
> @@ -534,8 +534,17 @@ int tpm_get_random(struct tpm_chip *chip, u8 *out, size_t max)
> }
> EXPORT_SYMBOL_GPL(tpm_get_random);
>
> +#ifdef CONFIG_ACPI
> +u32 tpm2_acpi_start_method = ACPI_TPM2_NOT_ALLOWED;
> +EXPORT_SYMBOL_GPL(tpm2_acpi_start_method);
> +#endif
> +
> static int __init tpm_init(void)
> {
> +#ifdef CONFIG_ACPI
> + struct acpi_table_tpm2 *tbl;
> + acpi_status status;
> +#endif
> int rc;
>
> rc = class_register(&tpm_class);
> @@ -562,6 +571,18 @@ static int __init tpm_init(void)
> goto out_unreg_chrdev;
> }
>
> +#ifdef CONFIG_ACPI
> + if (!acpi_disabled) {
> + status = acpi_get_table(ACPI_SIG_TPM2, 1,
> + (struct acpi_table_header **)&tbl);
> + if (ACPI_SUCCESS(status)) {
> + if (tbl->header.length >= sizeof(*tbl))
> + tpm2_acpi_start_method = tbl->start_method;
> + acpi_put_table((struct acpi_table_header *)tbl);
I would add right after acpi_put_table:
pr_info("tpm: TPM2 ACPI start method: 0%02x\n", tpm2_acpi_start_method);
It covers all three possible conditions:
1. No TPM2: nothing gets printed.
2. Has TPM2 and start method: start method gets printed.
3. Has TPM2 but no start emthod: 0x00 gets printed.
I hate fostering klog messages as we have acquired great tracing
capabilities over the years but here I think having this is even
"sysadmin-useful".
Br, Jarkko