@@ -25,60 +25,32 @@ struct tpm_svsm_priv {
u8 locality;
};
-static int tpm_svsm_send(struct tpm_chip *chip, u8 *buf, size_t len)
+static int tpm_svsm_send_recv(struct tpm_chip *chip, u8 *buf, size_t buf_len,
+ size_t cmd_len)
{
struct tpm_svsm_priv *priv = dev_get_drvdata(&chip->dev);
int ret;
ret = svsm_vtpm_fill_cmd_req((struct tpm_send_cmd_req *)priv->buffer,
- priv->locality, buf, len);
+ priv->locality, buf, cmd_len);
if (ret)
return ret;
/*
* The SVSM call uses the same buffer for the command and for the
- * response, so after this call, the buffer will contain the response
- * that can be used by .recv() op.
+ * response, so after this call, the buffer will contain the response.
*/
- return snp_svsm_vtpm_send_command(priv->buffer);
-}
-
-static int tpm_svsm_recv(struct tpm_chip *chip, u8 *buf, size_t len)
-{
- struct tpm_svsm_priv *priv = dev_get_drvdata(&chip->dev);
+ ret = snp_svsm_vtpm_send_command(priv->buffer);
+ if (ret)
+ return ret;
- /*
- * The internal buffer contains the response after we send the command
- * to SVSM.
- */
return svsm_vtpm_parse_cmd_resp((struct tpm_send_cmd_resp *)priv->buffer,
- buf, len);
-}
-
-static void tpm_svsm_cancel(struct tpm_chip *chip)
-{
- /* not supported */
-}
-
-static u8 tpm_svsm_status(struct tpm_chip *chip)
-{
- return 0;
-}
-
-static bool tpm_svsm_req_canceled(struct tpm_chip *chip, u8 status)
-{
- return false;
+ buf, buf_len);
}
static struct tpm_class_ops tpm_chip_ops = {
.flags = TPM_OPS_AUTO_STARTUP,
- .recv = tpm_svsm_recv,
- .send = tpm_svsm_send,
- .cancel = tpm_svsm_cancel,
- .status = tpm_svsm_status,
- .req_complete_mask = 0,
- .req_complete_val = 0,
- .req_canceled = tpm_svsm_req_canceled,
+ .send_recv = tpm_svsm_send_recv,
};
static int __init tpm_svsm_probe(struct platform_device *pdev)
This driver does not support interrupts, and receiving the response is synchronous with sending the command. Let's simplify the driver by implementing the new send_recv() op. Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> --- Note: this is based on "[PATCH v3 0/4] Enlightened vTPM support for SVSM on SEV-SNP" series [1]. If we will merge this series before it, we can just ignore this patch and I'll squash these changes in that series. [1] https://lore.kernel.org/linux-integrity/20250311094225.35129-1-sgarzare@redhat.com/ --- drivers/char/tpm/tpm_svsm.c | 46 ++++++++----------------------------- 1 file changed, 9 insertions(+), 37 deletions(-)