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 - pass the PF2VF responses back to the callers

Currently, any PF response to a VF request is fully parsed during the
interrupt handling. This way the individual response values are stored
into the accel_dev structure, preventing the caller to access and decode
the full response message itself.

Change this behavior, by letting the API return back the entire message
to the caller, in order to:
- keep correlated code together, that is, the (building of the)
request and the (decoding of the) response;
- avoid polluting the accel_dev data structure with unnecessary and at
times temporary values; only the entire message is stored in a
temporary buffer.

Signed-off-by: Marco Chiappero <marco.chiappero@intel.com>
Reviewed-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
25110fd2 1d4fde6c

+33 -26
+1 -1
drivers/crypto/qat/qat_c3xxxvf/adf_drv.c
··· 171 171 } 172 172 pci_set_master(pdev); 173 173 /* Completion for VF2PF request/response message exchange */ 174 - init_completion(&accel_dev->vf.iov_msg_completion); 174 + init_completion(&accel_dev->vf.msg_received); 175 175 176 176 ret = qat_crypto_dev_config(accel_dev); 177 177 if (ret)
+1 -1
drivers/crypto/qat/qat_c62xvf/adf_drv.c
··· 171 171 } 172 172 pci_set_master(pdev); 173 173 /* Completion for VF2PF request/response message exchange */ 174 - init_completion(&accel_dev->vf.iov_msg_completion); 174 + init_completion(&accel_dev->vf.msg_received); 175 175 176 176 ret = qat_crypto_dev_config(accel_dev); 177 177 if (ret)
+2 -2
drivers/crypto/qat/qat_common/adf_accel_devices.h
··· 271 271 char irq_name[ADF_MAX_MSIX_VECTOR_NAME]; 272 272 struct tasklet_struct pf2vf_bh_tasklet; 273 273 struct mutex vf2pf_lock; /* protect CSR access */ 274 - struct completion iov_msg_completion; 275 - u8 compatible; 274 + struct completion msg_received; 275 + u32 response; /* temp field holding pf2vf response */ 276 276 u8 pf_version; 277 277 } vf; 278 278 };
+15 -8
drivers/crypto/qat/qat_common/adf_pfvf_vf_msg.c
··· 52 52 int adf_vf2pf_request_version(struct adf_accel_dev *accel_dev) 53 53 { 54 54 struct adf_hw_device_data *hw_data = accel_dev->hw_device; 55 + u8 pf_version; 55 56 u32 msg = 0; 57 + int compat; 58 + u32 resp; 56 59 int ret; 57 60 58 61 msg = ADF_VF2PF_MSGORIGIN_SYSTEM; ··· 63 60 msg |= ADF_PFVF_COMPAT_THIS_VERSION << ADF_VF2PF_COMPAT_VER_REQ_SHIFT; 64 61 BUILD_BUG_ON(ADF_PFVF_COMPAT_THIS_VERSION > 255); 65 62 66 - ret = adf_send_vf2pf_req(accel_dev, msg); 63 + ret = adf_send_vf2pf_req(accel_dev, msg, &resp); 67 64 if (ret) { 68 65 dev_err(&GET_DEV(accel_dev), 69 66 "Failed to send Compatibility Version Request.\n"); 70 67 return ret; 71 68 } 72 69 70 + pf_version = (resp & ADF_PF2VF_VERSION_RESP_VERS_MASK) 71 + >> ADF_PF2VF_VERSION_RESP_VERS_SHIFT; 72 + compat = (resp & ADF_PF2VF_VERSION_RESP_RESULT_MASK) 73 + >> ADF_PF2VF_VERSION_RESP_RESULT_SHIFT; 74 + 73 75 /* Response from PF received, check compatibility */ 74 - switch (accel_dev->vf.compatible) { 76 + switch (compat) { 75 77 case ADF_PF2VF_VF_COMPATIBLE: 76 78 break; 77 79 case ADF_PF2VF_VF_COMPAT_UNKNOWN: 78 80 /* VF is newer than PF and decides whether it is compatible */ 79 - if (accel_dev->vf.pf_version >= hw_data->min_iov_compat_ver) { 80 - accel_dev->vf.compatible = ADF_PF2VF_VF_COMPATIBLE; 81 + if (pf_version >= hw_data->min_iov_compat_ver) 81 82 break; 82 - } 83 83 fallthrough; 84 84 case ADF_PF2VF_VF_INCOMPATIBLE: 85 85 dev_err(&GET_DEV(accel_dev), 86 86 "PF (vers %d) and VF (vers %d) are not compatible\n", 87 - accel_dev->vf.pf_version, 88 - ADF_PFVF_COMPAT_THIS_VERSION); 87 + pf_version, ADF_PFVF_COMPAT_THIS_VERSION); 89 88 return -EINVAL; 90 89 default: 91 90 dev_err(&GET_DEV(accel_dev), 92 91 "Invalid response from PF; assume not compatible\n"); 93 92 return -EINVAL; 94 93 } 95 - return ret; 94 + 95 + accel_dev->vf.pf_version = pf_version; 96 + return 0; 96 97 }
+12 -12
drivers/crypto/qat/qat_common/adf_pfvf_vf_proto.c
··· 47 47 * adf_send_vf2pf_req() - send VF2PF request message 48 48 * @accel_dev: Pointer to acceleration device. 49 49 * @msg: Request message to send 50 + * @resp: Returned PF response 50 51 * 51 52 * This function sends a message that requires a response from the VF to the PF 52 53 * and waits for a reply. 53 54 * 54 55 * Return: 0 on success, error code otherwise. 55 56 */ 56 - int adf_send_vf2pf_req(struct adf_accel_dev *accel_dev, u32 msg) 57 + int adf_send_vf2pf_req(struct adf_accel_dev *accel_dev, u32 msg, u32 *resp) 57 58 { 58 59 unsigned long timeout = msecs_to_jiffies(ADF_PFVF_MSG_RESP_TIMEOUT); 59 60 int ret; 60 61 61 - reinit_completion(&accel_dev->vf.iov_msg_completion); 62 + reinit_completion(&accel_dev->vf.msg_received); 62 63 63 64 /* Send request from VF to PF */ 64 65 ret = adf_send_vf2pf_msg(accel_dev, msg); ··· 70 69 } 71 70 72 71 /* Wait for response */ 73 - if (!wait_for_completion_timeout(&accel_dev->vf.iov_msg_completion, 72 + if (!wait_for_completion_timeout(&accel_dev->vf.msg_received, 74 73 timeout)) { 75 74 dev_err(&GET_DEV(accel_dev), 76 75 "PFVF request/response message timeout expired\n"); 77 76 return -EIO; 78 77 } 78 + 79 + if (likely(resp)) 80 + *resp = accel_dev->vf.response; 81 + 82 + /* Once copied, set to an invalid value */ 83 + accel_dev->vf.response = 0; 79 84 80 85 return 0; 81 86 } ··· 96 89 adf_pf2vf_handle_pf_restarting(accel_dev); 97 90 return false; 98 91 case ADF_PF2VF_MSGTYPE_VERSION_RESP: 99 - dev_dbg(&GET_DEV(accel_dev), 100 - "Version resp received from PF 0x%x\n", msg); 101 - accel_dev->vf.pf_version = 102 - (msg & ADF_PF2VF_VERSION_RESP_VERS_MASK) >> 103 - ADF_PF2VF_VERSION_RESP_VERS_SHIFT; 104 - accel_dev->vf.compatible = 105 - (msg & ADF_PF2VF_VERSION_RESP_RESULT_MASK) >> 106 - ADF_PF2VF_VERSION_RESP_RESULT_SHIFT; 107 - complete(&accel_dev->vf.iov_msg_completion); 92 + accel_dev->vf.response = msg; 93 + complete(&accel_dev->vf.msg_received); 108 94 return true; 109 95 default: 110 96 dev_err(&GET_DEV(accel_dev),
+1 -1
drivers/crypto/qat/qat_common/adf_pfvf_vf_proto.h
··· 7 7 #include "adf_accel_devices.h" 8 8 9 9 int adf_send_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 msg); 10 - int adf_send_vf2pf_req(struct adf_accel_dev *accel_dev, u32 msg); 10 + int adf_send_vf2pf_req(struct adf_accel_dev *accel_dev, u32 msg, u32 *resp); 11 11 12 12 int adf_enable_vf2pf_comms(struct adf_accel_dev *accel_dev); 13 13
+1 -1
drivers/crypto/qat/qat_dh895xccvf/adf_drv.c
··· 171 171 } 172 172 pci_set_master(pdev); 173 173 /* Completion for VF2PF request/response message exchange */ 174 - init_completion(&accel_dev->vf.iov_msg_completion); 174 + init_completion(&accel_dev->vf.msg_received); 175 175 176 176 ret = qat_crypto_dev_config(accel_dev); 177 177 if (ret)