From b2bcc88b513328491a0f02700b926678e63c944b Mon Sep 17 00:00:00 2001
From: Wenkai Lin <linwenkai6@hisilicon.com>
Date: Tue, 15 Feb 2022 11:49:50 +0800
Subject: [PATCH 57/64] uadk: fix send exception handling

when qm send message failed, uadk should return immediately
instead of enable interrupt.

Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
---
 drv/hisi_comp.c | 10 +++++++---
 drv/hisi_sec.c  | 24 ++++++++++++++++++------
 2 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/drv/hisi_comp.c b/drv/hisi_comp.c
index e0e913d..5ea5dc3 100644
--- a/drv/hisi_comp.c
+++ b/drv/hisi_comp.c
@@ -945,12 +945,16 @@ static int hisi_zip_comp_send(handle_t ctx, struct wd_comp_msg *msg, void *priv)
 		return ret;
 	}
 	ret = hisi_qm_send(h_qp, &sqe, 1, &count);
-	if (ret < 0 && ret != -WD_EBUSY)
-		WD_ERR("qm send is err(%d)!\n", ret);
+	if (ret < 0) {
+		if (ret != -WD_EBUSY)
+			WD_ERR("qm send is err(%d)!\n", ret);
+
+		return ret;
+	}
 
 	hisi_qm_enable_interrupt(ctx, msg->is_polled);
 
-	return ret;
+	return 0;
 }
 
 static int get_alg_type(__u32 type)
diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c
index 61e0698..338823b 100644
--- a/drv/hisi_sec.c
+++ b/drv/hisi_sec.c
@@ -946,11 +946,13 @@ int hisi_sec_cipher_send(handle_t ctx, struct wd_cipher_msg *msg)
 
 		if (msg->data_fmt == WD_SGL_BUF)
 			hisi_sec_put_sgl(h_qp, msg->alg_type, msg->in, msg->out);
+
+		return ret;
 	}
 
 	hisi_qm_enable_interrupt(ctx, msg->is_polled);
 
-	return ret;
+	return 0;
 }
 
 int hisi_sec_cipher_recv(handle_t ctx, struct wd_cipher_msg *recv_msg)
@@ -1147,11 +1149,13 @@ int hisi_sec_cipher_send_v3(handle_t ctx, struct wd_cipher_msg *msg)
 
 		if (msg->data_fmt == WD_SGL_BUF)
 			hisi_sec_put_sgl(h_qp, msg->alg_type, msg->in, msg->out);
+
+		return ret;
 	}
 
 	hisi_qm_enable_interrupt(ctx, msg->is_polled);
 
-	return ret;
+	return 0;
 }
 
 static void parse_cipher_bd3(struct hisi_sec_sqe3 *sqe, struct wd_cipher_msg *recv_msg)
@@ -1388,11 +1392,13 @@ int hisi_sec_digest_send(handle_t ctx, struct wd_digest_msg *msg)
 
 		if (msg->data_fmt == WD_SGL_BUF)
 			hisi_sec_put_sgl(h_qp, msg->alg_type, msg->in, msg->out);
+
+		return ret;
 	}
 
 	hisi_qm_enable_interrupt(ctx, msg->is_polled);
 
-	return ret;
+	return 0;
 }
 
 int hisi_sec_digest_recv(handle_t ctx, struct wd_digest_msg *recv_msg)
@@ -1544,11 +1550,13 @@ int hisi_sec_digest_send_v3(handle_t ctx, struct wd_digest_msg *msg)
 
 		if (msg->data_fmt == WD_SGL_BUF)
 			hisi_sec_put_sgl(h_qp, msg->alg_type, msg->in, msg->out);
+
+		return ret;
 	}
 
 	hisi_qm_enable_interrupt(ctx, msg->is_polled);
 
-	return ret;
+	return 0;
 }
 
 static void parse_digest_bd3(struct hisi_sec_sqe3 *sqe,
@@ -1887,11 +1895,13 @@ int hisi_sec_aead_send(handle_t ctx, struct wd_aead_msg *msg)
 
 		if (msg->data_fmt == WD_SGL_BUF)
 			hisi_sec_put_sgl(h_qp, msg->alg_type, msg->in, msg->out);
+
+		return ret;
 	}
 
 	hisi_qm_enable_interrupt(ctx, msg->is_polled);
 
-	return ret;
+	return 0;
 }
 
 static void parse_aead_bd2(struct hisi_sec_sqe *sqe,
@@ -2152,11 +2162,13 @@ int hisi_sec_aead_send_v3(handle_t ctx, struct wd_aead_msg *msg)
 
 		if (msg->data_fmt == WD_SGL_BUF)
 			hisi_sec_put_sgl(h_qp, msg->alg_type, msg->in, msg->out);
+
+		return ret;
 	}
 
 	hisi_qm_enable_interrupt(ctx, msg->is_polled);
 
-	return ret;
+	return 0;
 }
 
 static void parse_aead_bd3(struct hisi_sec_sqe3 *sqe,
-- 
2.25.1

