All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] crypto: hisilicon - update ACC module parameter
@ 2020-09-10 11:56 Longfang Liu
  2020-09-10 11:56 ` [PATCH 1/5] crypto: hisilicon - update mininum queue Longfang Liu
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Longfang Liu @ 2020-09-10 11:56 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto

In order to pass kernel crypto test, the ACC module parameter
pf_q_num needs to be set to an integer greater than 1,
and then fixed two bugs.

Longfang Liu (5):
  crypto: hisilicon - update mininum queue
  crypto: hisilicon - update HPRE module parameter description
  crypto: hisilicon - update SEC module parameter description
  crypto: hisilicon - update ZIP module parameter description
  crypto: hisilicon - fixed memory allocation error

 drivers/crypto/hisilicon/hpre/hpre_main.c  |  2 +-
 drivers/crypto/hisilicon/qm.h              |  4 ++--
 drivers/crypto/hisilicon/sec2/sec_crypto.c | 16 ++++++++++++----
 drivers/crypto/hisilicon/sec2/sec_main.c   |  2 +-
 drivers/crypto/hisilicon/zip/zip_main.c    |  2 +-
 5 files changed, 17 insertions(+), 9 deletions(-)

-- 
2.8.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/5] crypto: hisilicon - update mininum queue
  2020-09-10 11:56 [PATCH 0/5] crypto: hisilicon - update ACC module parameter Longfang Liu
@ 2020-09-10 11:56 ` Longfang Liu
  2020-09-10 11:56 ` [PATCH 2/5] crypto: hisilicon - update HPRE module parameter description Longfang Liu
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Longfang Liu @ 2020-09-10 11:56 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto

At present, as HPRE/SEC/ZIP modules' parameter 'pf_q_num' is 1,
kernel CRYPTO test will fail on the algorithms from the modules,
since 'QP' hardware resources are not enough for CRYPTO TFM.
To fix this, the minimum value of 'pf_q_num' should be 2.

Signed-off-by: Longfang Liu <liulongfang@huawei.com>
---
 drivers/crypto/hisilicon/qm.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/hisilicon/qm.h b/drivers/crypto/hisilicon/qm.h
index 6773f44..0420f4c 100644
--- a/drivers/crypto/hisilicon/qm.h
+++ b/drivers/crypto/hisilicon/qm.h
@@ -79,7 +79,7 @@
 #define QM_BASE_CE			QM_ECC_1BIT
 
 #define QM_Q_DEPTH			1024
-
+#define QM_MIN_QNUM                     2
 #define HISI_ACC_SGL_SGE_NR_MAX		255
 
 /* page number for queue file region */
@@ -309,7 +309,7 @@ static inline int q_num_set(const char *val, const struct kernel_param *kp,
 	}
 
 	ret = kstrtou32(val, 10, &n);
-	if (ret || !n || n > q_num)
+	if (ret || n < QM_MIN_QNUM || n > q_num)
 		return -EINVAL;
 
 	return param_set_int(val, kp);
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/5] crypto: hisilicon - update HPRE module parameter description
  2020-09-10 11:56 [PATCH 0/5] crypto: hisilicon - update ACC module parameter Longfang Liu
  2020-09-10 11:56 ` [PATCH 1/5] crypto: hisilicon - update mininum queue Longfang Liu
@ 2020-09-10 11:56 ` Longfang Liu
  2020-09-10 11:56 ` [PATCH 3/5] crypto: hisilicon - update SEC " Longfang Liu
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Longfang Liu @ 2020-09-10 11:56 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto

In order to pass kernel CRYPTO test, HPRE module parameter
'pf_q_num' needs to be set as greater than 1.

Signed-off-by: Longfang Liu <liulongfang@huawei.com>
---
 drivers/crypto/hisilicon/hpre/hpre_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c
