All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] crypto: hisilicon/hpre - misc clean up and fixes
@ 2020-09-19  3:13 yumeng 00484669
  2020-09-19  3:13 ` [PATCH v2 1/3] crypto: hisilicon/hpre - remove useless code yumeng 00484669
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: yumeng 00484669 @ 2020-09-19  3:13 UTC (permalink / raw
  To: herbert, davem; +Cc: linux-crypto, xuzaibo, wangzhou1, yumeng18, linux-kernel

Adjust some tiny coding problems and fix a bug of DH algorithm.

Changes since v1:
Remove 'u64' cast in 'cpu_to_le64';

Meng Yu (3):
  crypto: hisilicon/hpre - remove useless code
  crypto: hisilicon/hpre - adjust some coding style
  crypto: hisilicon/hpre - fix a bug in dh algorithm

 drivers/crypto/hisilicon/hpre/hpre.h        |  1 -
 drivers/crypto/hisilicon/hpre/hpre_crypto.c | 23 +++++++++++------------
 2 files changed, 11 insertions(+), 13 deletions(-)

-- 
2.8.1


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

* [PATCH v2 1/3] crypto: hisilicon/hpre - remove useless code
  2020-09-19  3:13 [PATCH v2 0/3] crypto: hisilicon/hpre - misc clean up and fixes yumeng 00484669
@ 2020-09-19  3:13 ` yumeng 00484669
  2020-09-19  3:13 ` [PATCH v2 2/3] crypto: hisilicon/hpre - adjust some coding style yumeng 00484669
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: yumeng 00484669 @ 2020-09-19  3:13 UTC (permalink / raw
  To: herbert, davem; +Cc: linux-crypto, xuzaibo, wangzhou1, yumeng18, linux-kernel

From: Meng Yu <yumeng18@huawei.com>

1. Remove unused member 'debug_root' in 'struct hpre_debug';
2. The u64 cast is redundant in 'cpu_to_le64'.

Fixes: 848974151618("crypto: hisilicon - Add debugfs for HPRE")
Fixes: dadbe4c11753("crypto: hisilicon/hpre - update debugfs ...")
Signed-off-by: Meng Yu <yumeng18@huawei.com>
Reviewed-by: Zaibo Xu <xuzaibo@huawei.com>
---
 drivers/crypto/hisilicon/hpre/hpre.h        | 1 -
 drivers/crypto/hisilicon/hpre/hpre_crypto.c | 8 ++++----
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/crypto/hisilicon/hpre/hpre.h b/drivers/crypto/hisilicon/hpre/hpre.h
index ed730d1..f69252b 100644
--- a/drivers/crypto/hisilicon/hpre/hpre.h
+++ b/drivers/crypto/hisilicon/hpre/hpre.h
@@ -56,7 +56,6 @@ struct hpre_dfx {
  * Just relevant for PF.
  */
 struct hpre_debug {
-	struct dentry *debug_root;
 	struct hpre_dfx dfx[HPRE_DFX_FILE_NUM];
 	struct hpre_debugfs_file files[HPRE_DEBUGFS_FILE_NUM];
 };
diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
index d685992..678a5ee 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
@@ -474,7 +474,7 @@ static int hpre_msg_request_set(struct hpre_ctx *ctx, void *req, bool is_rsa)
 		h_req->areq.dh = kreq;
 		msg = &h_req->req;
 		memset(msg, 0, sizeof(*msg));
-		msg->key = cpu_to_le64((u64)ctx->dh.dma_xa_p);
+		msg->key = cpu_to_le64(ctx->dh.dma_xa_p);
 	}
 
 	msg->dw0 |= cpu_to_le32(0x1 << HPRE_SQE_DONE_SHIFT);
@@ -740,7 +740,7 @@ static int hpre_rsa_enc(struct akcipher_request *req)
 		return ret;
 
 	msg->dw0 |= cpu_to_le32(HPRE_ALG_NC_NCRT);
-	msg->key = cpu_to_le64((u64)ctx->rsa.dma_pubkey);
+	msg->key = cpu_to_le64(ctx->rsa.dma_pubkey);
 
 	ret = hpre_hw_data_init(hpre_req, req->src, req->src_len, 1, 0);
 	if (unlikely(ret))
@@ -788,11 +788,11 @@ static int hpre_rsa_dec(struct akcipher_request *req)
 		return ret;
 
 	if (ctx->crt_g2_mode) {
-		msg->key = cpu_to_le64((u64)ctx->rsa.dma_crt_prikey);
+		msg->key = cpu_to_le64(ctx->rsa.dma_crt_prikey);
 		msg->dw0 = cpu_to_le32(le32_to_cpu(msg->dw0) |
 				       HPRE_ALG_NC_CRT);
 	} else {
-		msg->key = cpu_to_le64((u64)ctx->rsa.dma_prikey);
+		msg->key = cpu_to_le64(ctx->rsa.dma_prikey);
 		msg->dw0 = cpu_to_le32(le32_to_cpu(msg->dw0) |
 				       HPRE_ALG_NC_NCRT);
 	}
-- 
2.8.1


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

* [PATCH v2 2/3] crypto: hisilicon/hpre - adjust some coding style
  2020-09-19  3:13 [PATCH v2 0/3] crypto: hisilicon/hpre - misc clean up and fixes yumeng 00484669
  2020-09-19  3:13 ` [PATCH v2 1/3] crypto: hisilicon/hpre - remove useless code yumeng 00484669
