Linux-Renesas-SoC Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements
@ 2020-02-11 18:18 Geert Uytterhoeven
  2020-02-11 18:18 ` [PATCH v2 01/34] debugfs: regset32: Add Runtime PM support Geert Uytterhoeven
                   ` (36 more replies)
  0 siblings, 37 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:18 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

	Hi all,

This series contains several fixes, cleanups, and other improvements for
the ARM TrustZone CryptoCell driver.

The first 3 patches have been sent before:
  - [PATCH 0/2] Fix debugfs register access while suspended[1],
  - [PATCH] [RFC] crypto: ccree - fix retry handling in
    cc_send_sync_request()[2.

This is based on v5.6-rc1, with the following fixes from Gilad applied:
  - [PATCH 0/4] crypto: ccree - fixes[3],
  - [PATCH] crypto: ccree - dec auth tag size from cryptlen map[4].

This has been tested on R-Car H3 ES2.0.
To ease testing, I have pushed this series and its dependencies to the
topic/ccree-misc-v2  branch of my renesas-drivers repository at
git://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git.

Thanks for your comments!

[1] https://lore.kernel.org/r/20200124132957.15769-1-geert+renesas@glider.be/
[2] https://lore.kernel.org/r/20200128190913.23086-1-geert+renesas@glider.be/
[3] https://lore.kernel.org/r/20200129143757.680-1-gilad@benyossef.com/
[4] https://lore.kernel.org/r/20200202161914.9551-1-gilad@benyossef.com/

Geert Uytterhoeven (34):
  debugfs: regset32: Add Runtime PM support
  crypto: ccree - fix debugfs register access while suspended
  crypto: ccree - fix retry handling in cc_send_sync_request()
  crypto: ccree - remove unneeded casts
  crypto: ccree - swap SHA384 and SHA512 larval hashes at build time
  crypto: ccree - drop duplicated error message on SRAM exhaustion
  crypto: ccree - remove empty cc_sram_mgr_fini()
  crypto: ccree - clean up clock handling
  crypto: ccree - make mlli_params.mlli_virt_addr void *
  crypto: ccree - use existing helpers to split 64-bit addresses
  crypto: ccree - defer larval_digest_addr init until needed
  crypto: ccree - remove bogus paragraph about freeing SRAM
  crypto: ccree - use u32 for SRAM addresses
  crypto: ccree - simplify Runtime PM handling
  crypto: ccree - use of_device_get_match_data()
  crypto: ccree - remove cc_pm_is_dev_suspended() wrapper
  crypto: ccree - make cc_pm_{suspend,resume}() static
  crypto: ccree - remove struct cc_sram_ctx
  crypto: ccree - remove struct cc_debugfs_ctx
  crypto: ccree - remove struct buff_mgr_handle
  crypto: ccree - remove struct cc_cipher_handle
  crypto: ccree - extract cc_init_copy_sram()
  crypto: ccree - remove bogus kerneldoc markers
  crypto: ccree - improve kerneldoc in cc_hw_queue_defs.h
  crypto: ccree - improve kerneldoc in cc_buffer_mgr.c
  crypto: ccree - improve kerneldoc in cc_hash.[ch]
  crypto: ccree - improve kerneldoc in cc_request_mgr.[ch]
  crypto: ccree - improve kerneldoc in cc_sram_mgr.[ch]
  crypto: ccree - spelling s/Crytpcell/Cryptocell/
  crypto: ccree - grammar s/not room/no room/
  crypto: ccree - use existing dev helper in init_cc_resources()
  crypto: ccree - use devm_k[mz]alloc() for AEAD data
  crypto: ccree - use devm_k[mz]alloc() for cipher data
  crypto: ccree - use devm_kzalloc() for hash data

 drivers/crypto/ccree/cc_aead.c          |  61 +++---
 drivers/crypto/ccree/cc_buffer_mgr.c    |  66 +++---
 drivers/crypto/ccree/cc_buffer_mgr.h    |   4 +-
 drivers/crypto/ccree/cc_cipher.c        |  61 ++----
 drivers/crypto/ccree/cc_debugfs.c       |  29 +--
 drivers/crypto/ccree/cc_driver.c        | 127 +++++-------
 drivers/crypto/ccree/cc_driver.h        |  13 +-
 drivers/crypto/ccree/cc_hash.c          | 225 +++++++++------------
 drivers/crypto/ccree/cc_hash.h          |  31 ++-
 drivers/crypto/ccree/cc_hw_queue_defs.h | 255 ++++++++++++------------
 drivers/crypto/ccree/cc_pm.c            |  60 +-----
 drivers/crypto/ccree/cc_pm.h            |  21 --
 drivers/crypto/ccree/cc_request_mgr.c   |  47 +++--
 drivers/crypto/ccree/cc_request_mgr.h   |  19 +-
 drivers/crypto/ccree/cc_sram_mgr.c      |  78 +++-----
 drivers/crypto/ccree/cc_sram_mgr.h      |  45 ++---
 fs/debugfs/file.c                       |   8 +
 include/linux/debugfs.h                 |   1 +
 18 files changed, 456 insertions(+), 695 deletions(-)

-- 
2.17.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

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

* [PATCH v2 01/34] debugfs: regset32: Add Runtime PM support
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
@ 2020-02-11 18:18 ` Geert Uytterhoeven
  2020-02-11 18:18 ` [PATCH v2 02/34] crypto: ccree - fix debugfs register access while suspended Geert Uytterhoeven
                   ` (35 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:18 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

Hardware registers of devices under control of power management cannot
be accessed at all times.  If such a device is suspended, register
accesses may lead to undefined behavior, like reading bogus values, or
causing exceptions or system lock-ups.

Extend struct debugfs_regset32 with an optional field to let device
drivers specify the device the registers in the set belong to.  This
allows debugfs_show_regset32() to make sure the device is resumed while
its registers are being read.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
Affected drivers:
  - drivers/crypto/ccree (fixed)
  - drivers/gpu/drm/msm/disp/dpu1
  - drivers/usb/dwc3
  - drivers/usb/host/ehci-omap.c
  - drivers/usb/host/ehci-tegra.c
  - drivers/usb/host/ohci-platform.c
  - drivers/usb/host/xhci-dbgcap.c
  - drivers/usb/host/xhci-histb.c
  - drivers/usb/host/xhci-hub.c
  - drivers/usb/host/xhci-mtk.c
  - drivers/usb/host/xhci-pci.c
  - drivers/usb/host/xhci-tegra.c
  - drivers/usb/host/xhci.c
  - drivers/usb/mtu3
  - drivers/usb/musb
    drivers/usb/host/xhci-plat.c

Some drivers call pm_runtime_forbid(), but given the comment "users
should enable runtime pm using power/control in sysfs", this can be
overridden from userspace?

v2:
  - Add Reviewed-by, Acked-by,
  - s/locks/lock-ups/.
---
 fs/debugfs/file.c       | 8 ++++++++
 include/linux/debugfs.h | 1 +
 2 files changed, 9 insertions(+)

diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index 634b09d18b77f46f..204734f8d1c6d648 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -18,6 +18,7 @@
 #include <linux/slab.h>
 #include <linux/atomic.h>
 #include <linux/device.h>
+#include <linux/pm_runtime.h>
 #include <linux/poll.h>
 #include <linux/security.h>
 
@@ -1060,7 +1061,14 @@ static int debugfs_show_regset32(struct seq_file *s, void *data)
 {
 	struct debugfs_regset32 *regset = s->private;
 
+	if (regset->dev)
+		pm_runtime_get_sync(regset->dev);
+
 	debugfs_print_regs32(s, regset->regs, regset->nregs, regset->base, "");
+
+	if (regset->dev)
+		pm_runtime_put(regset->dev);
+
 	return 0;
 }
 
diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h
index 3d013de64f70ec42..ad416853e722fca7 100644
--- a/include/linux/debugfs.h
+++ b/include/linux/debugfs.h
@@ -35,6 +35,7 @@ struct debugfs_regset32 {
 	const struct debugfs_reg32 *regs;
 	int nregs;
 	void __iomem *base;
+	struct device *dev;	/* Optional device for Runtime PM */
 };
 
 extern struct dentry *arch_debugfs_dir;
-- 
2.17.1


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

* [PATCH v2 02/34] crypto: ccree - fix debugfs register access while suspended
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
  2020-02-11 18:18 ` [PATCH v2 01/34] debugfs: regset32: Add Runtime PM support Geert Uytterhoeven
@ 2020-02-11 18:18 ` Geert Uytterhoeven
  2020-02-11 18:18 ` [PATCH v2 03/34] crypto: ccree - fix retry handling in cc_send_sync_request() Geert Uytterhoeven
                   ` (34 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:18 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

Reading the debugfs files under /sys/kernel/debug/ccree/ can be done by
the user at any time.  On R-Car SoCs, the CCREE device is power-managed
using a moduile clock, and if this clock is not running, bogus register
values may be read.

Fix this by filling in the debugfs_regset32.dev field, so debugfs will
make sure the device is resumed while its registers are being read.

This fixes the bogus values (0x00000260) in the register dumps on R-Car
H3 ES1.0:

    -e6601000.crypto/regs:HOST_IRR = 0x00000260
    -e6601000.crypto/regs:HOST_POWER_DOWN_EN = 0x00000260
    +e6601000.crypto/regs:HOST_IRR = 0x00000038
    +e6601000.crypto/regs:HOST_POWER_DOWN_EN = 0x00000038
     e6601000.crypto/regs:AXIM_MON_ERR = 0x00000000
     e6601000.crypto/regs:DSCRPTR_QUEUE_CONTENT = 0x000002aa
    -e6601000.crypto/regs:HOST_IMR = 0x00000260
    +e6601000.crypto/regs:HOST_IMR = 0x017ffeff
     e6601000.crypto/regs:AXIM_CFG = 0x001f0007
     e6601000.crypto/regs:AXIM_CACHE_PARAMS = 0x00000000
    -e6601000.crypto/regs:GPR_HOST = 0x00000260
    +e6601000.crypto/regs:GPR_HOST = 0x017ffeff
     e6601000.crypto/regs:AXIM_MON_COMP = 0x00000000
    -e6601000.crypto/version:SIGNATURE = 0x00000260
    -e6601000.crypto/version:VERSION = 0x00000260
    +e6601000.crypto/version:SIGNATURE = 0xdcc63000
    +e6601000.crypto/version:VERSION = 0xaf400001

Note that this behavior is system-dependent, and the issue does not show
up on all R-Car Gen3 SoCs and boards.  Even when the device is
suspended, the module clock may be left enabled, if configured by the
firmware for Secure Mode, or when controlled by the Real-Time Core.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Gilad Ben-Yossef <gilad@benyossef.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
v2:
  - Add Acked-by, Reviewed-by.
---
 drivers/crypto/ccree/cc_debugfs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/crypto/ccree/cc_debugfs.c b/drivers/crypto/ccree/cc_debugfs.c
index 5669997386988055..35f3a2137502bd96 100644
--- a/drivers/crypto/ccree/cc_debugfs.c
+++ b/drivers/crypto/ccree/cc_debugfs.c
@@ -81,6 +81,7 @@ int cc_debugfs_init(struct cc_drvdata *drvdata)
 	regset->regs = debug_regs;
 	regset->nregs = ARRAY_SIZE(debug_regs);
 	regset->base = drvdata->cc_base;
+	regset->dev = dev;
 
 	ctx->dir = debugfs_create_dir(drvdata->plat_dev->name, cc_debugfs_dir);
 
@@ -102,6 +103,7 @@ int cc_debugfs_init(struct cc_drvdata *drvdata)
 		verset->nregs = ARRAY_SIZE(pid_cid_regs);
 	}
 	verset->base = drvdata->cc_base;
+	verset->dev = dev;
 
 	debugfs_create_regset32("version", 0400, ctx->dir, verset);
 
-- 
2.17.1


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

* [PATCH v2 03/34] crypto: ccree - fix retry handling in cc_send_sync_request()
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
  2020-02-11 18:18 ` [PATCH v2 01/34] debugfs: regset32: Add Runtime PM support Geert Uytterhoeven
  2020-02-11 18:18 ` [PATCH v2 02/34] crypto: ccree - fix debugfs register access while suspended Geert Uytterhoeven
@ 2020-02-11 18:18 ` Geert Uytterhoeven
  2020-02-11 18:18 ` [PATCH v2 04/34] crypto: ccree - remove unneeded casts Geert Uytterhoeven
                   ` (33 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:18 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

If cc_queues_status() indicates that the queue is full,
cc_send_sync_request() should loop and retry.

However, cc_queues_status() returns either 0 (for success), or -ENOSPC
(for queue full), while cc_send_sync_request() checks for real errors by
comparing with -EAGAIN.  Hence -ENOSPC is always considered a real
error, and the code never retries the operation.

Fix this by just removing the check, as cc_queues_status() never returns
any other error value than -ENOSPC.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Gilad Ben-Yossef <gilad@benyossef.com>
---
v2:
  - Add Acked-by: Gilad Ben-Yossef <gilad@benyossef.com>,
  - Drop RFC.
---
 drivers/crypto/ccree/cc_request_mgr.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/crypto/ccree/cc_request_mgr.c b/drivers/crypto/ccree/cc_request_mgr.c
index 9d61e6f1247819e2..b2a18122f320b7b2 100644
--- a/drivers/crypto/ccree/cc_request_mgr.c
+++ b/drivers/crypto/ccree/cc_request_mgr.c
@@ -476,10 +476,6 @@ int cc_send_sync_request(struct cc_drvdata *drvdata,
 			break;
 
 		spin_unlock_bh(&mgr->hw_lock);
-		if (rc != -EAGAIN) {
-			cc_pm_put_suspend(dev);
-			return rc;
-		}
 		wait_for_completion_interruptible(&drvdata->hw_queue_avail);
 		reinit_completion(&drvdata->hw_queue_avail);
 	}
-- 
2.17.1


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

* [PATCH v2 04/34] crypto: ccree - remove unneeded casts
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (2 preceding siblings ...)
  2020-02-11 18:18 ` [PATCH v2 03/34] crypto: ccree - fix retry handling in cc_send_sync_request() Geert Uytterhoeven
@ 2020-02-11 18:18 ` Geert Uytterhoeven
  2020-02-11 18:18 ` [PATCH v2 05/34] crypto: ccree - swap SHA384 and SHA512 larval hashes at build time Geert Uytterhoeven
                   ` (32 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:18 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

Unneeded casts prevent the compiler from performing valuable checks.
This is especially true for function pointers.

Remove these casts, to prevent silently introducing bugs when a
variable's type might be changed in the future.

No change in generated code.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_aead.c       |  7 +++----
 drivers/crypto/ccree/cc_buffer_mgr.c |  7 +++----
 drivers/crypto/ccree/cc_cipher.c     | 10 +++++-----
 drivers/crypto/ccree/cc_hash.c       | 24 ++++++++++++------------
 4 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/drivers/crypto/ccree/cc_aead.c b/drivers/crypto/ccree/cc_aead.c
index 0d95bda4de702a4a..7a62fb023d8d3769 100644
--- a/drivers/crypto/ccree/cc_aead.c
+++ b/drivers/crypto/ccree/cc_aead.c
@@ -448,8 +448,7 @@ static int cc_get_plain_hmac_key(struct crypto_aead *tfm, const u8 *authkey,
 		if (!key)
 			return -ENOMEM;
 
-		key_dma_addr = dma_map_single(dev, (void *)key, keylen,
-					      DMA_TO_DEVICE);
+		key_dma_addr = dma_map_single(dev, key, keylen, DMA_TO_DEVICE);
 		if (dma_mapping_error(dev, key_dma_addr)) {
 			dev_err(dev, "Mapping key va=0x%p len=%u for DMA failed\n",
 				key, keylen);
@@ -1921,8 +1920,8 @@ static int cc_proc_aead(struct aead_request *req,
 	}
 
 	/* Setup request structure */
-	cc_req.user_cb = (void *)cc_aead_complete;
-	cc_req.user_arg = (void *)req;
+	cc_req.user_cb = cc_aead_complete;
+	cc_req.user_arg = req;
 
 	/* Setup request context */
 	areq_ctx->gen_ctx.op_type = direct;
diff --git a/drivers/crypto/ccree/cc_buffer_mgr.c b/drivers/crypto/ccree/cc_buffer_mgr.c
index 954f14bddf1d7852..1e335abd744024d8 100644
--- a/drivers/crypto/ccree/cc_buffer_mgr.c
+++ b/drivers/crypto/ccree/cc_buffer_mgr.c
@@ -118,7 +118,7 @@ void cc_copy_sg_portion(struct device *dev, u8 *dest, struct scatterlist *sg,
 	u32 nents;
 
 	nents = sg_nents_for_len(sg, end);
-	sg_copy_buffer(sg, nents, (void *)dest, (end - to_skip + 1), to_skip,
+	sg_copy_buffer(sg, nents, dest, (end - to_skip + 1), to_skip,
 		       (direct == CC_SG_TO_BUF));
 }
 
@@ -415,10 +415,9 @@ int cc_map_cipher_request(struct cc_drvdata *drvdata, void *ctx,
 
 	/* Map IV buffer */
 	if (ivsize) {
-		dump_byte_array("iv", (u8 *)info, ivsize);
+		dump_byte_array("iv", info, ivsize);
 		req_ctx->gen_ctx.iv_dma_addr =
-			dma_map_single(dev, (void *)info,
-				       ivsize, DMA_BIDIRECTIONAL);
+			dma_map_single(dev, info, ivsize, DMA_BIDIRECTIONAL);
 		if (dma_mapping_error(dev, req_ctx->gen_ctx.iv_dma_addr)) {
 			dev_err(dev, "Mapping iv %u B at va=%pK for DMA failed\n",
 				ivsize, info);
diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c
index fc1646ccfe29bcaa..91d2edee47b8c843 100644
--- a/drivers/crypto/ccree/cc_cipher.c
+++ b/drivers/crypto/ccree/cc_cipher.c
@@ -184,7 +184,7 @@ static int cc_cipher_init(struct crypto_tfm *tfm)
 		ctx_p->user.key);
 
 	/* Map key buffer */
-	ctx_p->user.key_dma_addr = dma_map_single(dev, (void *)ctx_p->user.key,
+	ctx_p->user.key_dma_addr = dma_map_single(dev, ctx_p->user.key,
 						  max_key_buf_size,
 						  DMA_TO_DEVICE);
 	if (dma_mapping_error(dev, ctx_p->user.key_dma_addr)) {
@@ -284,7 +284,7 @@ static int cc_cipher_sethkey(struct crypto_skcipher *sktfm, const u8 *key,
 
 	dev_dbg(dev, "Setting HW key in context @%p for %s. keylen=%u\n",
 		ctx_p, crypto_tfm_alg_name(tfm), keylen);
-	dump_byte_array("key", (u8 *)key, keylen);
+	dump_byte_array("key", key, keylen);
 
 	/* STAT_PHASE_0: Init and sanity checks */
 
@@ -387,7 +387,7 @@ static int cc_cipher_setkey(struct crypto_skcipher *sktfm, const u8 *key,
 
 	dev_dbg(dev, "Setting key in context @%p for %s. keylen=%u\n",
 		ctx_p, crypto_tfm_alg_name(tfm), keylen);
-	dump_byte_array("key", (u8 *)key, keylen);
+	dump_byte_array("key", key, keylen);
 
 	/* STAT_PHASE_0: Init and sanity checks */
 
@@ -893,8 +893,8 @@ static int cc_cipher_process(struct skcipher_request *req,
 	}
 
 	/* Setup request structure */
-	cc_req.user_cb = (void *)cc_cipher_complete;
-	cc_req.user_arg = (void *)req;
+	cc_req.user_cb = cc_cipher_complete;
+	cc_req.user_arg = req;
 
 	/* Setup CPP operation details */
 	if (ctx_p->key_type == CC_POLICY_PROTECTED_KEY) {
diff --git a/drivers/crypto/ccree/cc_hash.c b/drivers/crypto/ccree/cc_hash.c
index 912e5ce5079d11ae..36ce015716c317df 100644
--- a/drivers/crypto/ccree/cc_hash.c
+++ b/drivers/crypto/ccree/cc_hash.c
@@ -752,7 +752,7 @@ static int cc_hash_setkey(struct crypto_ahash *ahash, const u8 *key,
 			return -ENOMEM;
 
 		ctx->key_params.key_dma_addr =
-			dma_map_single(dev, (void *)ctx->key_params.key, keylen,
+			dma_map_single(dev, ctx->key_params.key, keylen,
 				       DMA_TO_DEVICE);
 		if (dma_mapping_error(dev, ctx->key_params.key_dma_addr)) {
 			dev_err(dev, "Mapping key va=0x%p len=%u for DMA failed\n",
@@ -1067,8 +1067,8 @@ static int cc_alloc_ctx(struct cc_hash_ctx *ctx)
 	ctx->key_params.keylen = 0;
 
 	ctx->digest_buff_dma_addr =
-		dma_map_single(dev, (void *)ctx->digest_buff,
-			       sizeof(ctx->digest_buff), DMA_BIDIRECTIONAL);
+		dma_map_single(dev, ctx->digest_buff, sizeof(ctx->digest_buff),
+			       DMA_BIDIRECTIONAL);
 	if (dma_mapping_error(dev, ctx->digest_buff_dma_addr)) {
 		dev_err(dev, "Mapping digest len %zu B at va=%pK for DMA failed\n",
 			sizeof(ctx->digest_buff), ctx->digest_buff);
@@ -1079,7 +1079,7 @@ static int cc_alloc_ctx(struct cc_hash_ctx *ctx)
 		&ctx->digest_buff_dma_addr);
 
 	ctx->opad_tmp_keys_dma_addr =
-		dma_map_single(dev, (void *)ctx->opad_tmp_keys_buff,
+		dma_map_single(dev, ctx->opad_tmp_keys_buff,
 			       sizeof(ctx->opad_tmp_keys_buff),
 			       DMA_BIDIRECTIONAL);
 	if (dma_mapping_error(dev, ctx->opad_tmp_keys_dma_addr)) {
@@ -1196,8 +1196,8 @@ static int cc_mac_update(struct ahash_request *req)
 	idx++;
 
 	/* Setup request structure */
-	cc_req.user_cb = (void *)cc_update_complete;
-	cc_req.user_arg = (void *)req;
+	cc_req.user_cb = cc_update_complete;
+	cc_req.user_arg = req;
 
 	rc = cc_send_request(ctx->drvdata, &cc_req, desc, idx, &req->base);
 	if (rc != -EINPROGRESS && rc != -EBUSY) {
@@ -1254,8 +1254,8 @@ static int cc_mac_final(struct ahash_request *req)
 	}
 
 	/* Setup request structure */
-	cc_req.user_cb = (void *)cc_hash_complete;
-	cc_req.user_arg = (void *)req;
+	cc_req.user_cb = cc_hash_complete;
+	cc_req.user_arg = req;
 
 	if (state->xcbc_count && rem_cnt == 0) {
 		/* Load key for ECB decryption */
@@ -1369,8 +1369,8 @@ static int cc_mac_finup(struct ahash_request *req)
 	}
 
 	/* Setup request structure */
-	cc_req.user_cb = (void *)cc_hash_complete;
-	cc_req.user_arg = (void *)req;
+	cc_req.user_cb = cc_hash_complete;
+	cc_req.user_arg = req;
 
 	if (ctx->hw_mode == DRV_CIPHER_XCBC_MAC) {
 		key_len = CC_AES_128_BIT_KEY_SIZE;
@@ -1448,8 +1448,8 @@ static int cc_mac_digest(struct ahash_request *req)
 	}
 
 	/* Setup request structure */
-	cc_req.user_cb = (void *)cc_digest_complete;
-	cc_req.user_arg = (void *)req;
+	cc_req.user_cb = cc_digest_complete;
+	cc_req.user_arg = req;
 
 	if (ctx->hw_mode == DRV_CIPHER_XCBC_MAC) {
 		key_len = CC_AES_128_BIT_KEY_SIZE;
-- 
2.17.1


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

* [PATCH v2 05/34] crypto: ccree - swap SHA384 and SHA512 larval hashes at build time
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (3 preceding siblings ...)
  2020-02-11 18:18 ` [PATCH v2 04/34] crypto: ccree - remove unneeded casts Geert Uytterhoeven
@ 2020-02-11 18:18 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 06/34] crypto: ccree - drop duplicated error message on SRAM exhaustion Geert Uytterhoeven
                   ` (31 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:18 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

Due to the way the hardware works, every double word in the SHA384 and
SHA512 larval hashes must be swapped.  Currently this is done at run
time, during driver initialization.

However, this swapping can easily be done at build time.  Treating each
double word as two words has the benefit of changing the larval hashes'
types from u64[] to u32[], like for all other hashes, and allows
dropping the casts and size doublings when calling cc_set_sram_desc().

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_driver.c |  1 -
 drivers/crypto/ccree/cc_hash.c   | 49 +++++++++++---------------------
 drivers/crypto/ccree/cc_hash.h   |  2 --
 3 files changed, 17 insertions(+), 35 deletions(-)

diff --git a/drivers/crypto/ccree/cc_driver.c b/drivers/crypto/ccree/cc_driver.c
index 532bc95a83736f94..fc34d152f42090fc 100644
--- a/drivers/crypto/ccree/cc_driver.c
+++ b/drivers/crypto/ccree/cc_driver.c
@@ -653,7 +653,6 @@ static struct platform_driver ccree_driver = {
 
 static int __init ccree_init(void)
 {
-	cc_hash_global_init();
 	cc_debugfs_global_init();
 
 	return platform_driver_register(&ccree_driver);
diff --git a/drivers/crypto/ccree/cc_hash.c b/drivers/crypto/ccree/cc_hash.c
index 36ce015716c317df..c3146f550268e7ab 100644
--- a/drivers/crypto/ccree/cc_hash.c
+++ b/drivers/crypto/ccree/cc_hash.c
@@ -39,12 +39,19 @@ static const u32 cc_sha256_init[] = {
 	SHA256_H3, SHA256_H2, SHA256_H1, SHA256_H0 };
 static const u32 cc_digest_len_sha512_init[] = {
 	0x00000080, 0x00000000, 0x00000000, 0x00000000 };
-static u64 cc_sha384_init[] = {
-	SHA384_H7, SHA384_H6, SHA384_H5, SHA384_H4,
-	SHA384_H3, SHA384_H2, SHA384_H1, SHA384_H0 };
-static u64 cc_sha512_init[] = {
-	SHA512_H7, SHA512_H6, SHA512_H5, SHA512_H4,
-	SHA512_H3, SHA512_H2, SHA512_H1, SHA512_H0 };
+
+/*
+ * Due to the way the HW works, every double word in the SHA384 and SHA512
+ * larval hashes must be stored in hi/lo order
+ */
+#define hilo(x)	upper_32_bits(x), lower_32_bits(x)
+static const u32 cc_sha384_init[] = {
+	hilo(SHA384_H7), hilo(SHA384_H6), hilo(SHA384_H5), hilo(SHA384_H4),
+	hilo(SHA384_H3), hilo(SHA384_H2), hilo(SHA384_H1), hilo(SHA384_H0) };
+static const u32 cc_sha512_init[] = {
+	hilo(SHA512_H7), hilo(SHA512_H6), hilo(SHA512_H5), hilo(SHA512_H4),
+	hilo(SHA512_H3), hilo(SHA512_H2), hilo(SHA512_H1), hilo(SHA512_H0) };
+
 static const u32 cc_sm3_init[] = {
 	SM3_IVH, SM3_IVG, SM3_IVF, SM3_IVE,
 	SM3_IVD, SM3_IVC, SM3_IVB, SM3_IVA };
@@ -1942,8 +1949,8 @@ int cc_init_hash_sram(struct cc_drvdata *drvdata)
 	}
 
 	if (large_sha_supported) {
-		cc_set_sram_desc((u32 *)cc_sha384_init, sram_buff_ofs,
-				 (ARRAY_SIZE(cc_sha384_init) * 2), larval_seq,
+		cc_set_sram_desc(cc_sha384_init, sram_buff_ofs,
+				 ARRAY_SIZE(cc_sha384_init), larval_seq,
 				 &larval_seq_len);
 		rc = send_request_init(drvdata, larval_seq, larval_seq_len);
 		if (rc)
@@ -1951,8 +1958,8 @@ int cc_init_hash_sram(struct cc_drvdata *drvdata)
 		sram_buff_ofs += sizeof(cc_sha384_init);
 		larval_seq_len = 0;
 
-		cc_set_sram_desc((u32 *)cc_sha512_init, sram_buff_ofs,
-				 (ARRAY_SIZE(cc_sha512_init) * 2), larval_seq,
+		cc_set_sram_desc(cc_sha512_init, sram_buff_ofs,
+				 ARRAY_SIZE(cc_sha512_init), larval_seq,
 				 &larval_seq_len);
 		rc = send_request_init(drvdata, larval_seq, larval_seq_len);
 		if (rc)
@@ -1963,28 +1970,6 @@ int cc_init_hash_sram(struct cc_drvdata *drvdata)
 	return rc;
 }
 
-static void __init cc_swap_dwords(u32 *buf, unsigned long size)
-{
-	int i;
-	u32 tmp;
-
-	for (i = 0; i < size; i += 2) {
-		tmp = buf[i];
-		buf[i] = buf[i + 1];
-		buf[i + 1] = tmp;
-	}
-}
-
-/*
- * Due to the way the HW works we need to swap every
- * double word in the SHA384 and SHA512 larval hashes
- */
-void __init cc_hash_global_init(void)
-{
-	cc_swap_dwords((u32 *)&cc_sha384_init, (ARRAY_SIZE(cc_sha384_init) * 2));
-	cc_swap_dwords((u32 *)&cc_sha512_init, (ARRAY_SIZE(cc_sha512_init) * 2));
-}
-
 int cc_hash_alloc(struct cc_drvdata *drvdata)
 {
 	struct cc_hash_handle *hash_handle;
diff --git a/drivers/crypto/ccree/cc_hash.h b/drivers/crypto/ccree/cc_hash.h
index 0d6dc61484d79bc8..3dbd0abefea0546c 100644
--- a/drivers/crypto/ccree/cc_hash.h
+++ b/drivers/crypto/ccree/cc_hash.h
@@ -104,6 +104,4 @@ cc_digest_len_addr(void *drvdata, u32 mode);
  */
 cc_sram_addr_t cc_larval_digest_addr(void *drvdata, u32 mode);
 
-void cc_hash_global_init(void);
-
 #endif /*__CC_HASH_H__*/
-- 
2.17.1


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

* [PATCH v2 06/34] crypto: ccree - drop duplicated error message on SRAM exhaustion
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (4 preceding siblings ...)
  2020-02-11 18:18 ` [PATCH v2 05/34] crypto: ccree - swap SHA384 and SHA512 larval hashes at build time Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 07/34] crypto: ccree - remove empty cc_sram_mgr_fini() Geert Uytterhoeven
                   ` (30 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

When no SRAM can be allocated, cc_sram_alloc() already prints an error
message.  Hence there is no need to duplicate this in all callers.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_aead.c   | 1 -
 drivers/crypto/ccree/cc_driver.c | 1 -
 drivers/crypto/ccree/cc_hash.c   | 1 -
 3 files changed, 3 deletions(-)

diff --git a/drivers/crypto/ccree/cc_aead.c b/drivers/crypto/ccree/cc_aead.c
index 7a62fb023d8d3769..db89144ce6c5e974 100644
--- a/drivers/crypto/ccree/cc_aead.c
+++ b/drivers/crypto/ccree/cc_aead.c
@@ -2682,7 +2682,6 @@ int cc_aead_alloc(struct cc_drvdata *drvdata)
 							 MAX_HMAC_DIGEST_SIZE);
 
 	if (aead_handle->sram_workspace_addr == NULL_SRAM_ADDR) {
-		dev_err(dev, "SRAM pool exhausted\n");
 		rc = -ENOMEM;
 		goto fail1;
 	}
diff --git a/drivers/crypto/ccree/cc_driver.c b/drivers/crypto/ccree/cc_driver.c
index fc34d152f42090fc..599936a0b0a2cc63 100644
--- a/drivers/crypto/ccree/cc_driver.c
+++ b/drivers/crypto/ccree/cc_driver.c
@@ -477,7 +477,6 @@ static int init_cc_resources(struct platform_device *plat_dev)
 	new_drvdata->mlli_sram_addr =
 		cc_sram_alloc(new_drvdata, MAX_MLLI_BUFF_SIZE);
 	if (new_drvdata->mlli_sram_addr == NULL_SRAM_ADDR) {
-		dev_err(dev, "Failed to alloc MLLI Sram buffer\n");
 		rc = -ENOMEM;
 		goto post_sram_mgr_err;
 	}
diff --git a/drivers/crypto/ccree/cc_hash.c b/drivers/crypto/ccree/cc_hash.c
index c3146f550268e7ab..defeb35a16a626ff 100644
--- a/drivers/crypto/ccree/cc_hash.c
+++ b/drivers/crypto/ccree/cc_hash.c
@@ -2001,7 +2001,6 @@ int cc_hash_alloc(struct cc_drvdata *drvdata)
 
 	sram_buff = cc_sram_alloc(drvdata, sram_size_to_alloc);
 	if (sram_buff == NULL_SRAM_ADDR) {
-		dev_err(dev, "SRAM pool exhausted\n");
 		rc = -ENOMEM;
 		goto fail;
 	}
-- 
2.17.1


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

* [PATCH v2 07/34] crypto: ccree - remove empty cc_sram_mgr_fini()
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (5 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 06/34] crypto: ccree - drop duplicated error message on SRAM exhaustion Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 08/34] crypto: ccree - clean up clock handling Geert Uytterhoeven
                   ` (29 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

cc_sram_mgr_fini() doesn't do anything, so it can just be removed.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_driver.c   |  7 ++-----
 drivers/crypto/ccree/cc_sram_mgr.c | 10 ----------
 drivers/crypto/ccree/cc_sram_mgr.h |  7 -------
 3 files changed, 2 insertions(+), 22 deletions(-)

diff --git a/drivers/crypto/ccree/cc_driver.c b/drivers/crypto/ccree/cc_driver.c
index 599936a0b0a2cc63..f8aba89e48730e4d 100644
--- a/drivers/crypto/ccree/cc_driver.c
+++ b/drivers/crypto/ccree/cc_driver.c
@@ -478,13 +478,13 @@ static int init_cc_resources(struct platform_device *plat_dev)
 		cc_sram_alloc(new_drvdata, MAX_MLLI_BUFF_SIZE);
 	if (new_drvdata->mlli_sram_addr == NULL_SRAM_ADDR) {
 		rc = -ENOMEM;
-		goto post_sram_mgr_err;
+		goto post_fips_init_err;
 	}
 
 	rc = cc_req_mgr_init(new_drvdata);
 	if (rc) {
 		dev_err(dev, "cc_req_mgr_init failed\n");
-		goto post_sram_mgr_err;
+		goto post_fips_init_err;
 	}
 
 	rc = cc_buffer_mgr_init(new_drvdata);
@@ -538,8 +538,6 @@ static int init_cc_resources(struct platform_device *plat_dev)
 	 cc_buffer_mgr_fini(new_drvdata);
 post_req_mgr_err:
 	cc_req_mgr_fini(new_drvdata);
-post_sram_mgr_err:
-	cc_sram_mgr_fini(new_drvdata);
 post_fips_init_err:
 	cc_fips_fini(new_drvdata);
 post_debugfs_err:
@@ -568,7 +566,6 @@ static void cleanup_cc_resources(struct platform_device *plat_dev)
 	cc_pm_fini(drvdata);
 	cc_buffer_mgr_fini(drvdata);
 	cc_req_mgr_fini(drvdata);
-	cc_sram_mgr_fini(drvdata);
 	cc_fips_fini(drvdata);
 	cc_debugfs_fini(drvdata);
 	fini_cc_regs(drvdata);
diff --git a/drivers/crypto/ccree/cc_sram_mgr.c b/drivers/crypto/ccree/cc_sram_mgr.c
index 62c885e6e791cfe1..a3c13b37adce4641 100644
--- a/drivers/crypto/ccree/cc_sram_mgr.c
+++ b/drivers/crypto/ccree/cc_sram_mgr.c
@@ -12,16 +12,6 @@ struct cc_sram_ctx {
 	cc_sram_addr_t sram_free_offset;
 };
 
-/**
- * cc_sram_mgr_fini() - Cleanup SRAM pool.
- *
- * @drvdata: Associated device driver context
- */
-void cc_sram_mgr_fini(struct cc_drvdata *drvdata)
-{
-	/* Nothing needed */
-}
-
 /**
  * cc_sram_mgr_init() - Initializes SRAM pool.
  *      The pool starts right at the beginning of SRAM.
diff --git a/drivers/crypto/ccree/cc_sram_mgr.h b/drivers/crypto/ccree/cc_sram_mgr.h
index 1d14de9ee8c344ba..971029b0e2a16c36 100644
--- a/drivers/crypto/ccree/cc_sram_mgr.h
+++ b/drivers/crypto/ccree/cc_sram_mgr.h
@@ -29,13 +29,6 @@ typedef u64 cc_sram_addr_t;
  */
 int cc_sram_mgr_init(struct cc_drvdata *drvdata);
 
-/*!
- * Uninits SRAM pool.
- *
- * \param drvdata
- */
-void cc_sram_mgr_fini(struct cc_drvdata *drvdata);
-
 /*!
  * Allocated buffer from SRAM pool.
  * Note: Caller is responsible to free the LAST allocated buffer.
-- 
2.17.1


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

* [PATCH v2 08/34] crypto: ccree - clean up clock handling
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (6 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 07/34] crypto: ccree - remove empty cc_sram_mgr_fini() Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 09/34] crypto: ccree - make mlli_params.mlli_virt_addr void * Geert Uytterhoeven
                   ` (28 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

Use devm_clk_get_optional() instead of devm_clk_get() and explicit
optional clock handling.
As clk_prepare_enable() and clk_disable_unprepare() handle optional
clocks fine, the cc_clk_on() and cc_clk_off() wrappers can be removed.

While at it, use the new "%pe" format specifier to print error codes.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_driver.c | 55 ++++++--------------------------
 drivers/crypto/ccree/cc_driver.h |  2 --
 drivers/crypto/ccree/cc_pm.c     |  4 +--
 3 files changed, 11 insertions(+), 50 deletions(-)

diff --git a/drivers/crypto/ccree/cc_driver.c b/drivers/crypto/ccree/cc_driver.c
index f8aba89e48730e4d..a7b7f65939e2f620 100644
--- a/drivers/crypto/ccree/cc_driver.c
+++ b/drivers/crypto/ccree/cc_driver.c
@@ -302,22 +302,12 @@ static int init_cc_resources(struct platform_device *plat_dev)
 	platform_set_drvdata(plat_dev, new_drvdata);
 	new_drvdata->plat_dev = plat_dev;
 
-	clk = devm_clk_get(dev, NULL);
-	if (IS_ERR(clk))
-		switch (PTR_ERR(clk)) {
-		/* Clock is optional so this might be fine */
-		case -ENOENT:
-			break;
-
-		/* Clock not available, let's try again soon */
-		case -EPROBE_DEFER:
-			return -EPROBE_DEFER;
-
-		default:
-			dev_err(dev, "Error getting clock: %ld\n",
-				PTR_ERR(clk));
-			return PTR_ERR(clk);
-		}
+	clk = devm_clk_get_optional(dev, NULL);
+	if (IS_ERR(clk)) {
+		if (PTR_ERR(clk) != -EPROBE_DEFER)
+			dev_err(dev, "Error getting clock: %pe\n", clk);
+		return PTR_ERR(clk);
+	}
 	new_drvdata->clk = clk;
 
 	new_drvdata->coherent = of_dma_is_coherent(np);
@@ -362,7 +352,7 @@ static int init_cc_resources(struct platform_device *plat_dev)
 		return rc;
 	}
 
-	rc = cc_clk_on(new_drvdata);
+	rc = clk_prepare_enable(new_drvdata->clk);
 	if (rc) {
 		dev_err(dev, "Failed to enable clock");
 		return rc;
@@ -545,7 +535,7 @@ static int init_cc_resources(struct platform_device *plat_dev)
 post_regs_err:
 	fini_cc_regs(new_drvdata);
 post_clk_err:
-	cc_clk_off(new_drvdata);
+	clk_disable_unprepare(new_drvdata->clk);
 	return rc;
 }
 
@@ -569,23 +559,7 @@ static void cleanup_cc_resources(struct platform_device *plat_dev)
 	cc_fips_fini(drvdata);
 	cc_debugfs_fini(drvdata);
 	fini_cc_regs(drvdata);
-	cc_clk_off(drvdata);
-}
-
-int cc_clk_on(struct cc_drvdata *drvdata)
-{
-	struct clk *clk = drvdata->clk;
-	int rc;
-
-	if (IS_ERR(clk))
-		/* Not all devices have a clock associated with CCREE  */
-		return 0;
-
-	rc = clk_prepare_enable(clk);
-	if (rc)
-		return rc;
-
-	return 0;
+	clk_disable_unprepare(drvdata->clk);
 }
 
 unsigned int cc_get_default_hash_len(struct cc_drvdata *drvdata)
@@ -596,17 +570,6 @@ unsigned int cc_get_default_hash_len(struct cc_drvdata *drvdata)
 		return HASH_LEN_SIZE_630;
 }
 
-void cc_clk_off(struct cc_drvdata *drvdata)
-{
-	struct clk *clk = drvdata->clk;
-
-	if (IS_ERR(clk))
-		/* Not all devices have a clock associated with CCREE */
-		return;
-
-	clk_disable_unprepare(clk);
-}
-
 static int ccree_probe(struct platform_device *plat_dev)
 {
 	int rc;
diff --git a/drivers/crypto/ccree/cc_driver.h b/drivers/crypto/ccree/cc_driver.h
index c227718ba9923472..b983e721f2f758fe 100644
--- a/drivers/crypto/ccree/cc_driver.h
+++ b/drivers/crypto/ccree/cc_driver.h
@@ -212,8 +212,6 @@ static inline void dump_byte_array(const char *name, const u8 *the_array,
 bool cc_wait_for_reset_completion(struct cc_drvdata *drvdata);
 int init_cc_regs(struct cc_drvdata *drvdata, bool is_probe);
 void fini_cc_regs(struct cc_drvdata *drvdata);
-int cc_clk_on(struct cc_drvdata *drvdata);
-void cc_clk_off(struct cc_drvdata *drvdata);
 unsigned int cc_get_default_hash_len(struct cc_drvdata *drvdata);
 
 static inline void cc_iowrite(struct cc_drvdata *drvdata, u32 reg, u32 val)
diff --git a/drivers/crypto/ccree/cc_pm.c b/drivers/crypto/ccree/cc_pm.c
index 24c368b866f6b5ea..81376173c3ecf48f 100644
--- a/drivers/crypto/ccree/cc_pm.c
+++ b/drivers/crypto/ccree/cc_pm.c
@@ -26,7 +26,7 @@ int cc_pm_suspend(struct device *dev)
 	dev_dbg(dev, "set HOST_POWER_DOWN_EN\n");
 	fini_cc_regs(drvdata);
 	cc_iowrite(drvdata, CC_REG(HOST_POWER_DOWN_EN), POWER_DOWN_ENABLE);
-	cc_clk_off(drvdata);
+	clk_disable_unprepare(drvdata->clk);
 	return 0;
 }
 
@@ -37,7 +37,7 @@ int cc_pm_resume(struct device *dev)
 
 	dev_dbg(dev, "unset HOST_POWER_DOWN_EN\n");
 	/* Enables the device source clk */
-	rc = cc_clk_on(drvdata);
+	rc = clk_prepare_enable(drvdata->clk);
 	if (rc) {
 		dev_err(dev, "failed getting clock back on. We're toast.\n");
 		return rc;
-- 
2.17.1


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

* [PATCH v2 09/34] crypto: ccree - make mlli_params.mlli_virt_addr void *
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (7 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 08/34] crypto: ccree - clean up clock handling Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 10/34] crypto: ccree - use existing helpers to split 64-bit addresses Geert Uytterhoeven
                   ` (27 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

mlli_params.mlli_virt_addr is just a buffer of memory.
This allows to drop a cast.

No change in generated code.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_buffer_mgr.c | 2 +-
 drivers/crypto/ccree/cc_buffer_mgr.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/ccree/cc_buffer_mgr.c b/drivers/crypto/ccree/cc_buffer_mgr.c
index 1e335abd744024d8..abf08369f030faa8 100644
--- a/drivers/crypto/ccree/cc_buffer_mgr.c
+++ b/drivers/crypto/ccree/cc_buffer_mgr.c
@@ -207,7 +207,7 @@ static int cc_generate_mlli(struct device *dev, struct buffer_array *sg_data,
 		goto build_mlli_exit;
 	}
 	/* Point to start of MLLI */
-	mlli_p = (u32 *)mlli_params->mlli_virt_addr;
+	mlli_p = mlli_params->mlli_virt_addr;
 	/* go over all SG's and link it to one MLLI table */
 	for (i = 0; i < sg_data->num_of_buffers; i++) {
 		union buffer_array_entry *entry = &sg_data->entry[i];
diff --git a/drivers/crypto/ccree/cc_buffer_mgr.h b/drivers/crypto/ccree/cc_buffer_mgr.h
index 827b6cb1236e8a65..250d634902adc634 100644
--- a/drivers/crypto/ccree/cc_buffer_mgr.h
+++ b/drivers/crypto/ccree/cc_buffer_mgr.h
@@ -32,7 +32,7 @@ struct cc_mlli {
 
 struct mlli_params {
 	struct dma_pool *curr_pool;
-	u8 *mlli_virt_addr;
+	void *mlli_virt_addr;
 	dma_addr_t mlli_dma_addr;
 	u32 mlli_len;
 };
-- 
2.17.1


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

* [PATCH v2 10/34] crypto: ccree - use existing helpers to split 64-bit addresses
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (8 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 09/34] crypto: ccree - make mlli_params.mlli_virt_addr void * Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 11/34] crypto: ccree - defer larval_digest_addr init until needed Geert Uytterhoeven
                   ` (26 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

Use the existing lower_32_bits() and upper_32_bits() macros instead of
explicit casts and shifts to split a 64-bit address in its two 32-bit
parts.
Drop the superfluous cast to "u16", as the FIELD_PREP() macro already
masks it to the specified field width.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_hw_queue_defs.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/ccree/cc_hw_queue_defs.h b/drivers/crypto/ccree/cc_hw_queue_defs.h
index 9f4db9956e912f29..e3ec2a8084d864cd 100644
--- a/drivers/crypto/ccree/cc_hw_queue_defs.h
+++ b/drivers/crypto/ccree/cc_hw_queue_defs.h
@@ -239,9 +239,9 @@ static inline void set_din_type(struct cc_hw_desc *pdesc,
 				enum cc_dma_mode dma_mode, dma_addr_t addr,
 				u32 size, enum cc_axi_sec axi_sec)
 {
-	pdesc->word[0] = (u32)addr;
+	pdesc->word[0] = lower_32_bits(addr);
 #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
-	pdesc->word[5] |= FIELD_PREP(WORD5_DIN_ADDR_HIGH, ((u16)(addr >> 32)));
+	pdesc->word[5] |= FIELD_PREP(WORD5_DIN_ADDR_HIGH, upper_32_bits(addr));
 #endif
 	pdesc->word[1] |= FIELD_PREP(WORD1_DIN_DMA_MODE, dma_mode) |
 				FIELD_PREP(WORD1_DIN_SIZE, size) |
@@ -336,9 +336,9 @@ static inline void set_dout_type(struct cc_hw_desc *pdesc,
 				 enum cc_dma_mode dma_mode, dma_addr_t addr,
 				 u32 size, enum cc_axi_sec axi_sec)
 {
-	pdesc->word[2] = (u32)addr;
+	pdesc->word[2] = lower_32_bits(addr);
 #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
-	pdesc->word[5] |= FIELD_PREP(WORD5_DOUT_ADDR_HIGH, ((u16)(addr >> 32)));
+	pdesc->word[5] |= FIELD_PREP(WORD5_DOUT_ADDR_HIGH, upper_32_bits(addr));
 #endif
 	pdesc->word[3] |= FIELD_PREP(WORD3_DOUT_DMA_MODE, dma_mode) |
 				FIELD_PREP(WORD3_DOUT_SIZE, size) |
-- 
2.17.1


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

* [PATCH v2 11/34] crypto: ccree - defer larval_digest_addr init until needed
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (9 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 10/34] crypto: ccree - use existing helpers to split 64-bit addresses Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 12/34] crypto: ccree - remove bogus paragraph about freeing SRAM Geert Uytterhoeven
                   ` (25 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

While the larval digest addresses are not always used in
cc_get_plain_hmac_key() and cc_hash_digest(), they are always
calculated.

Defer their calculations to the points where needed.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_aead.c | 4 +++-
 drivers/crypto/ccree/cc_hash.c | 5 +++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/ccree/cc_aead.c b/drivers/crypto/ccree/cc_aead.c
index db89144ce6c5e974..d1e7e82b9a40f8ff 100644
--- a/drivers/crypto/ccree/cc_aead.c
+++ b/drivers/crypto/ccree/cc_aead.c
@@ -417,7 +417,7 @@ static int cc_get_plain_hmac_key(struct crypto_aead *tfm, const u8 *authkey,
 	dma_addr_t key_dma_addr = 0;
 	struct cc_aead_ctx *ctx = crypto_aead_ctx(tfm);
 	struct device *dev = drvdata_to_dev(ctx->drvdata);
-	u32 larval_addr = cc_larval_digest_addr(ctx->drvdata, ctx->auth_mode);
+	u32 larval_addr;
 	struct cc_crypto_req cc_req = {};
 	unsigned int blocksize;
 	unsigned int digestsize;
@@ -459,6 +459,8 @@ static int cc_get_plain_hmac_key(struct crypto_aead *tfm, const u8 *authkey,
 			/* Load hash initial state */
 			hw_desc_init(&desc[idx]);
 			set_cipher_mode(&desc[idx], hashmode);
+			larval_addr = cc_larval_digest_addr(ctx->drvdata,
+							    ctx->auth_mode);
 			set_din_sram(&desc[idx], larval_addr, digestsize);
 			set_flow_mode(&desc[idx], S_DIN_to_HASH);
 			set_setup_mode(&desc[idx], SETUP_LOAD_STATE0);
diff --git a/drivers/crypto/ccree/cc_hash.c b/drivers/crypto/ccree/cc_hash.c
index defeb35a16a626ff..cebbe2f08f606bf3 100644
--- a/drivers/crypto/ccree/cc_hash.c
+++ b/drivers/crypto/ccree/cc_hash.c
@@ -429,8 +429,7 @@ static int cc_hash_digest(struct ahash_request *req)
 	bool is_hmac = ctx->is_hmac;
 	struct cc_crypto_req cc_req = {};
 	struct cc_hw_desc desc[CC_MAX_HASH_SEQ_LEN];
-	cc_sram_addr_t larval_digest_addr =
-		cc_larval_digest_addr(ctx->drvdata, ctx->hash_mode);
+	cc_sram_addr_t larval_digest_addr;
 	int idx = 0;
 	int rc = 0;
 	gfp_t flags = cc_gfp_flags(&req->base);
@@ -472,6 +471,8 @@ static int cc_hash_digest(struct ahash_request *req)
 		set_din_type(&desc[idx], DMA_DLLI, state->digest_buff_dma_addr,
 			     ctx->inter_digestsize, NS_BIT);
 	} else {
+		larval_digest_addr = cc_larval_digest_addr(ctx->drvdata,
+							   ctx->hash_mode);
 		set_din_sram(&desc[idx], larval_digest_addr,
 			     ctx->inter_digestsize);
 	}
-- 
2.17.1


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

* [PATCH v2 12/34] crypto: ccree - remove bogus paragraph about freeing SRAM
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (10 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 11/34] crypto: ccree - defer larval_digest_addr init until needed Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 13/34] crypto: ccree - use u32 for SRAM addresses Geert Uytterhoeven
                   ` (24 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

The SRAM allocator does not support deallocating memory.
Hence remove all references to freeing SRAM.

Fix grammar while at it.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_sram_mgr.c | 3 ---
 drivers/crypto/ccree/cc_sram_mgr.h | 5 +----
 2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/crypto/ccree/cc_sram_mgr.c b/drivers/crypto/ccree/cc_sram_mgr.c
index a3c13b37adce4641..7d0e0db4f8df6e66 100644
--- a/drivers/crypto/ccree/cc_sram_mgr.c
+++ b/drivers/crypto/ccree/cc_sram_mgr.c
@@ -50,9 +50,6 @@ int cc_sram_mgr_init(struct cc_drvdata *drvdata)
 
 /*!
  * Allocated buffer from SRAM pool.
- * Note: Caller is responsible to free the LAST allocated buffer.
- * This function does not taking care of any fragmentation may occur
- * by the order of calls to alloc/free.
  *
  * \param drvdata
  * \param size The requested bytes to allocate
diff --git a/drivers/crypto/ccree/cc_sram_mgr.h b/drivers/crypto/ccree/cc_sram_mgr.h
index 971029b0e2a16c36..3b62dc3bd422a9c2 100644
--- a/drivers/crypto/ccree/cc_sram_mgr.h
+++ b/drivers/crypto/ccree/cc_sram_mgr.h
@@ -30,10 +30,7 @@ typedef u64 cc_sram_addr_t;
 int cc_sram_mgr_init(struct cc_drvdata *drvdata);
 
 /*!
- * Allocated buffer from SRAM pool.
- * Note: Caller is responsible to free the LAST allocated buffer.
- * This function does not taking care of any fragmentation may occur
- * by the order of calls to alloc/free.
+ * Allocate buffer from SRAM pool.
  *
  * \param drvdata
  * \param size The requested bytes to allocate
-- 
2.17.1


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

* [PATCH v2 13/34] crypto: ccree - use u32 for SRAM addresses
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (11 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 12/34] crypto: ccree - remove bogus paragraph about freeing SRAM Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 14/34] crypto: ccree - simplify Runtime PM handling Geert Uytterhoeven
                   ` (23 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

SRAM addresses are small integer offsets into local SRAM.  Currently
they are stored using a mixture of cc_sram_addr_t (u64), u32, and
dma_addr_t types.

Settle on u32, and remove the cc_sram_addr_t typedefs.
This allows to drop several casts.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_aead.c          |  6 +++---
 drivers/crypto/ccree/cc_buffer_mgr.h    |  2 +-
 drivers/crypto/ccree/cc_cipher.c        | 10 +++++-----
 drivers/crypto/ccree/cc_driver.h        |  2 +-
 drivers/crypto/ccree/cc_hash.c          | 21 ++++++++++-----------
 drivers/crypto/ccree/cc_hash.h          |  5 ++---
 drivers/crypto/ccree/cc_hw_queue_defs.h | 10 ++++------
 drivers/crypto/ccree/cc_sram_mgr.c      | 24 ++++++++++--------------
 drivers/crypto/ccree/cc_sram_mgr.h      | 15 ++++-----------
 9 files changed, 40 insertions(+), 55 deletions(-)

diff --git a/drivers/crypto/ccree/cc_aead.c b/drivers/crypto/ccree/cc_aead.c
index d1e7e82b9a40f8ff..78afa753b44f2dba 100644
--- a/drivers/crypto/ccree/cc_aead.c
+++ b/drivers/crypto/ccree/cc_aead.c
@@ -26,7 +26,7 @@
 #define MAX_NONCE_SIZE CTR_RFC3686_NONCE_SIZE
 
 struct cc_aead_handle {
-	cc_sram_addr_t sram_workspace_addr;
+	u32 sram_workspace_addr;
 	struct list_head aead_list;
 };
 
@@ -797,7 +797,7 @@ static void cc_proc_authen_desc(struct aead_request *areq,
 		 * assoc. + iv + data -compact in one table
 		 * if assoclen is ZERO only IV perform
 		 */
-		cc_sram_addr_t mlli_addr = areq_ctx->assoc.sram_addr;
+		u32 mlli_addr = areq_ctx->assoc.sram_addr;
 		u32 mlli_nents = areq_ctx->assoc.mlli_nents;
 
 		if (areq_ctx->is_single_pass) {
@@ -1171,7 +1171,7 @@ static void cc_mlli_to_sram(struct aead_request *req,
 	    req_ctx->data_buff_type == CC_DMA_BUF_MLLI ||
 	    !req_ctx->is_single_pass) && req_ctx->mlli_params.mlli_len) {
 		dev_dbg(dev, "Copy-to-sram: mlli_dma=%08x, mlli_size=%u\n",
-			(unsigned int)ctx->drvdata->mlli_sram_addr,
+			ctx->drvdata->mlli_sram_addr,
 			req_ctx->mlli_params.mlli_len);
 		/* Copy MLLI table host-to-sram */
 		hw_desc_init(&desc[*seq_size]);
diff --git a/drivers/crypto/ccree/cc_buffer_mgr.h b/drivers/crypto/ccree/cc_buffer_mgr.h
index 250d634902adc634..653441b6542e1fb1 100644
--- a/drivers/crypto/ccree/cc_buffer_mgr.h
+++ b/drivers/crypto/ccree/cc_buffer_mgr.h
@@ -24,7 +24,7 @@ enum cc_sg_cpy_direct {
 };
 
 struct cc_mlli {
-	cc_sram_addr_t sram_addr;
+	u32 sram_addr;
 	unsigned int mapped_nents;
 	unsigned int nents; //sg nents
 	unsigned int mlli_nents; //mlli nents might be different than the above
diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c
index 91d2edee47b8c843..1c7ced65008bc311 100644
--- a/drivers/crypto/ccree/cc_cipher.c
+++ b/drivers/crypto/ccree/cc_cipher.c
@@ -753,7 +753,7 @@ static void cc_setup_mlli_desc(struct crypto_tfm *tfm,
 		dev_dbg(dev, " bypass params addr %pad length 0x%X addr 0x%08X\n",
 			&req_ctx->mlli_params.mlli_dma_addr,
 			req_ctx->mlli_params.mlli_len,
-			(unsigned int)ctx_p->drvdata->mlli_sram_addr);
+			ctx_p->drvdata->mlli_sram_addr);
 		hw_desc_init(&desc[*seq_size]);
 		set_din_type(&desc[*seq_size], DMA_DLLI,
 			     req_ctx->mlli_params.mlli_dma_addr,
@@ -801,16 +801,16 @@ static void cc_setup_flow_desc(struct crypto_tfm *tfm,
 			     req_ctx->in_mlli_nents, NS_BIT);
 		if (req_ctx->out_nents == 0) {
 			dev_dbg(dev, " din/dout params addr 0x%08X addr 0x%08X\n",
-				(unsigned int)ctx_p->drvdata->mlli_sram_addr,
-				(unsigned int)ctx_p->drvdata->mlli_sram_addr);
+				ctx_p->drvdata->mlli_sram_addr,
+				ctx_p->drvdata->mlli_sram_addr);
 			set_dout_mlli(&desc[*seq_size],
 				      ctx_p->drvdata->mlli_sram_addr,
 				      req_ctx->in_mlli_nents, NS_BIT,
 				      (!last_desc ? 0 : 1));
 		} else {
 			dev_dbg(dev, " din/dout params addr 0x%08X addr 0x%08X\n",
-				(unsigned int)ctx_p->drvdata->mlli_sram_addr,
-				(unsigned int)ctx_p->drvdata->mlli_sram_addr +
+				ctx_p->drvdata->mlli_sram_addr,
+				ctx_p->drvdata->mlli_sram_addr +
 				(u32)LLI_ENTRY_BYTE_SIZE * req_ctx->in_nents);
 			set_dout_mlli(&desc[*seq_size],
 				      (ctx_p->drvdata->mlli_sram_addr +
diff --git a/drivers/crypto/ccree/cc_driver.h b/drivers/crypto/ccree/cc_driver.h
index b983e721f2f758fe..d7928b164a3b57e5 100644
--- a/drivers/crypto/ccree/cc_driver.h
+++ b/drivers/crypto/ccree/cc_driver.h
@@ -139,7 +139,7 @@ struct cc_drvdata {
 	int irq;
 	struct completion hw_queue_avail; /* wait for HW queue availability */
 	struct platform_device *plat_dev;
-	cc_sram_addr_t mlli_sram_addr;
+	u32 mlli_sram_addr;
 	void *buff_mgr_handle;
 	void *cipher_handle;
 	void *hash_handle;
diff --git a/drivers/crypto/ccree/cc_hash.c b/drivers/crypto/ccree/cc_hash.c
index cebbe2f08f606bf3..0b179aafd484738b 100644
--- a/drivers/crypto/ccree/cc_hash.c
+++ b/drivers/crypto/ccree/cc_hash.c
@@ -20,8 +20,8 @@
 #define CC_SM3_HASH_LEN_SIZE 8
 
 struct cc_hash_handle {
-	cc_sram_addr_t digest_len_sram_addr; /* const value in SRAM*/
-	cc_sram_addr_t larval_digest_sram_addr;   /* const value in SRAM */
+	u32 digest_len_sram_addr;	/* const value in SRAM*/
+	u32 larval_digest_sram_addr;   /* const value in SRAM */
 	struct list_head hash_list;
 };
 
@@ -429,7 +429,7 @@ static int cc_hash_digest(struct ahash_request *req)
 	bool is_hmac = ctx->is_hmac;
 	struct cc_crypto_req cc_req = {};
 	struct cc_hw_desc desc[CC_MAX_HASH_SEQ_LEN];
-	cc_sram_addr_t larval_digest_addr;
+	u32 larval_digest_addr;
 	int idx = 0;
 	int rc = 0;
 	gfp_t flags = cc_gfp_flags(&req->base);
@@ -734,7 +734,7 @@ static int cc_hash_setkey(struct crypto_ahash *ahash, const u8 *key,
 	int digestsize = 0;
 	int i, idx = 0, rc = 0;
 	struct cc_hw_desc desc[CC_MAX_HASH_SEQ_LEN];
-	cc_sram_addr_t larval_addr;
+	u32 larval_addr;
 	struct device *dev;
 
 	ctx = crypto_ahash_ctx(ahash);
@@ -1868,7 +1868,7 @@ static struct cc_hash_alg *cc_alloc_hash_alg(struct cc_hash_template *template,
 int cc_init_hash_sram(struct cc_drvdata *drvdata)
 {
 	struct cc_hash_handle *hash_handle = drvdata->hash_handle;
-	cc_sram_addr_t sram_buff_ofs = hash_handle->digest_len_sram_addr;
+	u32 sram_buff_ofs = hash_handle->digest_len_sram_addr;
 	unsigned int larval_seq_len = 0;
 	struct cc_hw_desc larval_seq[CC_DIGEST_SIZE_MAX / sizeof(u32)];
 	bool large_sha_supported = (drvdata->hw_rev >= CC_HW_REV_712);
@@ -1974,7 +1974,7 @@ int cc_init_hash_sram(struct cc_drvdata *drvdata)
 int cc_hash_alloc(struct cc_drvdata *drvdata)
 {
 	struct cc_hash_handle *hash_handle;
-	cc_sram_addr_t sram_buff;
+	u32 sram_buff;
 	u32 sram_size_to_alloc;
 	struct device *dev = drvdata_to_dev(drvdata);
 	int rc = 0;
@@ -2266,13 +2266,13 @@ static const void *cc_larval_digest(struct device *dev, u32 mode)
  *
  * \return u32 The address of the initial digest in SRAM
  */
-cc_sram_addr_t cc_larval_digest_addr(void *drvdata, u32 mode)
+u32 cc_larval_digest_addr(void *drvdata, u32 mode)
 {
 	struct cc_drvdata *_drvdata = (struct cc_drvdata *)drvdata;
 	struct cc_hash_handle *hash_handle = _drvdata->hash_handle;
 	struct device *dev = drvdata_to_dev(_drvdata);
 	bool sm3_supported = (_drvdata->hw_rev >= CC_HW_REV_713);
-	cc_sram_addr_t addr;
+	u32 addr;
 
 	switch (mode) {
 	case DRV_HASH_NULL:
@@ -2324,12 +2324,11 @@ cc_sram_addr_t cc_larval_digest_addr(void *drvdata, u32 mode)
 	return hash_handle->larval_digest_sram_addr;
 }
 
-cc_sram_addr_t
-cc_digest_len_addr(void *drvdata, u32 mode)
+u32 cc_digest_len_addr(void *drvdata, u32 mode)
 {
 	struct cc_drvdata *_drvdata = (struct cc_drvdata *)drvdata;
 	struct cc_hash_handle *hash_handle = _drvdata->hash_handle;
-	cc_sram_addr_t digest_len_addr = hash_handle->digest_len_sram_addr;
+	u32 digest_len_addr = hash_handle->digest_len_sram_addr;
 
 	switch (mode) {
 	case DRV_HASH_SHA1:
diff --git a/drivers/crypto/ccree/cc_hash.h b/drivers/crypto/ccree/cc_hash.h
index 3dbd0abefea0546c..d76ecae996ca3fa0 100644
--- a/drivers/crypto/ccree/cc_hash.h
+++ b/drivers/crypto/ccree/cc_hash.h
@@ -89,8 +89,7 @@ int cc_hash_free(struct cc_drvdata *drvdata);
  *
  * \return u32 returns the address of the initial digest length in SRAM
  */
-cc_sram_addr_t
-cc_digest_len_addr(void *drvdata, u32 mode);
+u32 cc_digest_len_addr(void *drvdata, u32 mode);
 
 /*!
  * Gets the address of the initial digest in SRAM
@@ -102,6 +101,6 @@ cc_digest_len_addr(void *drvdata, u32 mode);
  *
  * \return u32 The address of the initial digest in SRAM
  */
-cc_sram_addr_t cc_larval_digest_addr(void *drvdata, u32 mode);
+u32 cc_larval_digest_addr(void *drvdata, u32 mode);
 
 #endif /*__CC_HASH_H__*/
diff --git a/drivers/crypto/ccree/cc_hw_queue_defs.h b/drivers/crypto/ccree/cc_hw_queue_defs.h
index e3ec2a8084d864cd..36786344c57a92cf 100644
--- a/drivers/crypto/ccree/cc_hw_queue_defs.h
+++ b/drivers/crypto/ccree/cc_hw_queue_defs.h
@@ -290,10 +290,9 @@ static inline void set_cpp_crypto_key(struct cc_hw_desc *pdesc, u8 slot)
  * @addr: DIN address
  * @size Data size in bytes
  */
-static inline void set_din_sram(struct cc_hw_desc *pdesc, dma_addr_t addr,
-				u32 size)
+static inline void set_din_sram(struct cc_hw_desc *pdesc, u32 addr, u32 size)
 {
-	pdesc->word[0] = (u32)addr;
+	pdesc->word[0] = addr;
 	pdesc->word[1] |= FIELD_PREP(WORD1_DIN_SIZE, size) |
 				FIELD_PREP(WORD1_DIN_DMA_MODE, DMA_SRAM);
 }
@@ -373,9 +372,8 @@ static inline void set_dout_dlli(struct cc_hw_desc *pdesc, dma_addr_t addr,
  * @last_ind: The last indication bit
  * @axi_sec: AXI secure bit
  */
-static inline void set_dout_mlli(struct cc_hw_desc *pdesc, dma_addr_t addr,
-				 u32 size, enum cc_axi_sec axi_sec,
-				 bool last_ind)
+static inline void set_dout_mlli(struct cc_hw_desc *pdesc, u32 addr, u32 size,
+				 enum cc_axi_sec axi_sec, bool last_ind)
 {
 	set_dout_type(pdesc, DMA_MLLI, addr, size, axi_sec);
 	pdesc->word[3] |= FIELD_PREP(WORD3_DOUT_LAST_IND, last_ind);
diff --git a/drivers/crypto/ccree/cc_sram_mgr.c b/drivers/crypto/ccree/cc_sram_mgr.c
index 7d0e0db4f8df6e66..d46aad7c8140acaa 100644
--- a/drivers/crypto/ccree/cc_sram_mgr.c
+++ b/drivers/crypto/ccree/cc_sram_mgr.c
@@ -9,7 +9,7 @@
  * @sram_free_offset:   the offset to the non-allocated area
  */
 struct cc_sram_ctx {
-	cc_sram_addr_t sram_free_offset;
+	u32 sram_free_offset;
 };
 
 /**
@@ -22,23 +22,20 @@ struct cc_sram_ctx {
 int cc_sram_mgr_init(struct cc_drvdata *drvdata)
 {
 	struct cc_sram_ctx *ctx;
-	dma_addr_t start = 0;
+	u32 start = 0;
 	struct device *dev = drvdata_to_dev(drvdata);
 
 	if (drvdata->hw_rev < CC_HW_REV_712) {
 		/* Pool starts after ROM bytes */
-		start = (dma_addr_t)cc_ioread(drvdata,
-					      CC_REG(HOST_SEP_SRAM_THRESHOLD));
-
+		start = cc_ioread(drvdata, CC_REG(HOST_SEP_SRAM_THRESHOLD));
 		if ((start & 0x3) != 0) {
-			dev_err(dev, "Invalid SRAM offset %pad\n", &start);
+			dev_err(dev, "Invalid SRAM offset 0x%x\n", start);
 			return -EINVAL;
 		}
 	}
 
 	/* Allocate "this" context */
 	ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
-
 	if (!ctx)
 		return -ENOMEM;
 
@@ -54,11 +51,11 @@ int cc_sram_mgr_init(struct cc_drvdata *drvdata)
  * \param drvdata
  * \param size The requested bytes to allocate
  */
-cc_sram_addr_t cc_sram_alloc(struct cc_drvdata *drvdata, u32 size)
+u32 cc_sram_alloc(struct cc_drvdata *drvdata, u32 size)
 {
 	struct cc_sram_ctx *smgr_ctx = drvdata->sram_mgr_handle;
 	struct device *dev = drvdata_to_dev(drvdata);
-	cc_sram_addr_t p;
+	u32 p;
 
 	if ((size & 0x3)) {
 		dev_err(dev, "Requested buffer size (%u) is not multiple of 4",
@@ -66,14 +63,14 @@ cc_sram_addr_t cc_sram_alloc(struct cc_drvdata *drvdata, u32 size)
 		return NULL_SRAM_ADDR;
 	}
 	if (size > (CC_CC_SRAM_SIZE - smgr_ctx->sram_free_offset)) {
-		dev_err(dev, "Not enough space to allocate %u B (at offset %llu)\n",
+		dev_err(dev, "Not enough space to allocate %u B (at offset %u)\n",
 			size, smgr_ctx->sram_free_offset);
 		return NULL_SRAM_ADDR;
 	}
 
 	p = smgr_ctx->sram_free_offset;
 	smgr_ctx->sram_free_offset += size;
-	dev_dbg(dev, "Allocated %u B @ %u\n", size, (unsigned int)p);
+	dev_dbg(dev, "Allocated %u B @ %u\n", size, p);
 	return p;
 }
 
@@ -88,9 +85,8 @@ cc_sram_addr_t cc_sram_alloc(struct cc_drvdata *drvdata, u32 size)
  * @seq:	  A pointer to the given IN/OUT descriptor sequence
  * @seq_len:	  A pointer to the given IN/OUT sequence length
  */
-void cc_set_sram_desc(const u32 *src, cc_sram_addr_t dst,
-		      unsigned int nelement, struct cc_hw_desc *seq,
-		      unsigned int *seq_len)
+void cc_set_sram_desc(const u32 *src, u32 dst, unsigned int nelement,
+		      struct cc_hw_desc *seq, unsigned int *seq_len)
 {
 	u32 i;
 	unsigned int idx = *seq_len;
diff --git a/drivers/crypto/ccree/cc_sram_mgr.h b/drivers/crypto/ccree/cc_sram_mgr.h
index 3b62dc3bd422a9c2..04a857259d4148eb 100644
--- a/drivers/crypto/ccree/cc_sram_mgr.h
+++ b/drivers/crypto/ccree/cc_sram_mgr.h
@@ -10,13 +10,7 @@
 
 struct cc_drvdata;
 
-/**
- * Address (offset) within CC internal SRAM
- */
-
-typedef u64 cc_sram_addr_t;
-
-#define NULL_SRAM_ADDR ((cc_sram_addr_t)-1)
+#define NULL_SRAM_ADDR ((u32)-1)
 
 /*!
  * Initializes SRAM pool.
@@ -35,7 +29,7 @@ int cc_sram_mgr_init(struct cc_drvdata *drvdata);
  * \param drvdata
  * \param size The requested bytes to allocate
  */
-cc_sram_addr_t cc_sram_alloc(struct cc_drvdata *drvdata, u32 size);
+u32 cc_sram_alloc(struct cc_drvdata *drvdata, u32 size);
 
 /**
  * cc_set_sram_desc() - Create const descriptors sequence to
@@ -48,8 +42,7 @@ cc_sram_addr_t cc_sram_alloc(struct cc_drvdata *drvdata, u32 size);
  * @seq:	  A pointer to the given IN/OUT descriptor sequence
  * @seq_len:	  A pointer to the given IN/OUT sequence length
  */
-void cc_set_sram_desc(const u32 *src, cc_sram_addr_t dst,
-		      unsigned int nelement, struct cc_hw_desc *seq,
-		      unsigned int *seq_len);
+void cc_set_sram_desc(const u32 *src, u32 dst, unsigned int nelement,
+		      struct cc_hw_desc *seq, unsigned int *seq_len);
 
 #endif /*__CC_SRAM_MGR_H__*/
-- 
2.17.1


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

* [PATCH v2 14/34] crypto: ccree - simplify Runtime PM handling
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (12 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 13/34] crypto: ccree - use u32 for SRAM addresses Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 15/34] crypto: ccree - use of_device_get_match_data() Geert Uytterhoeven
                   ` (22 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

Currently, a large part of the probe function runs before Runtime PM is
enabled.  As the driver manages the device's clock manually, this may
work fine on some systems, but may break on platforms with a more
complex power hierarchy.

Fix this by moving the initialization of Runtime PM before the first
register access (in cc_wait_for_reset_completion()), and putting the
device to sleep only after the last access (in cc_set_ree_fips_status()).

This allows to remove the pm_on flag, which was used to track manually
if Runtime PM had been enabled or not.
Remove the cc_pm_{init,go,fini}() wrappers, as they are called only
once, and obscure operation.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_driver.c | 43 +++++++++++++++++++-------------
 drivers/crypto/ccree/cc_driver.h |  1 -
 drivers/crypto/ccree/cc_pm.c     | 38 +++-------------------------
 drivers/crypto/ccree/cc_pm.h     | 12 ---------
 4 files changed, 29 insertions(+), 65 deletions(-)

diff --git a/drivers/crypto/ccree/cc_driver.c b/drivers/crypto/ccree/cc_driver.c
index a7b7f65939e2f620..c7e44f212d4b0ac5 100644
--- a/drivers/crypto/ccree/cc_driver.c
+++ b/drivers/crypto/ccree/cc_driver.c
@@ -14,6 +14,7 @@
 #include <linux/of.h>
 #include <linux/clk.h>
 #include <linux/of_address.h>
+#include <linux/pm_runtime.h>
 
 #include "cc_driver.h"
 #include "cc_request_mgr.h"
@@ -360,6 +361,16 @@ static int init_cc_resources(struct platform_device *plat_dev)
 
 	new_drvdata->sec_disabled = cc_sec_disable;
 
+	pm_runtime_set_autosuspend_delay(dev, CC_SUSPEND_TIMEOUT);
+	pm_runtime_use_autosuspend(dev);
+	pm_runtime_set_active(dev);
+	pm_runtime_enable(dev);
+	rc = pm_runtime_get_sync(dev);
+	if (rc < 0) {
+		dev_err(dev, "pm_runtime_get_sync() failed: %d\n", rc);
+		goto post_pm_err;
+	}
+
 	/* wait for Crytpcell reset completion */
 	if (!cc_wait_for_reset_completion(new_drvdata)) {
 		dev_err(dev, "Cryptocell reset not completed");
@@ -372,7 +383,7 @@ static int init_cc_resources(struct platform_device *plat_dev)
 			dev_err(dev, "Invalid CC signature: SIGNATURE=0x%08X != expected=0x%08X\n",
 				val, hw_rev->sig);
 			rc = -EINVAL;
-			goto post_clk_err;
+			goto post_pm_err;
 		}
 		sig_cidr = val;
 		hw_rev_pidr = cc_ioread(new_drvdata, new_drvdata->ver_offset);
@@ -383,7 +394,7 @@ static int init_cc_resources(struct platform_device *plat_dev)
 			dev_err(dev, "Invalid CC PIDR: PIDR0124=0x%08X != expected=0x%08X\n",
 				val,  hw_rev->pidr_0124);
 			rc = -EINVAL;
-			goto post_clk_err;
+			goto post_pm_err;
 		}
 		hw_rev_pidr = val;
 
@@ -392,7 +403,7 @@ static int init_cc_resources(struct platform_device *plat_dev)
 			dev_err(dev, "Invalid CC CIDR: CIDR0123=0x%08X != expected=0x%08X\n",
 			val,  hw_rev->cidr_0123);
 			rc = -EINVAL;
-			goto post_clk_err;
+			goto post_pm_err;
 		}
 		sig_cidr = val;
 
@@ -411,7 +422,7 @@ static int init_cc_resources(struct platform_device *plat_dev)
 		default:
 			dev_err(dev, "Unsupported engines configuration.\n");
 			rc = -EINVAL;
-			goto post_clk_err;
+			goto post_pm_err;
 		}
 
 		/* Check security disable state */
@@ -437,14 +448,14 @@ static int init_cc_resources(struct platform_device *plat_dev)
 			      new_drvdata);
 	if (rc) {
 		dev_err(dev, "Could not register to interrupt %d\n", irq);
-		goto post_clk_err;
+		goto post_pm_err;
 	}
 	dev_dbg(dev, "Registered to IRQ: %d\n", irq);
 
 	rc = init_cc_regs(new_drvdata, true);
 	if (rc) {
 		dev_err(dev, "init_cc_regs failed\n");
-		goto post_clk_err;
+		goto post_pm_err;
 	}
 
 	rc = cc_debugfs_init(new_drvdata);
@@ -483,12 +494,6 @@ static int init_cc_resources(struct platform_device *plat_dev)
 		goto post_req_mgr_err;
 	}
 
-	rc = cc_pm_init(new_drvdata);
-	if (rc) {
-		dev_err(dev, "cc_pm_init failed\n");
-		goto post_buf_mgr_err;
-	}
-
 	/* Allocate crypto algs */
 	rc = cc_cipher_alloc(new_drvdata);
 	if (rc) {
@@ -509,15 +514,13 @@ static int init_cc_resources(struct platform_device *plat_dev)
 		goto post_hash_err;
 	}
 
-	/* All set, we can allow autosuspend */
-	cc_pm_go(new_drvdata);
-
 	/* If we got here and FIPS mode is enabled
 	 * it means all FIPS test passed, so let TEE
 	 * know we're good.
 	 */
 	cc_set_ree_fips_status(new_drvdata, true);
 
+	pm_runtime_put(dev);
 	return 0;
 
 post_hash_err:
@@ -534,7 +537,10 @@ static int init_cc_resources(struct platform_device *plat_dev)
 	cc_debugfs_fini(new_drvdata);
 post_regs_err:
 	fini_cc_regs(new_drvdata);
-post_clk_err:
+post_pm_err:
+	pm_runtime_put_noidle(dev);
+	pm_runtime_disable(dev);
+	pm_runtime_set_suspended(dev);
 	clk_disable_unprepare(new_drvdata->clk);
 	return rc;
 }
@@ -547,18 +553,21 @@ void fini_cc_regs(struct cc_drvdata *drvdata)
 
 static void cleanup_cc_resources(struct platform_device *plat_dev)
 {
+	struct device *dev = &plat_dev->dev;
 	struct cc_drvdata *drvdata =
 		(struct cc_drvdata *)platform_get_drvdata(plat_dev);
 
 	cc_aead_free(drvdata);
 	cc_hash_free(drvdata);
 	cc_cipher_free(drvdata);
-	cc_pm_fini(drvdata);
 	cc_buffer_mgr_fini(drvdata);
 	cc_req_mgr_fini(drvdata);
 	cc_fips_fini(drvdata);
 	cc_debugfs_fini(drvdata);
 	fini_cc_regs(drvdata);
+	pm_runtime_put_noidle(dev);
+	pm_runtime_disable(dev);
+	pm_runtime_set_suspended(dev);
 	clk_disable_unprepare(drvdata->clk);
 }
 
diff --git a/drivers/crypto/ccree/cc_driver.h b/drivers/crypto/ccree/cc_driver.h
index d7928b164a3b57e5..9e94a29d84ae61f1 100644
--- a/drivers/crypto/ccree/cc_driver.h
+++ b/drivers/crypto/ccree/cc_driver.h
@@ -158,7 +158,6 @@ struct cc_drvdata {
 	int std_bodies;
 	bool sec_disabled;
 	u32 comp_mask;
-	bool pm_on;
 };
 
 struct cc_crypto_alg {
diff --git a/drivers/crypto/ccree/cc_pm.c b/drivers/crypto/ccree/cc_pm.c
index 81376173c3ecf48f..f7729fc1ee597e9a 100644
--- a/drivers/crypto/ccree/cc_pm.c
+++ b/drivers/crypto/ccree/cc_pm.c
@@ -64,23 +64,15 @@ int cc_pm_resume(struct device *dev)
 
 int cc_pm_get(struct device *dev)
 {
-	int rc = 0;
-	struct cc_drvdata *drvdata = dev_get_drvdata(dev);
-
-	if (drvdata->pm_on)
-		rc = pm_runtime_get_sync(dev);
+	int rc = pm_runtime_get_sync(dev);
 
 	return (rc == 1 ? 0 : rc);
 }
 
 void cc_pm_put_suspend(struct device *dev)
 {
-	struct cc_drvdata *drvdata = dev_get_drvdata(dev);
-
-	if (drvdata->pm_on) {
-		pm_runtime_mark_last_busy(dev);
-		pm_runtime_put_autosuspend(dev);
-	}
+	pm_runtime_mark_last_busy(dev);
+	pm_runtime_put_autosuspend(dev);
 }
 
 bool cc_pm_is_dev_suspended(struct device *dev)
@@ -88,27 +80,3 @@ bool cc_pm_is_dev_suspended(struct device *dev)
 	/* check device state using runtime api */
 	return pm_runtime_suspended(dev);
 }
-
-int cc_pm_init(struct cc_drvdata *drvdata)
-{
-	struct device *dev = drvdata_to_dev(drvdata);
-
-	/* must be before the enabling to avoid redundant suspending */
-	pm_runtime_set_autosuspend_delay(dev, CC_SUSPEND_TIMEOUT);
-	pm_runtime_use_autosuspend(dev);
-	/* set us as active - note we won't do PM ops until cc_pm_go()! */
-	return pm_runtime_set_active(dev);
-}
-
-/* enable the PM module*/
-void cc_pm_go(struct cc_drvdata *drvdata)
-{
-	pm_runtime_enable(drvdata_to_dev(drvdata));
-	drvdata->pm_on = true;
-}
-
-void cc_pm_fini(struct cc_drvdata *drvdata)
-{
-	pm_runtime_disable(drvdata_to_dev(drvdata));
-	drvdata->pm_on = false;
-}
diff --git a/drivers/crypto/ccree/cc_pm.h b/drivers/crypto/ccree/cc_pm.h
index 80a18e11cae43f3d..2dcf53fa108e77a6 100644
--- a/drivers/crypto/ccree/cc_pm.h
+++ b/drivers/crypto/ccree/cc_pm.h
@@ -15,9 +15,6 @@
 
 extern const struct dev_pm_ops ccree_pm;
 
-int cc_pm_init(struct cc_drvdata *drvdata);
-void cc_pm_go(struct cc_drvdata *drvdata);
-void cc_pm_fini(struct cc_drvdata *drvdata);
 int cc_pm_suspend(struct device *dev);
 int cc_pm_resume(struct device *dev);
 int cc_pm_get(struct device *dev);
@@ -26,15 +23,6 @@ bool cc_pm_is_dev_suspended(struct device *dev);
 
 #else
 
-static inline int cc_pm_init(struct cc_drvdata *drvdata)
-{
-	return 0;
-}
-
-static inline void cc_pm_go(struct cc_drvdata *drvdata) {}
-
-static inline void cc_pm_fini(struct cc_drvdata *drvdata) {}
-
 static inline int cc_pm_get(struct device *dev)
 {
 	return 0;
-- 
2.17.1


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

* [PATCH v2 15/34] crypto: ccree - use of_device_get_match_data()
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (13 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 14/34] crypto: ccree - simplify Runtime PM handling Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 16/34] crypto: ccree - remove cc_pm_is_dev_suspended() wrapper Geert Uytterhoeven
                   ` (21 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

If the driver is probed, it means a match was found in
arm_ccree_dev_of_match[].  Hence we can just use the
of_device_get_match_data() helper.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_driver.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/crypto/ccree/cc_driver.c b/drivers/crypto/ccree/cc_driver.c
index c7e44f212d4b0ac5..e365ede32cc0e6a0 100644
--- a/drivers/crypto/ccree/cc_driver.c
+++ b/drivers/crypto/ccree/cc_driver.c
@@ -14,6 +14,7 @@
 #include <linux/of.h>
 #include <linux/clk.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
 #include <linux/pm_runtime.h>
 
 #include "cc_driver.h"
@@ -270,7 +271,6 @@ static int init_cc_resources(struct platform_device *plat_dev)
 	u32 val, hw_rev_pidr, sig_cidr;
 	u64 dma_mask;
 	const struct cc_hw_data *hw_rev;
-	const struct of_device_id *dev_id;
 	struct clk *clk;
 	int irq;
 	int rc = 0;
@@ -279,11 +279,7 @@ static int init_cc_resources(struct platform_device *plat_dev)
 	if (!new_drvdata)
 		return -ENOMEM;
 
-	dev_id = of_match_node(arm_ccree_dev_of_match, np);
-	if (!dev_id)
-		return -ENODEV;
-
-	hw_rev = (struct cc_hw_data *)dev_id->data;
+	hw_rev = of_device_get_match_data(dev);
 	new_drvdata->hw_rev_name = hw_rev->name;
 	new_drvdata->hw_rev = hw_rev->rev;
 	new_drvdata->std_bodies = hw_rev->std_bodies;
-- 
2.17.1


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

* [PATCH v2 16/34] crypto: ccree - remove cc_pm_is_dev_suspended() wrapper
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (14 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 15/34] crypto: ccree - use of_device_get_match_data() Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 17/34] crypto: ccree - make cc_pm_{suspend,resume}() static Geert Uytterhoeven
                   ` (20 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

If CONFIG_PM=y, cc_pm_is_dev_suspended() is just a wrapper around
pm_runtime_suspended().
If CONFIG_PM=n, cc_pm_is_dev_suspended() a dummy that behaves exactly
the same as the dummy for pm_runtime_suspended().

Hence remove cc_pm_is_dev_suspended(), and call pm_runtime_suspended()
directly.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_driver.c | 2 +-
 drivers/crypto/ccree/cc_pm.c     | 6 ------
 drivers/crypto/ccree/cc_pm.h     | 7 -------
 3 files changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/crypto/ccree/cc_driver.c b/drivers/crypto/ccree/cc_driver.c
index e365ede32cc0e6a0..02442596310cd98d 100644
--- a/drivers/crypto/ccree/cc_driver.c
+++ b/drivers/crypto/ccree/cc_driver.c
@@ -136,7 +136,7 @@ static irqreturn_t cc_isr(int irq, void *dev_id)
 
 	/* STAT_OP_TYPE_GENERIC STAT_PHASE_0: Interrupt */
 	/* if driver suspended return, probably shared interrupt */
-	if (cc_pm_is_dev_suspended(dev))
+	if (pm_runtime_suspended(dev))
 		return IRQ_NONE;
 
 	/* read the interrupt status */
diff --git a/drivers/crypto/ccree/cc_pm.c b/drivers/crypto/ccree/cc_pm.c
index f7729fc1ee597e9a..3b4927c41a177752 100644
--- a/drivers/crypto/ccree/cc_pm.c
+++ b/drivers/crypto/ccree/cc_pm.c
@@ -74,9 +74,3 @@ void cc_pm_put_suspend(struct device *dev)
 	pm_runtime_mark_last_busy(dev);
 	pm_runtime_put_autosuspend(dev);
 }
-
-bool cc_pm_is_dev_suspended(struct device *dev)
-{
-	/* check device state using runtime api */
-	return pm_runtime_suspended(dev);
-}
diff --git a/drivers/crypto/ccree/cc_pm.h b/drivers/crypto/ccree/cc_pm.h
index 2dcf53fa108e77a6..1fe1fc827f62f49e 100644
--- a/drivers/crypto/ccree/cc_pm.h
+++ b/drivers/crypto/ccree/cc_pm.h
@@ -19,7 +19,6 @@ int cc_pm_suspend(struct device *dev);
 int cc_pm_resume(struct device *dev);
 int cc_pm_get(struct device *dev);
 void cc_pm_put_suspend(struct device *dev);
-bool cc_pm_is_dev_suspended(struct device *dev);
 
 #else
 
@@ -30,12 +29,6 @@ static inline int cc_pm_get(struct device *dev)
 
 static inline void cc_pm_put_suspend(struct device *dev) {}
 
-static inline bool cc_pm_is_dev_suspended(struct device *dev)
-{
-	/* if PM not supported device is never suspend */
-	return false;
-}
-
 #endif
 
 #endif /*__POWER_MGR_H__*/
-- 
2.17.1


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

* [PATCH v2 17/34] crypto: ccree - make cc_pm_{suspend,resume}() static
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (15 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 16/34] crypto: ccree - remove cc_pm_is_dev_suspended() wrapper Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 18/34] crypto: ccree - remove struct cc_sram_ctx Geert Uytterhoeven
                   ` (19 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

cc_pm_suspend() and cc_pm_resume() are not used outside
drivers/crypto/ccree/cc_pm.c.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_pm.c | 12 ++++++------
 drivers/crypto/ccree/cc_pm.h |  2 --
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/crypto/ccree/cc_pm.c b/drivers/crypto/ccree/cc_pm.c
index 3b4927c41a177752..d39e1664fc7edfd3 100644
--- a/drivers/crypto/ccree/cc_pm.c
+++ b/drivers/crypto/ccree/cc_pm.c
@@ -15,11 +15,7 @@
 #define POWER_DOWN_ENABLE 0x01
 #define POWER_DOWN_DISABLE 0x00
 
-const struct dev_pm_ops ccree_pm = {
-	SET_RUNTIME_PM_OPS(cc_pm_suspend, cc_pm_resume, NULL)
-};
-
-int cc_pm_suspend(struct device *dev)
+static int cc_pm_suspend(struct device *dev)
 {
 	struct cc_drvdata *drvdata = dev_get_drvdata(dev);
 
@@ -30,7 +26,7 @@ int cc_pm_suspend(struct device *dev)
 	return 0;
 }
 
-int cc_pm_resume(struct device *dev)
+static int cc_pm_resume(struct device *dev)
 {
 	int rc;
 	struct cc_drvdata *drvdata = dev_get_drvdata(dev);
@@ -62,6 +58,10 @@ int cc_pm_resume(struct device *dev)
 	return 0;
 }
 
+const struct dev_pm_ops ccree_pm = {
+	SET_RUNTIME_PM_OPS(cc_pm_suspend, cc_pm_resume, NULL)
+};
+
 int cc_pm_get(struct device *dev)
 {
 	int rc = pm_runtime_get_sync(dev);
diff --git a/drivers/crypto/ccree/cc_pm.h b/drivers/crypto/ccree/cc_pm.h
index 1fe1fc827f62f49e..50cac33de11832bc 100644
--- a/drivers/crypto/ccree/cc_pm.h
+++ b/drivers/crypto/ccree/cc_pm.h
@@ -15,8 +15,6 @@
 
 extern const struct dev_pm_ops ccree_pm;
 
-int cc_pm_suspend(struct device *dev);
-int cc_pm_resume(struct device *dev);
 int cc_pm_get(struct device *dev);
 void cc_pm_put_suspend(struct device *dev);
 
-- 
2.17.1


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

* [PATCH v2 18/34] crypto: ccree - remove struct cc_sram_ctx
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (16 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 17/34] crypto: ccree - make cc_pm_{suspend,resume}() static Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 19/34] crypto: ccree - remove struct cc_debugfs_ctx Geert Uytterhoeven
                   ` (18 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

The cc_sram_ctx structure contains only a single member, and only one
instance exists.  Simplify the code and reduce memory consumption by
moving this member to struct cc_drvdata.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_driver.h   |  2 +-
 drivers/crypto/ccree/cc_sram_mgr.c | 27 +++++----------------------
 2 files changed, 6 insertions(+), 23 deletions(-)

diff --git a/drivers/crypto/ccree/cc_driver.h b/drivers/crypto/ccree/cc_driver.h
index 9e94a29d84ae61f1..7e483c22858245f9 100644
--- a/drivers/crypto/ccree/cc_driver.h
+++ b/drivers/crypto/ccree/cc_driver.h
@@ -146,7 +146,7 @@ struct cc_drvdata {
 	void *aead_handle;
 	void *request_mgr_handle;
 	void *fips_handle;
-	void *sram_mgr_handle;
+	u32 sram_free_offset;	/* offset to non-allocated area in SRAM */
 	void *debugfs;
 	struct clk *clk;
 	bool coherent;
diff --git a/drivers/crypto/ccree/cc_sram_mgr.c b/drivers/crypto/ccree/cc_sram_mgr.c
index d46aad7c8140acaa..38f36cbc05b3cf6f 100644
--- a/drivers/crypto/ccree/cc_sram_mgr.c
+++ b/drivers/crypto/ccree/cc_sram_mgr.c
@@ -4,14 +4,6 @@
 #include "cc_driver.h"
 #include "cc_sram_mgr.h"
 
-/**
- * struct cc_sram_ctx -Internal RAM context manager
- * @sram_free_offset:   the offset to the non-allocated area
- */
-struct cc_sram_ctx {
-	u32 sram_free_offset;
-};
-
 /**
  * cc_sram_mgr_init() - Initializes SRAM pool.
  *      The pool starts right at the beginning of SRAM.
@@ -21,7 +13,6 @@ struct cc_sram_ctx {
  */
 int cc_sram_mgr_init(struct cc_drvdata *drvdata)
 {
-	struct cc_sram_ctx *ctx;
 	u32 start = 0;
 	struct device *dev = drvdata_to_dev(drvdata);
 
@@ -34,14 +25,7 @@ int cc_sram_mgr_init(struct cc_drvdata *drvdata)
 		}
 	}
 
-	/* Allocate "this" context */
-	ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
-	if (!ctx)
-		return -ENOMEM;
-
-	ctx->sram_free_offset = start;
-	drvdata->sram_mgr_handle = ctx;
-
+	drvdata->sram_free_offset = start;
 	return 0;
 }
 
@@ -53,7 +37,6 @@ int cc_sram_mgr_init(struct cc_drvdata *drvdata)
  */
 u32 cc_sram_alloc(struct cc_drvdata *drvdata, u32 size)
 {
-	struct cc_sram_ctx *smgr_ctx = drvdata->sram_mgr_handle;
 	struct device *dev = drvdata_to_dev(drvdata);
 	u32 p;
 
@@ -62,14 +45,14 @@ u32 cc_sram_alloc(struct cc_drvdata *drvdata, u32 size)
 			size);
 		return NULL_SRAM_ADDR;
 	}
-	if (size > (CC_CC_SRAM_SIZE - smgr_ctx->sram_free_offset)) {
+	if (size > (CC_CC_SRAM_SIZE - drvdata->sram_free_offset)) {
 		dev_err(dev, "Not enough space to allocate %u B (at offset %u)\n",
-			size, smgr_ctx->sram_free_offset);
+			size, drvdata->sram_free_offset);
 		return NULL_SRAM_ADDR;
 	}
 
-	p = smgr_ctx->sram_free_offset;
-	smgr_ctx->sram_free_offset += size;
+	p = drvdata->sram_free_offset;
+	drvdata->sram_free_offset += size;
 	dev_dbg(dev, "Allocated %u B @ %u\n", size, p);
 	return p;
 }
-- 
2.17.1


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

* [PATCH v2 19/34] crypto: ccree - remove struct cc_debugfs_ctx
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (17 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 18/34] crypto: ccree - remove struct cc_sram_ctx Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 20/34] crypto: ccree - remove struct buff_mgr_handle Geert Uytterhoeven
                   ` (17 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

The cc_debugfs_ctx structure contains only a single member, and only one
instance exists.  Simplify the code and reduce memory consumption by
moving this member to struct cc_drvdata.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_debugfs.c | 27 +++++++--------------------
 drivers/crypto/ccree/cc_driver.h  |  2 +-
 2 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/drivers/crypto/ccree/cc_debugfs.c b/drivers/crypto/ccree/cc_debugfs.c
index 35f3a2137502bd96..c454afce7781017b 100644
--- a/drivers/crypto/ccree/cc_debugfs.c
+++ b/drivers/crypto/ccree/cc_debugfs.c
@@ -8,10 +8,6 @@
 #include "cc_crypto_ctx.h"
 #include "cc_debugfs.h"
 
-struct cc_debugfs_ctx {
-	struct dentry *dir;
-};
-
 #define CC_DEBUG_REG(_X) {	\
 	.name = __stringify(_X),\
 	.offset = CC_REG(_X)	\
@@ -67,13 +63,8 @@ void __exit cc_debugfs_global_fini(void)
 int cc_debugfs_init(struct cc_drvdata *drvdata)
 {
 	struct device *dev = drvdata_to_dev(drvdata);
-	struct cc_debugfs_ctx *ctx;
 	struct debugfs_regset32 *regset, *verset;
 
-	ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
-	if (!ctx)
-		return -ENOMEM;
-
 	regset = devm_kzalloc(dev, sizeof(*regset), GFP_KERNEL);
 	if (!regset)
 		return -ENOMEM;
@@ -83,15 +74,16 @@ int cc_debugfs_init(struct cc_drvdata *drvdata)
 	regset->base = drvdata->cc_base;
 	regset->dev = dev;
 
-	ctx->dir = debugfs_create_dir(drvdata->plat_dev->name, cc_debugfs_dir);
+	drvdata->dir = debugfs_create_dir(drvdata->plat_dev->name,
+					  cc_debugfs_dir);
 
-	debugfs_create_regset32("regs", 0400, ctx->dir, regset);
-	debugfs_create_bool("coherent", 0400, ctx->dir, &drvdata->coherent);
+	debugfs_create_regset32("regs", 0400, drvdata->dir, regset);
+	debugfs_create_bool("coherent", 0400, drvdata->dir, &drvdata->coherent);
 
 	verset = devm_kzalloc(dev, sizeof(*verset), GFP_KERNEL);
 	/* Failing here is not important enough to fail the module load */
 	if (!verset)
-		goto out;
+		return 0;
 
 	if (drvdata->hw_rev <= CC_HW_REV_712) {
 		ver_sig_regs[0].offset = drvdata->sig_offset;
@@ -105,16 +97,11 @@ int cc_debugfs_init(struct cc_drvdata *drvdata)
 	verset->base = drvdata->cc_base;
 	verset->dev = dev;
 
-	debugfs_create_regset32("version", 0400, ctx->dir, verset);
-
-out:
-	drvdata->debugfs = ctx;
+	debugfs_create_regset32("version", 0400, drvdata->dir, verset);
 	return 0;
 }
 
 void cc_debugfs_fini(struct cc_drvdata *drvdata)
 {
-	struct cc_debugfs_ctx *ctx = (struct cc_debugfs_ctx *)drvdata->debugfs;
-
-	debugfs_remove_recursive(ctx->dir);
+	debugfs_remove_recursive(drvdata->dir);
 }
diff --git a/drivers/crypto/ccree/cc_driver.h b/drivers/crypto/ccree/cc_driver.h
index 7e483c22858245f9..7360b403655c96f7 100644
--- a/drivers/crypto/ccree/cc_driver.h
+++ b/drivers/crypto/ccree/cc_driver.h
@@ -147,7 +147,7 @@ struct cc_drvdata {
 	void *request_mgr_handle;
 	void *fips_handle;
 	u32 sram_free_offset;	/* offset to non-allocated area in SRAM */
-	void *debugfs;
+	struct dentry *dir;	/* for debugfs */
 	struct clk *clk;
 	bool coherent;
 	char *hw_rev_name;
-- 
2.17.1


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

* [PATCH v2 20/34] crypto: ccree - remove struct buff_mgr_handle
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (18 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 19/34] crypto: ccree - remove struct cc_debugfs_ctx Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 21/34] crypto: ccree - remove struct cc_cipher_handle Geert Uytterhoeven
                   ` (16 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

The buff_mgr_handle structure contains only a single member, and only
one instance exists.  Simplify the code and reduce memory consumption by
moving this member to struct cc_drvdata.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_buffer_mgr.c | 41 ++++++----------------------
 drivers/crypto/ccree/cc_driver.h     |  2 +-
 2 files changed, 9 insertions(+), 34 deletions(-)

diff --git a/drivers/crypto/ccree/cc_buffer_mgr.c b/drivers/crypto/ccree/cc_buffer_mgr.c
index abf08369f030faa8..f2e782d2be155ee4 100644
--- a/drivers/crypto/ccree/cc_buffer_mgr.c
+++ b/drivers/crypto/ccree/cc_buffer_mgr.c
@@ -19,10 +19,6 @@ enum dma_buffer_type {
 	DMA_BUFF_TYPE = 2,
 };
 
-struct buff_mgr_handle {
-	struct dma_pool *mlli_buffs_pool;
-};
-
 union buffer_array_entry {
 	struct scatterlist *sgl;
 	dma_addr_t buffer_dma;
@@ -402,7 +398,6 @@ int cc_map_cipher_request(struct cc_drvdata *drvdata, void *ctx,
 {
 	struct cipher_req_ctx *req_ctx = (struct cipher_req_ctx *)ctx;
 	struct mlli_params *mlli_params = &req_ctx->mlli_params;
-	struct buff_mgr_handle *buff_mgr = drvdata->buff_mgr_handle;
 	struct device *dev = drvdata_to_dev(drvdata);
 	struct buffer_array sg_data;
 	u32 dummy = 0;
@@ -466,7 +461,7 @@ int cc_map_cipher_request(struct cc_drvdata *drvdata, void *ctx,
 	}
 
 	if (req_ctx->dma_buf_type == CC_DMA_BUF_MLLI) {
-		mlli_params->curr_pool = buff_mgr->mlli_buffs_pool;
+		mlli_params->curr_pool = drvdata->mlli_buffs_pool;
 		rc = cc_generate_mlli(dev, &sg_data, mlli_params, flags);
 		if (rc)
 			goto cipher_exit;
@@ -1007,7 +1002,6 @@ int cc_map_aead_request(struct cc_drvdata *drvdata, struct aead_request *req)
 	struct device *dev = drvdata_to_dev(drvdata);
 	struct buffer_array sg_data;
 	unsigned int authsize = areq_ctx->req_authsize;
-	struct buff_mgr_handle *buff_mgr = drvdata->buff_mgr_handle;
 	int rc = 0;
 	struct crypto_aead *tfm = crypto_aead_reqtfm(req);
 	bool is_gcm4543 = areq_ctx->is_gcm4543;
@@ -1180,7 +1174,7 @@ int cc_map_aead_request(struct cc_drvdata *drvdata, struct aead_request *req)
 	 */
 	if (areq_ctx->assoc_buff_type == CC_DMA_BUF_MLLI ||
 	    areq_ctx->data_buff_type == CC_DMA_BUF_MLLI) {
-		mlli_params->curr_pool = buff_mgr->mlli_buffs_pool;
+		mlli_params->curr_pool = drvdata->mlli_buffs_pool;
 		rc = cc_generate_mlli(dev, &sg_data, mlli_params, flags);
 		if (rc)
 			goto aead_map_failure;
@@ -1208,7 +1202,6 @@ int cc_map_hash_request_final(struct cc_drvdata *drvdata, void *ctx,
 	u32 *curr_buff_cnt = cc_hash_buf_cnt(areq_ctx);
 	struct mlli_params *mlli_params = &areq_ctx->mlli_params;
 	struct buffer_array sg_data;
-	struct buff_mgr_handle *buff_mgr = drvdata->buff_mgr_handle;
 	int rc = 0;
 	u32 dummy = 0;
 	u32 mapped_nents = 0;
@@ -1255,7 +1248,7 @@ int cc_map_hash_request_final(struct cc_drvdata *drvdata, void *ctx,
 
 	/*build mlli */
 	if (areq_ctx->data_dma_buf_type == CC_DMA_BUF_MLLI) {
-		mlli_params->curr_pool = buff_mgr->mlli_buffs_pool;
+		mlli_params->curr_pool = drvdata->mlli_buffs_pool;
 		/* add the src data to the sg_data */
 		cc_add_sg_entry(dev, &sg_data, areq_ctx->in_nents, src, nbytes,
 				0, true, &areq_ctx->mlli_nents);
@@ -1293,7 +1286,6 @@ int cc_map_hash_request_update(struct cc_drvdata *drvdata, void *ctx,
 	unsigned int update_data_len;
 	u32 total_in_len = nbytes + *curr_buff_cnt;
 	struct buffer_array sg_data;
-	struct buff_mgr_handle *buff_mgr = drvdata->buff_mgr_handle;
 	unsigned int swap_index = 0;
 	int rc = 0;
 	u32 dummy = 0;
@@ -1368,7 +1360,7 @@ int cc_map_hash_request_update(struct cc_drvdata *drvdata, void *ctx,
 	}
 
 	if (areq_ctx->data_dma_buf_type == CC_DMA_BUF_MLLI) {
-		mlli_params->curr_pool = buff_mgr->mlli_buffs_pool;
+		mlli_params->curr_pool = drvdata->mlli_buffs_pool;
 		/* add the src data to the sg_data */
 		cc_add_sg_entry(dev, &sg_data, areq_ctx->in_nents, src,
 				(update_data_len - *curr_buff_cnt), 0, true,
@@ -1435,39 +1427,22 @@ void cc_unmap_hash_request(struct device *dev, void *ctx,
 
 int cc_buffer_mgr_init(struct cc_drvdata *drvdata)
 {
-	struct buff_mgr_handle *buff_mgr_handle;
 	struct device *dev = drvdata_to_dev(drvdata);
 
-	buff_mgr_handle = kmalloc(sizeof(*buff_mgr_handle), GFP_KERNEL);
-	if (!buff_mgr_handle)
-		return -ENOMEM;
-
-	drvdata->buff_mgr_handle = buff_mgr_handle;
-
-	buff_mgr_handle->mlli_buffs_pool =
+	drvdata->mlli_buffs_pool =
 		dma_pool_create("dx_single_mlli_tables", dev,
 				MAX_NUM_OF_TOTAL_MLLI_ENTRIES *
 				LLI_ENTRY_BYTE_SIZE,
 				MLLI_TABLE_MIN_ALIGNMENT, 0);
 
-	if (!buff_mgr_handle->mlli_buffs_pool)
-		goto error;
+	if (!drvdata->mlli_buffs_pool)
+		return -ENOMEM;
 
 	return 0;
-
-error:
-	cc_buffer_mgr_fini(drvdata);
-	return -ENOMEM;
 }
 
 int cc_buffer_mgr_fini(struct cc_drvdata *drvdata)
 {
-	struct buff_mgr_handle *buff_mgr_handle = drvdata->buff_mgr_handle;
-
-	if (buff_mgr_handle) {
-		dma_pool_destroy(buff_mgr_handle->mlli_buffs_pool);
-		kfree(drvdata->buff_mgr_handle);
-		drvdata->buff_mgr_handle = NULL;
-	}
+	dma_pool_destroy(drvdata->mlli_buffs_pool);
 	return 0;
 }
diff --git a/drivers/crypto/ccree/cc_driver.h b/drivers/crypto/ccree/cc_driver.h
index 7360b403655c96f7..4895f124d2b83fb1 100644
--- a/drivers/crypto/ccree/cc_driver.h
+++ b/drivers/crypto/ccree/cc_driver.h
@@ -140,7 +140,7 @@ struct cc_drvdata {
 	struct completion hw_queue_avail; /* wait for HW queue availability */
 	struct platform_device *plat_dev;
 	u32 mlli_sram_addr;
-	void *buff_mgr_handle;
+	struct dma_pool *mlli_buffs_pool;
 	void *cipher_handle;
 	void *hash_handle;
 	void *aead_handle;
-- 
2.17.1


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

* [PATCH v2 21/34] crypto: ccree - remove struct cc_cipher_handle
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (19 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 20/34] crypto: ccree - remove struct buff_mgr_handle Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 22/34] crypto: ccree - extract cc_init_copy_sram() Geert Uytterhoeven
                   ` (15 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

The cc_cipher_handle structure contains only a single member, and only
one instance exists.  Simplify the code and reduce memory consumption by
moving this member to struct cc_drvdata.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_cipher.c | 33 ++++++++------------------------
 drivers/crypto/ccree/cc_driver.h |  2 +-
 2 files changed, 9 insertions(+), 26 deletions(-)

diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c
index 1c7ced65008bc311..a1430d669a584a85 100644
--- a/drivers/crypto/ccree/cc_cipher.c
+++ b/drivers/crypto/ccree/cc_cipher.c
@@ -20,10 +20,6 @@
 
 #define template_skcipher	template_u.skcipher
 
-struct cc_cipher_handle {
-	struct list_head alg_list;
-};
-
 struct cc_user_key_info {
 	u8 *key;
 	dma_addr_t key_dma_addr;
@@ -1669,36 +1665,24 @@ static struct cc_crypto_alg *cc_create_alg(const struct cc_alg_template *tmpl,
 int cc_cipher_free(struct cc_drvdata *drvdata)
 {
 	struct cc_crypto_alg *t_alg, *n;
-	struct cc_cipher_handle *cipher_handle = drvdata->cipher_handle;
-
-	if (cipher_handle) {
-		/* Remove registered algs */
-		list_for_each_entry_safe(t_alg, n, &cipher_handle->alg_list,
-					 entry) {
-			crypto_unregister_skcipher(&t_alg->skcipher_alg);
-			list_del(&t_alg->entry);
-			kfree(t_alg);
-		}
-		kfree(cipher_handle);
-		drvdata->cipher_handle = NULL;
+
+	/* Remove registered algs */
+	list_for_each_entry_safe(t_alg, n, &drvdata->alg_list, entry) {
+		crypto_unregister_skcipher(&t_alg->skcipher_alg);
+		list_del(&t_alg->entry);
+		kfree(t_alg);
 	}
 	return 0;
 }
 
 int cc_cipher_alloc(struct cc_drvdata *drvdata)
 {
-	struct cc_cipher_handle *cipher_handle;
 	struct cc_crypto_alg *t_alg;
 	struct device *dev = drvdata_to_dev(drvdata);
 	int rc = -ENOMEM;
 	int alg;
 
-	cipher_handle = kmalloc(sizeof(*cipher_handle), GFP_KERNEL);
-	if (!cipher_handle)
-		return -ENOMEM;
-
-	INIT_LIST_HEAD(&cipher_handle->alg_list);
-	drvdata->cipher_handle = cipher_handle;
+	INIT_LIST_HEAD(&drvdata->alg_list);
 
 	/* Linux crypto */
 	dev_dbg(dev, "Number of algorithms = %zu\n",
@@ -1730,8 +1714,7 @@ int cc_cipher_alloc(struct cc_drvdata *drvdata)
 			kfree(t_alg);
 			goto fail0;
 		} else {
-			list_add_tail(&t_alg->entry,
-				      &cipher_handle->alg_list);
+			list_add_tail(&t_alg->entry, &drvdata->alg_list);
 			dev_dbg(dev, "Registered %s\n",
 				t_alg->skcipher_alg.base.cra_driver_name);
 		}
diff --git a/drivers/crypto/ccree/cc_driver.h b/drivers/crypto/ccree/cc_driver.h
index 4895f124d2b83fb1..4790eb5cb8bdac3c 100644
--- a/drivers/crypto/ccree/cc_driver.h
+++ b/drivers/crypto/ccree/cc_driver.h
@@ -141,7 +141,7 @@ struct cc_drvdata {
 	struct platform_device *plat_dev;
 	u32 mlli_sram_addr;
 	struct dma_pool *mlli_buffs_pool;
-	void *cipher_handle;
+	struct list_head alg_list;
 	void *hash_handle;
 	void *aead_handle;
 	void *request_mgr_handle;
-- 
2.17.1


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

* [PATCH v2 22/34] crypto: ccree - extract cc_init_copy_sram()
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (20 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 21/34] crypto: ccree - remove struct cc_cipher_handle Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 23/34] crypto: ccree - remove bogus kerneldoc markers Geert Uytterhoeven
                   ` (14 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

Extract the copy to SRAM of the initial values for a hash algorithm into
its own function, to improve readability and ease maintenance.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_hash.c | 91 ++++++++++++++--------------------
 1 file changed, 36 insertions(+), 55 deletions(-)

diff --git a/drivers/crypto/ccree/cc_hash.c b/drivers/crypto/ccree/cc_hash.c
index 0b179aafd484738b..f3adc1ab0e01abec 100644
--- a/drivers/crypto/ccree/cc_hash.c
+++ b/drivers/crypto/ccree/cc_hash.c
@@ -1865,104 +1865,85 @@ static struct cc_hash_alg *cc_alloc_hash_alg(struct cc_hash_template *template,
 	return t_crypto_alg;
 }
 
+static int cc_init_copy_sram(struct cc_drvdata *drvdata, const u32 *data,
+			     unsigned int size, u32 *sram_buff_ofs)
+{
+	struct cc_hw_desc larval_seq[CC_DIGEST_SIZE_MAX / sizeof(u32)];
+	unsigned int larval_seq_len = 0;
+	int rc;
+
+	cc_set_sram_desc(data, *sram_buff_ofs, size / sizeof(*data),
+			 larval_seq, &larval_seq_len);
+	rc = send_request_init(drvdata, larval_seq, larval_seq_len);
+	if (rc)
+		return rc;
+
+	*sram_buff_ofs += size;
+	return 0;
+}
+
 int cc_init_hash_sram(struct cc_drvdata *drvdata)
 {
 	struct cc_hash_handle *hash_handle = drvdata->hash_handle;
 	u32 sram_buff_ofs = hash_handle->digest_len_sram_addr;
-	unsigned int larval_seq_len = 0;
-	struct cc_hw_desc larval_seq[CC_DIGEST_SIZE_MAX / sizeof(u32)];
 	bool large_sha_supported = (drvdata->hw_rev >= CC_HW_REV_712);
 	bool sm3_supported = (drvdata->hw_rev >= CC_HW_REV_713);
 	int rc = 0;
 
 	/* Copy-to-sram digest-len */
-	cc_set_sram_desc(cc_digest_len_init, sram_buff_ofs,
-			 ARRAY_SIZE(cc_digest_len_init), larval_seq,
-			 &larval_seq_len);
-	rc = send_request_init(drvdata, larval_seq, larval_seq_len);
+	rc = cc_init_copy_sram(drvdata, cc_digest_len_init,
+			       sizeof(cc_digest_len_init), &sram_buff_ofs);
 	if (rc)
 		goto init_digest_const_err;
 
-	sram_buff_ofs += sizeof(cc_digest_len_init);
-	larval_seq_len = 0;
-
 	if (large_sha_supported) {
 		/* Copy-to-sram digest-len for sha384/512 */
-		cc_set_sram_desc(cc_digest_len_sha512_init, sram_buff_ofs,
-				 ARRAY_SIZE(cc_digest_len_sha512_init),
-				 larval_seq, &larval_seq_len);
-		rc = send_request_init(drvdata, larval_seq, larval_seq_len);
+		rc = cc_init_copy_sram(drvdata, cc_digest_len_sha512_init,
+				       sizeof(cc_digest_len_sha512_init),
+				       &sram_buff_ofs);
 		if (rc)
 			goto init_digest_const_err;
-
-		sram_buff_ofs += sizeof(cc_digest_len_sha512_init);
-		larval_seq_len = 0;
 	}
 
 	/* The initial digests offset */
 	hash_handle->larval_digest_sram_addr = sram_buff_ofs;
 
 	/* Copy-to-sram initial SHA* digests */
-	cc_set_sram_desc(cc_md5_init, sram_buff_ofs, ARRAY_SIZE(cc_md5_init),
-			 larval_seq, &larval_seq_len);
-	rc = send_request_init(drvdata, larval_seq, larval_seq_len);
+	rc = cc_init_copy_sram(drvdata, cc_md5_init, sizeof(cc_md5_init),
+			       &sram_buff_ofs);
 	if (rc)
 		goto init_digest_const_err;
-	sram_buff_ofs += sizeof(cc_md5_init);
-	larval_seq_len = 0;
 
-	cc_set_sram_desc(cc_sha1_init, sram_buff_ofs,
-			 ARRAY_SIZE(cc_sha1_init), larval_seq,
-			 &larval_seq_len);
-	rc = send_request_init(drvdata, larval_seq, larval_seq_len);
+	rc = cc_init_copy_sram(drvdata, cc_sha1_init, sizeof(cc_sha1_init),
+			       &sram_buff_ofs);
 	if (rc)
 		goto init_digest_const_err;
-	sram_buff_ofs += sizeof(cc_sha1_init);
-	larval_seq_len = 0;
 
-	cc_set_sram_desc(cc_sha224_init, sram_buff_ofs,
-			 ARRAY_SIZE(cc_sha224_init), larval_seq,
-			 &larval_seq_len);
-	rc = send_request_init(drvdata, larval_seq, larval_seq_len);
+	rc = cc_init_copy_sram(drvdata, cc_sha224_init, sizeof(cc_sha224_init),
+			       &sram_buff_ofs);
 	if (rc)
 		goto init_digest_const_err;
-	sram_buff_ofs += sizeof(cc_sha224_init);
-	larval_seq_len = 0;
 
-	cc_set_sram_desc(cc_sha256_init, sram_buff_ofs,
-			 ARRAY_SIZE(cc_sha256_init), larval_seq,
-			 &larval_seq_len);
-	rc = send_request_init(drvdata, larval_seq, larval_seq_len);
+	rc = cc_init_copy_sram(drvdata, cc_sha256_init, sizeof(cc_sha256_init),
+			       &sram_buff_ofs);
 	if (rc)
 		goto init_digest_const_err;
-	sram_buff_ofs += sizeof(cc_sha256_init);
-	larval_seq_len = 0;
 
 	if (sm3_supported) {
-		cc_set_sram_desc(cc_sm3_init, sram_buff_ofs,
-				 ARRAY_SIZE(cc_sm3_init), larval_seq,
-				 &larval_seq_len);
-		rc = send_request_init(drvdata, larval_seq, larval_seq_len);
+		rc = cc_init_copy_sram(drvdata, cc_sm3_init,
+				       sizeof(cc_sm3_init), &sram_buff_ofs);
 		if (rc)
 			goto init_digest_const_err;
-		sram_buff_ofs += sizeof(cc_sm3_init);
-		larval_seq_len = 0;
 	}
 
 	if (large_sha_supported) {
-		cc_set_sram_desc(cc_sha384_init, sram_buff_ofs,
-				 ARRAY_SIZE(cc_sha384_init), larval_seq,
-				 &larval_seq_len);
-		rc = send_request_init(drvdata, larval_seq, larval_seq_len);
+		rc = cc_init_copy_sram(drvdata, cc_sha384_init,
+				       sizeof(cc_sha384_init), &sram_buff_ofs);
 		if (rc)
 			goto init_digest_const_err;
-		sram_buff_ofs += sizeof(cc_sha384_init);
-		larval_seq_len = 0;
 
-		cc_set_sram_desc(cc_sha512_init, sram_buff_ofs,
-				 ARRAY_SIZE(cc_sha512_init), larval_seq,
-				 &larval_seq_len);
-		rc = send_request_init(drvdata, larval_seq, larval_seq_len);
+		rc = cc_init_copy_sram(drvdata, cc_sha512_init,
+				       sizeof(cc_sha512_init), &sram_buff_ofs);
 		if (rc)
 			goto init_digest_const_err;
 	}
-- 
2.17.1


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

* [PATCH v2 23/34] crypto: ccree - remove bogus kerneldoc markers
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (21 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 22/34] crypto: ccree - extract cc_init_copy_sram() Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:44   ` Sergei Shtylyov
  2020-02-11 18:19 ` [PATCH v2 24/34] crypto: ccree - improve kerneldoc in cc_hw_queue_defs.h Geert Uytterhoeven
                   ` (13 subsequent siblings)
  36 siblings, 1 reply; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

Normal comments should start with "/*".
"/**" is reserver for kerneldoc.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_aead.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/ccree/cc_aead.c b/drivers/crypto/ccree/cc_aead.c
index 78afa753b44f2dba..be26aaf75e1fe9ea 100644
--- a/drivers/crypto/ccree/cc_aead.c
+++ b/drivers/crypto/ccree/cc_aead.c
@@ -1223,7 +1223,7 @@ static void cc_hmac_authenc(struct aead_request *req, struct cc_hw_desc desc[],
 				 req_ctx->is_single_pass);
 
 	if (req_ctx->is_single_pass) {
-		/**
+		/*
 		 * Single-pass flow
 		 */
 		cc_set_hmac_desc(req, desc, seq_size);
@@ -1235,7 +1235,7 @@ static void cc_hmac_authenc(struct aead_request *req, struct cc_hw_desc desc[],
 		return;
 	}
 
-	/**
+	/*
 	 * Double-pass flow
 	 * Fallback for unsupported single-pass modes,
 	 * i.e. using assoc. data of non-word-multiple
@@ -1276,7 +1276,7 @@ cc_xcbc_authenc(struct aead_request *req, struct cc_hw_desc desc[],
 				 req_ctx->is_single_pass);
 
 	if (req_ctx->is_single_pass) {
-		/**
+		/*
 		 * Single-pass flow
 		 */
 		cc_set_xcbc_desc(req, desc, seq_size);
@@ -1287,7 +1287,7 @@ cc_xcbc_authenc(struct aead_request *req, struct cc_hw_desc desc[],
 		return;
 	}
 
-	/**
+	/*
 	 * Double-pass flow
 	 * Fallback for unsupported single-pass modes,
 	 * i.e. using assoc. data of non-word-multiple
-- 
2.17.1


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

* [PATCH v2 24/34] crypto: ccree - improve kerneldoc in cc_hw_queue_defs.h
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (22 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 23/34] crypto: ccree - remove bogus kerneldoc markers Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 25/34] crypto: ccree - improve kerneldoc in cc_buffer_mgr.c Geert Uytterhoeven
                   ` (12 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

Miscellaneous improvements:
  - Start comment blocks with "/**" to enable kerneldoc,
  - Fix descriptor type of set_dout_mlli(),
  - Fix copied config parameter of set_cipher_config1(),
  - Fix copied config parameter of set_bytes_swap(),
  - Add missing function names to kerneldoc headers,
  - Add missing parameter descriptions,
  - Remove descriptions for nonexistent parameters,
  - Add missing colons,
  - Remove references to obsolete camelcase parameter names,
  - Sort according to actual parameter order,
  - Fix grammar and spelling.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_hw_queue_defs.h | 237 ++++++++++++------------
 1 file changed, 119 insertions(+), 118 deletions(-)

diff --git a/drivers/crypto/ccree/cc_hw_queue_defs.h b/drivers/crypto/ccree/cc_hw_queue_defs.h
index 36786344c57a92cf..25ef286699892df5 100644
--- a/drivers/crypto/ccree/cc_hw_queue_defs.h
+++ b/drivers/crypto/ccree/cc_hw_queue_defs.h
@@ -207,31 +207,32 @@ enum cc_hash_cipher_pad {
 /* Descriptor packing macros */
 /*****************************/
 
-/*
- * Init a HW descriptor struct
- * @pdesc: pointer HW descriptor struct
+/**
+ * hw_desc_init() - Init a HW descriptor struct
+ * @pdesc: pointer to HW descriptor struct
  */
 static inline void hw_desc_init(struct cc_hw_desc *pdesc)
 {
 	memset(pdesc, 0, sizeof(struct cc_hw_desc));
 }
 
-/*
- * Indicates the end of current HW descriptors flow and release the HW engines.
+/**
+ * set_queue_last_ind_bit() - Indicate the end of current HW descriptors flow
+ * and release the HW engines.
  *
- * @pdesc: pointer HW descriptor struct
+ * @pdesc: Pointer to HW descriptor struct
  */
 static inline void set_queue_last_ind_bit(struct cc_hw_desc *pdesc)
 {
 	pdesc->word[3] |= FIELD_PREP(WORD3_QUEUE_LAST_IND, 1);
 }
 
-/*
- * Set the DIN field of a HW descriptors
+/**
+ * set_din_type() - Set the DIN field of a HW descriptor
  *
- * @pdesc: pointer HW descriptor struct
- * @dma_mode: dmaMode The DMA mode: NO_DMA, SRAM, DLLI, MLLI, CONSTANT
- * @addr: dinAdr DIN address
+ * @pdesc: Pointer to HW descriptor struct
+ * @dma_mode: The DMA mode: NO_DMA, SRAM, DLLI, MLLI, CONSTANT
+ * @addr: DIN address
  * @size: Data size in bytes
  * @axi_sec: AXI secure bit
  */
@@ -248,11 +249,11 @@ static inline void set_din_type(struct cc_hw_desc *pdesc,
 				FIELD_PREP(WORD1_NS_BIT, axi_sec);
 }
 
-/*
- * Set the DIN field of a HW descriptors to NO DMA mode.
+/**
+ * set_din_no_dma() - Set the DIN field of a HW descriptor to NO DMA mode.
  * Used for NOP descriptor, register patches and other special modes.
  *
- * @pdesc: pointer HW descriptor struct
+ * @pdesc: Pointer to HW descriptor struct
  * @addr: DIN address
  * @size: Data size in bytes
  */
@@ -262,14 +263,11 @@ static inline void set_din_no_dma(struct cc_hw_desc *pdesc, u32 addr, u32 size)
 	pdesc->word[1] |= FIELD_PREP(WORD1_DIN_SIZE, size);
 }
 
-/*
- * Setup the special CPP descriptor
+/**
+ * set_cpp_crypto_key() - Setup the special CPP descriptor
  *
- * @pdesc: pointer HW descriptor struct
- * @alg: cipher used (AES / SM4)
- * @mode: mode used (CTR or CBC)
- * @slot: slot number
- * @ksize: key size
+ * @pdesc: Pointer to HW descriptor struct
+ * @slot: Slot number
  */
 static inline void set_cpp_crypto_key(struct cc_hw_desc *pdesc, u8 slot)
 {
@@ -281,14 +279,14 @@ static inline void set_cpp_crypto_key(struct cc_hw_desc *pdesc, u8 slot)
 	pdesc->word[4] |= FIELD_PREP(WORD4_SETUP_OPERATION, slot);
 }
 
-/*
- * Set the DIN field of a HW descriptors to SRAM mode.
+/**
+ * set_din_sram() - Set the DIN field of a HW descriptor to SRAM mode.
  * Note: No need to check SRAM alignment since host requests do not use SRAM and
- * adaptor will enforce alignment check.
+ * the adaptor will enforce alignment checks.
  *
- * @pdesc: pointer HW descriptor struct
+ * @pdesc: Pointer to HW descriptor struct
  * @addr: DIN address
- * @size Data size in bytes
+ * @size: Data size in bytes
  */
 static inline void set_din_sram(struct cc_hw_desc *pdesc, u32 addr, u32 size)
 {
@@ -297,10 +295,10 @@ static inline void set_din_sram(struct cc_hw_desc *pdesc, u32 addr, u32 size)
 				FIELD_PREP(WORD1_DIN_DMA_MODE, DMA_SRAM);
 }
 
-/*
- * Set the DIN field of a HW descriptors to CONST mode
+/**
+ * set_din_const() - Set the DIN field of a HW descriptor to CONST mode
  *
- * @pdesc: pointer HW descriptor struct
+ * @pdesc: Pointer to HW descriptor struct
  * @val: DIN const value
  * @size: Data size in bytes
  */
@@ -312,20 +310,20 @@ static inline void set_din_const(struct cc_hw_desc *pdesc, u32 val, u32 size)
 			FIELD_PREP(WORD1_DIN_SIZE, size);
 }
 
-/*
- * Set the DIN not last input data indicator
+/**
+ * set_din_not_last_indication() - Set the DIN not last input data indicator
  *
- * @pdesc: pointer HW descriptor struct
+ * @pdesc: Pointer to HW descriptor struct
  */
 static inline void set_din_not_last_indication(struct cc_hw_desc *pdesc)
 {
 	pdesc->word[1] |= FIELD_PREP(WORD1_NOT_LAST, 1);
 }
 
-/*
- * Set the DOUT field of a HW descriptors
+/**
+ * set_dout_type() - Set the DOUT field of a HW descriptor
  *
- * @pdesc: pointer HW descriptor struct
+ * @pdesc: Pointer to HW descriptor struct
  * @dma_mode: The DMA mode: NO_DMA, SRAM, DLLI, MLLI, CONSTANT
  * @addr: DOUT address
  * @size: Data size in bytes
@@ -344,15 +342,15 @@ static inline void set_dout_type(struct cc_hw_desc *pdesc,
 				FIELD_PREP(WORD3_NS_BIT, axi_sec);
 }
 
-/*
- * Set the DOUT field of a HW descriptors to DLLI type
+/**
+ * set_dout_dlli() - Set the DOUT field of a HW descriptor to DLLI type
  * The LAST INDICATION is provided by the user
  *
- * @pdesc pointer HW descriptor struct
+ * @pdesc: Pointer to HW descriptor struct
  * @addr: DOUT address
  * @size: Data size in bytes
- * @last_ind: The last indication bit
  * @axi_sec: AXI secure bit
+ * @last_ind: The last indication bit
  */
 static inline void set_dout_dlli(struct cc_hw_desc *pdesc, dma_addr_t addr,
 				 u32 size, enum cc_axi_sec axi_sec,
@@ -362,15 +360,15 @@ static inline void set_dout_dlli(struct cc_hw_desc *pdesc, dma_addr_t addr,
 	pdesc->word[3] |= FIELD_PREP(WORD3_DOUT_LAST_IND, last_ind);
 }
 
-/*
- * Set the DOUT field of a HW descriptors to DLLI type
+/**
+ * set_dout_mlli() - Set the DOUT field of a HW descriptor to MLLI type
  * The LAST INDICATION is provided by the user
  *
- * @pdesc: pointer HW descriptor struct
+ * @pdesc: Pointer to HW descriptor struct
  * @addr: DOUT address
  * @size: Data size in bytes
- * @last_ind: The last indication bit
  * @axi_sec: AXI secure bit
+ * @last_ind: The last indication bit
  */
 static inline void set_dout_mlli(struct cc_hw_desc *pdesc, u32 addr, u32 size,
 				 enum cc_axi_sec axi_sec, bool last_ind)
@@ -379,11 +377,11 @@ static inline void set_dout_mlli(struct cc_hw_desc *pdesc, u32 addr, u32 size,
 	pdesc->word[3] |= FIELD_PREP(WORD3_DOUT_LAST_IND, last_ind);
 }
 
-/*
- * Set the DOUT field of a HW descriptors to NO DMA mode.
+/**
+ * set_dout_no_dma() - Set the DOUT field of a HW descriptor to NO DMA mode.
  * Used for NOP descriptor, register patches and other special modes.
  *
- * @pdesc: pointer HW descriptor struct
+ * @pdesc: pointer to HW descriptor struct
  * @addr: DOUT address
  * @size: Data size in bytes
  * @write_enable: Enables a write operation to a register
@@ -396,54 +394,55 @@ static inline void set_dout_no_dma(struct cc_hw_desc *pdesc, u32 addr,
 			FIELD_PREP(WORD3_DOUT_LAST_IND, write_enable);
 }
 
-/*
- * Set the word for the XOR operation.
+/**
+ * set_xor_val() - Set the word for the XOR operation.
  *
- * @pdesc: pointer HW descriptor struct
- * @val: xor data value
+ * @pdesc: Pointer to HW descriptor struct
+ * @val: XOR data value
  */
 static inline void set_xor_val(struct cc_hw_desc *pdesc, u32 val)
 {
 	pdesc->word[2] = val;
 }
 
-/*
- * Sets the XOR indicator bit in the descriptor
+/**
+ * set_xor_active() - Set the XOR indicator bit in the descriptor
  *
- * @pdesc: pointer HW descriptor struct
+ * @pdesc: Pointer to HW descriptor struct
  */
 static inline void set_xor_active(struct cc_hw_desc *pdesc)
 {
 	pdesc->word[3] |= FIELD_PREP(WORD3_HASH_XOR_BIT, 1);
 }
 
-/*
- * Select the AES engine instead of HASH engine when setting up combined mode
- * with AES XCBC MAC
+/**
+ * set_aes_not_hash_mode() - Select the AES engine instead of HASH engine when
+ * setting up combined mode with AES XCBC MAC
  *
- * @pdesc: pointer HW descriptor struct
+ * @pdesc: Pointer to HW descriptor struct
  */
 static inline void set_aes_not_hash_mode(struct cc_hw_desc *pdesc)
 {
 	pdesc->word[4] |= FIELD_PREP(WORD4_AES_SEL_N_HASH, 1);
 }
 
-/*
- * Set aes xor crypto key, this in some secenrios select SM3 engine
+/**
+ * set_aes_xor_crypto_key() - Set aes xor crypto key, which in some scenarios
+ * selects the SM3 engine
  *
- * @pdesc: pointer HW descriptor struct
+ * @pdesc: Pointer to HW descriptor struct
  */
 static inline void set_aes_xor_crypto_key(struct cc_hw_desc *pdesc)
 {
 	pdesc->word[4] |= FIELD_PREP(WORD4_AES_XOR_CRYPTO_KEY, 1);
 }
 
-/*
- * Set the DOUT field of a HW descriptors to SRAM mode
+/**
+ * set_dout_sram() - Set the DOUT field of a HW descriptor to SRAM mode
  * Note: No need to check SRAM alignment since host requests do not use SRAM and
- * adaptor will enforce alignment check.
+ * the adaptor will enforce alignment checks.
  *
- * @pdesc: pointer HW descriptor struct
+ * @pdesc: Pointer to HW descriptor struct
  * @addr: DOUT address
  * @size: Data size in bytes
  */
@@ -454,32 +453,34 @@ static inline void set_dout_sram(struct cc_hw_desc *pdesc, u32 addr, u32 size)
 			FIELD_PREP(WORD3_DOUT_SIZE, size);
 }
 
-/*
- * Sets the data unit size for XEX mode in data_out_addr[15:0]
+/**
+ * set_xex_data_unit_size() - Set the data unit size for XEX mode in
+ * data_out_addr[15:0]
  *
- * @pdesc: pDesc pointer HW descriptor struct
- * @size: data unit size for XEX mode
+ * @pdesc: Pointer to HW descriptor struct
+ * @size: Data unit size for XEX mode
  */
 static inline void set_xex_data_unit_size(struct cc_hw_desc *pdesc, u32 size)
 {
 	pdesc->word[2] = size;
 }
 
-/*
- * Set the number of rounds for Multi2 in data_out_addr[15:0]
+/**
+ * set_multi2_num_rounds() - Set the number of rounds for Multi2 in
+ * data_out_addr[15:0]
  *
- * @pdesc: pointer HW descriptor struct
- * @num: number of rounds for Multi2
+ * @pdesc: Pointer to HW descriptor struct
+ * @num: Number of rounds for Multi2
  */
 static inline void set_multi2_num_rounds(struct cc_hw_desc *pdesc, u32 num)
 {
 	pdesc->word[2] = num;
 }
 
-/*
- * Set the flow mode.
+/**
+ * set_flow_mode() - Set the flow mode.
  *
- * @pdesc: pointer HW descriptor struct
+ * @pdesc: Pointer to HW descriptor struct
  * @mode: Any one of the modes defined in [CC7x-DESC]
  */
 static inline void set_flow_mode(struct cc_hw_desc *pdesc,
@@ -488,22 +489,22 @@ static inline void set_flow_mode(struct cc_hw_desc *pdesc,
 	pdesc->word[4] |= FIELD_PREP(WORD4_DATA_FLOW_MODE, mode);
 }
 
-/*
- * Set the cipher mode.
+/**
+ * set_cipher_mode() - Set the cipher mode.
  *
- * @pdesc: pointer HW descriptor struct
- * @mode:  Any one of the modes defined in [CC7x-DESC]
+ * @pdesc: Pointer to HW descriptor struct
+ * @mode: Any one of the modes defined in [CC7x-DESC]
  */
 static inline void set_cipher_mode(struct cc_hw_desc *pdesc, int mode)
 {
 	pdesc->word[4] |= FIELD_PREP(WORD4_CIPHER_MODE, mode);
 }
 
-/*
- * Set the cipher mode for hash algorithms.
+/**
+ * set_hash_cipher_mode() - Set the cipher mode for hash algorithms.
  *
- * @pdesc: pointer HW descriptor struct
- * @cipher_mode:  Any one of the modes defined in [CC7x-DESC]
+ * @pdesc: Pointer to HW descriptor struct
+ * @cipher_mode: Any one of the modes defined in [CC7x-DESC]
  * @hash_mode: specifies which hash is being handled
  */
 static inline void set_hash_cipher_mode(struct cc_hw_desc *pdesc,
@@ -515,10 +516,10 @@ static inline void set_hash_cipher_mode(struct cc_hw_desc *pdesc,
 		set_aes_xor_crypto_key(pdesc);
 }
 
-/*
- * Set the cipher configuration fields.
+/**
+ * set_cipher_config0() - Set the cipher configuration fields.
  *
- * @pdesc: pointer HW descriptor struct
+ * @pdesc: Pointer to HW descriptor struct
  * @mode: Any one of the modes defined in [CC7x-DESC]
  */
 static inline void set_cipher_config0(struct cc_hw_desc *pdesc, int mode)
@@ -526,11 +527,11 @@ static inline void set_cipher_config0(struct cc_hw_desc *pdesc, int mode)
 	pdesc->word[4] |= FIELD_PREP(WORD4_CIPHER_CONF0, mode);
 }
 
-/*
- * Set the cipher configuration fields.
+/**
+ * set_cipher_config1() - Set the cipher configuration fields.
  *
- * @pdesc: pointer HW descriptor struct
- * @config: Any one of the modes defined in [CC7x-DESC]
+ * @pdesc: Pointer to HW descriptor struct
+ * @config: Padding mode
  */
 static inline void set_cipher_config1(struct cc_hw_desc *pdesc,
 				      enum cc_hash_conf_pad config)
@@ -538,10 +539,10 @@ static inline void set_cipher_config1(struct cc_hw_desc *pdesc,
 	pdesc->word[4] |= FIELD_PREP(WORD4_CIPHER_CONF1, config);
 }
 
-/*
- * Set HW key configuration fields.
+/**
+ * set_hw_crypto_key() - Set HW key configuration fields.
  *
- * @pdesc: pointer HW descriptor struct
+ * @pdesc: Pointer to HW descriptor struct
  * @hw_key: The HW key slot asdefined in enum cc_hw_crypto_key
  */
 static inline void set_hw_crypto_key(struct cc_hw_desc *pdesc,
@@ -553,64 +554,64 @@ static inline void set_hw_crypto_key(struct cc_hw_desc *pdesc,
 				   (hw_key >> HW_KEY_SHIFT_CIPHER_CFG2));
 }
 
-/*
- * Set byte order of all setup-finalize descriptors.
+/**
+ * set_bytes_swap() - Set byte order of all setup-finalize descriptors.
  *
- * @pdesc: pointer HW descriptor struct
- * @config: Any one of the modes defined in [CC7x-DESC]
+ * @pdesc: Pointer to HW descriptor struct
+ * @config: True to enable byte swapping
  */
 static inline void set_bytes_swap(struct cc_hw_desc *pdesc, bool config)
 {
 	pdesc->word[4] |= FIELD_PREP(WORD4_BYTES_SWAP, config);
 }
 
-/*
- * Set CMAC_SIZE0 mode.
+/**
+ * set_cmac_size0_mode() - Set CMAC_SIZE0 mode.
  *
- * @pdesc: pointer HW descriptor struct
+ * @pdesc: Pointer to HW descriptor struct
  */
 static inline void set_cmac_size0_mode(struct cc_hw_desc *pdesc)
 {
 	pdesc->word[4] |= FIELD_PREP(WORD4_CMAC_SIZE0, 1);
 }
 
-/*
- * Set key size descriptor field.
+/**
+ * set_key_size() - Set key size descriptor field.
  *
- * @pdesc: pointer HW descriptor struct
- * @size: key size in bytes (NOT size code)
+ * @pdesc: Pointer to HW descriptor struct
+ * @size: Key size in bytes (NOT size code)
  */
 static inline void set_key_size(struct cc_hw_desc *pdesc, u32 size)
 {
 	pdesc->word[4] |= FIELD_PREP(WORD4_KEY_SIZE, size);
 }
 
-/*
- * Set AES key size.
+/**
+ * set_key_size_aes() - Set AES key size.
  *
- * @pdesc: pointer HW descriptor struct
- * @size: key size in bytes (NOT size code)
+ * @pdesc: Pointer to HW descriptor struct
+ * @size: Key size in bytes (NOT size code)
  */
 static inline void set_key_size_aes(struct cc_hw_desc *pdesc, u32 size)
 {
 	set_key_size(pdesc, ((size >> 3) - 2));
 }
 
-/*
- * Set DES key size.
+/**
+ * set_key_size_des() - Set DES key size.
  *
- * @pdesc: pointer HW descriptor struct
- * @size: key size in bytes (NOT size code)
+ * @pdesc: Pointer to HW descriptor struct
+ * @size: Key size in bytes (NOT size code)
  */
 static inline void set_key_size_des(struct cc_hw_desc *pdesc, u32 size)
 {
 	set_key_size(pdesc, ((size >> 3) - 1));
 }
 
-/*
- * Set the descriptor setup mode
+/**
+ * set_setup_mode() - Set the descriptor setup mode
  *
- * @pdesc: pointer HW descriptor struct
+ * @pdesc: Pointer to HW descriptor struct
  * @mode: Any one of the setup modes defined in [CC7x-DESC]
  */
 static inline void set_setup_mode(struct cc_hw_desc *pdesc,
@@ -619,10 +620,10 @@ static inline void set_setup_mode(struct cc_hw_desc *pdesc,
 	pdesc->word[4] |= FIELD_PREP(WORD4_SETUP_OPERATION, mode);
 }
 
-/*
- * Set the descriptor cipher DO
+/**
+ * set_cipher_do() - Set the descriptor cipher DO
  *
- * @pdesc: pointer HW descriptor struct
+ * @pdesc: Pointer to HW descriptor struct
  * @config: Any one of the cipher do defined in [CC7x-DESC]
  */
 static inline void set_cipher_do(struct cc_hw_desc *pdesc,
-- 
2.17.1


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

* [PATCH v2 25/34] crypto: ccree - improve kerneldoc in cc_buffer_mgr.c
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (23 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 24/34] crypto: ccree - improve kerneldoc in cc_hw_queue_defs.h Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 26/34] crypto: ccree - improve kerneldoc in cc_hash.[ch] Geert Uytterhoeven
                   ` (11 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

Miscellaneous improvements:
  - Add missing parameter and return value descriptions.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_buffer_mgr.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/crypto/ccree/cc_buffer_mgr.c b/drivers/crypto/ccree/cc_buffer_mgr.c
index f2e782d2be155ee4..1ea4812e93549d75 100644
--- a/drivers/crypto/ccree/cc_buffer_mgr.c
+++ b/drivers/crypto/ccree/cc_buffer_mgr.c
@@ -73,9 +73,13 @@ static void cc_copy_mac(struct device *dev, struct aead_request *req,
 /**
  * cc_get_sgl_nents() - Get scatterlist number of entries.
  *
+ * @dev: Device object
  * @sg_list: SG list
  * @nbytes: [IN] Total SGL data bytes.
  * @lbytes: [OUT] Returns the amount of bytes at the last entry
+ *
+ * Return:
+ * Number of entries in the scatterlist
  */
 static unsigned int cc_get_sgl_nents(struct device *dev,
 				     struct scatterlist *sg_list,
@@ -102,11 +106,13 @@ static unsigned int cc_get_sgl_nents(struct device *dev,
  * cc_copy_sg_portion() - Copy scatter list data,
  * from to_skip to end, to dest and vice versa
  *
- * @dest:
- * @sg:
- * @to_skip:
- * @end:
- * @direct:
+ * @dev: Device object
+ * @dest: Buffer to copy to/from
+ * @sg: SG list
+ * @to_skip: Number of bytes to skip before copying
+ * @end: Offset of last byte to copy
+ * @direct: Transfer direction (true == from SG list to buffer, false == from
+ *          buffer to SG list)
  */
 void cc_copy_sg_portion(struct device *dev, u8 *dest, struct scatterlist *sg,
 			u32 to_skip, u32 end, enum cc_sg_cpy_direct direct)
-- 
2.17.1


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

* [PATCH v2 26/34] crypto: ccree - improve kerneldoc in cc_hash.[ch]
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (24 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 25/34] crypto: ccree - improve kerneldoc in cc_buffer_mgr.c Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 27/34] crypto: ccree - improve kerneldoc in cc_request_mgr.[ch] Geert Uytterhoeven
                   ` (10 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

Miscellaneous improvements:
  - Start comment blocks with "/**" to enable kerneldoc,
  - Mark parameters using "@" instead of "\param",
  - Add missing function names to kerneldoc headers,
  - Add missing parameter descriptions.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_hash.c | 11 ++++++-----
 drivers/crypto/ccree/cc_hash.h | 24 ++++++++++++------------
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/crypto/ccree/cc_hash.c b/drivers/crypto/ccree/cc_hash.c
index f3adc1ab0e01abec..738f0debee98ebf1 100644
--- a/drivers/crypto/ccree/cc_hash.c
+++ b/drivers/crypto/ccree/cc_hash.c
@@ -2238,14 +2238,15 @@ static const void *cc_larval_digest(struct device *dev, u32 mode)
 	}
 }
 
-/*!
- * Gets the address of the initial digest in SRAM
+/**
+ * cc_larval_digest_addr() - Get the address of the initial digest in SRAM
  * according to the given hash mode
  *
- * \param drvdata
- * \param mode The Hash mode. Supported modes: MD5/SHA1/SHA224/SHA256
+ * @drvdata: Associated device driver context
+ * @mode: The Hash mode. Supported modes: MD5/SHA1/SHA224/SHA256
  *
- * \return u32 The address of the initial digest in SRAM
+ * Return:
+ * The address of the initial digest in SRAM
  */
 u32 cc_larval_digest_addr(void *drvdata, u32 mode)
 {
diff --git a/drivers/crypto/ccree/cc_hash.h b/drivers/crypto/ccree/cc_hash.h
index d76ecae996ca3fa0..3d0f2179e07ec1ce 100644
--- a/drivers/crypto/ccree/cc_hash.h
+++ b/drivers/crypto/ccree/cc_hash.h
@@ -80,26 +80,26 @@ int cc_hash_alloc(struct cc_drvdata *drvdata);
 int cc_init_hash_sram(struct cc_drvdata *drvdata);
 int cc_hash_free(struct cc_drvdata *drvdata);
 
-/*!
- * Gets the initial digest length
+/**
+ * cc_digest_len_addr() - Gets the initial digest length
  *
- * \param drvdata
- * \param mode The Hash mode. Supported modes:
- *             MD5/SHA1/SHA224/SHA256/SHA384/SHA512
+ * @drvdata: Associated device driver context
+ * @mode: The Hash mode. Supported modes: MD5/SHA1/SHA224/SHA256/SHA384/SHA512
  *
- * \return u32 returns the address of the initial digest length in SRAM
+ * Return:
+ * Returns the address of the initial digest length in SRAM
  */
 u32 cc_digest_len_addr(void *drvdata, u32 mode);
 
-/*!
- * Gets the address of the initial digest in SRAM
+/**
+ * cc_larval_digest_addr() - Gets the address of the initial digest in SRAM
  * according to the given hash mode
  *
- * \param drvdata
- * \param mode The Hash mode. Supported modes:
- *             MD5/SHA1/SHA224/SHA256/SHA384/SHA512
+ * @drvdata: Associated device driver context
+ * @mode: The Hash mode. Supported modes: MD5/SHA1/SHA224/SHA256/SHA384/SHA512
  *
- * \return u32 The address of the initial digest in SRAM
+ * Return:
+ * The address of the initial digest in SRAM
  */
 u32 cc_larval_digest_addr(void *drvdata, u32 mode);
 
-- 
2.17.1


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

* [PATCH v2 27/34] crypto: ccree - improve kerneldoc in cc_request_mgr.[ch]
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (25 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 26/34] crypto: ccree - improve kerneldoc in cc_hash.[ch] Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 28/34] crypto: ccree - improve kerneldoc in cc_sram_mgr.[ch] Geert Uytterhoeven
                   ` (9 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

Miscellaneous improvements:
  - Start comment blocks with "/**" to enable kerneldoc,
  - Mark parameters using "@" instead of "\param",
  - Fix copied is_dout parameter of cc_send_request(),
  - Add missing function names to kerneldoc headers,
  - Add missing parameter descriptions.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_request_mgr.c | 41 ++++++++++++++-------------
 drivers/crypto/ccree/cc_request_mgr.h | 19 ++++++-------
 2 files changed, 31 insertions(+), 29 deletions(-)

diff --git a/drivers/crypto/ccree/cc_request_mgr.c b/drivers/crypto/ccree/cc_request_mgr.c
index b2a18122f320b7b2..2b8a9f5a5bd3edee 100644
--- a/drivers/crypto/ccree/cc_request_mgr.c
+++ b/drivers/crypto/ccree/cc_request_mgr.c
@@ -206,12 +206,13 @@ static void enqueue_seq(struct cc_drvdata *drvdata, struct cc_hw_desc seq[],
 	}
 }
 
-/*!
- * Completion will take place if and only if user requested completion
- * by cc_send_sync_request().
+/**
+ * request_mgr_complete() - Completion will take place if and only if user
+ * requested completion by cc_send_sync_request().
  *
- * \param dev
- * \param dx_compl_h The completion event to signal
+ * @dev: Device pointer
+ * @dx_compl_h: The completion event to signal
+ * @dummy: unused error code
  */
 static void request_mgr_complete(struct device *dev, void *dx_compl_h,
 				 int dummy)
@@ -264,15 +265,15 @@ static int cc_queues_status(struct cc_drvdata *drvdata,
 	return -ENOSPC;
 }
 
-/*!
- * Enqueue caller request to crypto hardware.
+/**
+ * cc_do_send_request() - Enqueue caller request to crypto hardware.
  * Need to be called with HW lock held and PM running
  *
- * \param drvdata
- * \param cc_req The request to enqueue
- * \param desc The crypto sequence
- * \param len The crypto sequence length
- * \param add_comp If "true": add an artificial dout DMA to mark completion
+ * @drvdata: Associated device driver context
+ * @cc_req: The request to enqueue
+ * @desc: The crypto sequence
+ * @len: The crypto sequence length
+ * @add_comp: If "true": add an artificial dout DMA to mark completion
  *
  */
 static void cc_do_send_request(struct cc_drvdata *drvdata,
@@ -486,16 +487,18 @@ int cc_send_sync_request(struct cc_drvdata *drvdata,
 	return 0;
 }
 
-/*!
- * Enqueue caller request to crypto hardware during init process.
- * assume this function is not called in middle of a flow,
+/**
+ * send_request_init() - Enqueue caller request to crypto hardware during init
+ * process.
+ * Assume this function is not called in the middle of a flow,
  * since we set QUEUE_LAST_IND flag in the last descriptor.
  *
- * \param drvdata
- * \param desc The crypto sequence
- * \param len The crypto sequence length
+ * @drvdata: Associated device driver context
+ * @desc: The crypto sequence
+ * @len: The crypto sequence length
  *
- * \return int Returns "0" upon success
+ * Return:
+ * Returns "0" upon success
  */
 int send_request_init(struct cc_drvdata *drvdata, struct cc_hw_desc *desc,
 		      unsigned int len)
diff --git a/drivers/crypto/ccree/cc_request_mgr.h b/drivers/crypto/ccree/cc_request_mgr.h
index ff7746aaaf355acd..ae25ca843dceabc9 100644
--- a/drivers/crypto/ccree/cc_request_mgr.h
+++ b/drivers/crypto/ccree/cc_request_mgr.h
@@ -12,18 +12,17 @@
 
 int cc_req_mgr_init(struct cc_drvdata *drvdata);
 
-/*!
- * Enqueue caller request to crypto hardware.
+/**
+ * cc_send_request() - Enqueue caller request to crypto hardware.
  *
- * \param drvdata
- * \param cc_req The request to enqueue
- * \param desc The crypto sequence
- * \param len The crypto sequence length
- * \param is_dout If "true": completion is handled by the caller
- *	  If "false": this function adds a dummy descriptor completion
- *	  and waits upon completion signal.
+ * @drvdata: Associated device driver context
+ * @cc_req: The request to enqueue
+ * @desc: The crypto sequence
+ * @len: The crypto sequence length
+ * @req: Asynchronous crypto request
  *
- * \return int Returns -EINPROGRESS or error
+ * Return:
+ * Returns -EINPROGRESS or error
  */
 int cc_send_request(struct cc_drvdata *drvdata, struct cc_crypto_req *cc_req,
 		    struct cc_hw_desc *desc, unsigned int len,
-- 
2.17.1


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

* [PATCH v2 28/34] crypto: ccree - improve kerneldoc in cc_sram_mgr.[ch]
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (26 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 27/34] crypto: ccree - improve kerneldoc in cc_request_mgr.[ch] Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 29/34] crypto: ccree - spelling s/Crytpcell/Cryptocell/ Geert Uytterhoeven
                   ` (8 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

Miscellaneous improvements:
  - Start comment blocks with "/**" to enable kerneldoc,
  - Mark parameters using "@" instead of "\param",
  - Fix typos in parameter names,
  - Add missing function names to kerneldoc headers,
  - Add missing parameter and return value descriptions.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_sram_mgr.c | 16 +++++++++++-----
 drivers/crypto/ccree/cc_sram_mgr.h | 22 +++++++++++++---------
 2 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/drivers/crypto/ccree/cc_sram_mgr.c b/drivers/crypto/ccree/cc_sram_mgr.c
index 38f36cbc05b3cf6f..37a95856361fc52c 100644
--- a/drivers/crypto/ccree/cc_sram_mgr.c
+++ b/drivers/crypto/ccree/cc_sram_mgr.c
@@ -10,6 +10,9 @@
  *      Returns zero for success, negative value otherwise.
  *
  * @drvdata: Associated device driver context
+ *
+ * Return:
+ * 0 for success, negative error code for failure.
  */
 int cc_sram_mgr_init(struct cc_drvdata *drvdata)
 {
@@ -29,11 +32,14 @@ int cc_sram_mgr_init(struct cc_drvdata *drvdata)
 	return 0;
 }
 
-/*!
- * Allocated buffer from SRAM pool.
+/**
+ * cc_sram_alloc() - Allocate buffer from SRAM pool.
+ *
+ * @drvdata: Associated device driver context
+ * @size: The requested numer of bytes to allocate
  *
- * \param drvdata
- * \param size The requested bytes to allocate
+ * Return:
+ * Address offset in SRAM or NULL_SRAM_ADDR for failure.
  */
 u32 cc_sram_alloc(struct cc_drvdata *drvdata, u32 size)
 {
@@ -64,7 +70,7 @@ u32 cc_sram_alloc(struct cc_drvdata *drvdata, u32 size)
  *
  * @src:	  A pointer to array of words to set as consts.
  * @dst:	  The target SRAM buffer to set into
- * @nelements:	  The number of words in "src" array
+ * @nelement:	  The number of words in "src" array
  * @seq:	  A pointer to the given IN/OUT descriptor sequence
  * @seq_len:	  A pointer to the given IN/OUT sequence length
  */
diff --git a/drivers/crypto/ccree/cc_sram_mgr.h b/drivers/crypto/ccree/cc_sram_mgr.h
index 04a857259d4148eb..1c965ef83002a631 100644
--- a/drivers/crypto/ccree/cc_sram_mgr.h
+++ b/drivers/crypto/ccree/cc_sram_mgr.h
@@ -12,22 +12,26 @@ struct cc_drvdata;
 
 #define NULL_SRAM_ADDR ((u32)-1)
 
-/*!
- * Initializes SRAM pool.
+/**
+ * cc_sram_mgr_init() - Initializes SRAM pool.
  * The first X bytes of SRAM are reserved for ROM usage, hence, pool
  * starts right after X bytes.
  *
- * \param drvdata
+ * @drvdata: Associated device driver context
  *
- * \return int Zero for success, negative value otherwise.
+ * Return:
+ * Zero for success, negative value otherwise.
  */
 int cc_sram_mgr_init(struct cc_drvdata *drvdata);
 
-/*!
- * Allocate buffer from SRAM pool.
+/**
+ * cc_sram_alloc() - Allocate buffer from SRAM pool.
+ *
+ * @drvdata: Associated device driver context
+ * @size: The requested bytes to allocate
  *
- * \param drvdata
- * \param size The requested bytes to allocate
+ * Return:
+ * Address offset in SRAM or NULL_SRAM_ADDR for failure.
  */
 u32 cc_sram_alloc(struct cc_drvdata *drvdata, u32 size);
 
@@ -38,7 +42,7 @@ u32 cc_sram_alloc(struct cc_drvdata *drvdata, u32 size);
  *
  * @src:	  A pointer to array of words to set as consts.
  * @dst:	  The target SRAM buffer to set into
- * @nelements:	  The number of words in "src" array
+ * @nelement:	  The number of words in "src" array
  * @seq:	  A pointer to the given IN/OUT descriptor sequence
  * @seq_len:	  A pointer to the given IN/OUT sequence length
  */
-- 
2.17.1


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

* [PATCH v2 29/34] crypto: ccree - spelling s/Crytpcell/Cryptocell/
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (27 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 28/34] crypto: ccree - improve kerneldoc in cc_sram_mgr.[ch] Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 30/34] crypto: ccree - grammar s/not room/no room/ Geert Uytterhoeven
                   ` (7 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

Fix a typo in a comment.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/ccree/cc_driver.c b/drivers/crypto/ccree/cc_driver.c
index 02442596310cd98d..bd9db53c68ab4381 100644
--- a/drivers/crypto/ccree/cc_driver.c
+++ b/drivers/crypto/ccree/cc_driver.c
@@ -367,7 +367,7 @@ static int init_cc_resources(struct platform_device *plat_dev)
 		goto post_pm_err;
 	}
 
-	/* wait for Crytpcell reset completion */
+	/* Wait for Cryptocell reset completion */
 	if (!cc_wait_for_reset_completion(new_drvdata)) {
 		dev_err(dev, "Cryptocell reset not completed");
 	}
-- 
2.17.1


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

* [PATCH v2 30/34] crypto: ccree - grammar s/not room/no room/
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (28 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 29/34] crypto: ccree - spelling s/Crytpcell/Cryptocell/ Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 31/34] crypto: ccree - use existing dev helper in init_cc_resources() Geert Uytterhoeven
                   ` (6 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

Fix grammar in a comment.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_request_mgr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/ccree/cc_request_mgr.c b/drivers/crypto/ccree/cc_request_mgr.c
index 2b8a9f5a5bd3edee..2671cffb3b58fa27 100644
--- a/drivers/crypto/ccree/cc_request_mgr.c
+++ b/drivers/crypto/ccree/cc_request_mgr.c
@@ -378,7 +378,7 @@ static void cc_proc_backlog(struct cc_drvdata *drvdata)
 		rc = cc_queues_status(drvdata, mgr, bli->len);
 		if (rc) {
 			/*
-			 * There is still not room in the FIFO for
+			 * There is still no room in the FIFO for
 			 * this request. Bail out. We'll return here
 			 * on the next completion irq.
 			 */
-- 
2.17.1


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

* [PATCH v2 31/34] crypto: ccree - use existing dev helper in init_cc_resources()
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (29 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 30/34] crypto: ccree - grammar s/not room/no room/ Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 32/34] crypto: ccree - use devm_k[mz]alloc() for AEAD data Geert Uytterhoeven
                   ` (5 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

Use the existing dev helper variable instead of plat_dev->dev.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_driver.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/ccree/cc_driver.c b/drivers/crypto/ccree/cc_driver.c
index bd9db53c68ab4381..2d50991b9a17756b 100644
--- a/drivers/crypto/ccree/cc_driver.c
+++ b/drivers/crypto/ccree/cc_driver.c
@@ -331,13 +331,13 @@ static int init_cc_resources(struct platform_device *plat_dev)
 
 	init_completion(&new_drvdata->hw_queue_avail);
 
-	if (!plat_dev->dev.dma_mask)
-		plat_dev->dev.dma_mask = &plat_dev->dev.coherent_dma_mask;
+	if (!dev->dma_mask)
+		dev->dma_mask = &dev->coherent_dma_mask;
 
 	dma_mask = DMA_BIT_MASK(DMA_BIT_MASK_LEN);
 	while (dma_mask > 0x7fffffffUL) {
-		if (dma_supported(&plat_dev->dev, dma_mask)) {
-			rc = dma_set_coherent_mask(&plat_dev->dev, dma_mask);
+		if (dma_supported(dev, dma_mask)) {
+			rc = dma_set_coherent_mask(dev, dma_mask);
 			if (!rc)
 				break;
 		}
-- 
2.17.1


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

* [PATCH v2 32/34] crypto: ccree - use devm_k[mz]alloc() for AEAD data
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (30 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 31/34] crypto: ccree - use existing dev helper in init_cc_resources() Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 33/34] crypto: ccree - use devm_k[mz]alloc() for cipher data Geert Uytterhoeven
                   ` (4 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

As the lifetime of the AEAD data matches the lifetime of the driver,
AEAD data can be allocated using the managed allocators.
While at it, simplify cc_aead_free() by removing an unneeded cast, and
an unneeded check (aead_handle is always valid here).

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_aead.c   | 35 ++++++++++++--------------------
 drivers/crypto/ccree/cc_cipher.c |  8 ++++----
 drivers/crypto/ccree/cc_hash.c   |  9 ++++----
 3 files changed, 21 insertions(+), 31 deletions(-)

diff --git a/drivers/crypto/ccree/cc_aead.c b/drivers/crypto/ccree/cc_aead.c
index be26aaf75e1fe9ea..904aa66752b3bdf4 100644
--- a/drivers/crypto/ccree/cc_aead.c
+++ b/drivers/crypto/ccree/cc_aead.c
@@ -2615,7 +2615,7 @@ static struct cc_crypto_alg *cc_create_aead_alg(struct cc_alg_template *tmpl,
 	struct cc_crypto_alg *t_alg;
 	struct aead_alg *alg;
 
-	t_alg = kzalloc(sizeof(*t_alg), GFP_KERNEL);
+	t_alg = devm_kzalloc(dev, sizeof(*t_alg), GFP_KERNEL);
 	if (!t_alg)
 		return ERR_PTR(-ENOMEM);
 
@@ -2645,19 +2645,12 @@ static struct cc_crypto_alg *cc_create_aead_alg(struct cc_alg_template *tmpl,
 int cc_aead_free(struct cc_drvdata *drvdata)
 {
 	struct cc_crypto_alg *t_alg, *n;
-	struct cc_aead_handle *aead_handle =
-		(struct cc_aead_handle *)drvdata->aead_handle;
-
-	if (aead_handle) {
-		/* Remove registered algs */
-		list_for_each_entry_safe(t_alg, n, &aead_handle->aead_list,
-					 entry) {
-			crypto_unregister_aead(&t_alg->aead_alg);
-			list_del(&t_alg->entry);
-			kfree(t_alg);
-		}
-		kfree(aead_handle);
-		drvdata->aead_handle = NULL;
+	struct cc_aead_handle *aead_handle = drvdata->aead_handle;
+
+	/* Remove registered algs */
+	list_for_each_entry_safe(t_alg, n, &aead_handle->aead_list, entry) {
+		crypto_unregister_aead(&t_alg->aead_alg);
+		list_del(&t_alg->entry);
 	}
 
 	return 0;
@@ -2671,7 +2664,7 @@ int cc_aead_alloc(struct cc_drvdata *drvdata)
 	int alg;
 	struct device *dev = drvdata_to_dev(drvdata);
 
-	aead_handle = kmalloc(sizeof(*aead_handle), GFP_KERNEL);
+	aead_handle = devm_kmalloc(dev, sizeof(*aead_handle), GFP_KERNEL);
 	if (!aead_handle) {
 		rc = -ENOMEM;
 		goto fail0;
@@ -2706,18 +2699,16 @@ int cc_aead_alloc(struct cc_drvdata *drvdata)
 		if (rc) {
 			dev_err(dev, "%s alg registration failed\n",
 				t_alg->aead_alg.base.cra_driver_name);
-			goto fail2;
-		} else {
-			list_add_tail(&t_alg->entry, &aead_handle->aead_list);
-			dev_dbg(dev, "Registered %s\n",
-				t_alg->aead_alg.base.cra_driver_name);
+			goto fail1;
 		}
+
+		list_add_tail(&t_alg->entry, &aead_handle->aead_list);
+		dev_dbg(dev, "Registered %s\n",
+			t_alg->aead_alg.base.cra_driver_name);
 	}
 
 	return 0;
 
-fail2:
-	kfree(t_alg);
 fail1:
 	cc_aead_free(drvdata);
 fail0:
diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c
index a1430d669a584a85..517d78f9931943a3 100644
--- a/drivers/crypto/ccree/cc_cipher.c
+++ b/drivers/crypto/ccree/cc_cipher.c
@@ -1713,11 +1713,11 @@ int cc_cipher_alloc(struct cc_drvdata *drvdata)
 				t_alg->skcipher_alg.base.cra_driver_name);
 			kfree(t_alg);
 			goto fail0;
-		} else {
-			list_add_tail(&t_alg->entry, &drvdata->alg_list);
-			dev_dbg(dev, "Registered %s\n",
-				t_alg->skcipher_alg.base.cra_driver_name);
 		}
+
+		list_add_tail(&t_alg->entry, &drvdata->alg_list);
+		dev_dbg(dev, "Registered %s\n",
+			t_alg->skcipher_alg.base.cra_driver_name);
 	}
 	return 0;
 
diff --git a/drivers/crypto/ccree/cc_hash.c b/drivers/crypto/ccree/cc_hash.c
index 738f0debee98ebf1..2ca5532c07a2e2f4 100644
--- a/drivers/crypto/ccree/cc_hash.c
+++ b/drivers/crypto/ccree/cc_hash.c
@@ -2024,10 +2024,9 @@ int cc_hash_alloc(struct cc_drvdata *drvdata)
 					driver_hash[alg].driver_name);
 				kfree(t_alg);
 				goto fail;
-			} else {
-				list_add_tail(&t_alg->entry,
-					      &hash_handle->hash_list);
 			}
+
+			list_add_tail(&t_alg->entry, &hash_handle->hash_list);
 		}
 		if (hw_mode == DRV_CIPHER_XCBC_MAC ||
 		    hw_mode == DRV_CIPHER_CMAC)
@@ -2049,9 +2048,9 @@ int cc_hash_alloc(struct cc_drvdata *drvdata)
 				driver_hash[alg].driver_name);
 			kfree(t_alg);
 			goto fail;
-		} else {
-			list_add_tail(&t_alg->entry, &hash_handle->hash_list);
 		}
+
+		list_add_tail(&t_alg->entry, &hash_handle->hash_list);
 	}
 
 	return 0;
-- 
2.17.1


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

* [PATCH v2 33/34] crypto: ccree - use devm_k[mz]alloc() for cipher data
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (31 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 32/34] crypto: ccree - use devm_k[mz]alloc() for AEAD data Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
  2020-02-11 18:19 ` [PATCH v2 34/34] crypto: ccree - use devm_kzalloc() for hash data Geert Uytterhoeven
                   ` (3 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

As the lifetime of the cipher data matches the lifetime of the driver,
cipher data can be allocated using the managed allocators.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_cipher.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c
index 517d78f9931943a3..44dc8e6229062a02 100644
--- a/drivers/crypto/ccree/cc_cipher.c
+++ b/drivers/crypto/ccree/cc_cipher.c
@@ -1634,7 +1634,7 @@ static struct cc_crypto_alg *cc_create_alg(const struct cc_alg_template *tmpl,
 	struct cc_crypto_alg *t_alg;
 	struct skcipher_alg *alg;
 
-	t_alg = kzalloc(sizeof(*t_alg), GFP_KERNEL);
+	t_alg = devm_kzalloc(dev, sizeof(*t_alg), GFP_KERNEL);
 	if (!t_alg)
 		return ERR_PTR(-ENOMEM);
 
@@ -1670,7 +1670,6 @@ int cc_cipher_free(struct cc_drvdata *drvdata)
 	list_for_each_entry_safe(t_alg, n, &drvdata->alg_list, entry) {
 		crypto_unregister_skcipher(&t_alg->skcipher_alg);
 		list_del(&t_alg->entry);
-		kfree(t_alg);
 	}
 	return 0;
 }
@@ -1711,7 +1710,6 @@ int cc_cipher_alloc(struct cc_drvdata *drvdata)
 		if (rc) {
 			dev_err(dev, "%s alg registration failed\n",
 				t_alg->skcipher_alg.base.cra_driver_name);
-			kfree(t_alg);
 			goto fail0;
 		}
 
-- 
2.17.1


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

* [PATCH v2 34/34] crypto: ccree - use devm_kzalloc() for hash data
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (32 preceding siblings ...)
  2020-02-11 18:19 ` [PATCH v2 33/34] crypto: ccree - use devm_k[mz]alloc() for cipher data Geert Uytterhoeven
@ 2020-02-11 18:19 ` Geert Uytterhoeven
       [not found] ` <CAOtvUMfs84VXAecVNShoEg-CU6APjyiVTUBkogpFq_c3fbaX+Q@mail.gmail.com>
                   ` (2 subsequent siblings)
  36 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-11 18:19 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel, Geert Uytterhoeven

As the lifetime of the hash data matches the lifetime of the driver,
hash data can be allocated using the managed allocators.
While at it, simplify cc_hash_free() by removing an unneeded check
(hash_handle is always valid here).

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.

 drivers/crypto/ccree/cc_hash.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/crypto/ccree/cc_hash.c b/drivers/crypto/ccree/cc_hash.c
index 2ca5532c07a2e2f4..0c32aa2e6801ed7f 100644
--- a/drivers/crypto/ccree/cc_hash.c
+++ b/drivers/crypto/ccree/cc_hash.c
@@ -1828,7 +1828,7 @@ static struct cc_hash_alg *cc_alloc_hash_alg(struct cc_hash_template *template,
 	struct crypto_alg *alg;
 	struct ahash_alg *halg;
 
-	t_crypto_alg = kzalloc(sizeof(*t_crypto_alg), GFP_KERNEL);
+	t_crypto_alg = devm_kzalloc(dev, sizeof(*t_crypto_alg), GFP_KERNEL);
 	if (!t_crypto_alg)
 		return ERR_PTR(-ENOMEM);
 
@@ -1961,7 +1961,7 @@ int cc_hash_alloc(struct cc_drvdata *drvdata)
 	int rc = 0;
 	int alg;
 
-	hash_handle = kzalloc(sizeof(*hash_handle), GFP_KERNEL);
+	hash_handle = devm_kzalloc(dev, sizeof(*hash_handle), GFP_KERNEL);
 	if (!hash_handle)
 		return -ENOMEM;
 
@@ -2022,7 +2022,6 @@ int cc_hash_alloc(struct cc_drvdata *drvdata)
 			if (rc) {
 				dev_err(dev, "%s alg registration failed\n",
 					driver_hash[alg].driver_name);
-				kfree(t_alg);
 				goto fail;
 			}
 
@@ -2046,7 +2045,6 @@ int cc_hash_alloc(struct cc_drvdata *drvdata)
 		if (rc) {
 			dev_err(dev, "%s alg registration failed\n",
 				driver_hash[alg].driver_name);
-			kfree(t_alg);
 			goto fail;
 		}
 
@@ -2056,8 +2054,7 @@ int cc_hash_alloc(struct cc_drvdata *drvdata)
 	return 0;
 
 fail:
-	kfree(drvdata->hash_handle);
-	drvdata->hash_handle = NULL;
+	cc_hash_free(drvdata);
 	return rc;
 }
 
@@ -2066,17 +2063,12 @@ int cc_hash_free(struct cc_drvdata *drvdata)
 	struct cc_hash_alg *t_hash_alg, *hash_n;
 	struct cc_hash_handle *hash_handle = drvdata->hash_handle;
 
-	if (hash_handle) {
-		list_for_each_entry_safe(t_hash_alg, hash_n,
-					 &hash_handle->hash_list, entry) {
-			crypto_unregister_ahash(&t_hash_alg->ahash_alg);
-			list_del(&t_hash_alg->entry);
-			kfree(t_hash_alg);
-		}
-
-		kfree(hash_handle);
-		drvdata->hash_handle = NULL;
+	list_for_each_entry_safe(t_hash_alg, hash_n, &hash_handle->hash_list,
+				 entry) {
+		crypto_unregister_ahash(&t_hash_alg->ahash_alg);
+		list_del(&t_hash_alg->entry);
 	}
+
 	return 0;
 }
 
-- 
2.17.1


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

* Re: [PATCH v2 23/34] crypto: ccree - remove bogus kerneldoc markers
  2020-02-11 18:19 ` [PATCH v2 23/34] crypto: ccree - remove bogus kerneldoc markers Geert Uytterhoeven
@ 2020-02-11 18:44   ` Sergei Shtylyov
  0 siblings, 0 replies; 40+ messages in thread
From: Sergei Shtylyov @ 2020-02-11 18:44 UTC (permalink / raw)
  To: Geert Uytterhoeven, Gilad Ben-Yossef, Herbert Xu, David S . Miller
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel

Hello!

On 02/11/2020 09:19 PM, Geert Uytterhoeven wrote:

> Normal comments should start with "/*".
> "/**" is reserver for kerneldoc.

   Reserved for kernel-doc, perhaps?

> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
[...]

MBR, Sergei


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

* Re: [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements
       [not found] ` <CAOtvUMfs84VXAecVNShoEg-CU6APjyiVTUBkogpFq_c3fbaX+Q@mail.gmail.com>
@ 2020-02-13  7:47   ` Geert Uytterhoeven
  2020-02-19 15:41     ` Gilad Ben-Yossef
  0 siblings, 1 reply; 40+ messages in thread
From: Geert Uytterhoeven @ 2020-02-13  7:47 UTC (permalink / raw)
  To: Gilad Ben-Yossef
  Cc: Geert Uytterhoeven, Herbert Xu, David S . Miller,
	Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel

Hi Gilad,

On Thu, Feb 13, 2020 at 7:46 AM Gilad Ben-Yossef <gilad@benyossef.com> wrote:
> On Tuesday, February 11, 2020, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
>> This series contains several fixes, cleanups, and other improvements for
>> the ARM TrustZone CryptoCell driver.
>
>  Thank you so much for doing this Geert.
>
> The whole series looks wonderful. It does not only makes the driver better, it has made me a better programmer - I'm not ashamed to say I've learned some new things about the kernel API  from this series...
>
> I am currently out of the office until mid next week and away from my testing lab.
>
> I'd like to delay formal ACK until I return and run a regression test suite using some of the newer revisions of the hardware which the driver also support, just in case, although I don't forsee any issues. I hope that is ok.

Should be OK, we're only at rc1.
I'm looking forward to the test results on newer hardware revision/
Thanks!

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements
  2020-02-13  7:47   ` [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
@ 2020-02-19 15:41     ` Gilad Ben-Yossef
  0 siblings, 0 replies; 40+ messages in thread
From: Gilad Ben-Yossef @ 2020-02-19 15:41 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Geert Uytterhoeven, Herbert Xu, David S . Miller,
	Greg Kroah-Hartman, Rafael J . Wysocki, linux-crypto,
	linux-renesas-soc, linux-kernel

On Thu, Feb 13, 2020 at 9:47 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Gilad,
>
> On Thu, Feb 13, 2020 at 7:46 AM Gilad Ben-Yossef <gilad@benyossef.com> wrote:
> > On Tuesday, February 11, 2020, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
> >> This series contains several fixes, cleanups, and other improvements for
> >> the ARM TrustZone CryptoCell driver.
> >
> >  Thank you so much for doing this Geert.
> >
> > The whole series looks wonderful. It does not only makes the driver better, it has made me a better programmer - I'm not ashamed to say I've learned some new things about the kernel API  from this series...
> >
> > I am currently out of the office until mid next week and away from my testing lab.
> >
> > I'd like to delay formal ACK until I return and run a regression test suite using some of the newer revisions of the hardware which the driver also support, just in case, although I don't forsee any issues. I hope that is ok.
>
> Should be OK, we're only at rc1.
> I'm looking forward to the test results on newer hardware revision/


The smoke test on the most recent HW looks OK, I've submitted the
changes to a longer  regression test suite on multiple HW and it is
running.
I hope to have a final result and an ACK by tomorrow.

Thanks,
Gilad



-- 
Gilad Ben-Yossef
Chief Coffee Drinker

values of β will give rise to dom!

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

* Re: [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (34 preceding siblings ...)
       [not found] ` <CAOtvUMfs84VXAecVNShoEg-CU6APjyiVTUBkogpFq_c3fbaX+Q@mail.gmail.com>
@ 2020-02-20 12:29 ` Gilad Ben-Yossef
  2020-02-22  1:42 ` Herbert Xu
  36 siblings, 0 replies; 40+ messages in thread
From: Gilad Ben-Yossef @ 2020-02-20 12:29 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Herbert Xu, David S . Miller, Greg Kroah-Hartman,
	Rafael J . Wysocki, Linux Crypto Mailing List, Linux-Renesas,
	Linux kernel mailing list

On Tue, Feb 11, 2020 at 8:19 PM Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
>
>         Hi all,
>
> This series contains several fixes, cleanups, and other improvements for
> the ARM TrustZone CryptoCell driver.
>
> The first 3 patches have been sent before:
>   - [PATCH 0/2] Fix debugfs register access while suspended[1],
>   - [PATCH] [RFC] crypto: ccree - fix retry handling in
>     cc_send_sync_request()[2.
>
> This is based on v5.6-rc1, with the following fixes from Gilad applied:
>   - [PATCH 0/4] crypto: ccree - fixes[3],
>   - [PATCH] crypto: ccree - dec auth tag size from cryptlen map[4].
>
> This has been tested on R-Car H3 ES2.0.
> To ease testing, I have pushed this series and its dependencies to the
> topic/ccree-misc-v2  branch of my renesas-drivers repository at
> git://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git.
>
> Thanks for your comments!
>
> [1] https://lore.kernel.org/r/20200124132957.15769-1-geert+renesas@glider.be/
> [2] https://lore.kernel.org/r/20200128190913.23086-1-geert+renesas@glider.be/
> [3] https://lore.kernel.org/r/20200129143757.680-1-gilad@benyossef.com/
> [4] https://lore.kernel.org/r/20200202161914.9551-1-gilad@benyossef.com/
>

OK, looks fine and all relevant tests pass on the newer hardware on
all platforms.

Acked-by: Gilad Ben-Yossef <gilad@benyossef.com>

Thanks,
Gilad

> Geert Uytterhoeven (34):
>   debugfs: regset32: Add Runtime PM support
>   crypto: ccree - fix debugfs register access while suspended
>   crypto: ccree - fix retry handling in cc_send_sync_request()
>   crypto: ccree - remove unneeded casts
>   crypto: ccree - swap SHA384 and SHA512 larval hashes at build time
>   crypto: ccree - drop duplicated error message on SRAM exhaustion
>   crypto: ccree - remove empty cc_sram_mgr_fini()
>   crypto: ccree - clean up clock handling
>   crypto: ccree - make mlli_params.mlli_virt_addr void *
>   crypto: ccree - use existing helpers to split 64-bit addresses
>   crypto: ccree - defer larval_digest_addr init until needed
>   crypto: ccree - remove bogus paragraph about freeing SRAM
>   crypto: ccree - use u32 for SRAM addresses
>   crypto: ccree - simplify Runtime PM handling
>   crypto: ccree - use of_device_get_match_data()
>   crypto: ccree - remove cc_pm_is_dev_suspended() wrapper
>   crypto: ccree - make cc_pm_{suspend,resume}() static
>   crypto: ccree - remove struct cc_sram_ctx
>   crypto: ccree - remove struct cc_debugfs_ctx
>   crypto: ccree - remove struct buff_mgr_handle
>   crypto: ccree - remove struct cc_cipher_handle
>   crypto: ccree - extract cc_init_copy_sram()
>   crypto: ccree - remove bogus kerneldoc markers
>   crypto: ccree - improve kerneldoc in cc_hw_queue_defs.h
>   crypto: ccree - improve kerneldoc in cc_buffer_mgr.c
>   crypto: ccree - improve kerneldoc in cc_hash.[ch]
>   crypto: ccree - improve kerneldoc in cc_request_mgr.[ch]
>   crypto: ccree - improve kerneldoc in cc_sram_mgr.[ch]
>   crypto: ccree - spelling s/Crytpcell/Cryptocell/
>   crypto: ccree - grammar s/not room/no room/
>   crypto: ccree - use existing dev helper in init_cc_resources()
>   crypto: ccree - use devm_k[mz]alloc() for AEAD data
>   crypto: ccree - use devm_k[mz]alloc() for cipher data
>   crypto: ccree - use devm_kzalloc() for hash data
>
>  drivers/crypto/ccree/cc_aead.c          |  61 +++---
>  drivers/crypto/ccree/cc_buffer_mgr.c    |  66 +++---
>  drivers/crypto/ccree/cc_buffer_mgr.h    |   4 +-
>  drivers/crypto/ccree/cc_cipher.c        |  61 ++----
>  drivers/crypto/ccree/cc_debugfs.c       |  29 +--
>  drivers/crypto/ccree/cc_driver.c        | 127 +++++-------
>  drivers/crypto/ccree/cc_driver.h        |  13 +-
>  drivers/crypto/ccree/cc_hash.c          | 225 +++++++++------------
>  drivers/crypto/ccree/cc_hash.h          |  31 ++-
>  drivers/crypto/ccree/cc_hw_queue_defs.h | 255 ++++++++++++------------
>  drivers/crypto/ccree/cc_pm.c            |  60 +-----
>  drivers/crypto/ccree/cc_pm.h            |  21 --
>  drivers/crypto/ccree/cc_request_mgr.c   |  47 +++--
>  drivers/crypto/ccree/cc_request_mgr.h   |  19 +-
>  drivers/crypto/ccree/cc_sram_mgr.c      |  78 +++-----
>  drivers/crypto/ccree/cc_sram_mgr.h      |  45 ++---
>  fs/debugfs/file.c                       |   8 +
>  include/linux/debugfs.h                 |   1 +
>  18 files changed, 456 insertions(+), 695 deletions(-)
>
> --
> 2.17.1
>
> Gr{oetje,eeting}s,
>
>                                                 Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                                             -- Linus Torvalds



-- 
Gilad Ben-Yossef
Chief Coffee Drinker

values of β will give rise to dom!

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

* Re: [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements
  2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
                   ` (35 preceding siblings ...)
  2020-02-20 12:29 ` Gilad Ben-Yossef
@ 2020-02-22  1:42 ` Herbert Xu
  36 siblings, 0 replies; 40+ messages in thread
From: Herbert Xu @ 2020-02-22  1:42 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Gilad Ben-Yossef, David S . Miller, Greg Kroah-Hartman,
	Rafael J . Wysocki, linux-crypto, linux-renesas-soc,
	linux-kernel

On Tue, Feb 11, 2020 at 07:18:54PM +0100, Geert Uytterhoeven wrote:
> 	Hi all,
> 
> This series contains several fixes, cleanups, and other improvements for
> the ARM TrustZone CryptoCell driver.
> 
> The first 3 patches have been sent before:
>   - [PATCH 0/2] Fix debugfs register access while suspended[1],
>   - [PATCH] [RFC] crypto: ccree - fix retry handling in
>     cc_send_sync_request()[2.
> 
> This is based on v5.6-rc1, with the following fixes from Gilad applied:
>   - [PATCH 0/4] crypto: ccree - fixes[3],
>   - [PATCH] crypto: ccree - dec auth tag size from cryptlen map[4].
> 
> This has been tested on R-Car H3 ES2.0.
> To ease testing, I have pushed this series and its dependencies to the
> topic/ccree-misc-v2  branch of my renesas-drivers repository at
> git://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git.
> 
> Thanks for your comments!
> 
> [1] https://lore.kernel.org/r/20200124132957.15769-1-geert+renesas@glider.be/
> [2] https://lore.kernel.org/r/20200128190913.23086-1-geert+renesas@glider.be/
> [3] https://lore.kernel.org/r/20200129143757.680-1-gilad@benyossef.com/
> [4] https://lore.kernel.org/r/20200202161914.9551-1-gilad@benyossef.com/
> 
> Geert Uytterhoeven (34):
>   debugfs: regset32: Add Runtime PM support
>   crypto: ccree - fix debugfs register access while suspended
>   crypto: ccree - fix retry handling in cc_send_sync_request()
>   crypto: ccree - remove unneeded casts
>   crypto: ccree - swap SHA384 and SHA512 larval hashes at build time
>   crypto: ccree - drop duplicated error message on SRAM exhaustion
>   crypto: ccree - remove empty cc_sram_mgr_fini()
>   crypto: ccree - clean up clock handling
>   crypto: ccree - make mlli_params.mlli_virt_addr void *
>   crypto: ccree - use existing helpers to split 64-bit addresses
>   crypto: ccree - defer larval_digest_addr init until needed
>   crypto: ccree - remove bogus paragraph about freeing SRAM
>   crypto: ccree - use u32 for SRAM addresses
>   crypto: ccree - simplify Runtime PM handling
>   crypto: ccree - use of_device_get_match_data()
>   crypto: ccree - remove cc_pm_is_dev_suspended() wrapper
>   crypto: ccree - make cc_pm_{suspend,resume}() static
>   crypto: ccree - remove struct cc_sram_ctx
>   crypto: ccree - remove struct cc_debugfs_ctx
>   crypto: ccree - remove struct buff_mgr_handle
>   crypto: ccree - remove struct cc_cipher_handle
>   crypto: ccree - extract cc_init_copy_sram()
>   crypto: ccree - remove bogus kerneldoc markers
>   crypto: ccree - improve kerneldoc in cc_hw_queue_defs.h
>   crypto: ccree - improve kerneldoc in cc_buffer_mgr.c
>   crypto: ccree - improve kerneldoc in cc_hash.[ch]
>   crypto: ccree - improve kerneldoc in cc_request_mgr.[ch]
>   crypto: ccree - improve kerneldoc in cc_sram_mgr.[ch]
>   crypto: ccree - spelling s/Crytpcell/Cryptocell/
>   crypto: ccree - grammar s/not room/no room/
>   crypto: ccree - use existing dev helper in init_cc_resources()
>   crypto: ccree - use devm_k[mz]alloc() for AEAD data
>   crypto: ccree - use devm_k[mz]alloc() for cipher data
>   crypto: ccree - use devm_kzalloc() for hash data
> 
>  drivers/crypto/ccree/cc_aead.c          |  61 +++---
>  drivers/crypto/ccree/cc_buffer_mgr.c    |  66 +++---
>  drivers/crypto/ccree/cc_buffer_mgr.h    |   4 +-
>  drivers/crypto/ccree/cc_cipher.c        |  61 ++----
>  drivers/crypto/ccree/cc_debugfs.c       |  29 +--
>  drivers/crypto/ccree/cc_driver.c        | 127 +++++-------
>  drivers/crypto/ccree/cc_driver.h        |  13 +-
>  drivers/crypto/ccree/cc_hash.c          | 225 +++++++++------------
>  drivers/crypto/ccree/cc_hash.h          |  31 ++-
>  drivers/crypto/ccree/cc_hw_queue_defs.h | 255 ++++++++++++------------
>  drivers/crypto/ccree/cc_pm.c            |  60 +-----
>  drivers/crypto/ccree/cc_pm.h            |  21 --
>  drivers/crypto/ccree/cc_request_mgr.c   |  47 +++--
>  drivers/crypto/ccree/cc_request_mgr.h   |  19 +-
>  drivers/crypto/ccree/cc_sram_mgr.c      |  78 +++-----
>  drivers/crypto/ccree/cc_sram_mgr.h      |  45 ++---
>  fs/debugfs/file.c                       |   8 +
>  include/linux/debugfs.h                 |   1 +
>  18 files changed, 456 insertions(+), 695 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] 40+ messages in thread

end of thread, back to index

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-11 18:18 [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
2020-02-11 18:18 ` [PATCH v2 01/34] debugfs: regset32: Add Runtime PM support Geert Uytterhoeven
2020-02-11 18:18 ` [PATCH v2 02/34] crypto: ccree - fix debugfs register access while suspended Geert Uytterhoeven
2020-02-11 18:18 ` [PATCH v2 03/34] crypto: ccree - fix retry handling in cc_send_sync_request() Geert Uytterhoeven
2020-02-11 18:18 ` [PATCH v2 04/34] crypto: ccree - remove unneeded casts Geert Uytterhoeven
2020-02-11 18:18 ` [PATCH v2 05/34] crypto: ccree - swap SHA384 and SHA512 larval hashes at build time Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 06/34] crypto: ccree - drop duplicated error message on SRAM exhaustion Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 07/34] crypto: ccree - remove empty cc_sram_mgr_fini() Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 08/34] crypto: ccree - clean up clock handling Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 09/34] crypto: ccree - make mlli_params.mlli_virt_addr void * Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 10/34] crypto: ccree - use existing helpers to split 64-bit addresses Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 11/34] crypto: ccree - defer larval_digest_addr init until needed Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 12/34] crypto: ccree - remove bogus paragraph about freeing SRAM Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 13/34] crypto: ccree - use u32 for SRAM addresses Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 14/34] crypto: ccree - simplify Runtime PM handling Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 15/34] crypto: ccree - use of_device_get_match_data() Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 16/34] crypto: ccree - remove cc_pm_is_dev_suspended() wrapper Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 17/34] crypto: ccree - make cc_pm_{suspend,resume}() static Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 18/34] crypto: ccree - remove struct cc_sram_ctx Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 19/34] crypto: ccree - remove struct cc_debugfs_ctx Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 20/34] crypto: ccree - remove struct buff_mgr_handle Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 21/34] crypto: ccree - remove struct cc_cipher_handle Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 22/34] crypto: ccree - extract cc_init_copy_sram() Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 23/34] crypto: ccree - remove bogus kerneldoc markers Geert Uytterhoeven
2020-02-11 18:44   ` Sergei Shtylyov
2020-02-11 18:19 ` [PATCH v2 24/34] crypto: ccree - improve kerneldoc in cc_hw_queue_defs.h Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 25/34] crypto: ccree - improve kerneldoc in cc_buffer_mgr.c Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 26/34] crypto: ccree - improve kerneldoc in cc_hash.[ch] Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 27/34] crypto: ccree - improve kerneldoc in cc_request_mgr.[ch] Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 28/34] crypto: ccree - improve kerneldoc in cc_sram_mgr.[ch] Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 29/34] crypto: ccree - spelling s/Crytpcell/Cryptocell/ Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 30/34] crypto: ccree - grammar s/not room/no room/ Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 31/34] crypto: ccree - use existing dev helper in init_cc_resources() Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 32/34] crypto: ccree - use devm_k[mz]alloc() for AEAD data Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 33/34] crypto: ccree - use devm_k[mz]alloc() for cipher data Geert Uytterhoeven
2020-02-11 18:19 ` [PATCH v2 34/34] crypto: ccree - use devm_kzalloc() for hash data Geert Uytterhoeven
     [not found] ` <CAOtvUMfs84VXAecVNShoEg-CU6APjyiVTUBkogpFq_c3fbaX+Q@mail.gmail.com>
2020-02-13  7:47   ` [PATCH v2 00/34] crypto: ccree - miscellaneous fixes and improvements Geert Uytterhoeven
2020-02-19 15:41     ` Gilad Ben-Yossef
2020-02-20 12:29 ` Gilad Ben-Yossef
2020-02-22  1:42 ` Herbert Xu

Linux-Renesas-SoC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-renesas-soc/0 linux-renesas-soc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-renesas-soc linux-renesas-soc/ https://lore.kernel.org/linux-renesas-soc \
		linux-renesas-soc@vger.kernel.org
	public-inbox-index linux-renesas-soc

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-renesas-soc


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git