Skip to content

Commit 7bfda9c

Browse files
Eddie Jamesjarkkojs
authored andcommitted
tpm: Add flag to use default cancellation policy
The check for cancelled request depends on the VID of the chip, but some chips share VID which shouldn't share their cancellation behavior. This is the case for the Nuvoton NPCT75X, which should use the default cancellation check, not the Winbond one. To avoid changing the existing behavior, add a new flag to indicate that the chip should use the default cancellation check and set it for the I2C TPM2 TIS driver. Fixes: bbc23a0 ("tpm: Add tpm_tis_i2c backend for tpm_tis_core") Signed-off-by: Eddie James <eajames@linux.ibm.com> Tested-by: Joel Stanley <joel@jms.id.au> Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org> Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
1 parent 561d6ef commit 7bfda9c

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

drivers/char/tpm/tpm_tis_core.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -682,15 +682,19 @@ static bool tpm_tis_req_canceled(struct tpm_chip *chip, u8 status)
682682
{
683683
struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);
684684

685-
switch (priv->manufacturer_id) {
686-
case TPM_VID_WINBOND:
687-
return ((status == TPM_STS_VALID) ||
688-
(status == (TPM_STS_VALID | TPM_STS_COMMAND_READY)));
689-
case TPM_VID_STM:
690-
return (status == (TPM_STS_VALID | TPM_STS_COMMAND_READY));
691-
default:
692-
return (status == TPM_STS_COMMAND_READY);
685+
if (!test_bit(TPM_TIS_DEFAULT_CANCELLATION, &priv->flags)) {
686+
switch (priv->manufacturer_id) {
687+
case TPM_VID_WINBOND:
688+
return ((status == TPM_STS_VALID) ||
689+
(status == (TPM_STS_VALID | TPM_STS_COMMAND_READY)));
690+
case TPM_VID_STM:
691+
return (status == (TPM_STS_VALID | TPM_STS_COMMAND_READY));
692+
default:
693+
break;
694+
}
693695
}
696+
697+
return status == TPM_STS_COMMAND_READY;
694698
}
695699

696700
static irqreturn_t tis_int_handler(int dummy, void *dev_id)

drivers/char/tpm/tpm_tis_core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ enum tis_defaults {
8686
enum tpm_tis_flags {
8787
TPM_TIS_ITPM_WORKAROUND = BIT(0),
8888
TPM_TIS_INVALID_STATUS = BIT(1),
89+
TPM_TIS_DEFAULT_CANCELLATION = BIT(2),
8990
};
9091

9192
struct tpm_tis_data {

drivers/char/tpm/tpm_tis_i2c.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ static int tpm_tis_i2c_probe(struct i2c_client *dev,
329329
if (!phy->io_buf)
330330
return -ENOMEM;
331331

332+
set_bit(TPM_TIS_DEFAULT_CANCELLATION, &phy->priv.flags);
332333
phy->i2c_client = dev;
333334

334335
/* must precede all communication with the tpm */

0 commit comments

Comments
 (0)