@ 2020-09-19  3:13 ` yumeng 00484669
  2020-09-19  3:13 ` [PATCH v2 3/3] crypto: hisilicon/hpre - fix a bug in dh algorithm yumeng 00484669
  2020-09-25  8:17 ` [PATCH v2 0/3] crypto: hisilicon/hpre - misc clean up and fixes Herbert Xu
  3 siblings, 0 replies; 5+ messages in thread
From: yumeng 00484669 @ 2020-09-19  3:13 UTC (permalink / raw
  To: herbert, davem; +Cc: linux-crypto, xuzaibo, wangzhou1, yumeng18, linux-kernel

From: Meng Yu <yumeng18@huawei.com>

Adjust some coding style to make code aligned.

Signed-off-by: Meng Yu <yumeng18@huawei.com>
Reviewed-by: Zaibo Xu <xuzaibo@huawei.com>
---
 drivers/crypto/hisilicon/hpre/hpre_crypto.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
index 678a5ee..8bdaca0 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
@@ -188,8 +188,7 @@ static int hpre_get_data_dma_addr(struct hpre_asym_request *hpre_req,
 		hpre_req->dst = NULL;
 		dma_dir = DMA_FROM_DEVICE;
 	}
-	*tmp = dma_map_single(dev, sg_virt(data),
-			      len, dma_dir);
+	*tmp = dma_map_single(dev, sg_virt(data), len, dma_dir);
 	if (unlikely(dma_mapping_error(dev, *tmp))) {
 		dev_err(dev, "dma map data err!\n");
 		return -ENOMEM;
@@ -239,8 +238,8 @@ static int hpre_hw_data_init(struct hpre_asym_request *hpre_req,
 	    ((is_dh && !is_src) || !is_dh))
 		ret = hpre_get_data_dma_addr(hpre_req, data, len, is_src, &tmp);
 	else
-		ret = hpre_prepare_dma_buf(hpre_req, data, len,
-					  is_src, &tmp);
+		ret = hpre_prepare_dma_buf(hpre_req, data, len, is_src, &tmp);
+
 	if (unlikely(ret))
 		return ret;
 
@@ -267,11 +266,9 @@ static void hpre_hw_data_clr_all(struct hpre_ctx *ctx,
 
 	if (src) {
 		if (req->src)
-			dma_free_coherent(dev, ctx->key_sz,
-					  req->src, tmp);
+			dma_free_coherent(dev, ctx->key_sz, req->src, tmp);
 		else
-			dma_unmap_single(dev, tmp,
-					 ctx->key_sz, DMA_TO_DEVICE);
+			dma_unmap_single(dev, tmp, ctx->key_sz, DMA_TO_DEVICE);
 	}
 
 	tmp = le64_to_cpu(sqe->out);
-- 
2.8.1


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

* [PATCH v2 3/3] crypto: hisilicon/hpre - fix a bug in dh algorithm
  2020-09-19  3:13 [PATCH v2 0/3] crypto: hisilicon/hpre - misc clean up and fixes yumeng 00484669
  2020-09-19  3:13 ` [PATCH v2 1/3] crypto: hisilicon/hpre - remove useless code yumeng 00484669
  2020-09-19  3:13 ` [PATCH v2 2/3] crypto: hisilicon/hpre - adjust some coding style yumeng 00484669
@ 2020-09-19  3:13 ` yumeng 00484669
  2020-09-25  8:17 ` [PATCH v2 0/3] crypto: hisilicon/hpre - misc clean up and fixes Herbert Xu
  3 siblings, 0 replies; 5+ messages in thread
From: yumeng 00484669 @ 2020-09-19  3:13 UTC (permalink / raw
  To: herbert, davem; +Cc: linux-crypto, xuzaibo, wangzhou1, yumeng18, linux-kernel

From: Meng Yu <yumeng18@huawei.com>

Using 'g' not equal to 2 in dh algorithm may cause an error like this:

arm-smmu-v3 arm-smmu-v3.1.auto: event 0x10 received:
dh: Party A: generate public key test failed. err -22
11375.065672] dh alg: dh: test failed on vector 1, err=-22
arm-smmu-v3 arm-smmu-v3.1.auto:  0x0000790000000010
arm-smmu-v3 arm-smmu-v3.1.auto:  0x0000120800000080
hpre-dh self test failed
arm-smmu-v3 arm-smmu-v3.1.auto:  0x0000000000000000
arm-smmu-v3 arm-smmu-v3.1.auto:  0x0000000000000000
arm-smmu-v3 arm-smmu-v3.1.auto: event 0x10 received:
arm-smmu-v3 arm-smmu-v3.1.auto:  0x0000790000000010
arm-smmu-v3 arm-smmu-v3.1.auto:  0x0000120800000083
arm-smmu-v3 arm-smmu-v3.1.auto:  0x00000000000000c0
arm-smmu-v3 arm-smmu-v3.1.auto:  0x0000000000000000
arm-smmu-v3 arm-smmu-v3.1.auto: event 0x10 received:
arm-smmu-v3 arm-smmu-v3.1.auto:  0x0000790000000010
arm-smmu-v3 arm-smmu-v3.1.auto:  0x0000120800000081
arm-smmu-v3 arm-smmu-v3.1.auto:  0x0000000000000040
arm-smmu-v3 arm-smmu-v3.1.auto:  0x0000000000000000
arm-smmu-v3 arm-smmu-v3.1.auto: event 0x10 received:
arm-smmu-v3 arm-smmu-v3.1.auto:  0x0000790000000010
arm-smmu-v3 arm-smmu-v3.1.auto:  0x0000120800000082
arm-smmu-v3 arm-smmu-v3.1.auto:  0x0000000000000080
arm-smmu-v3 arm-smmu-v3.1.auto:  0x0000000000000000
hisi_hpre 0000:79:00.0: dat_rd_poison_int_set [error status=0x8] found
hisi_hpre 0000:79:00.0: ooo_rdrsp_err_int_set [error status=0xfc00] found
hisi_hpre 0000:79:00.0: Controller resetting...
hisi_hpre 0000:79:00.0: Controller reset complete
{2}[Hardware Error]: Hardware error from APEI Generic Hardware Error Source: 0
{2}[Hardware Error]: event severity: recoverable
{2}[Hardware Error]: Error 0, type: recoverable
{2}[Hardware Error]: section type: unknown, c8b328a8-9917-4af6-9a13-2e08ab2e7586
{2}[Hardware Error]: section length: 0x4c

as we missed initiating 'msg->in'.

Fixes: c8b4b477079d("crypto: hisilicon - add HiSilicon HPRE accelerator")
Signed-off-by: Meng Yu <yumeng18@huawei.com>
Reviewed-by: Zaibo Xu <xuzaibo@huawei.com>
---
 drivers/crypto/hisilicon/hpre/hpre_crypto.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
index 8bdaca0..a87f990 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
@@ -528,6 +528,8 @@ static int hpre_dh_compute_value(struct kpp_request *req)
 		ret = hpre_hw_data_init(hpre_req, req->src, req->src_len, 1, 1);
 		if (unlikely(ret))
 			goto clear_all;
+	} else {
+		msg->in = cpu_to_le64(ctx->dh.dma_g);
 	}
 
 	ret = hpre_hw_data_init(hpre_req, req->dst, req->dst_len, 0, 1);
-- 
2.8.1


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

* Re: [PATCH v2 0/3] crypto: hisilicon/hpre - misc clean up and fixes
  2020-09-19  3:13 [PATCH v2 0/3] crypto: hisilicon/hpre - misc clean up and fixes yumeng 00484669
                   ` (2 preceding siblings ...)
  2020-09-19  3:13 ` [PATCH v2 3/3] crypto: hisilicon/hpre - fix a bug in dh algorithm yumeng 00484669
@ 2020-09-25  8:17 ` Herbert Xu
  3 siblings, 0 replies; 5+ messages in thread
