Linux Integrity Measurement development
 help / color / mirror / Atom feed
From: Jim Broadus <jbroadus@gmail.com>
To: jarkko@kernel.org, linux-integrity@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: peterhuewe@gmx.de, jgg@ziepe.ca, Jim Broadus <jbroadus@gmail.com>
Subject: [PATCH v3 1/2] tpm: tpm_tis: store entire did_vid
Date: Tue, 26 May 2026 16:22:43 -0700	[thread overview]
Message-ID: <20260526232245.5409-2-jbroadus@gmail.com> (raw)
In-Reply-To: <20260526232245.5409-1-jbroadus@gmail.com>

The entire 32 bit did_vid is read from the device, but only the 16 bit
vendor id portion was stored in the tpm_tis_data structure. Storing the
entire value allows the device id to be used to handle quirks. Printing
the vid and did in the error case also helps identify problem devices.

Signed-off-by: Jim Broadus <jbroadus@gmail.com>
---
 drivers/char/tpm/tpm_tis_core.c | 22 ++++++++++++++--------
 drivers/char/tpm/tpm_tis_core.h |  2 +-
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index 21d79ad3b164..d0b87f5daa3e 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -792,9 +792,10 @@ static int probe_itpm(struct tpm_chip *chip)
 static bool tpm_tis_req_canceled(struct tpm_chip *chip, u8 status)
 {
 	struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);
+	u16 vendor_id = priv->did_vid;
 
 	if (!test_bit(TPM_TIS_DEFAULT_CANCELLATION, &priv->flags)) {
-		switch (priv->manufacturer_id) {
+		switch (vendor_id) {
 		case TPM_VID_WINBOND:
 			return ((status == TPM_STS_VALID) ||
 				(status == (TPM_STS_VALID | TPM_STS_COMMAND_READY)));
@@ -1115,7 +1116,8 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
 		      const struct tpm_tis_phy_ops *phy_ops,
 		      acpi_handle acpi_dev_handle)
 {
-	u32 vendor;
+	u16 vendor_id;
+	u16 device_id;
 	u32 intfcaps;
 	u32 intmask;
 	u32 clkrun_val;
@@ -1148,19 +1150,20 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
 
 	dev_set_drvdata(&chip->dev, priv);
 
-	rc = tpm_tis_read32(priv, TPM_DID_VID(0), &vendor);
+	rc = tpm_tis_read32(priv, TPM_DID_VID(0), &priv->did_vid);
 	if (rc < 0)
 		return rc;
 
-	priv->manufacturer_id = vendor;
+	vendor_id = priv->did_vid;
+	device_id = priv->did_vid >> 16;
 
-	if (priv->manufacturer_id == TPM_VID_ATML &&
+	if (vendor_id == TPM_VID_ATML &&
 		!(chip->flags & TPM_CHIP_FLAG_TPM2)) {
 		priv->timeout_min = TIS_TIMEOUT_MIN_ATML;
 		priv->timeout_max = TIS_TIMEOUT_MAX_ATML;
 	}
 
-	if (priv->manufacturer_id == TPM_VID_IFX)
+	if (vendor_id == TPM_VID_IFX)
 		set_bit(TPM_TIS_STATUS_VALID_RETRY, &priv->flags);
 
 	if (is_bsw()) {
@@ -1247,9 +1250,9 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
 	if (rc < 0)
 		goto out_err;
 
-	dev_info(dev, "%s TPM (device-id 0x%X, rev-id %d)\n",
+	dev_info(dev, "%s TPM (vendor-id 0x%X, device-id 0x%X, rev-id %d)\n",
 		 (chip->flags & TPM_CHIP_FLAG_TPM2) ? "2.0" : "1.2",
-		 vendor >> 16, rid);
+		 vendor_id, device_id, rid);
 
 	probe = probe_itpm(chip);
 	if (probe < 0) {
@@ -1315,6 +1318,9 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
 
 	return 0;
 out_err:
+	dev_err(dev, "TPM vid 0x%X, did 0x%X init failed with error %d\n",
+		vendor_id, device_id, rc);
+
 	if (chip->ops->clk_enable != NULL)
 		chip->ops->clk_enable(chip, false);
 
diff --git a/drivers/char/tpm/tpm_tis_core.h b/drivers/char/tpm/tpm_tis_core.h
index 6c3aa480396b..f2c77844062a 100644
--- a/drivers/char/tpm/tpm_tis_core.h
+++ b/drivers/char/tpm/tpm_tis_core.h
@@ -94,7 +94,7 @@ enum tpm_tis_flags {
 
 struct tpm_tis_data {
 	struct tpm_chip *chip;
-	u16 manufacturer_id;
+	u32 did_vid;
 	struct mutex locality_count_mutex;
 	unsigned int locality_count;
 	int locality;
-- 
2.54.0


  reply	other threads:[~2026-05-26 23:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-19 15:45 [PATCH v2] tpm: tpm_tis: Add optional delay after relinquish Jim Broadus
2026-05-26 23:22 ` [PATCH v3 0/2] tpm: tpm_tis: Fix probe of some older TPMs Jim Broadus
2026-05-26 23:22   ` Jim Broadus [this message]
2026-05-26 23:22   ` [PATCH v3 2/2] tpm: tpm_tis: Add settle time for some TPMs Jim Broadus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260526232245.5409-2-jbroadus@gmail.com \
    --to=jbroadus@gmail.com \
    --cc=jarkko@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterhuewe@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox