Skip to contentSkip to conversation

crypto: rockchip: permit to pass self-tests

PATCH Superseded Corentin Labbe 3 participants 25 messages Feb 28, 2022 – Mar 2, 2022

Subsystems (4)

v1 of 10 Superseded Latest is v10 →

lore
Share & tools
lore

Corentin Labbe

author maintainer
#0 lore raw

cover crypto: rockchip: permit to pass self-tests

Hello

The rockchip crypto driver is broken and do not pass self-tests. This serie's goal is to permit to become usable and pass self-tests.

This whole serie is tested on a rk3328-rock64 with selftests (with CONFIG_CRYPTO_MANAGER_EXTRA_TESTS=y)

Regards

Corentin Labbe (16):
crypto: rockchip: use dev_err for error message about interrupt
crypto: rockchip: do not use uninit variable
crypto: rockchip: do not do custom power management
crypto: rockchip: fix privete/private typo
crypto: rockchip: do not store mode globally
crypto: rockchip: add fallback for cipher
crypto: rockchip: add fallback for ahash
crypto: rockchip: better handle cipher key
crypto: rockchip: remove non-aligned handling
crypto: rockchip: rework by using crypto_engine
crypto: rockhip: do not handle dma clock
ARM: dts: rk3288: crypto do not need dma clock
crypto: rockchip: rewrite type
crypto: rockchip: add debugfs
arm64: dts: rockchip: add rk3328 crypto node
crypto: rockchip: add myself as maintainer

 MAINTAINERS                                   |   6 +
 arch/arm/boot/dts/rk3288.dtsi                 |   4 +-
 arch/arm64/boot/dts/rockchip/rk3328.dtsi      |  12 +
 drivers/crypto/Kconfig                        |  10 +
 drivers/crypto/rockchip/rk3288_crypto.c       | 283 +++--------
 drivers/crypto/rockchip/rk3288_crypto.h       |  68 ++-
 drivers/crypto/rockchip/rk3288_crypto_ahash.c | 214 +++++----
 .../crypto/rockchip/rk3288_crypto_skcipher.c  | 449 +++++++++++-------
 8 files changed, 533 insertions(+), 513 deletions(-)
Signature · 7 lines
2.34.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
author maintainer
#1 lore raw

PATCH 1/16 crypto: rockchip: use dev_err for error message about interrupt

Interrupt is mandatory so the message should be printed as error.

---
 drivers/crypto/rockchip/rk3288_crypto.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/crypto/rockchip/rk3288_crypto.c +1 -2
index 35d73061d156..45cc5f766788 100644
@@ -371,8 +371,7 @@ static int rk_crypto_probe(struct platform_device *pdev)
 
 	crypto_info->irq = platform_get_irq(pdev, 0);
 	if (crypto_info->irq < 0) {
-		dev_warn(crypto_info->dev,
-			 "control Interrupt is not available.\n");
+		dev_err(&pdev->dev, "control Interrupt is not available.\n");
 		err = crypto_info->irq;
 		goto err_crypto;
 	}
Signature · 7 lines
2.34.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
author maintainer
#2 lore raw

PATCH 2/16 crypto: rockchip: do not use uninit variable

In reply to Corentin Labbe

crypto_info->dev is not yet set, so use pdev-dev instead.

---
 drivers/crypto/rockchip/rk3288_crypto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/rockchip/rk3288_crypto.c +1 -1
index 45cc5f766788..21d3f1458584 100644
@@ -381,7 +381,7 @@ static int rk_crypto_probe(struct platform_device *pdev)
 			       "rk-crypto", pdev);
 
 	if (err) {
-		dev_err(crypto_info->dev, "irq request failed.\n");
+		dev_err(&pdev->dev, "irq request failed.\n");
 		goto err_crypto;
 	}
 
Signature · 7 lines
2.34.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
author maintainer
#3 lore raw

PATCH 3/16 crypto: rockchip: do not do custom power management

In reply to Corentin Labbe

The clock enable/disable at tfm init/exit is fragile, if 2 tfm are init in the same time and one is removed just after, it will leave the hardware uncloked even if a user remains.

Instead simply enable clocks at probe time.
We will do PM later.

Fixes ce0183cb6464b ("crypto: rockchip - switch to skcipher API")
---
 drivers/crypto/rockchip/rk3288_crypto.c          | 4 ++--
 drivers/crypto/rockchip/rk3288_crypto.h          | 2 --
 drivers/crypto/rockchip/rk3288_crypto_ahash.c    | 3 +--
 drivers/crypto/rockchip/rk3288_crypto_skcipher.c | 5 +++--
 4 files changed, 6 insertions(+), 8 deletions(-)
drivers/crypto/rockchip/rk3288_crypto.c +2 -2
index 21d3f1458584..4cff49b82983 100644
@@ -394,8 +394,7 @@ static int rk_crypto_probe(struct platform_device *pdev)
 		     rk_crypto_done_task_cb, (unsigned long)crypto_info);
 	crypto_init_queue(&crypto_info->queue, 50);
 
-	crypto_info->enable_clk = rk_crypto_enable_clk;
-	crypto_info->disable_clk = rk_crypto_disable_clk;
+	rk_crypto_enable_clk(crypto_info);
 	crypto_info->load_data = rk_load_data;
 	crypto_info->unload_data = rk_unload_data;
 	crypto_info->enqueue = rk_crypto_enqueue;
@@ -422,6 +421,7 @@ static int rk_crypto_remove(struct platform_device *pdev)
 	struct rk_crypto_info *crypto_tmp = platform_get_drvdata(pdev);
 
 	rk_crypto_unregister();
+	rk_crypto_disable_clk(crypto_tmp);
 	tasklet_kill(&crypto_tmp->done_task);
 	tasklet_kill(&crypto_tmp->queue_task);
 	return 0;
drivers/crypto/rockchip/rk3288_crypto.h +0 -2
index 97278c2574ff..2fa7131e4060 100644
@@ -220,8 +220,6 @@ struct rk_crypto_info {
 	int (*start)(struct rk_crypto_info *dev);
 	int (*update)(struct rk_crypto_info *dev);
 	void (*complete)(struct crypto_async_request *base, int err);
-	int (*enable_clk)(struct rk_crypto_info *dev);
-	void (*disable_clk)(struct rk_crypto_info *dev);
 	int (*load_data)(struct rk_crypto_info *dev,
 			 struct scatterlist *sg_src,
 			 struct scatterlist *sg_dst);
drivers/crypto/rockchip/rk3288_crypto_ahash.c +1 -2
index ed03058497bc..49017d1fb510 100644
@@ -301,7 +301,7 @@ static int rk_cra_hash_init(struct crypto_tfm *tfm)
 				 sizeof(struct rk_ahash_rctx) +
 				 crypto_ahash_reqsize(tctx->fallback_tfm));
 
-	return tctx->dev->enable_clk(tctx->dev);
+	return 0;
 }
 
 static void rk_cra_hash_exit(struct crypto_tfm *tfm)
@@ -309,7 +309,6 @@ static void rk_cra_hash_exit(struct crypto_tfm *tfm)
 	struct rk_ahash_ctx *tctx = crypto_tfm_ctx(tfm);
 
 	free_page((unsigned long)tctx->dev->addr_vir);
-	return tctx->dev->disable_clk(tctx->dev);
 }
 
 struct rk_crypto_tmp rk_ahash_sha1 = {
drivers/crypto/rockchip/rk3288_crypto_skcipher.c +3 -2
index 5bbf0d2722e1..8c44a19eab75 100644
@@ -388,8 +388,10 @@ static int rk_ablk_init_tfm(struct crypto_skcipher *tfm)
 	ctx->dev->update = rk_ablk_rx;
 	ctx->dev->complete = rk_crypto_complete;
 	ctx->dev->addr_vir = (char *)__get_free_page(GFP_KERNEL);
+	if (!ctx->dev->addr_vir)
+		return -ENOMEM;
 
-	return ctx->dev->addr_vir ? ctx->dev->enable_clk(ctx->dev) : -ENOMEM;
+	return 0;
 }
 
 static void rk_ablk_exit_tfm(struct crypto_skcipher *tfm)
@@ -397,7 +399,6 @@ static void rk_ablk_exit_tfm(struct crypto_skcipher *tfm)
 	struct rk_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);
 
 	free_page((unsigned long)ctx->dev->addr_vir);
