[PATCH -next 1/4] crypto: starfive - Skip dma setup for zeroed message

From: Jia Jie Ho
Date: Mon Apr 29 2024 - 02:23:07 EST


Skip dma setup and mapping for AES driver if plaintext is empty.

Signed-off-by: Jia Jie Ho <jiajie.ho@xxxxxxxxxxxxxxxx>
---
drivers/crypto/starfive/jh7110-aes.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/crypto/starfive/jh7110-aes.c b/drivers/crypto/starfive/jh7110-aes.c
index 72b7d46150d5..9d6e2f936f03 100644
--- a/drivers/crypto/starfive/jh7110-aes.c
+++ b/drivers/crypto/starfive/jh7110-aes.c
@@ -590,12 +590,16 @@ static int starfive_aes_do_one_req(struct crypto_engine *engine, void *areq)
if (ret)
return ret;

+ if (!cryp->total_in)
+ goto finish_req;
+
starfive_aes_dma_init(cryp);

ret = starfive_aes_map_sg(cryp, rctx->in_sg, rctx->out_sg);
if (ret)
return ret;

+finish_req:
starfive_aes_finish_req(ctx);

return 0;
--
2.40.1