[PATCH v2 3/4] tpm: tpm_tis: Use cached tpm2_acpi_start_method

Jarkko Sakkinen jarkko at kernel.org
Sat Nov 14 13:14:50 PST 2026


On Sat, Nov 14, 2026 at 07:34:33PM +0000, Siddharth Chintamaneni wrote:
> Use the cached tpm2_acpi_start_method value in check_acpi_tpm2() instead
> of mapping and unmapping the ACPI TPM2 table again during probe.
> 
> Signed-off-by: Siddharth Chintamaneni <sidchintamaneni at gmail.com>
> ---
>  drivers/char/tpm/tpm_tis.c | 18 +++++++-----------
>  1 file changed, 7 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
> index 6f8344894ea5..a6fb6f889e7d 100644
> --- a/drivers/char/tpm/tpm_tis.c
> +++ b/drivers/char/tpm/tpm_tis.c
> @@ -138,28 +138,24 @@ MODULE_DEVICE_TABLE(acpi, tpm_acpi_tbl);
>  static int check_acpi_tpm2(struct device *dev)



>  {
>  	const struct acpi_device_id *aid = acpi_match_device(tpm_acpi_tbl, dev);
> -	struct acpi_table_tpm2 *tbl;
> -	acpi_status st;
> -	int ret = 0;
>  
>  	if (!aid || aid->driver_data != DEVICE_IS_TPM2)
>  		return 0;
>  
> -	/* If the ACPI TPM2 signature is matched then a global ACPI_SIG_TPM2
> -	 * table is mandatory
> +	/*
> +	 * If the ACPI TPM2 signature is matched then a global ACPI_SIG_TPM2
> +	 * table is mandatory.
>  	 */

Delete this comment entirely. It has a low value.

> -	st = acpi_get_table(ACPI_SIG_TPM2, 1, (struct acpi_table_header **)&tbl);
> -	if (ACPI_FAILURE(st) || tbl->header.length < sizeof(*tbl)) {
> +	if (tpm2_acpi_start_method == ACPI_TPM2_NOT_ALLOWED) {
>  		dev_err(dev, FW_BUG "failed to get TPM2 ACPI table\n");

Delete dev_err()

>  		return -EINVAL;

-ENODEV

>  	}
>  
>  	/* The tpm2_crb driver handles this device */
> -	if (tbl->start_method != ACPI_TPM2_MEMORY_MAPPED)
> -		ret = -ENODEV;
> +	if (tpm2_acpi_start_method != ACPI_TPM2_MEMORY_MAPPED)
> +		return -ENODEV;
>  
> -	acpi_put_table((struct acpi_table_header *)tbl);
> -	return ret;
> +	return 0;
>  }
>  #else
>  static int check_acpi_tpm2(struct device *dev)
> -- 
> 2.45.4
> 


Finally after those suggestions this collapses into almost nothing i.e.,
please remove check_acpi_tpm2 entirely and open-code to the two call
sites.

Br, Jarkko



More information about the linux-arm-kernel mailing list