Skip to content

Commit dbfdaeb

Browse files
stuyod01jarkkojs
authored andcommitted
tpm_crb: Add idle support for the Arm FF-A start method
According to the CRB over FF-A specification [1], a TPM that implements the ABI must comply with the TCG PTP specification. This requires support for the Idle and Ready states. This patch implements CRB control area requests for goIdle and cmdReady on FF-A based TPMs. The FF-A message used to notify the TPM of CRB updates includes a locality parameter, which provides a hint to the TPM about which locality modified the CRB. This patch adds a locality parameter to __crb_go_idle() and __crb_cmd_ready() to support this. [1] https://developer.arm.com/documentation/den0138/latest/ Signed-off-by: Stuart Yoder <[email protected]> Reviewed-by: Jarkko Sakkinen <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]>
1 parent f406055 commit dbfdaeb

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

drivers/char/tpm/tpm_crb.c

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ static inline bool tpm_crb_has_idle(u32 start_method)
133133
{
134134
return !(start_method == ACPI_TPM2_START_METHOD ||
135135
start_method == ACPI_TPM2_COMMAND_BUFFER_WITH_START_METHOD ||
136-
start_method == ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC ||
137-
start_method == ACPI_TPM2_CRB_WITH_ARM_FFA);
136+
start_method == ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC);
138137
}
139138

140139
static bool crb_wait_for_reg_32(u32 __iomem *reg, u32 mask, u32 value,
@@ -191,7 +190,7 @@ static int crb_try_pluton_doorbell(struct crb_priv *priv, bool wait_for_complete
191190
*
192191
* Return: 0 always
193192
*/
194-
static int __crb_go_idle(struct device *dev, struct crb_priv *priv)
193+
static int __crb_go_idle(struct device *dev, struct crb_priv *priv, int loc)
195194
{
196195
int rc;
197196

@@ -200,6 +199,12 @@ static int __crb_go_idle(struct device *dev, struct crb_priv *priv)
200199

201200
iowrite32(CRB_CTRL_REQ_GO_IDLE, &priv->regs_t->ctrl_req);
202201

202+
if (priv->sm == ACPI_TPM2_CRB_WITH_ARM_FFA) {
203+
rc = tpm_crb_ffa_start(CRB_FFA_START_TYPE_COMMAND, loc);
204+
if (rc)
205+
return rc;
206+
}
207+
203208
rc = crb_try_pluton_doorbell(priv, true);
204209
if (rc)
205210
return rc;
@@ -220,7 +225,7 @@ static int crb_go_idle(struct tpm_chip *chip)
220225
struct device *dev = &chip->dev;
221226
struct crb_priv *priv = dev_get_drvdata(dev);
222227

223-
return __crb_go_idle(dev, priv);
228+
return __crb_go_idle(dev, priv, chip->locality);
224229
}
225230

226231
/**
@@ -238,7 +243,7 @@ static int crb_go_idle(struct tpm_chip *chip)
238243
*
239244
* Return: 0 on success -ETIME on timeout;
240245
*/
241-
static int __crb_cmd_ready(struct device *dev, struct crb_priv *priv)
246+
static int __crb_cmd_ready(struct device *dev, struct crb_priv *priv, int loc)
242247
{
243248
int rc;
244249

@@ -247,6 +252,12 @@ static int __crb_cmd_ready(struct device *dev, struct crb_priv *priv)
247252

248253
iowrite32(CRB_CTRL_REQ_CMD_READY, &priv->regs_t->ctrl_req);
249254

255+
if (priv->sm == ACPI_TPM2_CRB_WITH_ARM_FFA) {
256+
rc = tpm_crb_ffa_start(CRB_FFA_START_TYPE_COMMAND, loc);
257+
if (rc)
258+
return rc;
259+
}
260+
250261
rc = crb_try_pluton_doorbell(priv, true);
251262
if (rc)
252263
return rc;
@@ -267,7 +278,7 @@ static int crb_cmd_ready(struct tpm_chip *chip)
267278
struct device *dev = &chip->dev;
268279
struct crb_priv *priv = dev_get_drvdata(dev);
269280

270-
return __crb_cmd_ready(dev, priv);
281+
return __crb_cmd_ready(dev, priv, chip->locality);
271282
}
272283

273284
static int __crb_request_locality(struct device *dev,
@@ -444,7 +455,7 @@ static int crb_send(struct tpm_chip *chip, u8 *buf, size_t bufsiz, size_t len)
444455

445456
/* Seems to be necessary for every command */
446457
if (priv->sm == ACPI_TPM2_COMMAND_BUFFER_WITH_PLUTON)
447-
__crb_cmd_ready(&chip->dev, priv);
458+
__crb_cmd_ready(&chip->dev, priv, chip->locality);
448459

449460
memcpy_toio(priv->cmd, buf, len);
450461

@@ -672,7 +683,7 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv,
672683
* PTT HW bug w/a: wake up the device to access
673684
* possibly not retained registers.
674685
*/
675-
ret = __crb_cmd_ready(dev, priv);
686+
ret = __crb_cmd_ready(dev, priv, 0);
676687
if (ret)
677688
goto out_relinquish_locality;
678689

@@ -744,7 +755,7 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv,
744755
if (!ret)
745756
priv->cmd_size = cmd_size;
746757

747-
__crb_go_idle(dev, priv);
758+
__crb_go_idle(dev, priv, 0);
748759

749760
out_relinquish_locality:
750761

0 commit comments

Comments
 (0)