Re: [PATCH v2 4/4] tpm: tpm_crb: Use cached tpm2_acpi_start_method
From: Jarkko Sakkinen
Date: Sat Nov 14 2026 - 16:11:42 EST
On Sat, Nov 14, 2026 at 07:34:34PM +0000, Siddharth Chintamaneni wrote:
> Check the cached tpm2_acpi_start_method value at the start of
> crb_acpi_probe() before mapping the ACPI TPM2 table for CRB-specific
> parameters. This avoids mapping the table when it is absent or when the
> device uses ACPI_TPM2_MEMORY_MAPPED and belongs to tpm_tis.
>
> Signed-off-by: Siddharth Chintamaneni <sidchintamaneni@xxxxxxxxx>
> ---
> drivers/char/tpm/tpm_crb.c | 19 ++++++++++++-------
> 1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c
> index 4749a9183726..c1c2b72459a2 100644
> --- a/drivers/char/tpm/tpm_crb.c
> +++ b/drivers/char/tpm/tpm_crb.c
> @@ -945,18 +945,23 @@ static int crb_acpi_probe(struct platform_device *pdev)
> if (!device)
> return -ENODEV;
>
> - status = acpi_get_table(ACPI_SIG_TPM2, 1,
> - (struct acpi_table_header **) &buf);
> - if (ACPI_FAILURE(status) || buf->header.length < sizeof(*buf)) {
> + sm = tpm2_acpi_start_method;
sm and also priv->sm should be removed
The global should be accessed across the board when querying start
method. It should be the single source for it post-tpm_init.
> + if (sm == ACPI_TPM2_NOT_ALLOWED) {
> dev_err(dev, FW_BUG "failed to get TPM2 ACPI table\n");
Drop this message.
> return -EINVAL;
-ENODEV
> }
>
> /* Should the FIFO driver handle this? */
> - sm = buf->start_method;
> - if (sm == ACPI_TPM2_MEMORY_MAPPED) {
> - rc = -ENODEV;
> - goto out;
> + if (sm == ACPI_TPM2_MEMORY_MAPPED)
> + return -ENODEV;
> +
> + status = acpi_get_table(ACPI_SIG_TPM2, 1,
> + (struct acpi_table_header **)&buf);
> + if (ACPI_FAILURE(status) || buf->header.length < sizeof(*buf)) {
> + dev_err(dev, FW_BUG "failed to get TPM2 ACPI table\n");
Drop this message.
> + if (ACPI_SUCCESS(status))
> + acpi_put_table((struct acpi_table_header *)buf);
> + return -EINVAL;
-ENODEV
> }
>
> priv = devm_kzalloc_obj(dev, struct crb_priv);
> --
> 2.45.4
>
Br, Jarkko