Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: qat - handle retries due to collisions in adf_iov_putmsg()

Rework __adf_iov_putmsg() to handle retries due to collisions
internally, removing the need for an external retry loop.
The functions __adf_iov_putmsg() and adf_iov_putmsg() have been merged
together maintaining the adf_iov_putmsg() name.

This will allow to use this function only for GEN2 devices, since
collision are peculiar of this generation and therefore should be
confined to the actual implementation of the transport/medium access.

Note that now adf_iov_putmsg() will retry to send a message only in case
of collisions and will now fail if an ACK is not received from the
remote function.

Signed-off-by: Marco Chiappero <marco.chiappero@intel.com>
Co-developed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Marco Chiappero and committed by
Herbert Xu
1d613312 bd59b769

+19 -33
+19 -33
drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
··· 14 14 ADF_PFVF_MSG_ACK_MAX_RETRY + \ 15 15 ADF_PFVF_MSG_COLLISION_DETECT_DELAY) 16 16 17 - static int __adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr) 17 + static int adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr) 18 18 { 19 19 struct adf_accel_pci *pci_info = &accel_dev->accel_pci_dev; 20 20 struct adf_hw_device_data *hw_data = accel_dev->hw_device; ··· 24 24 u32 local_in_use_mask, local_in_use_pattern; 25 25 u32 remote_in_use_mask, remote_in_use_pattern; 26 26 struct mutex *lock; /* lock preventing concurrent acces of CSR */ 27 + unsigned int retries = ADF_PFVF_MSG_MAX_RETRIES; 27 28 u32 int_bit; 28 - int ret = 0; 29 + int ret; 29 30 30 31 if (accel_dev->is_vf) { 31 32 pf2vf_offset = hw_data->get_pf2vf_offset(0); ··· 46 45 int_bit = ADF_PF2VF_INT; 47 46 } 48 47 48 + msg &= ~local_in_use_mask; 49 + msg |= local_in_use_pattern; 50 + 49 51 mutex_lock(lock); 52 + 53 + start: 54 + ret = 0; 50 55 51 56 /* Check if the PFVF CSR is in use by remote function */ 52 57 val = ADF_CSR_RD(pmisc_bar_addr, pf2vf_offset); 53 58 if ((val & remote_in_use_mask) == remote_in_use_pattern) { 54 59 dev_dbg(&GET_DEV(accel_dev), 55 60 "PFVF CSR in use by remote function\n"); 56 - ret = -EBUSY; 57 - goto out; 61 + goto retry; 58 62 } 59 - 60 - msg &= ~local_in_use_mask; 61 - msg |= local_in_use_pattern; 62 63 63 64 /* Attempt to get ownership of the PFVF CSR */ 64 65 ADF_CSR_WR(pmisc_bar_addr, pf2vf_offset, msg | int_bit); ··· 80 77 if (val != msg) { 81 78 dev_dbg(&GET_DEV(accel_dev), 82 79 "Collision - PFVF CSR overwritten by remote function\n"); 83 - ret = -EIO; 84 - goto out; 80 + goto retry; 85 81 } 86 82 87 83 /* Finished with the PFVF CSR; relinquish it and leave msg in CSR */ ··· 88 86 out: 89 87 mutex_unlock(lock); 90 88 return ret; 91 - } 92 89 93 - /** 94 - * adf_iov_putmsg() - send PFVF message 95 - * @accel_dev: Pointer to acceleration device. 96 - * @msg: Message to send 97 - * @vf_nr: VF number to which the message will be sent if on PF, ignored 98 - * otherwise 99 - * 100 - * Function sends a message through the PFVF channel 101 - * 102 - * Return: 0 on success, error code otherwise. 103 - */ 104 - static int adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr) 105 - { 106 - u32 count = 0; 107 - int ret; 108 - 109 - do { 110 - ret = __adf_iov_putmsg(accel_dev, msg, vf_nr); 111 - if (ret) 112 - msleep(ADF_PFVF_MSG_RETRY_DELAY); 113 - } while (ret && (count++ < ADF_PFVF_MSG_MAX_RETRIES)); 114 - 115 - return ret; 90 + retry: 91 + if (--retries) { 92 + msleep(ADF_PFVF_MSG_RETRY_DELAY); 93 + goto start; 94 + } else { 95 + ret = -EBUSY; 96 + goto out; 97 + } 116 98 } 117 99 118 100 /**