* [PATCH 0/9] crypto: hisilicon - Optimize and fix some driver processes
@ 2024-04-03 10:00 Chenghai Huang
2024-04-03 10:00 ` [PATCH 1/9] crypto: hisilicon/sec - Add the condition for configuring the sriov function Chenghai Huang
` (8 more replies)
0 siblings, 9 replies; 11+ messages in thread
From: Chenghai Huang @ 2024-04-03 10:00 UTC (permalink / raw)
To: herbert, davem
Cc: linux-kernel, linux-crypto, fanghao11, liulongfang, shenyang39,
songzhiqi1, qianweili, liushangbin, linwenkai6, taoqi10,
wangzhou1, huangchenghai2
This patch series is mainly used to fix and optimize some
problems of hisilicon.
Chenghai Huang (9):
crypto: hisilicon/sec - Add the condition for configuring the sriov
function
crypto: hisilicon/debugfs - Fix debugfs uninit process issue
crypto: hisilicon/sgl - Delete redundant parameter verification
crypto: hisilicon/debugfs - Fix the processing logic issue in the
debugfs creation
crypto: hisilicon/qm - Add the default processing branch
crypto: hisilicon - Adjust debugfs creation and release order
crypto: hisilicon/sec - Fix memory leak for sec resource release
crypto: hisilicon/debugfs - Resolve the problem of applying for
redundant space in sq dump
crypto: hisilicon/debugfs - Add the err memory release process to qm
uninit
drivers/crypto/hisilicon/debugfs.c | 36 +++++++++++++++-------
drivers/crypto/hisilicon/hpre/hpre_main.c | 21 ++++++-------
drivers/crypto/hisilicon/qm.c | 8 ++---
drivers/crypto/hisilicon/sec2/sec_crypto.c | 4 ++-
drivers/crypto/hisilicon/sec2/sec_main.c | 26 ++++++++--------
drivers/crypto/hisilicon/sgl.c | 5 +--
drivers/crypto/hisilicon/zip/zip_main.c | 24 +++++++--------
7 files changed, 67 insertions(+), 57 deletions(-)
--
2.30.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/9] crypto: hisilicon/sec - Add the condition for configuring the sriov function
2024-04-03 10:00 [PATCH 0/9] crypto: hisilicon - Optimize and fix some driver processes Chenghai Huang
@ 2024-04-03 10:00 ` Chenghai Huang
2024-04-03 10:00 ` [PATCH 2/9] crypto: hisilicon/debugfs - Fix debugfs uninit process issue Chenghai Huang
` (7 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Chenghai Huang @ 2024-04-03 10:00 UTC (permalink / raw)
To: herbert, davem
Cc: linux-kernel, linux-crypto, fanghao11, liulongfang, shenyang39,
songzhiqi1, qianweili, liushangbin, linwenkai6, taoqi10,
wangzhou1, huangchenghai2
When CONFIG_PCI_IOV is disabled, the SRIOV configuration
function is not required. An error occurs if this function is
incorrectly called.
Consistent with other modules, add the condition for
configuring the sriov function of sec_pci_driver.
Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
---
drivers/crypto/hisilicon/sec2/sec_main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c b/drivers/crypto/hisilicon/sec2/sec_main.c
index c290d8937b19..f4e10741610f 100644
--- a/drivers/crypto/hisilicon/sec2/sec_main.c
+++ b/drivers/crypto/hisilicon/sec2/sec_main.c
@@ -1324,7 +1324,8 @@ static struct pci_driver sec_pci_driver = {
.probe = sec_probe,
.remove = sec_remove,
.err_handler = &sec_err_handler,
- .sriov_configure = hisi_qm_sriov_configure,
+ .sriov_configure = IS_ENABLED(CONFIG_PCI_IOV) ?
+ hisi_qm_sriov_configure : NULL,
.shutdown = hisi_qm_dev_shutdown,
.driver.pm = &sec_pm_ops,
};
--
2.30.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/9] crypto: hisilicon/debugfs - Fix debugfs uninit process issue
2024-04-03 10:00 [PATCH 0/9] crypto: hisilicon - Optimize and fix some driver processes Chenghai Huang
2024-04-03 10:00 ` [PATCH 1/9] crypto: hisilicon/sec - Add the condition for configuring the sriov function Chenghai Huang
@ 2024-04-03 10:00 ` Chenghai Huang
2024-04-03 10:00 ` [PATCH 3/9] crypto: hisilicon/sgl - Delete redundant parameter verification Chenghai Huang
` (6 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Chenghai Huang @ 2024-04-03 10:00 UTC (permalink / raw)
To: herbert, davem
Cc: linux-kernel, linux-crypto, fanghao11, liulongfang, shenyang39,
songzhiqi1, qianweili, liushangbin, linwenkai6, taoqi10,
wangzhou1, huangchenghai2
During the zip probe process, the debugfs failure does not stop
the probe. When debugfs initialization fails, jumping to the
error branch will also release regs, in addition to its own
rollback operation.
As a result, it may be released repeatedly during the regs
uninit process. Therefore, the null check needs to be added to
the regs uninit process.
Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
---
drivers/crypto/hisilicon/debugfs.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/drivers/crypto/hisilicon/debugfs.c b/drivers/crypto/hisilicon/debugfs.c
index cd67fa348ca7..6351a452878d 100644
--- a/drivers/crypto/hisilicon/debugfs.c
+++ b/drivers/crypto/hisilicon/debugfs.c
@@ -809,8 +809,14 @@ static void dfx_regs_uninit(struct hisi_qm *qm,
{
int i;
+ if (!dregs)
+ return;
+
/* Setting the pointer is NULL to prevent double free */
for (i = 0; i < reg_len; i++) {
+ if (!dregs[i].regs)
+ continue;
+
kfree(dregs[i].regs);
dregs[i].regs = NULL;
}
@@ -860,14 +866,21 @@ static struct dfx_diff_registers *dfx_regs_init(struct hisi_qm *qm,
static int qm_diff_regs_init(struct hisi_qm *qm,
struct dfx_diff_registers *dregs, u32 reg_len)
{
+ int ret;
+
qm->debug.qm_diff_regs = dfx_regs_init(qm, qm_diff_regs, ARRAY_SIZE(qm_diff_regs));
- if (IS_ERR(qm->debug.qm_diff_regs))
- return PTR_ERR(qm->debug.qm_diff_regs);
+ if (IS_ERR(qm->debug.qm_diff_regs)) {
+ ret = PTR_ERR(qm->debug.qm_diff_regs);
+ qm->debug.qm_diff_regs = NULL;
+ return ret;
+ }
qm->debug.acc_diff_regs = dfx_regs_init(qm, dregs, reg_len);
if (IS_ERR(qm->debug.acc_diff_regs)) {
dfx_regs_uninit(qm, qm->debug.qm_diff_regs, ARRAY_SIZE(qm_diff_regs));
- return PTR_ERR(qm->debug.acc_diff_regs);
+ ret = PTR_ERR(qm->debug.acc_diff_regs);
+ qm->debug.acc_diff_regs = NULL;
+ return ret;
}
return 0;
@@ -908,7 +921,9 @@ static int qm_last_regs_init(struct hisi_qm *qm)
static void qm_diff_regs_uninit(struct hisi_qm *qm, u32 reg_len)
{
dfx_regs_uninit(qm, qm->debug.acc_diff_regs, reg_len);
+ qm->debug.acc_diff_regs = NULL;
dfx_regs_uninit(qm, qm->debug.qm_diff_regs, ARRAY_SIZE(qm_diff_regs));
+ qm->debug.qm_diff_regs = NULL;
}
/**
--
2.30.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/9] crypto: hisilicon/sgl - Delete redundant parameter verification
2024-04-03 10:00 [PATCH 0/9] crypto: hisilicon - Optimize and fix some driver processes Chenghai Huang
2024-04-03 10:00 ` [PATCH 1/9] crypto: hisilicon/sec - Add the condition for configuring the sriov function Chenghai Huang
2024-04-03 10:00 ` [PATCH 2/9] crypto: hisilicon/debugfs - Fix debugfs uninit process issue Chenghai Huang
@ 2024-04-03 10:00 ` Chenghai Huang
2024-04-03 10:00 ` [PATCH 4/9] crypto: hisilicon/debugfs - Fix the processing logic issue in the debugfs creation Chenghai Huang
` (5 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Chenghai Huang @ 2024-04-03 10:00 UTC (permalink / raw)
To: herbert, davem
Cc: linux-kernel, linux-crypto, fanghao11, liulongfang, shenyang39,
songzhiqi1, qianweili, liushangbin, linwenkai6, taoqi10,
wangzhou1, huangchenghai2
The input parameter check in acc_get_sgl is redundant. The
caller has been verified once. When the check is performed for
multiple times, the performance deteriorates.
So the redundant parameter verification is deleted, and the
index verification is changed to the module entry function for
verification.
Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
---
drivers/crypto/hisilicon/sgl.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/crypto/hisilicon/sgl.c b/drivers/crypto/hisilicon/sgl.c
index 0beca257c20b..568acd0aee3f 100644
--- a/drivers/crypto/hisilicon/sgl.c
+++ b/drivers/crypto/hisilicon/sgl.c
@@ -161,9 +161,6 @@ static struct hisi_acc_hw_sgl *acc_get_sgl(struct hisi_acc_sgl_pool *pool,
struct mem_block *block;
u32 block_index, offset;
- if (!pool || !hw_sgl_dma || index >= pool->count)
- return ERR_PTR(-EINVAL);
-
block = pool->mem_block;
block_index = index / pool->sgl_num_per_block;
offset = index % pool->sgl_num_per_block;
@@ -230,7 +227,7 @@ hisi_acc_sg_buf_map_to_hw_sgl(struct device *dev,
struct scatterlist *sg;
int sg_n;
- if (!dev || !sgl || !pool || !hw_sgl_dma)
+ if (!dev || !sgl || !pool || !hw_sgl_dma || index >= pool->count)
return ERR_PTR(-EINVAL);
sg_n = sg_nents(sgl);
--
2.30.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/9] crypto: hisilicon/debugfs - Fix the processing logic issue in the debugfs creation
2024-04-03 10:00 [PATCH 0/9] crypto: hisilicon - Optimize and fix some driver processes Chenghai Huang
` (2 preceding siblings ...)
2024-04-03 10:00 ` [PATCH 3/9] crypto: hisilicon/sgl - Delete redundant parameter verification Chenghai Huang
@ 2024-04-03 10:00 ` Chenghai Huang
2024-04-03 10:00 ` [PATCH 5/9] crypto: hisilicon/qm - Add the default processing branch Chenghai Huang
` (4 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Chenghai Huang @ 2024-04-03 10:00 UTC (permalink / raw)
To: herbert, davem
Cc: linux-kernel, linux-crypto, fanghao11, liulongfang, shenyang39,
songzhiqi1, qianweili, liushangbin, linwenkai6, taoqi10,
wangzhou1, huangchenghai2
There is a scenario where the file directory is created but the
file attribute is not set. In this case, if a user accesses the
file, an error occurs.
So adjust the processing logic in the debugfs creation to
prevent the file from being accessed before the file attributes
such as the index are set.
Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
---
drivers/crypto/hisilicon/debugfs.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/crypto/hisilicon/debugfs.c b/drivers/crypto/hisilicon/debugfs.c
index 6351a452878d..e9fa42381242 100644
--- a/drivers/crypto/hisilicon/debugfs.c
+++ b/drivers/crypto/hisilicon/debugfs.c
@@ -1090,12 +1090,12 @@ static void qm_create_debugfs_file(struct hisi_qm *qm, struct dentry *dir,
{
struct debugfs_file *file = qm->debug.files + index;
- debugfs_create_file(qm_debug_file_name[index], 0600, dir, file,
- &qm_debug_fops);
-
file->index = index;
mutex_init(&file->lock);
file->debug = &qm->debug;
+
+ debugfs_create_file(qm_debug_file_name[index], 0600, dir, file,
+ &qm_debug_fops);
}
static int qm_debugfs_atomic64_set(void *data, u64 val)
--
2.30.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 5/9] crypto: hisilicon/qm - Add the default processing branch
2024-04-03 10:00 [PATCH 0/9] crypto: hisilicon - Optimize and fix some driver processes Chenghai Huang
` (3 preceding siblings ...)
2024-04-03 10:00 ` [PATCH 4/9] crypto: hisilicon/debugfs - Fix the processing logic issue in the debugfs creation Chenghai Huang
@ 2024-04-03 10:00 ` Chenghai Huang
2024-04-03 10:00 ` [PATCH 6/9] crypto: hisilicon - Adjust debugfs creation and release order Chenghai Huang
` (3 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Chenghai Huang @ 2024-04-03 10:00 UTC (permalink / raw)
To: herbert, davem
Cc: linux-kernel, linux-crypto, fanghao11, liulongfang, shenyang39,
songzhiqi1, qianweili, liushangbin, linwenkai6, taoqi10,
wangzhou1, huangchenghai2
The cmd type can be extended. Currently, only four types of cmd
can be processed. Therefor, add the default processing branch
to intercept incorrect parameter input.
Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
---
drivers/crypto/hisilicon/qm.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c
index 92f0a1d9b4a6..cedb3af1fc1a 100644
--- a/drivers/crypto/hisilicon/qm.c
+++ b/drivers/crypto/hisilicon/qm.c
@@ -645,6 +645,9 @@ int qm_set_and_get_xqc(struct hisi_qm *qm, u8 cmd, void *xqc, u32 qp_id, bool op
tmp_xqc = qm->xqc_buf.aeqc;
xqc_dma = qm->xqc_buf.aeqc_dma;
break;
+ default:
+ dev_err(&qm->pdev->dev, "unknown mailbox cmd %u\n", cmd);
+ return -EINVAL;
}
/* Setting xqc will fail if master OOO is blocked. */
--
2.30.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 6/9] crypto: hisilicon - Adjust debugfs creation and release order
2024-04-03 10:00 [PATCH 0/9] crypto: hisilicon - Optimize and fix some driver processes Chenghai Huang
` (4 preceding siblings ...)
2024-04-03 10:00 ` [PATCH 5/9] crypto: hisilicon/qm - Add the default processing branch Chenghai Huang
@ 2024-04-03 10:00 ` Chenghai Huang
2024-04-03 10:01 ` [PATCH 7/9] crypto: hisilicon/sec - Fix memory leak for sec resource release Chenghai Huang
` (2 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Chenghai Huang @ 2024-04-03 10:00 UTC (permalink / raw)
To: herbert, davem
Cc: linux-kernel, linux-crypto, fanghao11, liulongfang, shenyang39,
songzhiqi1, qianweili, liushangbin, linwenkai6, taoqi10,
wangzhou1, huangchenghai2
There is a scenario where the file directory is created but the
file memory is not set. In this case, if a user accesses the
file, an error occurs.
So during the creation process of debugfs, memory should be
allocated first before creating the directory. In the release
process, the directory should be deleted first before releasing
the memory to avoid the situation where the memory does not
exist when accessing the directory.
In addition, the directory released by the debugfs is a global
variable. When the debugfs of an accelerator fails to be
initialized, releasing the directory of the global variable
affects the debugfs initialization of other accelerators.
The debugfs root directory released by debugfs init should be a
member of qm, not a global variable.
Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
---
drivers/crypto/hisilicon/hpre/hpre_main.c | 21 ++++++++++----------
drivers/crypto/hisilicon/sec2/sec_main.c | 23 +++++++++++-----------
drivers/crypto/hisilicon/zip/zip_main.c | 24 +++++++++++------------
3 files changed, 32 insertions(+), 36 deletions(-)
diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c
index d93aa6630a57..25b44416da45 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_main.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_main.c
@@ -1074,41 +1074,40 @@ static int hpre_debugfs_init(struct hisi_qm *qm)
struct device *dev = &qm->pdev->dev;
int ret;
- qm->debug.debug_root = debugfs_create_dir(dev_name(dev),
- hpre_debugfs_root);
-
- qm->debug.sqe_mask_offset = HPRE_SQE_MASK_OFFSET;
- qm->debug.sqe_mask_len = HPRE_SQE_MASK_LEN;
ret = hisi_qm_regs_debugfs_init(qm, hpre_diff_regs, ARRAY_SIZE(hpre_diff_regs));
if (ret) {
dev_warn(dev, "Failed to init HPRE diff regs!\n");
- goto debugfs_remove;
+ return ret;
}
+ qm->debug.debug_root = debugfs_create_dir(dev_name(dev),
+ hpre_debugfs_root);
+ qm->debug.sqe_mask_offset = HPRE_SQE_MASK_OFFSET;
+ qm->debug.sqe_mask_len = HPRE_SQE_MASK_LEN;
+
hisi_qm_debug_init(qm);
if (qm->pdev->device == PCI_DEVICE_ID_HUAWEI_HPRE_PF) {
ret = hpre_ctrl_debug_init(qm);
if (ret)
- goto failed_to_create;
+ goto debugfs_remove;
}
hpre_dfx_debug_init(qm);
return 0;
-failed_to_create:
- hisi_qm_regs_debugfs_uninit(qm, ARRAY_SIZE(hpre_diff_regs));
debugfs_remove:
debugfs_remove_recursive(qm->debug.debug_root);
+ hisi_qm_regs_debugfs_uninit(qm, ARRAY_SIZE(hpre_diff_regs));
return ret;
}
static void hpre_debugfs_exit(struct hisi_qm *qm)
{
- hisi_qm_regs_debugfs_uninit(qm, ARRAY_SIZE(hpre_diff_regs));
-
debugfs_remove_recursive(qm->debug.debug_root);
+
+ hisi_qm_regs_debugfs_uninit(qm, ARRAY_SIZE(hpre_diff_regs));
}
static int hpre_pre_store_cap_reg(struct hisi_qm *qm)
diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c b/drivers/crypto/hisilicon/sec2/sec_main.c
index f4e10741610f..853b1cb85016 100644
--- a/drivers/crypto/hisilicon/sec2/sec_main.c
+++ b/drivers/crypto/hisilicon/sec2/sec_main.c
@@ -901,37 +901,36 @@ static int sec_debugfs_init(struct hisi_qm *qm)
struct device *dev = &qm->pdev->dev;
int ret;
- qm->debug.debug_root = debugfs_create_dir(dev_name(dev),
- sec_debugfs_root);
- qm->debug.sqe_mask_offset = SEC_SQE_MASK_OFFSET;
- qm->debug.sqe_mask_len = SEC_SQE_MASK_LEN;
-
ret = hisi_qm_regs_debugfs_init(qm, sec_diff_regs, ARRAY_SIZE(sec_diff_regs));
if (ret) {
dev_warn(dev, "Failed to init SEC diff regs!\n");
- goto debugfs_remove;
+ return ret;
}
+ qm->debug.debug_root = debugfs_create_dir(dev_name(dev),
+ sec_debugfs_root);
+ qm->debug.sqe_mask_offset = SEC_SQE_MASK_OFFSET;
+ qm->debug.sqe_mask_len = SEC_SQE_MASK_LEN;
+
hisi_qm_debug_init(qm);
ret = sec_debug_init(qm);
if (ret)
- goto failed_to_create;
+ goto debugfs_remove;
return 0;
-failed_to_create:
- hisi_qm_regs_debugfs_uninit(qm, ARRAY_SIZE(sec_diff_regs));
debugfs_remove:
- debugfs_remove_recursive(sec_debugfs_root);
+ debugfs_remove_recursive(qm->debug.debug_root);
+ hisi_qm_regs_debugfs_uninit(qm, ARRAY_SIZE(sec_diff_regs));
return ret;
}
static void sec_debugfs_exit(struct hisi_qm *qm)
{
- hisi_qm_regs_debugfs_uninit(qm, ARRAY_SIZE(sec_diff_regs));
-
debugfs_remove_recursive(qm->debug.debug_root);
+
+ hisi_qm_regs_debugfs_uninit(qm, ARRAY_SIZE(sec_diff_regs));
}
static int sec_show_last_regs_init(struct hisi_qm *qm)
diff --git a/drivers/crypto/hisilicon/zip/zip_main.c b/drivers/crypto/hisilicon/zip/zip_main.c
index 732b6c308c48..399b681ee423 100644
--- a/drivers/crypto/hisilicon/zip/zip_main.c
+++ b/drivers/crypto/hisilicon/zip/zip_main.c
@@ -886,36 +886,34 @@ static int hisi_zip_ctrl_debug_init(struct hisi_qm *qm)
static int hisi_zip_debugfs_init(struct hisi_qm *qm)
{
struct device *dev = &qm->pdev->dev;
- struct dentry *dev_d;
int ret;
- dev_d = debugfs_create_dir(dev_name(dev), hzip_debugfs_root);
-
- qm->debug.sqe_mask_offset = HZIP_SQE_MASK_OFFSET;
- qm->debug.sqe_mask_len = HZIP_SQE_MASK_LEN;
- qm->debug.debug_root = dev_d;
ret = hisi_qm_regs_debugfs_init(qm, hzip_diff_regs, ARRAY_SIZE(hzip_diff_regs));
if (ret) {
dev_warn(dev, "Failed to init ZIP diff regs!\n");
- goto debugfs_remove;
+ return ret;
}
+ qm->debug.sqe_mask_offset = HZIP_SQE_MASK_OFFSET;
+ qm->debug.sqe_mask_len = HZIP_SQE_MASK_LEN;
+ qm->debug.debug_root = debugfs_create_dir(dev_name(dev),
+ hzip_debugfs_root);
+
hisi_qm_debug_init(qm);
if (qm->fun_type == QM_HW_PF) {
ret = hisi_zip_ctrl_debug_init(qm);
if (ret)
- goto failed_to_create;
+ goto debugfs_remove;
}
hisi_zip_dfx_debug_init(qm);
return 0;
-failed_to_create:
- hisi_qm_regs_debugfs_uninit(qm, ARRAY_SIZE(hzip_diff_regs));
debugfs_remove:
- debugfs_remove_recursive(hzip_debugfs_root);
+ debugfs_remove_recursive(qm->debug.debug_root);
+ hisi_qm_regs_debugfs_uninit(qm, ARRAY_SIZE(hzip_diff_regs));
return ret;
}
@@ -939,10 +937,10 @@ static void hisi_zip_debug_regs_clear(struct hisi_qm *qm)
static void hisi_zip_debugfs_exit(struct hisi_qm *qm)
{
- hisi_qm_regs_debugfs_uninit(qm, ARRAY_SIZE(hzip_diff_regs));
-
debugfs_remove_recursive(qm->debug.debug_root);
+ hisi_qm_regs_debugfs_uninit(qm, ARRAY_SIZE(hzip_diff_regs));
+
if (qm->fun_type == QM_HW_PF) {
hisi_zip_debug_regs_clear(qm);
qm->debug.curr_qm_qp_num = 0;
--
2.30.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 7/9] crypto: hisilicon/sec - Fix memory leak for sec resource release
2024-04-03 10:00 [PATCH 0/9] crypto: hisilicon - Optimize and fix some driver processes Chenghai Huang
` (5 preceding siblings ...)
2024-04-03 10:00 ` [PATCH 6/9] crypto: hisilicon - Adjust debugfs creation and release order Chenghai Huang
@ 2024-04-03 10:01 ` Chenghai Huang
2024-04-03 10:01 ` [PATCH 8/9] crypto: hisilicon/debugfs - Resolve the problem of applying for redundant space in sq dump Chenghai Huang
2024-04-03 10:01 ` [PATCH 9/9] crypto: hisilicon/debugfs - Add the err memory release process to qm uninit Chenghai Huang
8 siblings, 0 replies; 11+ messages in thread
From: Chenghai Huang @ 2024-04-03 10:01 UTC (permalink / raw)
To: herbert, davem
Cc: linux-kernel, linux-crypto, fanghao11, liulongfang, shenyang39,
songzhiqi1, qianweili, liushangbin, linwenkai6, taoqi10,
wangzhou1, huangchenghai2
The AIV is one of the SEC resources. When releasing resources,
it need to release the AIV resources at the same time.Otherwise,
memory leakage occurs.
The aiv resource release is added to the sec resource release
function.
Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
---
drivers/crypto/hisilicon/sec2/sec_crypto.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/crypto/hisilicon/sec2/sec_crypto.c b/drivers/crypto/hisilicon/sec2/sec_crypto.c
index 93a972fcbf63..0558f98e221f 100644
--- a/drivers/crypto/hisilicon/sec2/sec_crypto.c
+++ b/drivers/crypto/hisilicon/sec2/sec_crypto.c
@@ -481,8 +481,10 @@ static void sec_alg_resource_free(struct sec_ctx *ctx,
if (ctx->pbuf_supported)
sec_free_pbuf_resource(dev, qp_ctx->res);
- if (ctx->alg_type == SEC_AEAD)
+ if (ctx->alg_type == SEC_AEAD) {
sec_free_mac_resource(dev, qp_ctx->res);
+ sec_free_aiv_resource(dev, qp_ctx->res);
+ }
}
static int sec_alloc_qp_ctx_resource(struct sec_ctx *ctx, struct sec_qp_ctx *qp_ctx)
--
2.30.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 8/9] crypto: hisilicon/debugfs - Resolve the problem of applying for redundant space in sq dump
2024-04-03 10:00 [PATCH 0/9] crypto: hisilicon - Optimize and fix some driver processes Chenghai Huang
` (6 preceding siblings ...)
2024-04-03 10:01 ` [PATCH 7/9] crypto: hisilicon/sec - Fix memory leak for sec resource release Chenghai Huang
@ 2024-04-03 10:01 ` Chenghai Huang
2024-04-03 22:57 ` kernel test robot
2024-04-03 10:01 ` [PATCH 9/9] crypto: hisilicon/debugfs - Add the err memory release process to qm uninit Chenghai Huang
8 siblings, 1 reply; 11+ messages in thread
From: Chenghai Huang @ 2024-04-03 10:01 UTC (permalink / raw)
To: herbert, davem
Cc: linux-kernel, linux-crypto, fanghao11, liulongfang, shenyang39,
songzhiqi1, qianweili, liushangbin, linwenkai6, taoqi10,
wangzhou1, huangchenghai2
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(-)
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);
--
2.30.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 9/9] crypto: hisilicon/debugfs - Add the err memory release process to qm uninit
2024-04-03 10:00 [PATCH 0/9] crypto: hisilicon - Optimize and fix some driver processes Chenghai Huang
` (7 preceding siblings ...)
2024-04-03 10:01 ` [PATCH 8/9] crypto: hisilicon/debugfs - Resolve the problem of applying for redundant space in sq dump Chenghai Huang
@ 2024-04-03 10:01 ` Chenghai Huang
8 siblings, 0 replies; 11+ messages in thread
From: Chenghai Huang @ 2024-04-03 10:01 UTC (permalink / raw)
To: herbert, davem
Cc: linux-kernel, linux-crypto, fanghao11, liulongfang, shenyang39,
songzhiqi1, qianweili, liushangbin, linwenkai6, taoqi10,
wangzhou1, huangchenghai2
When the qm uninit command is executed, the err data needs to
be released to prevent memory leakage. The error information
release operation and uacce_remove are integrated in
qm_remove_uacce.
So add the qm_remove_uacce to qm uninit to avoid err memory
leakage.
Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
---
drivers/crypto/hisilicon/qm.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c
index cedb3af1fc1a..3dac8d8e8568 100644
--- a/drivers/crypto/hisilicon/qm.c
+++ b/drivers/crypto/hisilicon/qm.c
@@ -2896,12 +2896,9 @@ void hisi_qm_uninit(struct hisi_qm *qm)
hisi_qm_set_state(qm, QM_NOT_READY);
up_write(&qm->qps_lock);
+ qm_remove_uacce(qm);
qm_irqs_unregister(qm);
hisi_qm_pci_uninit(qm);
- if (qm->use_sva) {
- uacce_remove(qm->uacce);
- qm->uacce = NULL;
- }
}
EXPORT_SYMBOL_GPL(hisi_qm_uninit);
--
2.30.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 8/9] crypto: hisilicon/debugfs - Resolve the problem of applying for redundant space in sq dump
2024-04-03 10:01 ` [PATCH 8/9] crypto: hisilicon/debugfs - Resolve the problem of applying for redundant space in sq dump Chenghai Huang
@ 2024-04-03 22:57 ` kernel test robot
0 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2024-04-03 22:57 UTC (permalink / raw)
To: Chenghai Huang, herbert, davem
Cc: oe-kbuild-all, linux-kernel, linux-crypto, fanghao11, liulongfang,
shenyang39, songzhiqi1, qianweili, liushangbin, linwenkai6,
taoqi10, wangzhou1, huangchenghai2
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
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2024-04-03 22:57 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-03 10:00 [PATCH 0/9] crypto: hisilicon - Optimize and fix some driver processes Chenghai Huang
2024-04-03 10:00 ` [PATCH 1/9] crypto: hisilicon/sec - Add the condition for configuring the sriov function Chenghai Huang
2024-04-03 10:00 ` [PATCH 2/9] crypto: hisilicon/debugfs - Fix debugfs uninit process issue Chenghai Huang
2024-04-03 10:00 ` [PATCH 3/9] crypto: hisilicon/sgl - Delete redundant parameter verification Chenghai Huang
2024-04-03 10:00 ` [PATCH 4/9] crypto: hisilicon/debugfs - Fix the processing logic issue in the debugfs creation Chenghai Huang
2024-04-03 10:00 ` [PATCH 5/9] crypto: hisilicon/qm - Add the default processing branch Chenghai Huang
2024-04-03 10:00 ` [PATCH 6/9] crypto: hisilicon - Adjust debugfs creation and release order Chenghai Huang
2024-04-03 10:01 ` [PATCH 7/9] crypto: hisilicon/sec - Fix memory leak for sec resource release Chenghai Huang
2024-04-03 10:01 ` [PATCH 8/9] crypto: hisilicon/debugfs - Resolve the problem of applying for redundant space in sq dump Chenghai Huang
2024-04-03 22:57 ` kernel test robot
2024-04-03 10:01 ` [PATCH 9/9] crypto: hisilicon/debugfs - Add the err memory release process to qm uninit Chenghai Huang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).