From: lizhi <lizhi206@huawei.com> driver inclusion category: cleanup bugzilla: https://atomgit.com/openeuler/kernel/issues/10368 CVE: NA ---------------------------------------------------------------------- Remove dead code from the SEC2 BD_TYPE2 submission path. The req_list pointer array, send_head ring cursor and the sec_sqe.type2.tag write were populated on send but never read back on completion. The BD_TYPE2 completion callback sec_req_cb recovers the request via container_of on qp->msg[cq_head] and does not consume the tag or req_list, so these writes and the per-queue kcalloc(q_depth, sizeof(struct sec_req *)) allocation were pure overhead. Drop the unused fields and their write sites to save memory per queue and avoid future maintenance confusion. Signed-off-by: lizhi <lizhi206@huawei.com> Signed-off-by: Ruibin Deng <dengruibin@h-partners.com> --- drivers/crypto/hisilicon/sec2/sec.h | 2 -- drivers/crypto/hisilicon/sec2/sec_crypto.c | 17 +---------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/drivers/crypto/hisilicon/sec2/sec.h b/drivers/crypto/hisilicon/sec2/sec.h index c12a39a8a9d4..9e33dbf371ef 100644 --- a/drivers/crypto/hisilicon/sec2/sec.h +++ b/drivers/crypto/hisilicon/sec2/sec.h @@ -158,7 +158,6 @@ struct sec_cipher_ctx { /* SEC queue context which defines queue's relatives */ struct sec_qp_ctx { struct hisi_qp *qp; - struct sec_req **req_list; struct idr req_idr; struct sec_alg_res *res; struct sec_ctx *ctx; @@ -166,7 +165,6 @@ struct sec_qp_ctx { spinlock_t id_lock; struct hisi_acc_sgl_pool *c_in_pool; struct hisi_acc_sgl_pool *c_out_pool; - u16 send_head; }; enum sec_alg_type { diff --git a/drivers/crypto/hisilicon/sec2/sec_crypto.c b/drivers/crypto/hisilicon/sec2/sec_crypto.c index 2d22860c030a..cf3e76b10eeb 100644 --- a/drivers/crypto/hisilicon/sec2/sec_crypto.c +++ b/drivers/crypto/hisilicon/sec2/sec_crypto.c @@ -214,18 +214,11 @@ static int qp_send_message(struct sec_req *req) return -EBUSY; } - if (qp_ctx->ctx->type_supported == SEC_BD_TYPE2) { - req->sec_sqe.type2.tag = cpu_to_le16((u16)qp_ctx->send_head); - qp_ctx->req_list[qp_ctx->send_head] = req; - } - ret = hisi_qp_send(qp_ctx->qp, &req->sec_sqe); if (ret) { spin_unlock_bh(&qp_ctx->req_lock); return ret; } - if (qp_ctx->ctx->type_supported == SEC_BD_TYPE2) - qp_ctx->send_head = (qp_ctx->send_head + 1) % qp_ctx->qp->sq_depth; spin_unlock_bh(&qp_ctx->req_lock); @@ -574,13 +567,9 @@ static int sec_alloc_qp_ctx_resource(struct sec_ctx *ctx, struct sec_qp_ctx *qp_ struct device *dev = ctx->dev; int ret = -ENOMEM; - qp_ctx->req_list = kcalloc(q_depth, sizeof(struct sec_req *), GFP_KERNEL); - if (!qp_ctx->req_list) - return ret; - qp_ctx->res = kcalloc(q_depth, sizeof(struct sec_alg_res), GFP_KERNEL); if (!qp_ctx->res) - goto err_free_req_list; + return ret; qp_ctx->res->depth = q_depth; qp_ctx->c_in_pool = hisi_acc_create_sgl_pool(dev, q_depth, SEC_SGL_SGE_NR); @@ -607,8 +596,6 @@ static int sec_alloc_qp_ctx_resource(struct sec_ctx *ctx, struct sec_qp_ctx *qp_ hisi_acc_free_sgl_pool(dev, qp_ctx->c_in_pool); err_free_res: kfree(qp_ctx->res); -err_free_req_list: - kfree(qp_ctx->req_list); return ret; } @@ -620,7 +607,6 @@ static void sec_free_qp_ctx_resource(struct sec_ctx *ctx, struct sec_qp_ctx *qp_ hisi_acc_free_sgl_pool(dev, qp_ctx->c_out_pool); hisi_acc_free_sgl_pool(dev, qp_ctx->c_in_pool); kfree(qp_ctx->res); - kfree(qp_ctx->req_list); } static int sec_create_qp_ctx(struct sec_ctx *ctx, int qp_ctx_id) @@ -642,7 +628,6 @@ static int sec_create_qp_ctx(struct sec_ctx *ctx, int qp_ctx_id) spin_lock_init(&qp_ctx->req_lock); idr_init(&qp_ctx->req_idr); spin_lock_init(&qp_ctx->id_lock); - qp_ctx->send_head = 0; ret = sec_alloc_qp_ctx_resource(ctx, qp_ctx); if (ret) -- 2.43.0