crypto: qat - update timeout logic in put admin msg
Replace timeout logic in adf_put_admin_msg_sync() with existing macro readl_poll_timeout(). Signed-off-by: Wojciech Ziemba <wojciech.ziemba@intel.com> Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
e4e245ad03
commit
a79d471c65
1 changed files with 19 additions and 15 deletions
|
@ -3,7 +3,7 @@
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
#include <linux/mutex.h>
|
#include <linux/mutex.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/iopoll.h>
|
||||||
#include <linux/pci.h>
|
#include <linux/pci.h>
|
||||||
#include <linux/dma-mapping.h>
|
#include <linux/dma-mapping.h>
|
||||||
#include "adf_accel_devices.h"
|
#include "adf_accel_devices.h"
|
||||||
|
@ -17,6 +17,8 @@
|
||||||
#define ADF_DH895XCC_MAILBOX_STRIDE 0x1000
|
#define ADF_DH895XCC_MAILBOX_STRIDE 0x1000
|
||||||
#define ADF_ADMINMSG_LEN 32
|
#define ADF_ADMINMSG_LEN 32
|
||||||
#define ADF_CONST_TABLE_SIZE 1024
|
#define ADF_CONST_TABLE_SIZE 1024
|
||||||
|
#define ADF_ADMIN_POLL_DELAY_US 20
|
||||||
|
#define ADF_ADMIN_POLL_TIMEOUT_US (5 * USEC_PER_SEC)
|
||||||
|
|
||||||
static const u8 const_tab[1024] __aligned(1024) = {
|
static const u8 const_tab[1024] __aligned(1024) = {
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
@ -111,12 +113,13 @@ struct adf_admin_comms {
|
||||||
static int adf_put_admin_msg_sync(struct adf_accel_dev *accel_dev, u32 ae,
|
static int adf_put_admin_msg_sync(struct adf_accel_dev *accel_dev, u32 ae,
|
||||||
void *in, void *out)
|
void *in, void *out)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
u32 status;
|
||||||
struct adf_admin_comms *admin = accel_dev->admin;
|
struct adf_admin_comms *admin = accel_dev->admin;
|
||||||
int offset = ae * ADF_ADMINMSG_LEN * 2;
|
int offset = ae * ADF_ADMINMSG_LEN * 2;
|
||||||
void __iomem *mailbox = admin->mailbox_addr;
|
void __iomem *mailbox = admin->mailbox_addr;
|
||||||
int mb_offset = ae * ADF_DH895XCC_MAILBOX_STRIDE;
|
int mb_offset = ae * ADF_DH895XCC_MAILBOX_STRIDE;
|
||||||
struct icp_qat_fw_init_admin_req *request = in;
|
struct icp_qat_fw_init_admin_req *request = in;
|
||||||
int times, received;
|
|
||||||
|
|
||||||
mutex_lock(&admin->lock);
|
mutex_lock(&admin->lock);
|
||||||
|
|
||||||
|
@ -127,24 +130,25 @@ static int adf_put_admin_msg_sync(struct adf_accel_dev *accel_dev, u32 ae,
|
||||||
|
|
||||||
memcpy(admin->virt_addr + offset, in, ADF_ADMINMSG_LEN);
|
memcpy(admin->virt_addr + offset, in, ADF_ADMINMSG_LEN);
|
||||||
ADF_CSR_WR(mailbox, mb_offset, 1);
|
ADF_CSR_WR(mailbox, mb_offset, 1);
|
||||||
received = 0;
|
|
||||||
for (times = 0; times < 50; times++) {
|
ret = readl_poll_timeout(mailbox + mb_offset, status,
|
||||||
msleep(20);
|
status == 0, ADF_ADMIN_POLL_DELAY_US,
|
||||||
if (ADF_CSR_RD(mailbox, mb_offset) == 0) {
|
ADF_ADMIN_POLL_TIMEOUT_US);
|
||||||
received = 1;
|
if (ret < 0) {
|
||||||
break;
|
/* Response timeout */
|
||||||
}
|
|
||||||
}
|
|
||||||
if (received)
|
|
||||||
memcpy(out, admin->virt_addr + offset +
|
|
||||||
ADF_ADMINMSG_LEN, ADF_ADMINMSG_LEN);
|
|
||||||
else
|
|
||||||
dev_err(&GET_DEV(accel_dev),
|
dev_err(&GET_DEV(accel_dev),
|
||||||
"Failed to send admin msg %d to accelerator %d\n",
|
"Failed to send admin msg %d to accelerator %d\n",
|
||||||
request->cmd_id, ae);
|
request->cmd_id, ae);
|
||||||
|
} else {
|
||||||
|
/* Response received from admin message, we can now
|
||||||
|
* make response data available in "out" parameter.
|
||||||
|
*/
|
||||||
|
memcpy(out, admin->virt_addr + offset +
|
||||||
|
ADF_ADMINMSG_LEN, ADF_ADMINMSG_LEN);
|
||||||
|
}
|
||||||
|
|
||||||
mutex_unlock(&admin->lock);
|
mutex_unlock(&admin->lock);
|
||||||
return received ? 0 : -EFAULT;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int adf_send_admin(struct adf_accel_dev *accel_dev,
|
static int adf_send_admin(struct adf_accel_dev *accel_dev,
|
||||||
|
|
Loading…
Add table
Reference in a new issue