[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Yaut12SfSYPGcs6S@iki.fi>
Date: Sat, 4 Dec 2021 20:05:11 +0200
From: Jarkko Sakkinen <jarkko@...nel.org>
To: Rob Barnes <robbarnes@...gle.com>
Cc: Peter Huewe <peterhuewe@....de>, Jason Gunthorpe <jgg@...pe.ca>,
linux-integrity@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] char: tpm: cr50: Set TPM_FIRMWARE_POWER_MANAGED based
on device property
On Thu, Dec 02, 2021 at 08:03:40PM +0000, Rob Barnes wrote:
> Set TPM_FIRMWARE_POWER_MANAGED flag based on 'firmware-power-managed'
> ACPI DSD property. For the CR50 TPM, this flag defaults to true when
> the property is unset.
>
> When this flag is set to false, the CR50 TPM driver will always send
> a shutdown command whenever the system suspends.
>
> Signed-off-by: Rob Barnes <robbarnes@...gle.com>
> ---
> drivers/char/tpm/tpm_tis_i2c_cr50.c | 14 +++++++++++++-
> drivers/char/tpm/tpm_tis_spi_cr50.c | 14 +++++++++++++-
> 2 files changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm_tis_i2c_cr50.c b/drivers/char/tpm/tpm_tis_i2c_cr50.c
> index c89278103703..70143cc4f4e8 100644
> --- a/drivers/char/tpm/tpm_tis_i2c_cr50.c
> +++ b/drivers/char/tpm/tpm_tis_i2c_cr50.c
> @@ -628,6 +628,17 @@ static bool tpm_cr50_i2c_req_canceled(struct tpm_chip *chip, u8 status)
> return status == TPM_STS_COMMAND_READY;
> }
>
> +static bool tpm_cr50_i2c_is_firmware_power_managed(struct device *dev)
> +{
> + u8 val;
> + int ret;
empty line here.
> + /* This flag should default true when the device property is not present */
> + ret = device_property_read_u8(dev, "firmware-power-managed", &val);
> + if (ret)
> + return 1;
"return true;" and empty line here.
> + return val;
> +}
> +
> static const struct tpm_class_ops cr50_i2c = {
> .flags = TPM_OPS_AUTO_STARTUP,
> .status = &tpm_cr50_i2c_tis_status,
> @@ -686,7 +697,8 @@ static int tpm_cr50_i2c_probe(struct i2c_client *client)
>
> /* cr50 is a TPM 2.0 chip */
> chip->flags |= TPM_CHIP_FLAG_TPM2;
> - chip->flags |= TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED;
> + if (tpm_cr50_i2c_is_firmware_power_managed(dev))
> + chip->flags |= TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED;
>
> /* Default timeouts */
> chip->timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
> diff --git a/drivers/char/tpm/tpm_tis_spi_cr50.c b/drivers/char/tpm/tpm_tis_spi_cr50.c
> index dae98dbeeeac..6c40ff99d3ea 100644
> --- a/drivers/char/tpm/tpm_tis_spi_cr50.c
> +++ b/drivers/char/tpm/tpm_tis_spi_cr50.c
> @@ -185,6 +185,17 @@ static int cr50_spi_flow_control(struct tpm_tis_spi_phy *phy,
> return 0;
> }
>
> +static bool tpm_cr50_spi_is_firmware_power_managed(struct device *dev)
> +{
> + u8 val;
> + int ret;
Ditto.
> + /* This flag should default true when the device property is not present */
> + ret = device_property_read_u8(dev, "firmware-power-managed", &val);
> + if (ret)
> + return 1;
Ditto.
> + return val;
> +}
> +
> static int tpm_tis_spi_cr50_transfer(struct tpm_tis_data *data, u32 addr, u16 len,
> u8 *in, const u8 *out)
> {
> @@ -309,7 +320,8 @@ int cr50_spi_probe(struct spi_device *spi)
> cr50_print_fw_version(&phy->priv);
>
> chip = dev_get_drvdata(&spi->dev);
> - chip->flags |= TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED;
> + if (tpm_cr50_spi_is_firmware_power_managed(&spi->dev))
> + chip->flags |= TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED;
>
> return 0;
> }
> --
> 2.34.0.384.gca35af8252-goog
>
/Jarkko
Powered by blists - more mailing lists