diff mbox series

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

Message ID 20240403100102.2735306-9-huangchenghai2@huawei.com (mailing list archive)
State Superseded
Delegated to: Herbert Xu
Headers show
Series crypto: hisilicon - Optimize and fix some driver processes | expand

Commit Message

Chenghai Huang April 3, 2024, 10:01 a.m. UTC
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: Chenghai Huang <huangchenghai2@huawei.com>
---
 drivers/crypto/hisilicon/debugfs.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

kernel test robot April 3, 2024, 10:57 p.m. UTC | #1
Hi Chenghai,

kernel test robot noticed the following build warnings:

[auto build test WARNING on herbert-cryptodev-2.6/master]
[also build test WARNING on herbert-crypto-2.6/master linus/master v6.9-rc2 next-20240403]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Chenghai-Huang/crypto-hisilicon-sec-Add-the-condition-for-configuring-the-sriov-function/20240403-180924
base:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
patch link:    https://lore.kernel.org/r/20240403100102.2735306-9-huangchenghai2%40huawei.com
patch subject: [PATCH 8/9] crypto: hisilicon/debugfs - Resolve the problem of applying for redundant space in sq dump
config: arm64-defconfig (https://download.01.org/0day-ci/archive/20240404/202404040616.cF0Pvb9M-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240404/202404040616.cF0Pvb9M-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202404040616.cF0Pvb9M-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/crypto/hisilicon/debugfs.c: In function 'qm_sq_dump':
>> drivers/crypto/hisilicon/debugfs.c:314:21: warning: unused variable 'sqe_curr' [-Wunused-variable]
     314 |         void *sqe, *sqe_curr;
         |                     ^~~~~~~~


vim +/sqe_curr +314 drivers/crypto/hisilicon/debugfs.c

94476b2b6d60bc Kai Ye         2022-11-12  310  
9c75609842f091 Kai Ye         2022-11-12  311  static int qm_sq_dump(struct hisi_qm *qm, char *s, char *name)
94476b2b6d60bc Kai Ye         2022-11-12  312  {
94476b2b6d60bc Kai Ye         2022-11-12  313  	u16 sq_depth = qm->qp_array->cq_depth;
94476b2b6d60bc Kai Ye         2022-11-12 @314  	void *sqe, *sqe_curr;
94476b2b6d60bc Kai Ye         2022-11-12  315  	struct hisi_qp *qp;
94476b2b6d60bc Kai Ye         2022-11-12  316  	u32 qp_id, sqe_id;
94476b2b6d60bc Kai Ye         2022-11-12  317  	int ret;
94476b2b6d60bc Kai Ye         2022-11-12  318  
94476b2b6d60bc Kai Ye         2022-11-12  319  	ret = q_dump_param_parse(qm, s, &sqe_id, &qp_id, sq_depth);
94476b2b6d60bc Kai Ye         2022-11-12  320  	if (ret)
94476b2b6d60bc Kai Ye         2022-11-12  321  		return ret;
94476b2b6d60bc Kai Ye         2022-11-12  322  
e0bbea3a20f7a0 Chenghai Huang 2024-04-03  323  	sqe = kzalloc(qm->sqe_size, GFP_KERNEL);
94476b2b6d60bc Kai Ye         2022-11-12  324  	if (!sqe)
94476b2b6d60bc Kai Ye         2022-11-12  325  		return -ENOMEM;
94476b2b6d60bc Kai Ye         2022-11-12  326  
94476b2b6d60bc Kai Ye         2022-11-12  327  	qp = &qm->qp_array[qp_id];
e0bbea3a20f7a0 Chenghai Huang 2024-04-03  328  	memcpy(sqe, qp->sqe + sqe_id * qm->sqe_size, qm->sqe_size);
e0bbea3a20f7a0 Chenghai Huang 2024-04-03  329  	memset(sqe + qm->debug.sqe_mask_offset, QM_SQE_ADDR_MASK,
94476b2b6d60bc Kai Ye         2022-11-12  330  	       qm->debug.sqe_mask_len);
94476b2b6d60bc Kai Ye         2022-11-12  331  
e0bbea3a20f7a0 Chenghai Huang 2024-04-03  332  	dump_show(qm, sqe, qm->sqe_size, name);
94476b2b6d60bc Kai Ye         2022-11-12  333  
94476b2b6d60bc Kai Ye         2022-11-12  334  	kfree(sqe);
94476b2b6d60bc Kai Ye         2022-11-12  335  
94476b2b6d60bc Kai Ye         2022-11-12  336  	return 0;
94476b2b6d60bc Kai Ye         2022-11-12  337  }
94476b2b6d60bc Kai Ye         2022-11-12  338
diff mbox series

Patch

diff --git a/drivers/crypto/hisilicon/debugfs.c b/drivers/crypto/hisilicon/debugfs.c
index e9fa42381242..8e259ed4aecd 100644
--- a/drivers/crypto/hisilicon/debugfs.c
+++ b/drivers/crypto/hisilicon/debugfs.c
@@ -320,17 +320,16 @@  static int qm_sq_dump(struct hisi_qm *qm, char *s, char *name)
 	if (ret)
 		return ret;
 
-	sqe = kzalloc(qm->sqe_size * sq_depth, GFP_KERNEL);
+	sqe = kzalloc(qm->sqe_size, GFP_KERNEL);
 	if (!sqe)
 		return -ENOMEM;
 
 	qp = &qm->qp_array[qp_id];
-	memcpy(sqe, qp->sqe, qm->sqe_size * sq_depth);
-	sqe_curr = sqe + (u32)(sqe_id * qm->sqe_size);
-	memset(sqe_curr + qm->debug.sqe_mask_offset, QM_SQE_ADDR_MASK,
+	memcpy(sqe, qp->sqe + sqe_id * qm->sqe_size, qm->sqe_size);
+	memset(sqe + qm->debug.sqe_mask_offset, QM_SQE_ADDR_MASK,
 	       qm->debug.sqe_mask_len);
 
-	dump_show(qm, sqe_curr, qm->sqe_size, name);
+	dump_show(qm, sqe, qm->sqe_size, name);
 
 	kfree(sqe);