Commit 283a5f55 authored by Chenghai Huang's avatar Chenghai Huang Committed by 白凤
Browse files

crypto: hisilicon/debugfs - Resolve the problem of applying for redundant space in sq dump

maillist inclusion
category: cleanup
bugzilla: https://gitee.com/openeuler/kernel/issues/I9GMIW
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev.git/commit/?id=745a11899a8c



----------------------------------------------------------------------

When dumping SQ, only the corresponding ID's SQE needs to be
dumped, and there is no need to apply for the entire SQE
memory. This is because excessive dump operations can lead to
memory resource waste.

Therefor apply for the space corresponding to sqe_id separately
to avoid space waste.

Signed-off-by: default avatarChenghai Huang <huangchenghai2@huawei.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarJangShui Yang <yangjiangshui@h-partners.com>
Signed-off-by: default avatarXiaoFeng Ma <maxiaofeng14@h-partners.com>
parent 573a5282
Loading
Loading
Loading
Loading
+5 −6
Original line number Original line Diff line number Diff line
@@ -311,7 +311,7 @@ static int q_dump_param_parse(struct hisi_qm *qm, char *s,
static int qm_sq_dump(struct hisi_qm *qm, char *s, char *name)
static int qm_sq_dump(struct hisi_qm *qm, char *s, char *name)
{
{
	u16 sq_depth = qm->qp_array->cq_depth;
	u16 sq_depth = qm->qp_array->cq_depth;
	void *sqe, *sqe_curr;
	void *sqe;
	struct hisi_qp *qp;
	struct hisi_qp *qp;
	u32 qp_id, sqe_id;
	u32 qp_id, sqe_id;
	int ret;
	int ret;
@@ -320,17 +320,16 @@ static int qm_sq_dump(struct hisi_qm *qm, char *s, char *name)
	if (ret)
	if (ret)
		return ret;
		return ret;


	sqe = kzalloc(qm->sqe_size * sq_depth, GFP_KERNEL);
	sqe = kzalloc(qm->sqe_size, GFP_KERNEL);
	if (!sqe)
	if (!sqe)
		return -ENOMEM;
		return -ENOMEM;


	qp = &qm->qp_array[qp_id];
	qp = &qm->qp_array[qp_id];
	memcpy(sqe, qp->sqe, qm->sqe_size * sq_depth);
	memcpy(sqe, qp->sqe + sqe_id * qm->sqe_size, qm->sqe_size);
	sqe_curr = sqe + (u32)(sqe_id * qm->sqe_size);
	memset(sqe + qm->debug.sqe_mask_offset, QM_SQE_ADDR_MASK,
	memset(sqe_curr + qm->debug.sqe_mask_offset, QM_SQE_ADDR_MASK,
	       qm->debug.sqe_mask_len);
	       qm->debug.sqe_mask_len);


	dump_show(qm, sqe_curr, qm->sqe_size, name);
	dump_show(qm, sqe, qm->sqe_size, name);


	kfree(sqe);
	kfree(sqe);