index 45741d2..cf9169d 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_main.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_main.c
@@ -190,7 +190,7 @@ static const struct kernel_param_ops hpre_pf_q_num_ops = {
 
 static u32 pf_q_num = HPRE_PF_DEF_Q_NUM;
 module_param_cb(pf_q_num, &hpre_pf_q_num_ops, &pf_q_num, 0444);
-MODULE_PARM_DESC(pf_q_num, "Number of queues in PF of CS(1-1024)");
+MODULE_PARM_DESC(pf_q_num, "Number of queues in PF of CS(2-1024)");
 
 static const struct kernel_param_ops vfs_num_ops = {
 	.set = vfs_num_set,
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/5] crypto: hisilicon - update SEC module parameter description
  2020-09-10 11:56 [PATCH 0/5] crypto: hisilicon - update ACC module parameter Longfang Liu
  2020-09-10 11:56 ` [PATCH 1/5] crypto: hisilicon - update mininum queue Longfang Liu
  2020-09-10 11:56 ` [PATCH 2/5] crypto: hisilicon - update HPRE module parameter description Longfang Liu
@ 2020-09-10 11:56 ` Longfang Liu
  2020-09-10 11:56 ` [PATCH 4/5] crypto: hisilicon - update ZIP " Longfang Liu
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Longfang Liu @ 2020-09-10 11:56 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto

In order to pass kernel CRYPTO test, SEC module parameter
'pf_q_num' needs to be set as greater than 1.

Signed-off-by: Longfang Liu <liulongfang@huawei.com>
---
 drivers/crypto/hisilicon/sec2/sec_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c b/drivers/crypto/hisilicon/sec2/sec_main.c
index f912e57..de42264 100644
--- a/drivers/crypto/hisilicon/sec2/sec_main.c
+++ b/drivers/crypto/hisilicon/sec2/sec_main.c
@@ -169,7 +169,7 @@ static const struct kernel_param_ops sec_pf_q_num_ops = {
 
 static u32 pf_q_num = SEC_PF_DEF_Q_NUM;
 module_param_cb(pf_q_num, &sec_pf_q_num_ops, &pf_q_num, 0444);
-MODULE_PARM_DESC(pf_q_num, "Number of queues in PF(v1 0-4096, v2 0-1024)");
+MODULE_PARM_DESC(pf_q_num, "Number of queues in PF(v1 2-4096, v2 2-1024)");
 
 static int sec_ctx_q_num_set(const char *val, const struct kernel_param *kp)
 {
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/5] crypto: hisilicon - update ZIP module parameter description
  2020-09-10 11:56 [PATCH 0/5] crypto: hisilicon - update ACC module parameter Longfang Liu
                   ` (2 preceding siblings ...)
  2020-09-10 11:56 ` [PATCH 3/5] crypto: hisilicon - update SEC " Longfang Liu
@ 2020-09-10 11:56 ` Longfang Liu
  2020-09-10 11:56 ` [PATCH 5/5] crypto: hisilicon - fixed memory allocation error Longfang Liu
  2020-09-18  7:29 ` [PATCH 0/5] crypto: hisilicon - update ACC module parameter Herbert Xu
  5 siblings, 0 replies; 8+ messages in thread
From: Longfang Liu @ 2020-09-10 11:56 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto

In order to pass kernel CRYPTO test, ZIP module parameter
'pf_q_num' needs to be set as greater than 1.

Signed-off-by: Longfang Liu <liulongfang@huawei.com>
---
 drivers/crypto/hisilicon/zip/zip_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/hisilicon/zip/zip_main.c b/drivers/crypto/hisilicon/zip/zip_main.c
index 7e86b0f..9ca10be 100644
--- a/drivers/crypto/hisilicon/zip/zip_main.c
+++ b/drivers/crypto/hisilicon/zip/zip_main.c
@@ -220,7 +220,7 @@ static const struct kernel_param_ops pf_q_num_ops = {
 
 static u32 pf_q_num = HZIP_PF_DEF_Q_NUM;
 module_param_cb(pf_q_num, &pf_q_num_ops, &pf_q_num, 0444);
-MODULE_PARM_DESC(pf_q_num, "Number of queues in PF(v1 1-4096, v2 1-1024)");
+MODULE_PARM_DESC(pf_q_num, "Number of queues in PF(v1 2-4096, v2 2-1024)");
 
 static const struct kernel_param_ops vfs_num_ops = {
 	.set = vfs_num_set,
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 5/5] crypto: hisilicon - fixed memory allocation error
  2020-09-10 11:56 [PATCH 0/5] crypto: hisilicon - update ACC module parameter Longfang Liu
                   ` (3 preceding siblings ...)
  2020-09-10 11:56 ` [PATCH 4/5] crypto: hisilicon - update ZIP " Longfang Liu
@ 2020-09-10 11:56 ` Longfang Liu
  2020-09-18  7:29 ` [PATCH 0/5] crypto: hisilicon - update ACC module parameter Herbert Xu
  5 siblings, 0 replies; 8+ messages in thread
From: Longfang Liu @ 2020-09-10 11:56 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto

1. Fix the bug of 'mac' memory leak as allocating 'pbuf' failing.
2. Fix the bug of 'qps' leak as allocating 'qp_ctx' failing.

Signed-off-by: Longfang Liu <liulongfang@huawei.com>
---
 drivers/crypto/hisilicon/sec2/sec_crypto.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/hisilicon/sec2/sec_crypto.c b/drivers/crypto/hisilicon/sec2/sec_crypto.c
index 543d9ee..bb49342 100644
--- a/drivers/crypto/hisilicon/sec2/sec_crypto.c
+++ b/drivers/crypto/hisilicon/sec2/sec_crypto.c
@@ -340,11 +340,14 @@ static int sec_alg_resource_alloc(struct sec_ctx *ctx,
 		ret = sec_alloc_pbuf_resource(dev, res);
 		if (ret) {
 			dev_err(dev, "fail to alloc pbuf dma resource!\n");
-			goto alloc_fail;
+			goto alloc_pbuf_fail;
 		}
 	}
 
 	return 0;
+alloc_pbuf_fail:
+	if (ctx->alg_type == SEC_AEAD)
+		sec_free_mac_resource(dev, qp_ctx->res);
 alloc_fail:
 	sec_free_civ_resource(dev, res);
 
@@ -455,8 +458,10 @@ static int sec_ctx_base_init(struct sec_ctx *ctx)
 	ctx->fake_req_limit = QM_Q_DEPTH >> 1;
 	ctx->qp_ctx = kcalloc(sec->ctx_q_num, sizeof(struct sec_qp_ctx),
 			      GFP_KERNEL);
-	if (!ctx->qp_ctx)
-		return -ENOMEM;
+	if (!ctx->qp_ctx) {
+		ret = -ENOMEM;
+		goto err_destroy_qps;
+	}
 
 	for (i = 0; i < sec->ctx_q_num; i++) {
 		ret = sec_create_qp_ctx(&sec->qm, ctx, i, 0);
@@ -465,12 +470,15 @@ static int sec_ctx_base_init(struct sec_ctx *ctx)
 	}
 
 	return 0;
+
 err_sec_release_qp_ctx:
 	for (i = i - 1; i >= 0; i--)
 		sec_release_qp_ctx(ctx, &ctx->qp_ctx[i]);
 
-	sec_destroy_qps(ctx->qps, sec->ctx_q_num);
 	kfree(ctx->qp_ctx);
+err_destroy_qps:
+	sec_destroy_qps(ctx->qps, sec->ctx_q_num);
+
 	return ret;
 }
 
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/5] crypto: hisilicon - update ACC module parameter
  2020-09-10 11:56 [PATCH 0/5] crypto: hisilicon - update ACC module parameter Longfang Liu
                   ` (4 preceding siblings ...)
  2020-09-10 11:56 ` [PATCH 5/5] crypto: hisilicon - fixed memory allocation error Longfang Liu
@ 2020-09-18  7:29 ` Herbert Xu
  5 siblings, 0 replies; 8+ messages in thread
From: Herbert Xu @ 2020-09-18  7:29 UTC (permalink / raw)
  To: Longfang Liu; +Cc: linux-crypto

On Thu, Sep 10, 2020 at 07:56:38PM +0800, Longfang Liu wrote:
> In order to pass kernel crypto test, the ACC module parameter
> pf_q_num needs to be set to an integer greater than 1,
> and then fixed two bugs.
> 
> Longfang Liu (5):
>   crypto: hisilicon - update mininum queue
>   crypto: hisilicon - update HPRE module parameter description
>   crypto: hisilicon - update SEC module parameter description
>   crypto: hisilicon - update ZIP module parameter description
>   crypto: hisilicon - fixed memory allocation error
> 
>  drivers/crypto/hisilicon/hpre/hpre_main.c  |  2 +-
>  drivers/crypto/hisilicon/qm.h              |  4 ++--
>  drivers/crypto/hisilicon/sec2/sec_crypto.c | 16 ++++++++++++----
>  drivers/crypto/hisilicon/sec2/sec_main.c   |  2 +-
>  drivers/crypto/hisilicon/zip/zip_main.c    |  2 +-
>  5 files changed, 17 insertions(+), 9 deletions(-)

All applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/5] crypto: hisilicon - update HPRE module parameter description
  2020-09-10 12:56 Longfang Liu
@ 2020-09-10 12:56 ` Longfang Liu
  0 siblings, 0 replies; 8+ messages in thread
From: Longfang Liu @ 2020-09-10 12:56 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto

In order to pass kernel CRYPTO test, HPRE module parameter
'pf_q_num' needs to be set as greater than 1.

Signed-off-by: Longfang Liu <liulongfang@huawei.com>
---
 drivers/crypto/hisilicon/hpre/hpre_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c
index 45741d2..cf9169d 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_main.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_main.c
@@ -190,7 +190,7 @@ static const struct kernel_param_ops hpre_pf_q_num_ops = {
 
 static u32 pf_q_num = HPRE_PF_DEF_Q_NUM;
 module_param_cb(pf_q_num, &hpre_pf_q_num_ops, &pf_q_num, 0444);
-MODULE_PARM_DESC(pf_q_num, "Number of queues in PF of CS(1-1024)");
+MODULE_PARM_DESC(pf_q_num, "Number of queues in PF of CS(2-1024)");
 
 static const struct kernel_param_ops vfs_num_ops = {
 	.set = vfs_num_set,
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-09-18  7:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-10 11:56 [PATCH 0/5] crypto: hisilicon - update ACC module parameter Longfang Liu
2020-09-10 11:56 ` [PATCH 1/5] crypto: hisilicon - update mininum queue Longfang Liu
2020-09-10 11:56 ` [PATCH 2/5] crypto: hisilicon - update HPRE module parameter description Longfang Liu
2020-09-10 11:56 ` [PATCH 3/5] crypto: hisilicon - update SEC " Longfang Liu
2020-09-10 11:56 ` [PATCH 4/5] crypto: hisilicon - update ZIP " Longfang Liu
2020-09-10 11:56 ` [PATCH 5/5] crypto: hisilicon - fixed memory allocation error Longfang Liu
2020-09-18  7:29 ` [PATCH 0/5] crypto: hisilicon - update ACC module parameter Herbert Xu
2020-09-10 12:56 Longfang Liu
2020-09-10 12:56 ` [PATCH 2/5] crypto: hisilicon - update HPRE module parameter description Longfang Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.