* [PATCHv2 0/5] cesa: small cleanups
@ 2024-10-10 19:45 Rosen Penev
2024-10-10 19:45 ` [PATCHv2 1/5] crypto: cesa: add COMPILE_TEST Rosen Penev
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: Rosen Penev @ 2024-10-10 19:45 UTC (permalink / raw)
To: linux-crypto
Cc: Boris Brezillon, Arnaud Ebalard, Srujana Challa, Herbert Xu,
David S. Miller, Rosen Penev, Uwe Kleine-König, open list
Mostly increased devm usage and added COMPILE_TEST.
v2: fix wrong returns in clk_get conversions
Rosen Penev (5):
crypto: cesa: add COMPILE_TEST
crypto: cesa: use enabled variants for clk_get
crypto: cesa: remove irq_set_affinity_hint
crypto: cesa: move loop to mv_cesa_put_sram
crypto: cesa: use devm_platform_get_and_ioremap_resource
drivers/crypto/marvell/Kconfig | 2 +-
drivers/crypto/marvell/cesa/cesa.c | 79 ++++++++++--------------------
2 files changed, 28 insertions(+), 53 deletions(-)
--
2.46.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCHv2 1/5] crypto: cesa: add COMPILE_TEST
2024-10-10 19:45 [PATCHv2 0/5] cesa: small cleanups Rosen Penev
@ 2024-10-10 19:45 ` Rosen Penev
2024-10-10 19:45 ` [PATCHv2 2/5] crypto: cesa: use enabled variants for clk_get Rosen Penev
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Rosen Penev @ 2024-10-10 19:45 UTC (permalink / raw)
To: linux-crypto
Cc: Boris Brezillon, Arnaud Ebalard, Srujana Challa, Herbert Xu,
David S. Miller, Rosen Penev, Uwe Kleine-König, open list
This can build on x86. Allows more CI coverage.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/crypto/marvell/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/marvell/Kconfig b/drivers/crypto/marvell/Kconfig
index 78217577aa54..4c25a78ab3ed 100644
--- a/drivers/crypto/marvell/Kconfig
+++ b/drivers/crypto/marvell/Kconfig
@@ -7,7 +7,7 @@ config CRYPTO_DEV_MARVELL
config CRYPTO_DEV_MARVELL_CESA
tristate "Marvell's Cryptographic Engine driver"
- depends on PLAT_ORION || ARCH_MVEBU
+ depends on PLAT_ORION || ARCH_MVEBU || COMPILE_TEST
select CRYPTO_LIB_AES
select CRYPTO_LIB_DES
select CRYPTO_SKCIPHER
--
2.46.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCHv2 2/5] crypto: cesa: use enabled variants for clk_get
2024-10-10 19:45 [PATCHv2 0/5] cesa: small cleanups Rosen Penev
2024-10-10 19:45 ` [PATCHv2 1/5] crypto: cesa: add COMPILE_TEST Rosen Penev
@ 2024-10-10 19:45 ` Rosen Penev
2024-10-10 19:45 ` [PATCHv2 3/5] crypto: cesa: remove irq_set_affinity_hint Rosen Penev
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Rosen Penev @ 2024-10-10 19:45 UTC (permalink / raw)
To: linux-crypto
Cc: Boris Brezillon, Arnaud Ebalard, Srujana Challa, Herbert Xu,
David S. Miller, Rosen Penev, Uwe Kleine-König, open list
Avoids manual frees. Also simplifiies the code with _optional
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/crypto/marvell/cesa/cesa.c | 28 ++++++++++------------------
1 file changed, 10 insertions(+), 18 deletions(-)
diff --git a/drivers/crypto/marvell/cesa/cesa.c b/drivers/crypto/marvell/cesa/cesa.c
index 5fd31ba715c2..74a1d1ad67d3 100644
--- a/drivers/crypto/marvell/cesa/cesa.c
+++ b/drivers/crypto/marvell/cesa/cesa.c
@@ -510,25 +510,21 @@ static int mv_cesa_probe(struct platform_device *pdev)
* if the clock does not exist.
*/
snprintf(res_name, sizeof(res_name), "cesa%u", i);
- engine->clk = devm_clk_get(dev, res_name);
+ engine->clk = devm_clk_get_optional_enabled(dev, res_name);
if (IS_ERR(engine->clk)) {
- engine->clk = devm_clk_get(dev, NULL);
- if (IS_ERR(engine->clk))
- engine->clk = NULL;
+ engine->clk = devm_clk_get_optional_enabled(dev, NULL);
+ if (IS_ERR(engine->clk)) {
+ ret = PTR_ERR(engine->clk);
+ goto err_cleanup;
+ }
}
snprintf(res_name, sizeof(res_name), "cesaz%u", i);
- engine->zclk = devm_clk_get(dev, res_name);
- if (IS_ERR(engine->zclk))
- engine->zclk = NULL;
-
- ret = clk_prepare_enable(engine->clk);
- if (ret)
- goto err_cleanup;
-
- ret = clk_prepare_enable(engine->zclk);
- if (ret)
+ engine->zclk = devm_clk_get_optional_enabled(dev, res_name);
+ if (IS_ERR(engine->zclk)) {
+ ret = PTR_ERR(engine->zclk);
goto err_cleanup;
+ }
engine->regs = cesa->regs + CESA_ENGINE_OFF(i);
@@ -571,8 +567,6 @@ static int mv_cesa_probe(struct platform_device *pdev)
err_cleanup:
for (i = 0; i < caps->nengines; i++) {
- clk_disable_unprepare(cesa->engines[i].zclk);
- clk_disable_unprepare(cesa->engines[i].clk);
mv_cesa_put_sram(pdev, i);
if (cesa->engines[i].irq > 0)
irq_set_affinity_hint(cesa->engines[i].irq, NULL);
@@ -589,8 +583,6 @@ static void mv_cesa_remove(struct platform_device *pdev)
mv_cesa_remove_algs(cesa);
for (i = 0; i < cesa->caps->nengines; i++) {
- clk_disable_unprepare(cesa->engines[i].zclk);
- clk_disable_unprepare(cesa->engines[i].clk);
mv_cesa_put_sram(pdev, i);
irq_set_affinity_hint(cesa->engines[i].irq, NULL);
}
--
2.46.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCHv2 3/5] crypto: cesa: remove irq_set_affinity_hint
2024-10-10 19:45 [PATCHv2 0/5] cesa: small cleanups Rosen Penev
2024-10-10 19:45 ` [PATCHv2 1/5] crypto: cesa: add COMPILE_TEST Rosen Penev
2024-10-10 19:45 ` [PATCHv2 2/5] crypto: cesa: use enabled variants for clk_get Rosen Penev
@ 2024-10-10 19:45 ` Rosen Penev
2024-10-10 19:45 ` [PATCHv2 4/5] crypto: cesa: move loop to mv_cesa_put_sram Rosen Penev
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Rosen Penev @ 2024-10-10 19:45 UTC (permalink / raw)
To: linux-crypto
Cc: Boris Brezillon, Arnaud Ebalard, Srujana Challa, Herbert Xu,
David S. Miller, Rosen Penev, Uwe Kleine-König, open list
This is unnecessary as the irqs are devm managed.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/crypto/marvell/cesa/cesa.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/crypto/marvell/cesa/cesa.c b/drivers/crypto/marvell/cesa/cesa.c
index 74a1d1ad67d3..21e13f4a1f48 100644
--- a/drivers/crypto/marvell/cesa/cesa.c
+++ b/drivers/crypto/marvell/cesa/cesa.c
@@ -566,11 +566,8 @@ static int mv_cesa_probe(struct platform_device *pdev)
return 0;
err_cleanup:
- for (i = 0; i < caps->nengines; i++) {
+ for (i = 0; i < caps->nengines; i++)
mv_cesa_put_sram(pdev, i);
- if (cesa->engines[i].irq > 0)
- irq_set_affinity_hint(cesa->engines[i].irq, NULL);
- }
return ret;
}
@@ -582,10 +579,8 @@ static void mv_cesa_remove(struct platform_device *pdev)
mv_cesa_remove_algs(cesa);
- for (i = 0; i < cesa->caps->nengines; i++) {
+ for (i = 0; i < cesa->caps->nengines; i++)
mv_cesa_put_sram(pdev, i);
- irq_set_affinity_hint(cesa->engines[i].irq, NULL);
- }
}
static const struct platform_device_id mv_cesa_plat_id_table[] = {
--
2.46.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCHv2 4/5] crypto: cesa: move loop to mv_cesa_put_sram
2024-10-10 19:45 [PATCHv2 0/5] cesa: small cleanups Rosen Penev
` (2 preceding siblings ...)
2024-10-10 19:45 ` [PATCHv2 3/5] crypto: cesa: remove irq_set_affinity_hint Rosen Penev
@ 2024-10-10 19:45 ` Rosen Penev
2024-10-18 9:11 ` Herbert Xu
2024-10-10 19:45 ` [PATCHv2 5/5] crypto: cesa: use devm_platform_get_and_ioremap_resource Rosen Penev
2024-10-19 11:58 ` [PATCHv2 0/5] cesa: small cleanups Herbert Xu
5 siblings, 1 reply; 8+ messages in thread
From: Rosen Penev @ 2024-10-10 19:45 UTC (permalink / raw)
To: linux-crypto
Cc: Boris Brezillon, Arnaud Ebalard, Srujana Challa, Herbert Xu,
David S. Miller, Rosen Penev, Uwe Kleine-König, open list
Simpler to move it there. More readable remove.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/crypto/marvell/cesa/cesa.c | 31 +++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/drivers/crypto/marvell/cesa/cesa.c b/drivers/crypto/marvell/cesa/cesa.c
index 21e13f4a1f48..a65f328b7094 100644
--- a/drivers/crypto/marvell/cesa/cesa.c
+++ b/drivers/crypto/marvell/cesa/cesa.c
@@ -416,17 +416,23 @@ static int mv_cesa_get_sram(struct platform_device *pdev, int idx)
return 0;
}
-static void mv_cesa_put_sram(struct platform_device *pdev, int idx)
+static void mv_cesa_put_sram(struct platform_device *pdev)
{
struct mv_cesa_dev *cesa = platform_get_drvdata(pdev);
- struct mv_cesa_engine *engine = &cesa->engines[idx];
+ const struct mv_cesa_caps *caps = &orion_caps;
+ int i;
- if (engine->pool)
- gen_pool_free(engine->pool, (unsigned long)engine->sram_pool,
- cesa->sram_size);
- else
- dma_unmap_resource(cesa->dev, engine->sram_dma,
- cesa->sram_size, DMA_BIDIRECTIONAL, 0);
+ for (i = 0; i < caps->nengines; i++) {
+ struct mv_cesa_engine *engine = &cesa->engines[i];
+ if (engine->pool)
+ gen_pool_free(engine->pool,
+ (unsigned long)engine->sram_pool,
+ cesa->sram_size);
+ else
+ dma_unmap_resource(cesa->dev, engine->sram_dma,
+ cesa->sram_size, DMA_BIDIRECTIONAL,
+ 0);
+ }
}
static int mv_cesa_probe(struct platform_device *pdev)
@@ -566,21 +572,16 @@ static int mv_cesa_probe(struct platform_device *pdev)
return 0;
err_cleanup:
- for (i = 0; i < caps->nengines; i++)
- mv_cesa_put_sram(pdev, i);
-
+ mv_cesa_put_sram(pdev);
return ret;
}
static void mv_cesa_remove(struct platform_device *pdev)
{
struct mv_cesa_dev *cesa = platform_get_drvdata(pdev);
- int i;
mv_cesa_remove_algs(cesa);
-
- for (i = 0; i < cesa->caps->nengines; i++)
- mv_cesa_put_sram(pdev, i);
+ mv_cesa_put_sram(pdev);
}
static const struct platform_device_id mv_cesa_plat_id_table[] = {
--
2.46.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCHv2 5/5] crypto: cesa: use devm_platform_get_and_ioremap_resource
2024-10-10 19:45 [PATCHv2 0/5] cesa: small cleanups Rosen Penev
` (3 preceding siblings ...)
2024-10-10 19:45 ` [PATCHv2 4/5] crypto: cesa: move loop to mv_cesa_put_sram Rosen Penev
@ 2024-10-10 19:45 ` Rosen Penev
2024-10-19 11:58 ` [PATCHv2 0/5] cesa: small cleanups Herbert Xu
5 siblings, 0 replies; 8+ messages in thread
From: Rosen Penev @ 2024-10-10 19:45 UTC (permalink / raw)
To: linux-crypto
Cc: Boris Brezillon, Arnaud Ebalard, Srujana Challa, Herbert Xu,
David S. Miller, Rosen Penev, Uwe Kleine-König, open list
Removes separate steps. Requires index instead of name.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/crypto/marvell/cesa/cesa.c | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)
diff --git a/drivers/crypto/marvell/cesa/cesa.c b/drivers/crypto/marvell/cesa/cesa.c
index a65f328b7094..ef4b1c2336bb 100644
--- a/drivers/crypto/marvell/cesa/cesa.c
+++ b/drivers/crypto/marvell/cesa/cesa.c
@@ -375,7 +375,6 @@ static int mv_cesa_get_sram(struct platform_device *pdev, int idx)
{
struct mv_cesa_dev *cesa = platform_get_drvdata(pdev);
struct mv_cesa_engine *engine = &cesa->engines[idx];
- const char *res_name = "sram";
struct resource *res;
engine->pool = of_gen_pool_get(cesa->dev->of_node,
@@ -391,19 +390,7 @@ static int mv_cesa_get_sram(struct platform_device *pdev, int idx)
return -ENOMEM;
}
- if (cesa->caps->nengines > 1) {
- if (!idx)
- res_name = "sram0";
- else
- res_name = "sram1";
- }
-
- res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
- res_name);
- if (!res || resource_size(res) < cesa->sram_size)
- return -EINVAL;
-
- engine->sram = devm_ioremap_resource(cesa->dev, res);
+ engine->sram = devm_platform_get_and_ioremap_resource(pdev, idx, &res);
if (IS_ERR(engine->sram))
return PTR_ERR(engine->sram);
--
2.46.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCHv2 4/5] crypto: cesa: move loop to mv_cesa_put_sram
2024-10-10 19:45 ` [PATCHv2 4/5] crypto: cesa: move loop to mv_cesa_put_sram Rosen Penev
@ 2024-10-18 9:11 ` Herbert Xu
0 siblings, 0 replies; 8+ messages in thread
From: Herbert Xu @ 2024-10-18 9:11 UTC (permalink / raw)
To: Rosen Penev
Cc: linux-crypto, Boris Brezillon, Arnaud Ebalard, Srujana Challa,
David S. Miller, Uwe Kleine-König, open list
On Thu, Oct 10, 2024 at 12:45:16PM -0700, Rosen Penev wrote:
>
> @@ -566,21 +572,16 @@ static int mv_cesa_probe(struct platform_device *pdev)
> return 0;
>
> err_cleanup:
> - for (i = 0; i < caps->nengines; i++)
> - mv_cesa_put_sram(pdev, i);
> -
> + mv_cesa_put_sram(pdev);
I think it'd be cleaner if you introduced a new function that
did the loop and kept mv_cesa_put_sram as is.
Thanks,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCHv2 0/5] cesa: small cleanups
2024-10-10 19:45 [PATCHv2 0/5] cesa: small cleanups Rosen Penev
` (4 preceding siblings ...)
2024-10-10 19:45 ` [PATCHv2 5/5] crypto: cesa: use devm_platform_get_and_ioremap_resource Rosen Penev
@ 2024-10-19 11:58 ` Herbert Xu
5 siblings, 0 replies; 8+ messages in thread
From: Herbert Xu @ 2024-10-19 11:58 UTC (permalink / raw)
To: Rosen Penev
Cc: linux-crypto, Boris Brezillon, Arnaud Ebalard, Srujana Challa,
David S. Miller, Uwe Kleine-König, open list
On Thu, Oct 10, 2024 at 12:45:12PM -0700, Rosen Penev wrote:
> Mostly increased devm usage and added COMPILE_TEST.
>
> v2: fix wrong returns in clk_get conversions
>
> Rosen Penev (5):
> crypto: cesa: add COMPILE_TEST
> crypto: cesa: use enabled variants for clk_get
> crypto: cesa: remove irq_set_affinity_hint
> crypto: cesa: move loop to mv_cesa_put_sram
> crypto: cesa: use devm_platform_get_and_ioremap_resource
>
> drivers/crypto/marvell/Kconfig | 2 +-
> drivers/crypto/marvell/cesa/cesa.c | 79 ++++++++++--------------------
> 2 files changed, 28 insertions(+), 53 deletions(-)
>
> --
> 2.46.2
Patches 1-3,5 applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-10-19 11:58 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-10 19:45 [PATCHv2 0/5] cesa: small cleanups Rosen Penev
2024-10-10 19:45 ` [PATCHv2 1/5] crypto: cesa: add COMPILE_TEST Rosen Penev
2024-10-10 19:45 ` [PATCHv2 2/5] crypto: cesa: use enabled variants for clk_get Rosen Penev
2024-10-10 19:45 ` [PATCHv2 3/5] crypto: cesa: remove irq_set_affinity_hint Rosen Penev
2024-10-10 19:45 ` [PATCHv2 4/5] crypto: cesa: move loop to mv_cesa_put_sram Rosen Penev
2024-10-18 9:11 ` Herbert Xu
2024-10-10 19:45 ` [PATCHv2 5/5] crypto: cesa: use devm_platform_get_and_ioremap_resource Rosen Penev
2024-10-19 11:58 ` [PATCHv2 0/5] cesa: small cleanups Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).