libwd/0156-drv-hpre-add-hpre_result_check.patch
Yang Shen ec2f993b84 libwd: backport for uadk from 2.3.31 to 2.3.36
Update some patch for uadk from mainline.
To get more information, please visit the homepage:
https://github.comp/Linaro/uadk

Signed-off-by: Yang Shen <shenyang39@huawei.com>
2022-07-28 15:32:23 +08:00

139 lines
4.1 KiB
Diff

From 06d0a1a22e611a23f91573d125dc83295a2b0256 Mon Sep 17 00:00:00 2001
From: Weili Qian <qianweili@huawei.com>
Date: Sat, 23 Jul 2022 10:48:57 +0800
Subject: [PATCH 171/183] drv/hpre: add hpre_result_check()
When process recv completed task from hardware,
driver will check BD status. The check logic for ECC/DH/RSA
is the same. Therefore, call hpre_resut_check() to check the BD
status to reduce duplicate code.
Signed-off-by: Weili Qian <qianweili@huawei.com>
---
drv/hisi_hpre.c | 75 ++++++++++++++++++++-----------------------------
1 file changed, 30 insertions(+), 45 deletions(-)
diff --git a/drv/hisi_hpre.c b/drv/hisi_hpre.c
index 8454eff..76529e8 100644
--- a/drv/hisi_hpre.c
+++ b/drv/hisi_hpre.c
@@ -531,6 +531,25 @@ static int rsa_send(handle_t ctx, void *rsa_msg)
return hisi_qm_send(h_qp, &hw_msg, 1, &send_cnt);
}
+static void hpre_result_check(struct hisi_hpre_sqe *hw_msg,
+ __u8 *result)
+{
+ *result = WD_SUCCESS;
+
+ if (hw_msg->done != HPRE_HW_TASK_DONE ||
+ hw_msg->etype || hw_msg->etype1) {
+ WD_ERR("failed to do hpre task! done=0x%x, etype=0x%x, etype1=0x%x!\n",
+ hw_msg->done, hw_msg->etype, hw_msg->etype1);
+ if (hw_msg->etype1 & HPRE_HW_SVA_ERROR)
+ WD_ERR("failed to SVA prefetch: status=%u!\n",
+ hw_msg->sva_status);
+ if (hw_msg->done == HPRE_HW_TASK_INIT)
+ *result = WD_EINVAL;
+ else
+ *result = WD_IN_EPARA;
+ }
+}
+
static int rsa_recv(handle_t ctx, void *rsa_msg)
{
handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx);
@@ -547,25 +566,13 @@ static int rsa_recv(handle_t ctx, void *rsa_msg)
if (ret)
return ret;
- if (hw_msg.done != HPRE_HW_TASK_DONE ||
- hw_msg.etype || hw_msg.etype1) {
- WD_ERR("failed to do rsa task! done=0x%x, etype=0x%x, etype1=0x%x!\n",
- hw_msg.done, hw_msg.etype, hw_msg.etype1);
- if (hw_msg.etype1 & HPRE_HW_SVA_ERROR)
- WD_ERR("failed to SVA prefetch: status=%u!\n",
- hw_msg.sva_status);
- if (hw_msg.done == HPRE_HW_TASK_INIT)
- msg->result = WD_EINVAL;
- else
- msg->result = WD_IN_EPARA;
- } else {
- msg->tag = LW_U16(hw_msg.low_tag);
+ msg->tag = LW_U16(hw_msg.low_tag);
+ hpre_result_check(&hw_msg, &msg->result);
+ if (!msg->result) {
ret = rsa_out_transfer(msg, &hw_msg);
if (ret) {
WD_ERR("failed to transfer out rsa BD!\n");
msg->result = WD_OUT_EPARA;
- } else {
- msg->result = WD_SUCCESS;
}
}
@@ -696,25 +703,13 @@ static int dh_recv(handle_t ctx, void *dh_msg)
if (ret)
return ret;
- if (hw_msg.done != HPRE_HW_TASK_DONE ||
- hw_msg.etype || hw_msg.etype1) {
- WD_ERR("failed to do dh task! done=0x%x, etype=0x%x, etype1=0x%x!\n",
- hw_msg.done, hw_msg.etype, hw_msg.etype1);
- if (hw_msg.etype1 & HPRE_HW_SVA_ERROR)
- WD_ERR("failed to SVA prefetch: status=%u!\n",
- hw_msg.sva_status);
- if (hw_msg.done == HPRE_HW_TASK_INIT)
- msg->result = WD_EINVAL;
- else
- msg->result = WD_IN_EPARA;
- } else {
- msg->tag = LW_U16(hw_msg.low_tag);
+ msg->tag = LW_U16(hw_msg.low_tag);
+ hpre_result_check(&hw_msg, &msg->result);
+ if (!msg->result) {
ret = dh_out_transfer(msg, &hw_msg);
if (ret) {
WD_ERR("failed to transfer out dh BD!\n");
msg->result = WD_OUT_EPARA;
- } else {
- msg->result = WD_SUCCESS;
}
}
@@ -2191,26 +2186,16 @@ static int ecc_sqe_parse(struct wd_ecc_msg *msg, struct hisi_hpre_sqe *hw_msg)
{
int ret;
- if (hw_msg->done != HPRE_HW_TASK_DONE ||
- hw_msg->etype || hw_msg->etype1) {
- WD_ERR("failed to do ecc task! done=0x%x, etype=0x%x, etype1=0x%x!\n",
- hw_msg->done, hw_msg->etype, hw_msg->etype1);
- if (hw_msg->etype1 & HPRE_HW_SVA_ERROR)
- WD_ERR("failed to SVA prefetch: status=%u!\n",
- hw_msg->sva_status);
-
- if (hw_msg->done == HPRE_HW_TASK_INIT)
- ret = -WD_EINVAL;
- else
- ret = -WD_IN_EPARA;
- } else {
- msg->result = WD_SUCCESS;
+ msg->tag = LW_U16(hw_msg->low_tag);
+ hpre_result_check(hw_msg, &msg->result);
+ if (!msg->result) {
ret = ecc_out_transfer(msg, hw_msg);
if (ret) {
msg->result = WD_OUT_EPARA;
WD_ERR("failed to transfer out ecc BD, ret = %d!\n", ret);
}
- msg->tag = LW_U16(hw_msg->low_tag);
+ } else {
+ ret = -msg->result;
}
return ret;
--
2.27.0