Skip to contentSkip to conversation

tpm: cr50: Support opening the TPM multiple times

PATCH In review Simon Glass 2 participants 3 messages Apr 1, 2025 – Apr 2, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tpm: cr50: Support opening the TPM multiple times

The tpm_auto_start() function is used in tests and assumes that it can open the TPM even if it is already open and a locality claimed. The cr50 driver does not use the common TPM2 TIS code so lacks a check for the is_open field of struct tpm_chip and in fact it doesn't use that struct.

Add an equivalent check to cr50_i2c_open().

This fixes tpm_auto_start() on coral.

---

 drivers/tpm/cr50_i2c.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/tpm/cr50_i2c.c +4 -0
index 08ec179346e..5b2d5ccb146 100644
@@ -737,9 +737,13 @@ static int cr50_i2c_report_state(struct udevice *dev, char *str, int str_max)
 
 static int cr50_i2c_open(struct udevice *dev)
 {
+	struct cr50_priv *priv = dev_get_priv(dev);
 	char buf[80];
 	int ret;
 
+	if (priv->locality != -1)
+		return -EBUSY;
+
 	ret = process_reset(dev);
 	if (ret)
 		return log_msg_ret("reset", ret);
Signature · 4 lines
2.43.0

base-commit: e0695b08a71e167bf5ce83ae25acfdebca554b8d
branch: tpm
Reviewed-by on v1 1/1
#1 lore raw

Hi Simon,

Quoted 9 lines · Simon Glass

The tpm_auto_start() function is used in tests and assumes that it can open the TPM even if it is already open and a locality claimed. The cr50 driver does not use the common TPM2 TIS code so lacks a check for the is_open field of struct tpm_chip and in fact it doesn't use that struct.

Add an equivalent check to cr50_i2c_open().

This fixes tpm_auto_start() on coral.

Mind if I change this on the commit. it doesn't fix tpm_auto_start() it fixes *all* init on that TPM because tpm init && tpminit hangs as well

Other than that

Quoted 30 lines

---

 drivers/tpm/cr50_i2c.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/tpm/cr50_i2c.c +4 -1
index 08ec179346e..5b2d5ccb146 100644
@@ -737,9 +737,13 @@ static int cr50_i2c_report_state(struct udevice *dev, char *str, int str_max)
 
 static int cr50_i2c_open(struct udevice *dev)
 {
+       struct cr50_priv *priv = dev_get_priv(dev);
        char buf[80];
        int ret;
 
+       if (priv->locality != -1)
+               return -EBUSY;
+
        ret = process_reset(dev);
        if (ret)
                return log_msg_ret("reset", ret);
--

2.43.0

base-commit: e0695b08a71e167bf5ce83ae25acfdebca554b8d
branch: tpm

#2 lore raw

HI Ilias,

Quoted 14 lines · Ilias Apalodimas

Hi Simon,

Quoted 9 lines · Simon Glass

The tpm_auto_start() function is used in tests and assumes that it can open the TPM even if it is already open and a locality claimed. The cr50 driver does not use the common TPM2 TIS code so lacks a check for the is_open field of struct tpm_chip and in fact it doesn't use that struct.

Add an equivalent check to cr50_i2c_open().

This fixes tpm_auto_start() on coral.

Quoted 7 lines

Mind if I change this on the commit. it doesn't fix tpm_auto_start() it fixes *all* init on that TPM because tpm init && tpminit hangs as well

Other than that

OK thanks, yes please go ahead.

Quoted 29 lines
Quoted 29 lines

---

 drivers/tpm/cr50_i2c.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/tpm/cr50_i2c.c +4 -1
index 08ec179346e..5b2d5ccb146 100644
@@ -737,9 +737,13 @@ static int cr50_i2c_report_state(struct udevice *dev, char *str, int str_max)
 
 static int cr50_i2c_open(struct udevice *dev)
 {
+       struct cr50_priv *priv = dev_get_priv(dev);
        char buf[80];
        int ret;
 
+       if (priv->locality != -1)
+               return -EBUSY;
+
        ret = process_reset(dev);
        if (ret)
                return log_msg_ret("reset", ret);
--

2.43.0

Quoted 2 lines
Quoted 2 lines

base-commit: e0695b08a71e167bf5ce83ae25acfdebca554b8d
branch: tpm

Regards,
Simon