tpm: ibmvtpm: retry on H_CLOSED in tpm_ibmvtpm_send()
Subsystems (3)
PATCH 1/1 tpm: ibmvtpm: retry on H_CLOSED in tpm_ibmvtpm_send()
tpm_ibmvtpm_send() can fail during LPM resume with an H_CLOSED return from ibmvtpm_send_crq(). The PAPR says, 'The “partner partition suspended” transport event disables the associated CRQ such that any H_SEND_CRQ hcall() to the associated CRQ returns H_Closed until the CRQ has been explicitly enabled using the H_ENABLE_CRQ hcall.' This patch adds a check in tpm_ibmvtpm_send() for an H_CLOSED return from ibmvtpm_send_crq() and in that case calls tpm_ibmvtpm_resume() and retries the ibmvtpm_send_crq() once.
--- drivers/char/tpm/tpm_ibmvtpm.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
drivers/char/tpm/tpm_ibmvtpm.c +18 -5
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Copyright (C) 2012 IBM Corporation +* Copyright (C) 2012-2020 IBM Corporation * * Author: Ashley Lai <[email protected]> *
@@ -25,6 +25,8 @@#include "tpm.h" #include "tpm_ibmvtpm.h" +static int tpm_ibmvtpm_resume (struct device *dev); +static const char tpm_ibmvtpm_driver_name[] ="tpm_ibmvtpm" ;static const struct vio_device_id tpm_ibmvtpm_device_table[] = {
@@ -147,6 +149,7 @@ static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count) {struct ibmvtpm_dev *ibmvtpm =dev_get_drvdata (&chip->dev);int rc, sig; +bool retry = true;if (!ibmvtpm->rtce_buf) {dev_err (ibmvtpm->dev,"ibmvtpm device is not ready\n" );
@@ -179,18 +182,28 @@ static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)*/ ibmvtpm->tpm_processing_cmd = true; +again: rc =ibmvtpm_send_crq (ibmvtpm->vdev,IBMVTPM_VALID_CMD ,VTPM_TPM_COMMAND , count, ibmvtpm->rtce_dma_handle); +if (rc !=H_SUCCESS ) { +/* +* H_CLOSED can be returned after LPM resume. Call +* tpm_ibmvtpm_resume() to re-enable the CRQ then retry +* ibmvtpm_send_crq() once before failing. +*/ +if (rc ==H_CLOSED && retry) { +tpm_ibmvtpm_resume (ibmvtpm->dev); + retry = false; + goto again; + }dev_err (ibmvtpm->dev,"tpm_ibmvtpm_send failed rc=%d\n" , rc); - rc =0 ; ibmvtpm->tpm_processing_cmd = false; - }else - rc =0 ; + }spin_unlock (&ibmvtpm->rtce_lock); -return rc; +return 0 ; }static void tpm_ibmvtpm_cancel (struct tpm_chip *chip)
Signature · 1 line
2.23.0
Quoted 9 lines · George Wilson
tpm_ibmvtpm_send()can fail during LPM resume with anH_CLOSEDreturn fromibmvtpm_send_crq(). The PAPR says, 'The “partner partition suspended” transport event disables the associated CRQ such that anyH_SEND_CRQhcall()to the associated CRQ returnsH_Closeduntil the CRQ has been explicitly enabled using theH_ENABLE_CRQhcall.' This patch adds a check intpm_ibmvtpm_send()for anH_CLOSEDreturn fromibmvtpm_send_crq()and in that case callstpm_ibmvtpm_resume()and retries theibmvtpm_send_crq()once.
Quoted 3 lines
Reported-by Linh Pham <[email protected]>Reviewed-by Stefan Berger <[email protected]>Signed-off-by George Wilson <[email protected]>
What is LPM anyway?
/Jarkko
Quoted 10 lines · Jarkko Sakkinen
Quoted 9 lines · George Wilson
tpm_ibmvtpm_send()can fail during LPM resume with anH_CLOSEDreturn fromibmvtpm_send_crq(). The PAPR says, 'The “partner partition suspended” transport event disables the associated CRQ such that anyH_SEND_CRQhcall()to the associated CRQ returnsH_Closeduntil the CRQ has been explicitly enabled using theH_ENABLE_CRQhcall.' This patch adds a check intpm_ibmvtpm_send()for anH_CLOSEDreturn fromibmvtpm_send_crq()and in that case callstpm_ibmvtpm_resume()and retries theibmvtpm_send_crq()once.
Quoted 5 lines
Quoted 3 lines
Reported-by Linh Pham <[email protected]>Reviewed-by Stefan Berger <[email protected]>Signed-off-by George Wilson <[email protected]>What is LPM anyway?
It's PowerVM Live Partition Mobility.
Quoted 2 lines
/Jarkko
Signature · 3 lines
George Wilson IBM Linux Technology Center Security Development