-	ctx->dev->disable_clk(ctx->dev);
 }
 
 struct rk_crypto_tmp rk_ecb_aes_alg = {
Signature · 7 lines
2.34.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
author maintainer
#4 lore raw

PATCH 4/16 crypto: rockchip: fix privete/private typo

In reply to Corentin Labbe

This fix a simple typo on private word.

---
 drivers/crypto/rockchip/rk3288_crypto.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/rockchip/rk3288_crypto.h +1 -1
index 2fa7131e4060..656d6795d400 100644
@@ -235,7 +235,7 @@ struct rk_ahash_ctx {
 	struct crypto_ahash		*fallback_tfm;
 };
 
-/* the privete variable of hash for fallback */
+/* the private variable of hash for fallback */
 struct rk_ahash_rctx {
 	struct ahash_request		fallback_req;
 	u32				mode;
Signature · 7 lines
2.34.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
author maintainer
#5 lore raw

PATCH 5/16 crypto: rockchip: do not store mode globally

In reply to Corentin Labbe

Storing the mode globally does not work if 2 requests are handled in the same time.
We should store it in a request context.

Fixes ce0183cb6464b ("crypto: rockchip - switch to skcipher API")
---
 drivers/crypto/rockchip/rk3288_crypto.h       |  5 +-
 .../crypto/rockchip/rk3288_crypto_skcipher.c  | 58 ++++++++++++-------
 2 files changed, 41 insertions(+), 22 deletions(-)
drivers/crypto/rockchip/rk3288_crypto.h +4 -1
index 656d6795d400..c919d9a43a08 100644
@@ -245,10 +245,13 @@ struct rk_ahash_rctx {
 struct rk_cipher_ctx {
 	struct rk_crypto_info		*dev;
 	unsigned int			keylen;
-	u32				mode;
 	u8				iv[AES_BLOCK_SIZE];
 };
 
+struct rk_cipher_rctx {
+	u32				mode;
+};
+
 enum alg_type {
 	ALG_TYPE_HASH,
 	ALG_TYPE_CIPHER,
drivers/crypto/rockchip/rk3288_crypto_skcipher.c +37 -21

208 lines not on this page · raw message

Signature · 7 lines
2.34.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
author maintainer
#6 lore raw

PATCH 6/16 crypto: rockchip: add fallback for cipher

In reply to Corentin Labbe

The hardware does not handle 0 size length request, let's add a fallback.
Furthermore fallback will be used for all unaligned case the hardware cannot handle.

Fixes ce0183cb6464b ("crypto: rockchip - switch to skcipher API")
---
 drivers/crypto/rockchip/rk3288_crypto.h       |   2 +
 .../crypto/rockchip/rk3288_crypto_skcipher.c  | 100 +++++++++++++++---
 2 files changed, 89 insertions(+), 13 deletions(-)
drivers/crypto/rockchip/rk3288_crypto.h +2 -0
index c919d9a43a08..8b1e15d8ddc6 100644
@@ -246,10 +246,12 @@ struct rk_cipher_ctx {
 	struct rk_crypto_info		*dev;
 	unsigned int			keylen;
 	u8				iv[AES_BLOCK_SIZE];
+	struct crypto_skcipher *fallback_tfm;
 };
 
 struct rk_cipher_rctx {
 	u32				mode;
+	struct skcipher_request fallback_req;   // keep at the end
 };
 
 enum alg_type {
drivers/crypto/rockchip/rk3288_crypto_skcipher.c +87 -13

178 lines not on this page · raw message

Signature · 7 lines
2.34.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
author maintainer
#7 lore raw

PATCH 7/16 crypto: rockchip: add fallback for ahash

In reply to Corentin Labbe

Adds a fallback for all case hardware cannot handle.

Fixes ce0183cb6464b ("crypto: rockchip - switch to skcipher API")
---
 drivers/crypto/rockchip/rk3288_crypto_ahash.c | 37 +++++++++++++++++++
 1 file changed, 37 insertions(+)
drivers/crypto/rockchip/rk3288_crypto_ahash.c +37 -0
index 49017d1fb510..417cf4487514 100644
@@ -16,6 +16,40 @@
  * so we put the fixed hash out when met zero message.
  */
 
+static bool rk_ahash_need_fallback(struct ahash_request *req)
+{
+	struct scatterlist *sg;
+
+	sg = req->src;
+	while (sg) {
+		if (!IS_ALIGNED(sg->offset, sizeof(u32))) {
+			return true;
+		}
+		if (sg->length % 4) {
+			return true;
+		}
+		sg = sg_next(sg);
+	}
+	return false;
+}
+
+static int rk_ahash_digest_fb(struct ahash_request *areq)
+{
+	struct rk_ahash_rctx *rctx = ahash_request_ctx(areq);
+	struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq);
+	struct rk_ahash_ctx *tfmctx = crypto_ahash_ctx(tfm);
+
+	ahash_request_set_tfm(&rctx->fallback_req, tfmctx->fallback_tfm);
+	rctx->fallback_req.base.flags = areq->base.flags &
+					CRYPTO_TFM_REQ_MAY_SLEEP;
+
+	rctx->fallback_req.nbytes = areq->nbytes;
+	rctx->fallback_req.src = areq->src;
+	rctx->fallback_req.result = areq->result;
+
+	return crypto_ahash_digest(&rctx->fallback_req);
+}
+
 static int zero_message_process(struct ahash_request *req)
 {
 	struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
@@ -167,6 +201,9 @@ static int rk_ahash_digest(struct ahash_request *req)
 	struct rk_ahash_ctx *tctx = crypto_tfm_ctx(req->base.tfm);
 	struct rk_crypto_info *dev = tctx->dev;
 
+	if (rk_ahash_need_fallback(req))
+		return rk_ahash_digest_fb(req);
+
 	if (!req->nbytes)
 		return zero_message_process(req);
 	else
Signature · 7 lines
2.34.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
author maintainer
#8 lore raw

PATCH 8/16 crypto: rockchip: better handle cipher key

In reply to Corentin Labbe

The key should not be set in hardware too much in advance, this will fail it 2 TFM with different keys generate alternative requests. The key should be stored and used just before doing cipher operations.

Fixes ce0183cb6464b ("crypto: rockchip - switch to skcipher API")
---
 drivers/crypto/rockchip/rk3288_crypto.h          | 1 +
 drivers/crypto/rockchip/rk3288_crypto_skcipher.c | 9 ++++++---
 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/crypto/rockchip/rk3288_crypto.h +1 -0
index 8b1e15d8ddc6..826508e4a0c3 100644
@@ -245,6 +245,7 @@ struct rk_ahash_rctx {
 struct rk_cipher_ctx {
 	struct rk_crypto_info		*dev;
 	unsigned int			keylen;
+	u32 key[AES_MAX_KEY_SIZE / 4];
 	u8				iv[AES_BLOCK_SIZE];
 	struct crypto_skcipher *fallback_tfm;
 };
drivers/crypto/rockchip/rk3288_crypto_skcipher.c +6 -3
index 060d52f18b31..cc817d361fda 100644
@@ -95,7 +95,7 @@ static int rk_aes_setkey(struct crypto_skcipher *cipher,
 	    keylen != AES_KEYSIZE_256)
 		return -EINVAL;
 	ctx->keylen = keylen;
-	memcpy_toio(ctx->dev->reg + RK_CRYPTO_AES_KEY_0, key, keylen);
+	memcpy(ctx->key, key, keylen);
 
 	return crypto_skcipher_setkey(ctx->fallback_tfm, key, keylen);
 }
@@ -111,7 +111,7 @@ static int rk_des_setkey(struct crypto_skcipher *cipher,
 		return err;
 
 	ctx->keylen = keylen;
-	memcpy_toio(ctx->dev->reg + RK_CRYPTO_TDES_KEY1_0, key, keylen);
+	memcpy(ctx->key, key, keylen);
 
 	return crypto_skcipher_setkey(ctx->fallback_tfm, key, keylen);
 }
@@ -127,7 +127,8 @@ static int rk_tdes_setkey(struct crypto_skcipher *cipher,
 		return err;
 
 	ctx->keylen = keylen;
-	memcpy_toio(ctx->dev->reg + RK_CRYPTO_TDES_KEY1_0, key, keylen);
+	memcpy(ctx->key, key, keylen);
+
 	return crypto_skcipher_setkey(ctx->fallback_tfm, key, keylen);
 }
 
@@ -283,6 +284,7 @@ static void rk_ablk_hw_init(struct rk_crypto_info *dev)
 			     RK_CRYPTO_TDES_BYTESWAP_IV;
 		CRYPTO_WRITE(dev, RK_CRYPTO_TDES_CTRL, rctx->mode);
 		memcpy_toio(dev->reg + RK_CRYPTO_TDES_IV_0, req->iv, ivsize);
+		memcpy_toio(ctx->dev->reg + RK_CRYPTO_TDES_KEY1_0, ctx->key, ctx->keylen);
 		conf_reg = RK_CRYPTO_DESSEL;
 	} else {
 		rctx->mode |= RK_CRYPTO_AES_FIFO_MODE |
@@ -295,6 +297,7 @@ static void rk_ablk_hw_init(struct rk_crypto_info *dev)
 			rctx->mode |= RK_CRYPTO_AES_256BIT_key;
 		CRYPTO_WRITE(dev, RK_CRYPTO_AES_CTRL, rctx->mode);
 		memcpy_toio(dev->reg + RK_CRYPTO_AES_IV_0, req->iv, ivsize);
+		memcpy_toio(ctx->dev->reg + RK_CRYPTO_AES_KEY_0, ctx->key, ctx->keylen);
 	}
 	conf_reg |= RK_CRYPTO_BYTESWAP_BTFIFO |
 		    RK_CRYPTO_BYTESWAP_BRFIFO;
Signature · 7 lines
2.34.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
author maintainer
#9 lore raw

PATCH 9/16 crypto: rockchip: remove non-aligned handling

In reply to Corentin Labbe

Now driver have fallback for un-aligned cases, remove all code handling those cases.

Fixes ce0183cb6464b ("crypto: rockchip - switch to skcipher API")
---
 drivers/crypto/rockchip/rk3288_crypto.c       | 69 +++++--------------
 drivers/crypto/rockchip/rk3288_crypto.h       |  4 --
 drivers/crypto/rockchip/rk3288_crypto_ahash.c | 23 ++-----
 .../crypto/rockchip/rk3288_crypto_skcipher.c  | 40 +++--------
 4 files changed, 31 insertions(+), 105 deletions(-)
drivers/crypto/rockchip/rk3288_crypto.c +16 -53
index 4cff49b82983..b3db096e2ec2 100644
@@ -88,63 +88,26 @@ static int rk_load_data(struct rk_crypto_info *dev,
 {
 	unsigned int count;
 
-	dev->aligned = dev->aligned ?
-		check_alignment(sg_src, sg_dst, dev->align_size) :
-		dev->aligned;
-	if (dev->aligned) {
-		count = min(dev->left_bytes, sg_src->length);
-		dev->left_bytes -= count;
-
-		if (!dma_map_sg(dev->dev, sg_src, 1, DMA_TO_DEVICE)) {
-			dev_err(dev->dev, "[%s:%d] dma_map_sg(src)  error\n",
+	count = min(dev->left_bytes, sg_src->length);
+	dev->left_bytes -= count;
+
+	if (!dma_map_sg(dev->dev, sg_src, 1, DMA_TO_DEVICE)) {
+		dev_err(dev->dev, "[%s:%d] dma_map_sg(src)  error\n",
 				__func__, __LINE__);
-			return -EINVAL;
-		}
-		dev->addr_in = sg_dma_address(sg_src);
+		return -EINVAL;
+	}
+	dev->addr_in = sg_dma_address(sg_src);
 
-		if (sg_dst) {
-			if (!dma_map_sg(dev->dev, sg_dst, 1, DMA_FROM_DEVICE)) {
-				dev_err(dev->dev,
+	if (sg_dst) {
+		if (!dma_map_sg(dev->dev, sg_dst, 1, DMA_FROM_DEVICE)) {
+			dev_err(dev->dev,
 					"[%s:%d] dma_map_sg(dst)  error\n",
 					__func__, __LINE__);
-				dma_unmap_sg(dev->dev, sg_src, 1,
-					     DMA_TO_DEVICE);
-				return -EINVAL;
-			}
-			dev->addr_out = sg_dma_address(sg_dst);
-		}
-	} else {
-		count = (dev->left_bytes > PAGE_SIZE) ?
-			PAGE_SIZE : dev->left_bytes;
-
-		if (!sg_pcopy_to_buffer(dev->first, dev->src_nents,
-					dev->addr_vir, count,
-					dev->total - dev->left_bytes)) {
-			dev_err(dev->dev, "[%s:%d] pcopy err\n",
-				__func__, __LINE__);
+			dma_unmap_sg(dev->dev, sg_src, 1,
+					DMA_TO_DEVICE);
 			return -EINVAL;
 		}
-		dev->left_bytes -= count;
-		sg_init_one(&dev->sg_tmp, dev->addr_vir, count);
-		if (!dma_map_sg(dev->dev, &dev->sg_tmp, 1, DMA_TO_DEVICE)) {
-			dev_err(dev->dev, "[%s:%d] dma_map_sg(sg_tmp)  error\n",
-				__func__, __LINE__);
-			return -ENOMEM;
-		}
-		dev->addr_in = sg_dma_address(&dev->sg_tmp);
-
-		if (sg_dst) {
-			if (!dma_map_sg(dev->dev, &dev->sg_tmp, 1,
-					DMA_FROM_DEVICE)) {
-				dev_err(dev->dev,
-					"[%s:%d] dma_map_sg(sg_tmp)  error\n",
-					__func__, __LINE__);
-				dma_unmap_sg(dev->dev, &dev->sg_tmp, 1,
-					     DMA_TO_DEVICE);
-				return -ENOMEM;
-			}
-			dev->addr_out = sg_dma_address(&dev->sg_tmp);
-		}
+		dev->addr_out = sg_dma_address(sg_dst);
 	}
 	dev->count = count;
 	return 0;
@@ -154,11 +117,11 @@ static void rk_unload_data(struct rk_crypto_info *dev)
 {
 	struct scatterlist *sg_in, *sg_out;
 
-	sg_in = dev->aligned ? dev->sg_src : &dev->sg_tmp;
+	sg_in = dev->sg_src;
 	dma_unmap_sg(dev->dev, sg_in, 1, DMA_TO_DEVICE);
 
 	if (dev->sg_dst) {
-		sg_out = dev->aligned ? dev->sg_dst : &dev->sg_tmp;
+		sg_out = dev->sg_dst;
 		dma_unmap_sg(dev->dev, sg_out, 1, DMA_FROM_DEVICE);
 	}
 }
drivers/crypto/rockchip/rk3288_crypto.h +0 -4
index 826508e4a0c3..d35b84071935 100644
@@ -204,12 +204,8 @@ struct rk_crypto_info {
 	/* the public variable */
 	struct scatterlist		*sg_src;
 	struct scatterlist		*sg_dst;
-	struct scatterlist		sg_tmp;
 	struct scatterlist		*first;
 	unsigned int			left_bytes;
-	void				*addr_vir;
-	int				aligned;
-	int				align_size;
 	size_t				src_nents;
 	size_t				dst_nents;
 	unsigned int			total;
drivers/crypto/rockchip/rk3288_crypto_ahash.c +6 -17
index 417cf4487514..6030c03a1726 100644
@@ -236,8 +236,6 @@ static int rk_ahash_start(struct rk_crypto_info *dev)
 
 	dev->total = req->nbytes;
 	dev->left_bytes = req->nbytes;
-	dev->aligned = 0;
-	dev->align_size = 4;
 	dev->sg_dst = NULL;
 	dev->sg_src = req->src;
 	dev->first = req->src;
@@ -272,15 +270,13 @@ static int rk_ahash_crypto_rx(struct rk_crypto_info *dev)
 
 	dev->unload_data(dev);
 	if (dev->left_bytes) {
-		if (dev->aligned) {
-			if (sg_is_last(dev->sg_src)) {
-				dev_warn(dev->dev, "[%s:%d], Lack of data\n",
-					 __func__, __LINE__);
-				err = -ENOMEM;
-				goto out_rx;
-			}
-			dev->sg_src = sg_next(dev->sg_src);
+		if (sg_is_last(dev->sg_src)) {
+			dev_warn(dev->dev, "[%s:%d], Lack of data\n",
+					__func__, __LINE__);
+			err = -ENOMEM;
+			goto out_rx;
 		}
+		dev->sg_src = sg_next(dev->sg_src);
 		err = rk_ahash_set_data_start(dev);
 	} else {
 		/*
@@ -318,11 +314,6 @@ static int rk_cra_hash_init(struct crypto_tfm *tfm)
 	algt = container_of(alg, struct rk_crypto_tmp, alg.hash);
 
 	tctx->dev = algt->dev;
-	tctx->dev->addr_vir = (void *)__get_free_page(GFP_KERNEL);
-	if (!tctx->dev->addr_vir) {
-		dev_err(tctx->dev->dev, "failed to kmalloc for addr_vir\n");
-		return -ENOMEM;
-	}
 	tctx->dev->start = rk_ahash_start;
 	tctx->dev->update = rk_ahash_crypto_rx;
 	tctx->dev->complete = rk_ahash_crypto_complete;
@@ -344,8 +335,6 @@ static int rk_cra_hash_init(struct crypto_tfm *tfm)
 static void rk_cra_hash_exit(struct crypto_tfm *tfm)
 {
 	struct rk_ahash_ctx *tctx = crypto_tfm_ctx(tfm);
-
-	free_page((unsigned long)tctx->dev->addr_vir);
 }
 
 struct rk_crypto_tmp rk_ahash_sha1 = {
drivers/crypto/rockchip/rk3288_crypto_skcipher.c +9 -31
index cc817d361fda..cef9621ac189 100644
@@ -356,7 +356,6 @@ static int rk_ablk_start(struct rk_crypto_info *dev)
 	dev->src_nents = sg_nents(req->src);
 	dev->sg_dst = req->dst;
 	dev->dst_nents = sg_nents(req->dst);
-	dev->aligned = 1;
 
 	spin_lock_irqsave(&dev->lock, flags);
 	rk_ablk_hw_init(dev);
@@ -376,13 +375,9 @@ static void rk_iv_copyback(struct rk_crypto_info *dev)
 
 	/* Update the IV buffer to contain the next IV for encryption mode. */
 	if (!(rctx->mode & RK_CRYPTO_DEC)) {
-		if (dev->aligned) {
-			memcpy(req->iv, sg_virt(dev->sg_dst) +
-				dev->sg_dst->length - ivsize, ivsize);
-		} else {
-			memcpy(req->iv, dev->addr_vir +
-				dev->count - ivsize, ivsize);
-		}
+		memcpy(req->iv,
+		       sg_virt(dev->sg_dst) + dev->sg_dst->length - ivsize,
+		       ivsize);
 	}
 }
 
@@ -420,27 +415,16 @@ static int rk_ablk_rx(struct rk_crypto_info *dev)
 		skcipher_request_cast(dev->async_req);
 
 	dev->unload_data(dev);
-	if (!dev->aligned) {
-		if (!sg_pcopy_from_buffer(req->dst, dev->dst_nents,
-					  dev->addr_vir, dev->count,
-					  dev->total - dev->left_bytes -
-					  dev->count)) {
-			err = -EINVAL;
-			goto out_rx;
-		}
-	}
 	if (dev->left_bytes) {
 		rk_update_iv(dev);
-		if (dev->aligned) {
-			if (sg_is_last(dev->sg_src)) {
-				dev_err(dev->dev, "[%s:%d] Lack of data\n",
+		if (sg_is_last(dev->sg_src)) {
+			dev_err(dev->dev, "[%s:%d] Lack of data\n",
 					__func__, __LINE__);
-				err = -ENOMEM;
-				goto out_rx;
-			}
-			dev->sg_src = sg_next(dev->sg_src);
-			dev->sg_dst = sg_next(dev->sg_dst);
+			err = -ENOMEM;
+			goto out_rx;
 		}
+		dev->sg_src = sg_next(dev->sg_src);
+		dev->sg_dst = sg_next(dev->sg_dst);
 		err = rk_set_data_start(dev);
 	} else {
 		rk_iv_copyback(dev);
@@ -462,13 +446,9 @@ static int rk_ablk_init_tfm(struct crypto_skcipher *tfm)
 	algt = container_of(alg, struct rk_crypto_tmp, alg.skcipher);
 
 	ctx->dev = algt->dev;
-	ctx->dev->align_size = crypto_tfm_alg_alignmask(crypto_skcipher_tfm(tfm)) + 1;
 	ctx->dev->start = rk_ablk_start;
 	ctx->dev->update = rk_ablk_rx;
 	ctx->dev->complete = rk_crypto_complete;
-	ctx->dev->addr_vir = (char *)__get_free_page(GFP_KERNEL);
-	if (!ctx->dev->addr_vir)
-		return -ENOMEM;
 
 	ctx->fallback_tfm = crypto_alloc_skcipher(name, 0, CRYPTO_ALG_NEED_FALLBACK);
 	if (IS_ERR(ctx->fallback_tfm)) {
@@ -490,8 +470,6 @@ static int rk_ablk_init_tfm(struct crypto_skcipher *tfm)
 static void rk_ablk_exit_tfm(struct crypto_skcipher *tfm)
 {
 	struct rk_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);
-
-	free_page((unsigned long)ctx->dev->addr_vir);
 }
 
 struct rk_crypto_tmp rk_ecb_aes_alg = {
Signature · 7 lines
2.34.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
author maintainer
#15 lore raw

PATCH 11/16 crypto: rockhip: do not handle dma clock

In reply to Corentin Labbe

The DMA clock is handled by the DMA controller, so the crypto does not have to touch it.

---
 drivers/crypto/rockchip/rk3288_crypto.c | 16 +---------------
 drivers/crypto/rockchip/rk3288_crypto.h |  1 -
 2 files changed, 1 insertion(+), 16 deletions(-)
drivers/crypto/rockchip/rk3288_crypto.c +1 -15
index 94ef1283789f..645855d2651b 100644
@@ -40,15 +40,8 @@ static int rk_crypto_enable_clk(struct rk_crypto_info *dev)
 			__func__, __LINE__);
 		goto err_hclk;
 	}
-	err = clk_prepare_enable(dev->dmaclk);
-	if (err) {
-		dev_err(dev->dev, "[%s:%d], Couldn't enable clock dmaclk\n",
-			__func__, __LINE__);
-		goto err_dmaclk;
-	}
+
 	return err;
-err_dmaclk:
-	clk_disable_unprepare(dev->hclk);
 err_hclk:
 	clk_disable_unprepare(dev->aclk);
 err_aclk:
@@ -59,7 +52,6 @@ static int rk_crypto_enable_clk(struct rk_crypto_info *dev)
 
 static void rk_crypto_disable_clk(struct rk_crypto_info *dev)
 {
-	clk_disable_unprepare(dev->dmaclk);
 	clk_disable_unprepare(dev->hclk);
 	clk_disable_unprepare(dev->aclk);
 	clk_disable_unprepare(dev->sclk);
@@ -199,12 +191,6 @@ static int rk_crypto_probe(struct platform_device *pdev)
 		goto err_crypto;
 	}
 
-	crypto_info->dmaclk = devm_clk_get(&pdev->dev, "apb_pclk");
-	if (IS_ERR(crypto_info->dmaclk)) {
-		err = PTR_ERR(crypto_info->dmaclk);
-		goto err_crypto;
-	}
-
 	crypto_info->irq = platform_get_irq(pdev, 0);
 	if (crypto_info->irq < 0) {
 		dev_err(&pdev->dev, "control Interrupt is not available.\n");
drivers/crypto/rockchip/rk3288_crypto.h +0 -1
index c741e97057dc..963fbfc4d14e 100644
@@ -191,7 +191,6 @@ struct rk_crypto_info {
 	struct clk			*aclk;
 	struct clk			*hclk;
 	struct clk			*sclk;
-	struct clk			*dmaclk;
 	struct reset_control		*rst;
 	void __iomem			*reg;
 	int				irq;
Signature · 7 lines
2.34.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author maintainer
#16 lore raw

PATCH 12/16 ARM: dts: rk3288: crypto do not need dma clock

In reply to Corentin Labbe

The DMA clock is already enabled by DMA and so crypto does not need to handle it.

---
 arch/arm/boot/dts/rk3288.dtsi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/boot/dts/rk3288.dtsi +2 -2
index 26b9bbe310af..64be7d4a2d39 100644
@@ -976,8 +976,8 @@ crypto: crypto@ff8a0000 {
 		reg = <0x0 0xff8a0000 0x0 0x4000>;
 		interrupts = <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&cru ACLK_CRYPTO>, <&cru HCLK_CRYPTO>,
-			 <&cru SCLK_CRYPTO>, <&cru ACLK_DMAC1>;
-		clock-names = "aclk", "hclk", "sclk", "apb_pclk";
+			 <&cru SCLK_CRYPTO>;
+		clock-names = "aclk", "hclk", "sclk";
 		resets = <&cru SRST_CRYPTO>;
 		reset-names = "crypto-rst";
 	};
Signature · 7 lines
2.34.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
author maintainer
#10 lore raw

PATCH 10/16 crypto: rockchip: rework by using crypto_engine

In reply to Corentin Labbe

Instead of doing manual queue management, let's use the crypto/engine for that.
In the same time, rework the requests handling to be easier to understand (and fix all bugs related to them).

Fixes ce0183cb6464b ("crypto: rockchip - switch to skcipher API")
---
 drivers/crypto/rockchip/rk3288_crypto.c       | 150 +---------
 drivers/crypto/rockchip/rk3288_crypto.h       |  39 +--
 drivers/crypto/rockchip/rk3288_crypto_ahash.c | 147 +++++-----
 .../crypto/rockchip/rk3288_crypto_skcipher.c  | 256 +++++++++---------
 4 files changed, 227 insertions(+), 365 deletions(-)
drivers/crypto/rockchip/rk3288_crypto.c +7 -143
index b3db096e2ec2..94ef1283789f 100644
@@ -65,149 +65,24 @@ static void rk_crypto_disable_clk(struct rk_crypto_info *dev)
 	clk_disable_unprepare(dev->sclk);
 }
 
-static int check_alignment(struct scatterlist *sg_src,
-			   struct scatterlist *sg_dst,
-			   int align_mask)
-{
-	int in, out, align;
-
-	in = IS_ALIGNED((uint32_t)sg_src->offset, 4) &&
-	     IS_ALIGNED((uint32_t)sg_src->length, align_mask);
-	if (!sg_dst)
-		return in;
-	out = IS_ALIGNED((uint32_t)sg_dst->offset, 4) &&
-	      IS_ALIGNED((uint32_t)sg_dst->length, align_mask);
-	align = in && out;
-
-	return (align && (sg_src->length == sg_dst->length));
-}
-
-static int rk_load_data(struct rk_crypto_info *dev,
-			struct scatterlist *sg_src,
-			struct scatterlist *sg_dst)
-{
-	unsigned int count;
-
-	count = min(dev->left_bytes, sg_src->length);
-	dev->left_bytes -= count;
-
-	if (!dma_map_sg(dev->dev, sg_src, 1, DMA_TO_DEVICE)) {
-		dev_err(dev->dev, "[%s:%d] dma_map_sg(src)  error\n",
-				__func__, __LINE__);
-		return -EINVAL;
-	}
-	dev->addr_in = sg_dma_address(sg_src);
-
-	if (sg_dst) {
-		if (!dma_map_sg(dev->dev, sg_dst, 1, DMA_FROM_DEVICE)) {
-			dev_err(dev->dev,
-					"[%s:%d] dma_map_sg(dst)  error\n",
-					__func__, __LINE__);
-			dma_unmap_sg(dev->dev, sg_src, 1,
-					DMA_TO_DEVICE);
-			return -EINVAL;
-		}
-		dev->addr_out = sg_dma_address(sg_dst);
-	}
-	dev->count = count;
-	return 0;
-}
-
-static void rk_unload_data(struct rk_crypto_info *dev)
-{
-	struct scatterlist *sg_in, *sg_out;
-
-	sg_in = dev->sg_src;
-	dma_unmap_sg(dev->dev, sg_in, 1, DMA_TO_DEVICE);
-
-	if (dev->sg_dst) {
-		sg_out = dev->sg_dst;
-		dma_unmap_sg(dev->dev, sg_out, 1, DMA_FROM_DEVICE);
-	}
-}
-
 static irqreturn_t rk_crypto_irq_handle(int irq, void *dev_id)
 {
 	struct rk_crypto_info *dev  = platform_get_drvdata(dev_id);
 	u32 interrupt_status;
 
-	spin_lock(&dev->lock);
 	interrupt_status = CRYPTO_READ(dev, RK_CRYPTO_INTSTS);
 	CRYPTO_WRITE(dev, RK_CRYPTO_INTSTS, interrupt_status);
 
+	dev->status = 1;
 	if (interrupt_status & 0x0a) {
 		dev_warn(dev->dev, "DMA Error\n");
-		dev->err = -EFAULT;
+		dev->status = 0;
 	}
-	tasklet_schedule(&dev->done_task);
+	complete(&dev->complete);
 
-	spin_unlock(&dev->lock);
 	return IRQ_HANDLED;
 }
 
-static int rk_crypto_enqueue(struct rk_crypto_info *dev,
-			      struct crypto_async_request *async_req)
-{
-	unsigned long flags;
-	int ret;
-
-	spin_lock_irqsave(&dev->lock, flags);
-	ret = crypto_enqueue_request(&dev->queue, async_req);
-	if (dev->busy) {
-		spin_unlock_irqrestore(&dev->lock, flags);
-		return ret;
-	}
-	dev->busy = true;
-	spin_unlock_irqrestore(&dev->lock, flags);
-	tasklet_schedule(&dev->queue_task);
-
-	return ret;
-}
-
-static void rk_crypto_queue_task_cb(unsigned long data)
-{
-	struct rk_crypto_info *dev = (struct rk_crypto_info *)data;
-	struct crypto_async_request *async_req, *backlog;
-	unsigned long flags;
-	int err = 0;
-
-	dev->err = 0;
-	spin_lock_irqsave(&dev->lock, flags);
-	backlog   = crypto_get_backlog(&dev->queue);
-	async_req = crypto_dequeue_request(&dev->queue);
-
-	if (!async_req) {
-		dev->busy = false;
-		spin_unlock_irqrestore(&dev->lock, flags);
-		return;
-	}
-	spin_unlock_irqrestore(&dev->lock, flags);
-
-	if (backlog) {
-		backlog->complete(backlog, -EINPROGRESS);
-		backlog = NULL;
-	}
-
-	dev->async_req = async_req;
-	err = dev->start(dev);
-	if (err)
-		dev->complete(dev->async_req, err);
-}
-
-static void rk_crypto_done_task_cb(unsigned long data)
-{
-	struct rk_crypto_info *dev = (struct rk_crypto_info *)data;
-
-	if (dev->err) {
-		dev->complete(dev->async_req, dev->err);
-		return;
-	}
-
-	dev->err = dev->update(dev);
-	if (dev->err)
-		dev->complete(dev->async_req, dev->err);
-}
-
 static struct rk_crypto_tmp *rk_cipher_algs[] = {
 	&rk_ecb_aes_alg,
 	&rk_cbc_aes_alg,
@@ -300,8 +175,6 @@ static int rk_crypto_probe(struct platform_device *pdev)
 	if (err)
 		goto err_crypto;
 
-	spin_lock_init(&crypto_info->lock);
-
 	crypto_info->reg = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(crypto_info->reg)) {
 		err = PTR_ERR(crypto_info->reg);
@@ -351,17 +224,11 @@ static int rk_crypto_probe(struct platform_device *pdev)
 	crypto_info->dev = &pdev->dev;
 	platform_set_drvdata(pdev, crypto_info);
 
-	tasklet_init(&crypto_info->queue_task,
-		     rk_crypto_queue_task_cb, (unsigned long)crypto_info);
-	tasklet_init(&crypto_info->done_task,
-		     rk_crypto_done_task_cb, (unsigned long)crypto_info);
-	crypto_init_queue(&crypto_info->queue, 50);
+	crypto_info->engine = crypto_engine_alloc_init(&pdev->dev, true);
+	crypto_engine_start(crypto_info->engine);
+	init_completion(&crypto_info->complete);
 
 	rk_crypto_enable_clk(crypto_info);
-	crypto_info->load_data = rk_load_data;
-	crypto_info->unload_data = rk_unload_data;
-	crypto_info->enqueue = rk_crypto_enqueue;
-	crypto_info->busy = false;
 
 	err = rk_crypto_register(crypto_info);
 	if (err) {
@@ -373,9 +240,8 @@ static int rk_crypto_probe(struct platform_device *pdev)
 	return 0;
 
 err_register_alg:
-	tasklet_kill(&crypto_info->queue_task);
-	tasklet_kill(&crypto_info->done_task);
 err_crypto:
+	dev_err(dev, "Crypto Accelerator not successfully registered\n");
 	return err;
 }
 
@@ -385,8 +251,6 @@ static int rk_crypto_remove(struct platform_device *pdev)
 
 	rk_crypto_unregister();
 	rk_crypto_disable_clk(crypto_tmp);
-	tasklet_kill(&crypto_tmp->done_task);
-	tasklet_kill(&crypto_tmp->queue_task);
 	return 0;
 }
 
drivers/crypto/rockchip/rk3288_crypto.h +10 -29
index d35b84071935..c741e97057dc 100644
@@ -5,9 +5,11 @@
 #include <crypto/aes.h>
 #include <crypto/internal/des.h>
 #include <crypto/algapi.h>
+#include <linux/dma-mapping.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/scatterlist.h>
+#include <crypto/engine.h>
 #include <crypto/internal/hash.h>
 #include <crypto/internal/skcipher.h>
 
@@ -193,39 +195,15 @@ struct rk_crypto_info {
 	struct reset_control		*rst;
 	void __iomem			*reg;
 	int				irq;
-	struct crypto_queue		queue;
-	struct tasklet_struct		queue_task;
-	struct tasklet_struct		done_task;
-	struct crypto_async_request	*async_req;
-	int 				err;
-	/* device lock */
-	spinlock_t			lock;
-
-	/* the public variable */
-	struct scatterlist		*sg_src;
-	struct scatterlist		*sg_dst;
-	struct scatterlist		*first;
-	unsigned int			left_bytes;
-	size_t				src_nents;
-	size_t				dst_nents;
-	unsigned int			total;
-	unsigned int			count;
-	dma_addr_t			addr_in;
-	dma_addr_t			addr_out;
-	bool				busy;
-	int (*start)(struct rk_crypto_info *dev);
-	int (*update)(struct rk_crypto_info *dev);
-	void (*complete)(struct crypto_async_request *base, int err);
-	int (*load_data)(struct rk_crypto_info *dev,
-			 struct scatterlist *sg_src,
-			 struct scatterlist *sg_dst);
-	void (*unload_data)(struct rk_crypto_info *dev);
-	int (*enqueue)(struct rk_crypto_info *dev,
-		       struct crypto_async_request *async_req);
+
+	struct crypto_engine *engine;
+	struct completion complete;
+	int status;
 };
 
 /* the private variable of hash */
 struct rk_ahash_ctx {
+	struct crypto_engine_ctx enginectx;
 	struct rk_crypto_info		*dev;
 	/* for fallback */
 	struct crypto_ahash		*fallback_tfm;
@@ -235,10 +213,12 @@ struct rk_ahash_ctx {
 struct rk_ahash_rctx {
 	struct ahash_request		fallback_req;
 	u32				mode;
+	int nrsg;
 };
 
 /* the private variable of cipher */
 struct rk_cipher_ctx {
+	struct crypto_engine_ctx enginectx;
 	struct rk_crypto_info		*dev;
 	unsigned int			keylen;
 	u32 key[AES_MAX_KEY_SIZE / 4];
@@ -247,6 +227,7 @@ struct rk_cipher_ctx {
 };
 
 struct rk_cipher_rctx {
+	u8 backup_iv[AES_BLOCK_SIZE];
 	u32				mode;
 	struct skcipher_request fallback_req;   // keep at the end
 };
drivers/crypto/rockchip/rk3288_crypto_ahash.c +81 -66

221 lines not on this page · raw message

drivers/crypto/rockchip/rk3288_crypto_skcipher.c +129 -127

334 lines not on this page · raw message

Signature · 1 line
2.34.1
author maintainer
#21 lore raw

PATCH 15/16 arm64: dts: rockchip: add rk3328 crypto node

In reply to Corentin Labbe

rk3328 has a crypto IP handled by the rk3288 crypto driver so adds a node for it.

---
 arch/arm64/boot/dts/rockchip/rk3328.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm64/boot/dts/rockchip/rk3328.dtsi +12 -0
index b822533dc7f1..b5b47ddc38f9 100644
@@ -1007,6 +1007,18 @@ gic: interrupt-controller@ff811000 {
 		      (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>;
 	};
 
+	crypto: crypto@ff060000 {
+		compatible = "rockchip,rk3288-crypto";
+		reg = <0x0 0xff060000 0x0 0x4000>;
+		interrupts = <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&cru HCLK_CRYPTO_MST>, <&cru HCLK_CRYPTO_SLV>,
+			 <&cru SCLK_CRYPTO>;
+		clock-names = "aclk", "hclk", "sclk";
+		resets = <&cru SRST_CRYPTO>;
+		reset-names = "crypto-rst";
+		status = "okay";
+	};
+
 	pinctrl: pinctrl {
 		compatible = "rockchip,rk3328-pinctrl";
 		rockchip,grf = <&grf>;
Signature · 7 lines
2.34.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
author maintainer
#17 lore raw

PATCH 13/16 crypto: rockchip: rewrite type

In reply to Corentin Labbe

Instead of using a custom type for classify algorithms, let's just use already defined ones.
And let's made a bit more verbose about what is registered.

---
 drivers/crypto/rockchip/rk3288_crypto.c       | 26 +++++++++++++------
 drivers/crypto/rockchip/rk3288_crypto.h       |  7 +----
 drivers/crypto/rockchip/rk3288_crypto_ahash.c |  6 ++---
 .../crypto/rockchip/rk3288_crypto_skcipher.c  | 12 ++++-----
 4 files changed, 28 insertions(+), 23 deletions(-)
drivers/crypto/rockchip/rk3288_crypto.c +18 -8
index 645855d2651b..24a9e3fbf969 100644
@@ -94,12 +94,22 @@ static int rk_crypto_register(struct rk_crypto_info *crypto_info)
 
 	for (i = 0; i < ARRAY_SIZE(rk_cipher_algs); i++) {
 		rk_cipher_algs[i]->dev = crypto_info;
-		if (rk_cipher_algs[i]->type == ALG_TYPE_CIPHER)
-			err = crypto_register_skcipher(
-					&rk_cipher_algs[i]->alg.skcipher);
-		else
-			err = crypto_register_ahash(
-					&rk_cipher_algs[i]->alg.hash);
+		switch (rk_cipher_algs[i]->type) {
+		case CRYPTO_ALG_TYPE_SKCIPHER:
+			dev_info(crypto_info->dev, "Register %s as\n",
+				 rk_cipher_algs[i]->alg.skcipher.base.cra_name,
+				 rk_cipher_algs[i]->alg.skcipher.base.cra_driver_name);
+			err = crypto_register_skcipher(&rk_cipher_algs[i]->alg.skcipher);
+			break;
+		case CRYPTO_ALG_TYPE_AHASH:
+			dev_info(crypto_info->dev, "Register %s as %s\n",
+				 rk_cipher_algs[i]->alg.hash.halg.base.cra_name,
+				 rk_cipher_algs[i]->alg.hash.halg.base.cra_driver_name);
+			err = crypto_register_ahash(&rk_cipher_algs[i]->alg.hash);
+			break;
+		default:
+			dev_err(crypto_info->dev, "unknown algorithm\n");
+		}
 		if (err)
 			goto err_cipher_algs;
 	}
@@ -107,7 +117,7 @@ static int rk_crypto_register(struct rk_crypto_info *crypto_info)
 
 err_cipher_algs:
 	for (k = 0; k < i; k++) {
-		if (rk_cipher_algs[i]->type == ALG_TYPE_CIPHER)
+		if (rk_cipher_algs[i]->type == CRYPTO_ALG_TYPE_SKCIPHER)
 			crypto_unregister_skcipher(&rk_cipher_algs[k]->alg.skcipher);
 		else
 			crypto_unregister_ahash(&rk_cipher_algs[i]->alg.hash);
@@ -120,7 +130,7 @@ static void rk_crypto_unregister(void)
 	unsigned int i;
 
 	for (i = 0; i < ARRAY_SIZE(rk_cipher_algs); i++) {
-		if (rk_cipher_algs[i]->type == ALG_TYPE_CIPHER)
+		if (rk_cipher_algs[i]->type == CRYPTO_ALG_TYPE_SKCIPHER)
 			crypto_unregister_skcipher(&rk_cipher_algs[i]->alg.skcipher);
 		else
 			crypto_unregister_ahash(&rk_cipher_algs[i]->alg.hash);
drivers/crypto/rockchip/rk3288_crypto.h +1 -6
index 963fbfc4d14e..c94ae950d2fa 100644
@@ -231,18 +231,13 @@ struct rk_cipher_rctx {
 	struct skcipher_request fallback_req;   // keep at the end
 };
 
-enum alg_type {
-	ALG_TYPE_HASH,
-	ALG_TYPE_CIPHER,
-};
-
 struct rk_crypto_tmp {
+	u32 type;
 	struct rk_crypto_info		*dev;
 	union {
 		struct skcipher_alg	skcipher;
 		struct ahash_alg	hash;
 	} alg;
-	enum alg_type			type;
 };
 
 extern struct rk_crypto_tmp rk_ecb_aes_alg;
drivers/crypto/rockchip/rk3288_crypto_ahash.c +3 -3
index b2417d40e178..87d6a03fa1bb 100644
@@ -353,7 +353,7 @@ static void rk_cra_hash_exit(struct crypto_tfm *tfm)
 }
 
 struct rk_crypto_tmp rk_ahash_sha1 = {
-	.type = ALG_TYPE_HASH,
+	.type = CRYPTO_ALG_TYPE_AHASH,
 	.alg.hash = {
 		.init = rk_ahash_init,
 		.update = rk_ahash_update,
@@ -383,7 +383,7 @@ struct rk_crypto_tmp rk_ahash_sha1 = {
 };
 
 struct rk_crypto_tmp rk_ahash_sha256 = {
-	.type = ALG_TYPE_HASH,
+	.type = CRYPTO_ALG_TYPE_AHASH,
 	.alg.hash = {
 		.init = rk_ahash_init,
 		.update = rk_ahash_update,
@@ -413,7 +413,7 @@ struct rk_crypto_tmp rk_ahash_sha256 = {
 };
 
 struct rk_crypto_tmp rk_ahash_md5 = {
-	.type = ALG_TYPE_HASH,
+	.type = CRYPTO_ALG_TYPE_AHASH,
 	.alg.hash = {
 		.init = rk_ahash_init,
 		.update = rk_ahash_update,
drivers/crypto/rockchip/rk3288_crypto_skcipher.c +6 -6
index e4e40fefa993..fe67ac6a911c 100644
@@ -475,7 +475,7 @@ static void rk_ablk_exit_tfm(struct crypto_skcipher *tfm)
 }
 
 struct rk_crypto_tmp rk_ecb_aes_alg = {
-	.type = ALG_TYPE_CIPHER,
+	.type = CRYPTO_ALG_TYPE_SKCIPHER,
 	.alg.skcipher = {
 		.base.cra_name		= "ecb(aes)",
 		.base.cra_driver_name	= "ecb-aes-rk",
@@ -497,7 +497,7 @@ struct rk_crypto_tmp rk_ecb_aes_alg = {
 };
 
 struct rk_crypto_tmp rk_cbc_aes_alg = {
-	.type = ALG_TYPE_CIPHER,
+	.type = CRYPTO_ALG_TYPE_SKCIPHER,
 	.alg.skcipher = {
 		.base.cra_name		= "cbc(aes)",
 		.base.cra_driver_name	= "cbc-aes-rk",
@@ -520,7 +520,7 @@ struct rk_crypto_tmp rk_cbc_aes_alg = {
 };
 
 struct rk_crypto_tmp rk_ecb_des_alg = {
-	.type = ALG_TYPE_CIPHER,
+	.type = CRYPTO_ALG_TYPE_SKCIPHER,
 	.alg.skcipher = {
 		.base.cra_name		= "ecb(des)",
 		.base.cra_driver_name	= "ecb-des-rk",
@@ -542,7 +542,7 @@ struct rk_crypto_tmp rk_ecb_des_alg = {
 };
 
 struct rk_crypto_tmp rk_cbc_des_alg = {
-	.type = ALG_TYPE_CIPHER,
+	.type = CRYPTO_ALG_TYPE_SKCIPHER,
 	.alg.skcipher = {
 		.base.cra_name		= "cbc(des)",
 		.base.cra_driver_name	= "cbc-des-rk",
@@ -565,7 +565,7 @@ struct rk_crypto_tmp rk_cbc_des_alg = {
 };
 
 struct rk_crypto_tmp rk_ecb_des3_ede_alg = {
-	.type = ALG_TYPE_CIPHER,
+	.type = CRYPTO_ALG_TYPE_SKCIPHER,
 	.alg.skcipher = {
 		.base.cra_name		= "ecb(des3_ede)",
 		.base.cra_driver_name	= "ecb-des3-ede-rk",
@@ -587,7 +587,7 @@ struct rk_crypto_tmp rk_ecb_des3_ede_alg = {
 };
 
 struct rk_crypto_tmp rk_cbc_des3_ede_alg = {
-	.type = ALG_TYPE_CIPHER,
+	.type = CRYPTO_ALG_TYPE_SKCIPHER,
 	.alg.skcipher = {
 		.base.cra_name		= "cbc(des3_ede)",
 		.base.cra_driver_name	= "cbc-des3-ede-rk",
Signature · 7 lines
2.34.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
author maintainer
#20 lore raw

PATCH 14/16 crypto: rockchip: add debugfs

In reply to Corentin Labbe

This patch enable to access usage stats for each algorithm.

---
 drivers/crypto/Kconfig                        | 10 +++++
 drivers/crypto/rockchip/rk3288_crypto.c       | 45 +++++++++++++++++++
 drivers/crypto/rockchip/rk3288_crypto.h       | 11 +++++
 drivers/crypto/rockchip/rk3288_crypto_ahash.c |  8 ++++
 .../crypto/rockchip/rk3288_crypto_skcipher.c  | 19 +++++++-
 5 files changed, 92 insertions(+), 1 deletion(-)
drivers/crypto/Kconfig +10 -0
index 4f705674f94f..98e4b6c21087 100644
@@ -796,6 +796,16 @@ config CRYPTO_DEV_ROCKCHIP
 	  This driver interfaces with the hardware crypto accelerator.
 	  Supporting cbc/ecb chainmode, and aes/des/des3_ede cipher mode.
 
+config CRYPTO_DEV_ROCKCHIP_DEBUG
+	bool "Enable Rockchip crypto stats"
+	depends on CRYPTO_DEV_ROCKCHIP
+	depends on DEBUG_FS
+	help
+	  Say y to enable Rockchip crypto debug stats.
+	  This will create /sys/kernel/debug/rk3288_crypto/stats for displaying
+	  the number of requests per algorithm and other internal stats.
+
+
 config CRYPTO_DEV_ZYNQMP_AES
 	tristate "Support for Xilinx ZynqMP AES hw accelerator"
 	depends on ZYNQMP_FIRMWARE || COMPILE_TEST
drivers/crypto/rockchip/rk3288_crypto.c +45 -0

63 lines not on this page · raw message

drivers/crypto/rockchip/rk3288_crypto.h +11 -0
index c94ae950d2fa..e2a6d735f2e2 100644
@@ -7,6 +7,7 @@
 #include <crypto/algapi.h>
 #include <linux/dma-mapping.h>
 #include <linux/interrupt.h>
+#include <linux/debugfs.h>
 #include <linux/delay.h>
 #include <linux/scatterlist.h>
 #include <crypto/engine.h>
@@ -198,6 +199,10 @@ struct rk_crypto_info {
 	struct crypto_engine *engine;
 	struct completion complete;
 	int status;
+#ifdef CONFIG_CRYPTO_DEV_ROCKCHIP_DEBUG
+	struct dentry *dbgfs_dir;
+	struct dentry *dbgfs_stats;
+#endif
 };
 
 /* the private variable of hash */
@@ -238,6 +243,12 @@ struct rk_crypto_tmp {
 		struct skcipher_alg	skcipher;
 		struct ahash_alg	hash;
 	} alg;
+	unsigned long stat_req;
+	unsigned long stat_fb;
+	unsigned long stat_fb_len;
+	unsigned long stat_fb_sglen;
+	unsigned long stat_fb_align;
+	unsigned long stat_fb_sgdiff;
 };
 
 extern struct rk_crypto_tmp rk_ecb_aes_alg;
drivers/crypto/rockchip/rk3288_crypto_ahash.c +8 -0
index 87d6a03fa1bb..628ede48b868 100644
@@ -39,6 +39,10 @@ static int rk_ahash_digest_fb(struct ahash_request *areq)
 	struct rk_ahash_rctx *rctx = ahash_request_ctx(areq);
 	struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq);
 	struct rk_ahash_ctx *tfmctx = crypto_ahash_ctx(tfm);
+	struct ahash_alg *alg = __crypto_ahash_alg(tfm->base.__crt_alg);
+	struct rk_crypto_tmp *algt = container_of(alg, struct rk_crypto_tmp, alg.hash);
+
+	algt->stat_fb++;
 
 	ahash_request_set_tfm(&rctx->fallback_req, tfmctx->fallback_tfm);
 	rctx->fallback_req.base.flags = areq->base.flags &
@@ -249,6 +253,8 @@ static int rk_hash_run(struct crypto_engine *engine, void *breq)
 	struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq);
 	struct rk_ahash_rctx *rctx = ahash_request_ctx(areq);
 	struct rk_ahash_ctx *tctx = crypto_ahash_ctx(tfm);
+	struct ahash_alg *alg = __crypto_ahash_alg(tfm->base.__crt_alg);
+	struct rk_crypto_tmp *algt = container_of(alg, struct rk_crypto_tmp, alg.hash);
 	struct scatterlist *sg = areq->src;
 	int err = 0;
 	int i;
@@ -256,6 +262,8 @@ static int rk_hash_run(struct crypto_engine *engine, void *breq)
 
 	rctx->mode = 0;
 
+	algt->stat_req++;
+
 	switch (crypto_ahash_digestsize(tfm)) {
 	case SHA1_DIGEST_SIZE:
 		rctx->mode = RK_CRYPTO_HASH_SHA1;
drivers/crypto/rockchip/rk3288_crypto_skcipher.c +18 -1
index fe67ac6a911c..94c51e760afc 100644
@@ -16,6 +16,9 @@
 
 static int rk_cipher_need_fallback(struct skcipher_request *req)
 {
+	struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
+	struct skcipher_alg *alg = crypto_skcipher_alg(tfm);
+	struct rk_crypto_tmp *algt = container_of(alg, struct rk_crypto_tmp, alg.skcipher);
 	struct scatterlist *sgs, *sgd;
 
 	if (!req->cryptlen)
@@ -24,9 +27,11 @@ static int rk_cipher_need_fallback(struct skcipher_request *req)
 	sgs = req->src;
 	while (sgs) {
 		if (!IS_ALIGNED(sgs->offset, sizeof(u32))) {
+			algt->stat_fb_align++;
 			return true;
 		}
 		if (sgs->length % 16) {
+			algt->stat_fb_len++;
 			return true;
 		}
 		sgs = sg_next(sgs);
@@ -34,9 +39,11 @@ static int rk_cipher_need_fallback(struct skcipher_request *req)
 	sgd = req->dst;
 	while (sgd) {
 		if (!IS_ALIGNED(sgd->offset, sizeof(u32))) {
+			algt->stat_fb_align++;
 			return true;
 		}
 		if (sgd->length % 16) {
+			algt->stat_fb_len++;
 			return true;
 		}
 		sgd = sg_next(sgd);
@@ -44,8 +51,10 @@ static int rk_cipher_need_fallback(struct skcipher_request *req)
 	sgs = req->src;
 	sgd = req->dst;
 	while (sgs && sgd) {
-		if (sgs->length != sgd->length)
+		if (sgs->length != sgd->length) {
+			algt->stat_fb_sgdiff++;
 			return true;
+		}
 		sgs = sg_next(sgs);
 		sgd = sg_next(sgd);
 	}
@@ -57,8 +66,12 @@ static int rk_cipher_fallback(struct skcipher_request *areq)
 	struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
 	struct rk_cipher_ctx *op = crypto_skcipher_ctx(tfm);
 	struct rk_cipher_rctx *rctx = skcipher_request_ctx(areq);
+	struct skcipher_alg *alg = crypto_skcipher_alg(tfm);
+	struct rk_crypto_tmp *algt = container_of(alg, struct rk_crypto_tmp, alg.skcipher);
 	int err;
 
+	algt->stat_fb++;
+
 	skcipher_request_set_tfm(&rctx->fallback_req, op->fallback_tfm);
 	skcipher_request_set_callback(&rctx->fallback_req, areq->base.flags,
 				      areq->base.complete, areq->base.data);
@@ -325,6 +338,10 @@ static int rk_cipher_run(struct crypto_engine *engine, void *async_req)
 	u8 *ivtouse = areq->iv;
 	unsigned int len = areq->cryptlen;
 	unsigned int todo;
+	struct skcipher_alg *alg = crypto_skcipher_alg(tfm);
+	struct rk_crypto_tmp *algt = container_of(alg, struct rk_crypto_tmp, alg.skcipher);
+
+	algt->stat_req++;
 
 	ivsize = crypto_skcipher_ivsize(tfm);
 	if (areq->iv && crypto_skcipher_ivsize(tfm) > 0) {
Signature · 7 lines
2.34.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
author maintainer
#22 lore raw

PATCH 16/16 crypto: rockchip: add myself as maintainer

In reply to Corentin Labbe

Nobody is set as maintainer of rockchip crypto, I propose to do it as I have already reworked lot of this code.

---
 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
index db8052bc1d26..b1b2303ac285 100644
@@ -16828,6 +16828,12 @@ F:	Documentation/ABI/*/sysfs-driver-hid-roccat*
 F:	drivers/hid/hid-roccat*
 F:	include/linux/hid-roccat*
 
+ROCKCHIP CRYPTO DRIVERS
+M:	Corentin Labbe <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/crypto/rockchip/
+
 ROCKCHIP I2S TDM DRIVER
 M:	Nicolas Frattaroli <[email protected]>
 L:	[email protected]
Signature · 1 line
2.34.1
#11 lore raw

Re: [PATCH 10/16] crypto: rockchip: rework by using crypto_engine

In reply to Corentin Labbe
I love your patch! Perhaps something to improve:

Hi Corentin,

I love your patch! Perhaps something to improve:

[auto build test WARNING on rockchip/for-next]
[also build test WARNING on herbert-cryptodev-2.6/master herbert-crypto-2.6/master v5.17-rc6 next-20220228] [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]

url:    https://github.com/0day-ci/linux/commits/Corentin-Labbe/crypto-rockchip-permit-to-pass-self-tests/20220301-035430
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git for-next
config: arm64-randconfig-r006-20220228 (https://download.01.org/0day-ci/archive/20220301/[email protected]/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project d271fc04d5b97b12e6b797c6067d3c96a8d7470e)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install arm64 cross compiling tool for clang build
# apt-get install binutils-aarch64-linux-gnu
# https://github.com/0day-ci/linux/commit/7e5f8e4a5f09473643937e0ecff342bf336793fb
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Corentin-Labbe/crypto-rockchip-permit-to-pass-self-tests/20220301-035430 git checkout 7e5f8e4a5f09473643937e0ecff342bf336793fb
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/crypto/rockchip/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

>> drivers/crypto/rockchip/rk3288_crypto_skcipher.c:386:10: warning: format specifies type 'unsigned int' but the argument has type 'unsigned long' [-Wformat]
                           todo, rctx->mode & RK_CRYPTO_DEC);
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:163:47: note: expanded from macro 'dev_dbg'
                   dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \
                                                       ~~~     ^~~~~~~~~~~
   include/linux/dev_printk.h:129:34: note: expanded from macro 'dev_printk'
                   _dev_printk(level, dev, fmt, ##__VA_ARGS__);            \
                                           ~~~    ^~~~~~~~~~~
   drivers/crypto/rockchip/rk3288_crypto_skcipher.c:474:24: warning: unused variable 'ctx' [-Wunused-variable]
           struct rk_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);
                                 ^

2 warnings generated.

vim +386 drivers/crypto/rockchip/rk3288_crypto_skcipher.c

311
312 static int rk_cipher_run(struct crypto_engine *engine, void *async_req)
313 {
314 struct skcipher_request *areq = container_of(async_req, struct skcipher_request, base);
315 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
316 struct rk_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);
317 struct rk_cipher_rctx *rctx = skcipher_request_ctx(areq);
318 struct scatterlist *sgs, *sgd;
319 int err = 0;
320 int n = 0;
321 int ivsize = crypto_skcipher_ivsize(tfm);
322 int offset;
323 u8 iv[AES_BLOCK_SIZE];
324 u8 biv[AES_BLOCK_SIZE];
325 u8 *ivtouse = areq->iv;
326 unsigned int len = areq->cryptlen;
327 unsigned int todo;
328
329 ivsize = crypto_skcipher_ivsize(tfm);
330 if (areq->iv && crypto_skcipher_ivsize(tfm) > 0) {
331 if (rctx->mode & RK_CRYPTO_DEC) {
332 offset = areq->cryptlen - ivsize;
333 scatterwalk_map_and_copy(rctx->backup_iv, areq->src,
334 offset, ivsize, 0);
335 }
336 }
337
338 sgs = areq->src;
339 sgd = areq->dst;
340
341 while (sgs && sgd && len) {
342 if (!sgs->length) {
343 sgs = sg_next(sgs);
344 sgd = sg_next(sgd);
345 continue;
346 }
347 if (rctx->mode & RK_CRYPTO_DEC) {
348 /* we backup last block of source to be used as IV at next step */
349 offset = sgs->length - ivsize;
350 scatterwalk_map_and_copy(biv, sgs, offset, ivsize, 0);
351 }
352 if (sgs == sgd) {
353 err = dma_map_sg(ctx->dev->dev, sgs, 1, DMA_BIDIRECTIONAL);
354 if (err <= 0) {
355 err = -EINVAL;
356 goto theend_iv;
357 }
358 } else {
359 err = dma_map_sg(ctx->dev->dev, sgs, 1, DMA_TO_DEVICE);
360 if (err <= 0) {
361 err = -EINVAL;
362 goto theend_iv;
363 }
364 err = dma_map_sg(ctx->dev->dev, sgd, 1, DMA_FROM_DEVICE);
365 if (err <= 0) {
366 err = -EINVAL;
367 goto theend_sgs;
368 }
369 }
370 err = 0;
371 rk_ablk_hw_init(ctx->dev, areq);
372 if (ivsize) {
373 if (ivsize == DES_BLOCK_SIZE)
374 memcpy_toio(ctx->dev->reg + RK_CRYPTO_TDES_IV_0, ivtouse, ivsize);
375 else
376 memcpy_toio(ctx->dev->reg + RK_CRYPTO_AES_IV_0, ivtouse, ivsize);
377 }
378 reinit_completion(&ctx->dev->complete);
379 ctx->dev->status = 0;
380
381 todo = min(sg_dma_len(sgs), len);
382 len -= todo;
383 dev_dbg(ctx->dev->dev, "LEN=%d/%d/%u ivsize=%d mode=%x n=%d BI=%d todo=%u way=%x\n",
384 sg_dma_len(sgs), sg_dma_len(sgd), areq->cryptlen,
385 ivsize, rctx->mode, n, sgs == sgd,

 > 386				todo, rctx->mode & RK_CRYPTO_DEC);

387 crypto_dma_start(ctx->dev, sgs, sgd, todo / 4);
388 wait_for_completion_interruptible_timeout(&ctx->dev->complete,
389 msecs_to_jiffies(2000));
390 if (!ctx->dev->status) {
391 dev_err(ctx->dev->dev, "DMA timeout\n");
392 err = -EFAULT;
393 goto theend;
394 }
395 if (sgs == sgd) {
396 dma_unmap_sg(ctx->dev->dev, sgs, 1, DMA_BIDIRECTIONAL);
397 } else {
398 dma_unmap_sg(ctx->dev->dev, sgs, 1, DMA_TO_DEVICE);
399 dma_unmap_sg(ctx->dev->dev, sgd, 1, DMA_FROM_DEVICE);
400 }
401 if (rctx->mode & RK_CRYPTO_DEC) {
402 memcpy(iv, biv, ivsize);
403 ivtouse = iv;
404 } else {
405 offset = sgd->length - ivsize;
406 scatterwalk_map_and_copy(iv, sgd, offset, ivsize, 0);
407 ivtouse = iv;
408 }
409 sgs = sg_next(sgs);
410 sgd = sg_next(sgd);
411 n++;
412 }
413
414 if (areq->iv && ivsize > 0) {
415 offset = areq->cryptlen - ivsize;
416 if (rctx->mode & RK_CRYPTO_DEC) {
417 memcpy(areq->iv, rctx->backup_iv, ivsize);
418 memzero_explicit(rctx->backup_iv, ivsize);
419 } else {
420 scatterwalk_map_and_copy(areq->iv, areq->dst, offset,
421 ivsize, 0);
422 }
423 }
424
425 theend:
426 local_bh_disable();
427 crypto_finalize_skcipher_request(engine, areq, err);
428 local_bh_enable();
429 return 0;
430
431 theend_sgs:
432 if (sgs == sgd) {
433 dma_unmap_sg(ctx->dev->dev, sgs, 1, DMA_BIDIRECTIONAL);
434 } else {
435 dma_unmap_sg(ctx->dev->dev, sgs, 1, DMA_TO_DEVICE);
436 dma_unmap_sg(ctx->dev->dev, sgd, 1, DMA_FROM_DEVICE);
437 }
438 theend_iv:
439 return err;
440 }
441

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

#12 lore raw

Re: [PATCH 10/16] crypto: rockchip: rework by using crypto_engine

In reply to Corentin Labbe
I love your patch! Perhaps something to improve:

Hi Corentin,

I love your patch! Perhaps something to improve:

[auto build test WARNING on rockchip/for-next]
[also build test WARNING on herbert-cryptodev-2.6/master herbert-crypto-2.6/master v5.17-rc6 next-20220228] [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]

url:    https://github.com/0day-ci/linux/commits/Corentin-Labbe/crypto-rockchip-permit-to-pass-self-tests/20220301-035430
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git for-next
config: arm-defconfig (https://download.01.org/0day-ci/archive/20220301/[email protected]/config)
compiler: arm-linux-gnueabi-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/7e5f8e4a5f09473643937e0ecff342bf336793fb
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Corentin-Labbe/crypto-rockchip-permit-to-pass-self-tests/20220301-035430 git checkout 7e5f8e4a5f09473643937e0ecff342bf336793fb
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arm SHELL=/bin/bash drivers/crypto/rockchip/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

In file included from include/linux/device.h:15,
from drivers/crypto/rockchip/rk3288_crypto_skcipher.c:11:
drivers/crypto/rockchip/rk3288_crypto_skcipher.c: In function 'rk_cipher_run':

>> drivers/crypto/rockchip/rk3288_crypto_skcipher.c:383:40: warning: format '%x' expects argument of type 'unsigned int', but argument 12 has type 'long unsigned int' [-Wformat=]
     383 |                 dev_dbg(ctx->dev->dev, "LEN=%d/%d/%u ivsize=%d mode=%x n=%d BI=%d todo=%u way=%x\n",
         |                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:129:41: note: in definition of macro 'dev_printk'
     129 |                 _dev_printk(level, dev, fmt, ##__VA_ARGS__);            \
         |                                         ^~~
   include/linux/dev_printk.h:163:45: note: in expansion of macro 'dev_fmt'
     163 |                 dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \
         |                                             ^~~~~~~
   drivers/crypto/rockchip/rk3288_crypto_skcipher.c:383:17: note: in expansion of macro 'dev_dbg'
     383 |                 dev_dbg(ctx->dev->dev, "LEN=%d/%d/%u ivsize=%d mode=%x n=%d BI=%d todo=%u way=%x\n",
         |                 ^~~~~~~
   drivers/crypto/rockchip/rk3288_crypto_skcipher.c:383:96: note: format string is defined here
     383 |                 dev_dbg(ctx->dev->dev, "LEN=%d/%d/%u ivsize=%d mode=%x n=%d BI=%d todo=%u way=%x\n",
         |                                                                                               ~^
         |                                                                                                |
         |                                                                                                unsigned int
         |                                                                                               %lx
   drivers/crypto/rockchip/rk3288_crypto_skcipher.c: In function 'rk_ablk_exit_tfm':
   drivers/crypto/rockchip/rk3288_crypto_skcipher.c:474:31: warning: unused variable 'ctx' [-Wunused-variable]
     474 |         struct rk_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);
         |                               ^~~

vim +383 drivers/crypto/rockchip/rk3288_crypto_skcipher.c

311
312 static int rk_cipher_run(struct crypto_engine *engine, void *async_req)
313 {
314 struct skcipher_request *areq = container_of(async_req, struct skcipher_request, base);
315 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
316 struct rk_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);
317 struct rk_cipher_rctx *rctx = skcipher_request_ctx(areq);
318 struct scatterlist *sgs, *sgd;
319 int err = 0;
320 int n = 0;
321 int ivsize = crypto_skcipher_ivsize(tfm);
322 int offset;
323 u8 iv[AES_BLOCK_SIZE];
324 u8 biv[AES_BLOCK_SIZE];
325 u8 *ivtouse = areq->iv;
326 unsigned int len = areq->cryptlen;
327 unsigned int todo;
328
329 ivsize = crypto_skcipher_ivsize(tfm);
330 if (areq->iv && crypto_skcipher_ivsize(tfm) > 0) {
331 if (rctx->mode & RK_CRYPTO_DEC) {
332 offset = areq->cryptlen - ivsize;
333 scatterwalk_map_and_copy(rctx->backup_iv, areq->src,
334 offset, ivsize, 0);
335 }
336 }
337
338 sgs = areq->src;
339 sgd = areq->dst;
340
341 while (sgs && sgd && len) {
342 if (!sgs->length) {
343 sgs = sg_next(sgs);
344 sgd = sg_next(sgd);
345 continue;
346 }
347 if (rctx->mode & RK_CRYPTO_DEC) {
348 /* we backup last block of source to be used as IV at next step */
349 offset = sgs->length - ivsize;
350 scatterwalk_map_and_copy(biv, sgs, offset, ivsize, 0);
351 }
352 if (sgs == sgd) {
353 err = dma_map_sg(ctx->dev->dev, sgs, 1, DMA_BIDIRECTIONAL);
354 if (err <= 0) {
355 err = -EINVAL;
356 goto theend_iv;
357 }
358 } else {
359 err = dma_map_sg(ctx->dev->dev, sgs, 1, DMA_TO_DEVICE);
360 if (err <= 0) {
361 err = -EINVAL;
362 goto theend_iv;
363 }
364 err = dma_map_sg(ctx->dev->dev, sgd, 1, DMA_FROM_DEVICE);
365 if (err <= 0) {
366 err = -EINVAL;
367 goto theend_sgs;
368 }
369 }
370 err = 0;
371 rk_ablk_hw_init(ctx->dev, areq);
372 if (ivsize) {
373 if (ivsize == DES_BLOCK_SIZE)
374 memcpy_toio(ctx->dev->reg + RK_CRYPTO_TDES_IV_0, ivtouse, ivsize);
375 else
376 memcpy_toio(ctx->dev->reg + RK_CRYPTO_AES_IV_0, ivtouse, ivsize);
377 }
378 reinit_completion(&ctx->dev->complete);
379 ctx->dev->status = 0;
380
381 todo = min(sg_dma_len(sgs), len);
382 len -= todo;

 > 383			dev_dbg(ctx->dev->dev, "LEN=%d/%d/%u ivsize=%d mode=%x n=%d BI=%d todo=%u way=%x\n",

384 sg_dma_len(sgs), sg_dma_len(sgd), areq->cryptlen,
385 ivsize, rctx->mode, n, sgs == sgd,
386 todo, rctx->mode & RK_CRYPTO_DEC);
387 crypto_dma_start(ctx->dev, sgs, sgd, todo / 4);
388 wait_for_completion_interruptible_timeout(&ctx->dev->complete,
389 msecs_to_jiffies(2000));
390 if (!ctx->dev->status) {
391 dev_err(ctx->dev->dev, "DMA timeout\n");
392 err = -EFAULT;
393 goto theend;
394 }
395 if (sgs == sgd) {
396 dma_unmap_sg(ctx->dev->dev, sgs, 1, DMA_BIDIRECTIONAL);
397 } else {
398 dma_unmap_sg(ctx->dev->dev, sgs, 1, DMA_TO_DEVICE);
399 dma_unmap_sg(ctx->dev->dev, sgd, 1, DMA_FROM_DEVICE);
400 }
401 if (rctx->mode & RK_CRYPTO_DEC) {
402 memcpy(iv, biv, ivsize);
403 ivtouse = iv;
404 } else {
405 offset = sgd->length - ivsize;
406 scatterwalk_map_and_copy(iv, sgd, offset, ivsize, 0);
407 ivtouse = iv;
408 }
409 sgs = sg_next(sgs);
410 sgd = sg_next(sgd);
411 n++;
412 }
413
414 if (areq->iv && ivsize > 0) {
415 offset = areq->cryptlen - ivsize;
416 if (rctx->mode & RK_CRYPTO_DEC) {
417 memcpy(areq->iv, rctx->backup_iv, ivsize);
418 memzero_explicit(rctx->backup_iv, ivsize);
419 } else {
420 scatterwalk_map_and_copy(areq->iv, areq->dst, offset,
421 ivsize, 0);
422 }
423 }
424
425 theend:
426 local_bh_disable();
427 crypto_finalize_skcipher_request(engine, areq, err);
428 local_bh_enable();
429 return 0;
430
431 theend_sgs:
432 if (sgs == sgd) {
433 dma_unmap_sg(ctx->dev->dev, sgs, 1, DMA_BIDIRECTIONAL);
434 } else {
435 dma_unmap_sg(ctx->dev->dev, sgs, 1, DMA_TO_DEVICE);
436 dma_unmap_sg(ctx->dev->dev, sgd, 1, DMA_FROM_DEVICE);
437 }
438 theend_iv:
439 return err;
440 }
441

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

#18 lore raw

Re: [PATCH 13/16] crypto: rockchip: rewrite type

In reply to Corentin Labbe
I love your patch! Perhaps something to improve:

Hi Corentin,

I love your patch! Perhaps something to improve:

[auto build test WARNING on rockchip/for-next]
[also build test WARNING on herbert-cryptodev-2.6/master herbert-crypto-2.6/master v5.17-rc6 next-20220228] [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]

url:    https://github.com/0day-ci/linux/commits/Corentin-Labbe/crypto-rockchip-permit-to-pass-self-tests/20220301-035430
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git for-next
config: arm64-randconfig-r006-20220228 (https://download.01.org/0day-ci/archive/20220301/[email protected]/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project d271fc04d5b97b12e6b797c6067d3c96a8d7470e)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install arm64 cross compiling tool for clang build
# apt-get install binutils-aarch64-linux-gnu
# https://github.com/0day-ci/linux/commit/03fb353165f76dc7c5ed7c27401537552070406b
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Corentin-Labbe/crypto-rockchip-permit-to-pass-self-tests/20220301-035430 git checkout 03fb353165f76dc7c5ed7c27401537552070406b
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/crypto/rockchip/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

>> drivers/crypto/rockchip/rk3288_crypto.c:101:6: warning: data argument not used by format string [-Wformat-extra-args]
                                    rk_cipher_algs[i]->alg.skcipher.base.cra_driver_name);
                                    ^
   include/linux/dev_printk.h:150:67: note: expanded from macro 'dev_info'
           dev_printk_index_wrap(_dev_info, KERN_INFO, dev, dev_fmt(fmt), ##__VA_ARGS__)
                                                                    ~~~     ^
   include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
                   _p_func(dev, fmt, ##__VA_ARGS__);                       \
                                ~~~    ^

1 warning generated.

vim +101 drivers/crypto/rockchip/rk3288_crypto.c

    89	
    90	static int rk_crypto_register(struct rk_crypto_info *crypto_info)
    91	{
    92		unsigned int i, k;
    93		int err = 0;
    94	
    95		for (i = 0; i < ARRAY_SIZE(rk_cipher_algs); i++) {
    96			rk_cipher_algs[i]->dev = crypto_info;
    97			switch (rk_cipher_algs[i]->type) {
    98			case CRYPTO_ALG_TYPE_SKCIPHER:
    99				dev_info(crypto_info->dev, "Register %s as\n",
   100					 rk_cipher_algs[i]->alg.skcipher.base.cra_name,
 > 101					 rk_cipher_algs[i]->alg.skcipher.base.cra_driver_name);

102 err = crypto_register_skcipher(&rk_cipher_algs[i]->alg.skcipher);
103 break;
104 case CRYPTO_ALG_TYPE_AHASH:
105 dev_info(crypto_info->dev, "Register %s as %s\n",
106 rk_cipher_algs[i]->alg.hash.halg.base.cra_name,
107 rk_cipher_algs[i]->alg.hash.halg.base.cra_driver_name);
108 err = crypto_register_ahash(&rk_cipher_algs[i]->alg.hash);
109 break;
110 default:
111 dev_err(crypto_info->dev, "unknown algorithm\n");
112 }
113 if (err)
114 goto err_cipher_algs;
115 }
116 return 0;
117
118 err_cipher_algs:
119 for (k = 0; k < i; k++) {
120 if (rk_cipher_algs[i]->type == CRYPTO_ALG_TYPE_SKCIPHER)
121 crypto_unregister_skcipher(&rk_cipher_algs[k]->alg.skcipher);
122 else
123 crypto_unregister_ahash(&rk_cipher_algs[i]->alg.hash);
124 }
125 return err;
126 }
127

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

#19 lore raw

Re: [PATCH 13/16] crypto: rockchip: rewrite type

In reply to Corentin Labbe
I love your patch! Perhaps something to improve:

Hi Corentin,

I love your patch! Perhaps something to improve:

[auto build test WARNING on rockchip/for-next]
[also build test WARNING on herbert-cryptodev-2.6/master herbert-crypto-2.6/master v5.17-rc6 next-20220228] [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]

url:    https://github.com/0day-ci/linux/commits/Corentin-Labbe/crypto-rockchip-permit-to-pass-self-tests/20220301-035430
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git for-next
config: arm-defconfig (https://download.01.org/0day-ci/archive/20220301/[email protected]/config)
compiler: arm-linux-gnueabi-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/03fb353165f76dc7c5ed7c27401537552070406b
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Corentin-Labbe/crypto-rockchip-permit-to-pass-self-tests/20220301-035430 git checkout 03fb353165f76dc7c5ed7c27401537552070406b
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arm SHELL=/bin/bash drivers/crypto/rockchip/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

In file included from include/linux/device.h:15,

                    from include/linux/dma-mapping.h:7,
                    from drivers/crypto/rockchip/rk3288_crypto.h:8,
                    from drivers/crypto/rockchip/rk3288_crypto.c:12:
   drivers/crypto/rockchip/rk3288_crypto.c: In function 'rk_crypto_register':
>> drivers/crypto/rockchip/rk3288_crypto.c:99:52: warning: too many arguments for format [-Wformat-extra-args]
      99 |                         dev_info(crypto_info->dev, "Register %s as\n",
         |                                                    ^~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
     110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
         |                              ^~~
   include/linux/dev_printk.h:150:58: note: in expansion of macro 'dev_fmt'
     150 |         dev_printk_index_wrap(_dev_info, KERN_INFO, dev, dev_fmt(fmt), ##__VA_ARGS__)
         |                                                          ^~~~~~~
   drivers/crypto/rockchip/rk3288_crypto.c:99:25: note: in expansion of macro 'dev_info'
      99 |                         dev_info(crypto_info->dev, "Register %s as\n",
         |                         ^~~~~~~~

vim +99 drivers/crypto/rockchip/rk3288_crypto.c

  > 12	#include "rk3288_crypto.h"
    13	#include <linux/dma-mapping.h>
    14	#include <linux/module.h>
    15	#include <linux/platform_device.h>
    16	#include <linux/of.h>
    17	#include <linux/clk.h>
    18	#include <linux/crypto.h>
    19	#include <linux/reset.h>
    20	
    21	static int rk_crypto_enable_clk(struct rk_crypto_info *dev)
    22	{
    23		int err;
    24	
    25		err = clk_prepare_enable(dev->sclk);
    26		if (err) {
    27			dev_err(dev->dev, "[%s:%d], Couldn't enable clock sclk\n",
    28				__func__, __LINE__);
    29			goto err_return;
    30		}
    31		err = clk_prepare_enable(dev->aclk);
    32		if (err) {
    33			dev_err(dev->dev, "[%s:%d], Couldn't enable clock aclk\n",
    34				__func__, __LINE__);
    35			goto err_aclk;
    36		}
    37		err = clk_prepare_enable(dev->hclk);
    38		if (err) {
    39			dev_err(dev->dev, "[%s:%d], Couldn't enable clock hclk\n",
    40				__func__, __LINE__);
    41			goto err_hclk;
    42		}
    43	
    44		return err;
    45	err_hclk:
    46		clk_disable_unprepare(dev->aclk);
    47	err_aclk:
    48		clk_disable_unprepare(dev->sclk);
    49	err_return:
    50		return err;
    51	}
    52	
    53	static void rk_crypto_disable_clk(struct rk_crypto_info *dev)
    54	{
    55		clk_disable_unprepare(dev->hclk);
    56		clk_disable_unprepare(dev->aclk);
    57		clk_disable_unprepare(dev->sclk);
    58	}
    59	
    60	static irqreturn_t rk_crypto_irq_handle(int irq, void *dev_id)
    61	{
    62		struct rk_crypto_info *dev  = platform_get_drvdata(dev_id);
    63		u32 interrupt_status;
    64	
    65		interrupt_status = CRYPTO_READ(dev, RK_CRYPTO_INTSTS);
    66		CRYPTO_WRITE(dev, RK_CRYPTO_INTSTS, interrupt_status);
    67	
    68		dev->status = 1;
    69		if (interrupt_status & 0x0a) {
    70			dev_warn(dev->dev, "DMA Error\n");
    71			dev->status = 0;
    72		}
    73		complete(&dev->complete);
    74	
    75		return IRQ_HANDLED;
    76	}
    77	
    78	static struct rk_crypto_tmp *rk_cipher_algs[] = {
    79		&rk_ecb_aes_alg,
    80		&rk_cbc_aes_alg,
    81		&rk_ecb_des_alg,
    82		&rk_cbc_des_alg,
    83		&rk_ecb_des3_ede_alg,
    84		&rk_cbc_des3_ede_alg,
    85		&rk_ahash_sha1,
    86		&rk_ahash_sha256,
    87		&rk_ahash_md5,
    88	};
    89	
    90	static int rk_crypto_register(struct rk_crypto_info *crypto_info)
    91	{
    92		unsigned int i, k;
    93		int err = 0;
    94	
    95		for (i = 0; i < ARRAY_SIZE(rk_cipher_algs); i++) {
    96			rk_cipher_algs[i]->dev = crypto_info;
    97			switch (rk_cipher_algs[i]->type) {
    98			case CRYPTO_ALG_TYPE_SKCIPHER:
  > 99				dev_info(crypto_info->dev, "Register %s as\n",

100 rk_cipher_algs[i]->alg.skcipher.base.cra_name,
101 rk_cipher_algs[i]->alg.skcipher.base.cra_driver_name);
102 err = crypto_register_skcipher(&rk_cipher_algs[i]->alg.skcipher);
103 break;
104 case CRYPTO_ALG_TYPE_AHASH:
105 dev_info(crypto_info->dev, "Register %s as %s\n",
106 rk_cipher_algs[i]->alg.hash.halg.base.cra_name,
107 rk_cipher_algs[i]->alg.hash.halg.base.cra_driver_name);
108 err = crypto_register_ahash(&rk_cipher_algs[i]->alg.hash);
109 break;
110 default:
111 dev_err(crypto_info->dev, "unknown algorithm\n");
112 }
113 if (err)
114 goto err_cipher_algs;
115 }
116 return 0;
117
118 err_cipher_algs:
119 for (k = 0; k < i; k++) {
120 if (rk_cipher_algs[i]->type == CRYPTO_ALG_TYPE_SKCIPHER)
121 crypto_unregister_skcipher(&rk_cipher_algs[k]->alg.skcipher);
122 else
123 crypto_unregister_ahash(&rk_cipher_algs[i]->alg.hash);
124 }
125 return err;
126 }
127

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

#13 lore raw

Re: [PATCH 10/16] crypto: rockchip: rework by using crypto_engine

In reply to Corentin Labbe
Quoted 8 lines · Corentin Labbe

Instead of doing manual queue management, let's use the crypto/engine for that.
In the same time, rework the requests handling to be easier to understand (and fix all bugs related to them).

Fixes ce0183cb6464b ("crypto: rockchip - switch to skcipher API")

---

In addition to the warnings reported by the kernel test robot, this needs to add select CRYPTO_ENGINE to Kconfig for the Rockchip driver.

Regards,
John

Tested-by on the v1 series
#23 lore raw
In reply to Corentin Labbe
Quoted 5 lines · Corentin Labbe

The rockchip crypto driver is broken and do not pass self-tests. This serie's goal is to permit to become usable and pass self-tests.

This whole serie is tested on a rk3328-rock64 with selftests (with CONFIG_CRYPTO_MANAGER_EXTRA_TESTS=y)

I previously noticed this breakage on rk3288 but never got time to investigate (disabling the driver was quicker).

This series fixes everything on rk3288 as well, thanks!

I hit the same warnings as the kernel test robot as well as a missing new kconfig dependency (see separate reply to patch 10), but this is

Regards,
John

author maintainer
#14 lore raw

Re: [PATCH 10/16] crypto: rockchip: rework by using crypto_engine

In reply to John Keeping
Quoted 6 lines · John Keeping
Quoted 5 lines · Corentin Labbe

Instead of doing manual queue management, let's use the crypto/engine for that.
In the same time, rework the requests handling to be easier to understand (and fix all bugs related to them).

Quoted 7 lines
Quoted 3 lines
Fixes ce0183cb6464b ("crypto: rockchip - switch to skcipher API")

---

In addition to the warnings reported by the kernel test robot, this needs to add select CRYPTO_ENGINE to Kconfig for the Rockchip driver.

Hello

Thanks for the report, I will fix this in v2

Thanks

author maintainer
#24 lore raw
In reply to John Keeping
Quoted 10 lines · John Keeping
Quoted 5 lines · Corentin Labbe

The rockchip crypto driver is broken and do not pass self-tests. This serie's goal is to permit to become usable and pass self-tests.

This whole serie is tested on a rk3328-rock64 with selftests (with CONFIG_CRYPTO_MANAGER_EXTRA_TESTS=y)

I previously noticed this breakage on rk3288 but never got time to investigate (disabling the driver was quicker).

Quoted 7 lines

This series fixes everything on rk3288 as well, thanks!

I hit the same warnings as the kernel test robot as well as a missing new kconfig dependency (see separate reply to patch 10), but this is

Thanks for the test, but since I have added some code in v2, could you re-test it ?

Regards