* [PATCH] crypto: amcc - embed pdr_uinfo as flexible array in crypto4xx_device
@ 2026-06-13 23:45 Rosen Penev
2026-06-14 1:27 ` Rosen Penev
0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2026-06-13 23:45 UTC (permalink / raw)
To: linux-crypto; +Cc: Herbert Xu, David S. Miller, open list
No need to allocate and free separately.
This keeps crypto4xx_destroy_pdr dedicated to dma freeing only.
Assisted-by: opencode:big-pickle
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/crypto/amcc/crypto4xx_core.c | 12 +-----------
drivers/crypto/amcc/crypto4xx_core.h | 3 ++-
2 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/drivers/crypto/amcc/crypto4xx_core.c b/drivers/crypto/amcc/crypto4xx_core.c
index 001da785af07..ea1e40b3184b 100644
--- a/drivers/crypto/amcc/crypto4xx_core.c
+++ b/drivers/crypto/amcc/crypto4xx_core.c
@@ -171,14 +171,6 @@ static u32 crypto4xx_build_pdr(struct crypto4xx_device *dev)
if (!dev->pdr)
return -ENOMEM;
- dev->pdr_uinfo = kzalloc_objs(struct pd_uinfo, PPC4XX_NUM_PD);
- if (!dev->pdr_uinfo) {
- dma_free_coherent(dev->core_dev->device,
- sizeof(struct ce_pd) * PPC4XX_NUM_PD,
- dev->pdr,
- dev->pdr_pa);
- return -ENOMEM;
- }
dev->shadow_sa_pool = dma_alloc_coherent(dev->core_dev->device,
sizeof(union shadow_sa_buf) * PPC4XX_NUM_PD,
&dev->shadow_sa_pool_pa,
@@ -226,8 +218,6 @@ static void crypto4xx_destroy_pdr(struct crypto4xx_device *dev)
dma_free_coherent(dev->core_dev->device,
sizeof(struct sa_state_record) * PPC4XX_NUM_PD,
dev->shadow_sr_pool, dev->shadow_sr_pool_pa);
-
- kfree(dev->pdr_uinfo);
}
static u32 crypto4xx_get_pd_from_pdr_nolock(struct crypto4xx_device *dev)
@@ -1247,7 +1237,7 @@ static int crypto4xx_probe(struct platform_device *ofdev)
dev_set_drvdata(dev, core_dev);
core_dev->ofdev = ofdev;
core_dev->dev = devm_kzalloc(
- &ofdev->dev, sizeof(struct crypto4xx_device), GFP_KERNEL);
+ &ofdev->dev, struct_size(core_dev->dev, pdr_uinfo, PPC4XX_NUM_PD), GFP_KERNEL);
if (!core_dev->dev)
return -ENOMEM;
diff --git a/drivers/crypto/amcc/crypto4xx_core.h b/drivers/crypto/amcc/crypto4xx_core.h
index 66a95733c86d..bd4a286514a4 100644
--- a/drivers/crypto/amcc/crypto4xx_core.h
+++ b/drivers/crypto/amcc/crypto4xx_core.h
@@ -93,11 +93,12 @@ struct crypto4xx_device {
u32 gdr_head;
u32 sdr_tail;
u32 sdr_head;
- struct pd_uinfo *pdr_uinfo;
struct list_head alg_list; /* List of algorithm supported
by this device */
struct ratelimit_state aead_ratelimit;
bool is_revb;
+
+ struct pd_uinfo pdr_uinfo[];
};
struct crypto4xx_core_device {
--
2.54.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] crypto: amcc - embed pdr_uinfo as flexible array in crypto4xx_device
2026-06-13 23:45 [PATCH] crypto: amcc - embed pdr_uinfo as flexible array in crypto4xx_device Rosen Penev
@ 2026-06-14 1:27 ` Rosen Penev
0 siblings, 0 replies; 2+ messages in thread
From: Rosen Penev @ 2026-06-14 1:27 UTC (permalink / raw)
To: linux-crypto; +Cc: Herbert Xu, David S. Miller, open list
On Sat, Jun 13, 2026 at 4:46 PM Rosen Penev <rosenp@gmail.com> wrote:
>
> No need to allocate and free separately.
On further review, it makes more sense to change to a static array.
>
> This keeps crypto4xx_destroy_pdr dedicated to dma freeing only.
>
> Assisted-by: opencode:big-pickle
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
> drivers/crypto/amcc/crypto4xx_core.c | 12 +-----------
> drivers/crypto/amcc/crypto4xx_core.h | 3 ++-
> 2 files changed, 3 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/crypto/amcc/crypto4xx_core.c b/drivers/crypto/amcc/crypto4xx_core.c
> index 001da785af07..ea1e40b3184b 100644
> --- a/drivers/crypto/amcc/crypto4xx_core.c
> +++ b/drivers/crypto/amcc/crypto4xx_core.c
> @@ -171,14 +171,6 @@ static u32 crypto4xx_build_pdr(struct crypto4xx_device *dev)
> if (!dev->pdr)
> return -ENOMEM;
>
> - dev->pdr_uinfo = kzalloc_objs(struct pd_uinfo, PPC4XX_NUM_PD);
> - if (!dev->pdr_uinfo) {
> - dma_free_coherent(dev->core_dev->device,
> - sizeof(struct ce_pd) * PPC4XX_NUM_PD,
> - dev->pdr,
> - dev->pdr_pa);
> - return -ENOMEM;
> - }
> dev->shadow_sa_pool = dma_alloc_coherent(dev->core_dev->device,
> sizeof(union shadow_sa_buf) * PPC4XX_NUM_PD,
> &dev->shadow_sa_pool_pa,
> @@ -226,8 +218,6 @@ static void crypto4xx_destroy_pdr(struct crypto4xx_device *dev)
> dma_free_coherent(dev->core_dev->device,
> sizeof(struct sa_state_record) * PPC4XX_NUM_PD,
> dev->shadow_sr_pool, dev->shadow_sr_pool_pa);
> -
> - kfree(dev->pdr_uinfo);
> }
>
> static u32 crypto4xx_get_pd_from_pdr_nolock(struct crypto4xx_device *dev)
> @@ -1247,7 +1237,7 @@ static int crypto4xx_probe(struct platform_device *ofdev)
> dev_set_drvdata(dev, core_dev);
> core_dev->ofdev = ofdev;
> core_dev->dev = devm_kzalloc(
> - &ofdev->dev, sizeof(struct crypto4xx_device), GFP_KERNEL);
> + &ofdev->dev, struct_size(core_dev->dev, pdr_uinfo, PPC4XX_NUM_PD), GFP_KERNEL);
> if (!core_dev->dev)
> return -ENOMEM;
>
> diff --git a/drivers/crypto/amcc/crypto4xx_core.h b/drivers/crypto/amcc/crypto4xx_core.h
> index 66a95733c86d..bd4a286514a4 100644
> --- a/drivers/crypto/amcc/crypto4xx_core.h
> +++ b/drivers/crypto/amcc/crypto4xx_core.h
> @@ -93,11 +93,12 @@ struct crypto4xx_device {
> u32 gdr_head;
> u32 sdr_tail;
> u32 sdr_head;
> - struct pd_uinfo *pdr_uinfo;
> struct list_head alg_list; /* List of algorithm supported
> by this device */
> struct ratelimit_state aead_ratelimit;
> bool is_revb;
> +
> + struct pd_uinfo pdr_uinfo[];
> };
>
> struct crypto4xx_core_device {
> --
> 2.54.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-14 1:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-13 23:45 [PATCH] crypto: amcc - embed pdr_uinfo as flexible array in crypto4xx_device Rosen Penev
2026-06-14 1:27 ` Rosen Penev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox