]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
crypto: qat - detect PFVF collision after ACK
authorGiovanni Cabiddu <giovanni.cabiddu@intel.com>
Tue, 28 Sep 2021 11:44:29 +0000 (12:44 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Nov 2021 10:04:05 +0000 (11:04 +0100)
[ Upstream commit 9b768e8a3909ac1ab39ed44a3933716da7761a6f ]

Detect a PFVF collision between the local and the remote function by
checking if the message on the PFVF CSR has been overwritten.
This is done after the remote function confirms that the message has
been received, by clearing the interrupt bit, or the maximum number of
attempts (ADF_IOV_MSG_ACK_MAX_RETRY) to check the CSR has been exceeded.

Fixes: ed8ccaef52fa ("crypto: qat - Add support for SRIOV")
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Co-developed-by: Marco Chiappero <marco.chiappero@intel.com>
Signed-off-by: Marco Chiappero <marco.chiappero@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/crypto/qat/qat_common/adf_pf2vf_msg.c

index efa4bffb4f601e5cddce6943285c6079fb758f52..bb479c577ce2332e517641aea1592e6095fec2cf 100644 (file)
@@ -150,6 +150,13 @@ static int __adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr)
                val = ADF_CSR_RD(pmisc_bar_addr, pf2vf_offset);
        } while ((val & int_bit) && (count++ < ADF_IOV_MSG_ACK_MAX_RETRY));
 
+       if (val != msg) {
+               dev_dbg(&GET_DEV(accel_dev),
+                       "Collision - PFVF CSR overwritten by remote function\n");
+               ret = -EIO;
+               goto out;
+       }
+
        if (val & int_bit) {
                dev_dbg(&GET_DEV(accel_dev), "ACK not received from remote\n");
                val &= ~int_bit;