From: Herbert Xu @ 2020-09-25  8:17 UTC (permalink / raw
  To: yumeng 00484669; +Cc: davem, linux-crypto, xuzaibo, wangzhou1, linux-kernel

On Sat, Sep 19, 2020 at 11:13:49AM +0800, yumeng 00484669 wrote:
> Adjust some tiny coding problems and fix a bug of DH algorithm.
> 
> Changes since v1:
> Remove 'u64' cast in 'cpu_to_le64';
> 
> Meng Yu (3):
>   crypto: hisilicon/hpre - remove useless code
>   crypto: hisilicon/hpre - adjust some coding style
>   crypto: hisilicon/hpre - fix a bug in dh algorithm
> 
>  drivers/crypto/hisilicon/hpre/hpre.h        |  1 -
>  drivers/crypto/hisilicon/hpre/hpre_crypto.c | 23 +++++++++++------------
>  2 files changed, 11 insertions(+), 13 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] 5+ messages in thread

end of thread, other threads:[~2020-09-25  8:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-19  3:13 [PATCH v2 0/3] crypto: hisilicon/hpre - misc clean up and fixes yumeng 00484669
2020-09-19  3:13 ` [PATCH v2 1/3] crypto: hisilicon/hpre - remove useless code yumeng 00484669
2020-09-19  3:13 ` [PATCH v2 2/3] crypto: hisilicon/hpre - adjust some coding style yumeng 00484669
2020-09-19  3:13 ` [PATCH v2 3/3] crypto: hisilicon/hpre - fix a bug in dh algorithm yumeng 00484669
2020-09-25  8:17 ` [PATCH v2 0/3] crypto: hisilicon/hpre - misc clean up and fixes Herbert Xu

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.