[PATCHv2] crypto: cesa: switch to non-devm IRQ to free it earlier

Rosen Penev posted 1 patch 1 week, 5 days ago
drivers/crypto/marvell/cesa/cesa.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
[PATCHv2] crypto: cesa: switch to non-devm IRQ to free it earlier
Posted by Rosen Penev 1 week, 5 days ago
Switch the IRQ request from devm_request_threaded_irq() to
request_threaded_irq() so the IRQ is released explicitly, allowing it to
be freed earlier in the cleanup path rather than deferred to device
teardown.

Add the matching free_irq() and irq_set_affinity_hint(NULL) calls in both
the probe error path and the remove function to release the IRQ and clear
the affinity hint set during probe.

Fixes: f63601fd616ab ("crypto: marvell/cesa - add a new driver for Marvell's CESA")
Assisted-by: opencode:big-pickle
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 v2: fixed Fixes tag and reworded commit
 drivers/crypto/marvell/cesa/cesa.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/marvell/cesa/cesa.c b/drivers/crypto/marvell/cesa/cesa.c
index 75d8ba23d9a2..57c9295be711 100644
--- a/drivers/crypto/marvell/cesa/cesa.c
+++ b/drivers/crypto/marvell/cesa/cesa.c
@@ -511,7 +511,7 @@ static int mv_cesa_probe(struct platform_device *pdev)
 		writel(engine->sram_dma & CESA_SA_SRAM_MSK,
 		       engine->regs + CESA_SA_DESC_P0);
 
-		ret = devm_request_threaded_irq(dev, irq, NULL, mv_cesa_int,
+		ret = request_threaded_irq(irq, NULL, mv_cesa_int,
 						IRQF_ONESHOT,
 						dev_name(&pdev->dev),
 						engine);
@@ -540,6 +540,10 @@ static int mv_cesa_probe(struct platform_device *pdev)
 	return 0;
 
 err_cleanup:
+	while (i--) {
+		irq_set_affinity_hint(cesa->engines[i].irq, NULL);
+		free_irq(cesa->engines[i].irq, &cesa->engines[i]);
+	}
 	for (i = 0; i < caps->nengines; i++)
 		mv_cesa_put_sram(pdev, i);
 
@@ -553,8 +557,13 @@ 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++) {
+		struct mv_cesa_engine *engine = &cesa->engines[i];
+
+		irq_set_affinity_hint(engine->irq, NULL);
+		free_irq(engine->irq, engine);
 		mv_cesa_put_sram(pdev, i);
+	}
 }
 
 static const struct platform_device_id mv_cesa_plat_id_table[] = {
-- 
2.55.0
Re: [PATCHv2] crypto: cesa: switch to non-devm IRQ to free it earlier
Posted by Herbert Xu 1 week, 1 day ago
On Sun, Jul 12, 2026 at 08:15:32PM -0700, Rosen Penev wrote:
> Switch the IRQ request from devm_request_threaded_irq() to
> request_threaded_irq() so the IRQ is released explicitly, allowing it to
> be freed earlier in the cleanup path rather than deferred to device
> teardown.
> 
> Add the matching free_irq() and irq_set_affinity_hint(NULL) calls in both
> the probe error path and the remove function to release the IRQ and clear
> the affinity hint set during probe.
> 
> Fixes: f63601fd616ab ("crypto: marvell/cesa - add a new driver for Marvell's CESA")
> Assisted-by: opencode:big-pickle
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>  v2: fixed Fixes tag and reworded commit
>  drivers/crypto/marvell/cesa/cesa.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)

This makes the code more complicated.  You need to explain why this
is desirable and the explanation needs to go into the patch description.

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
Re: [PATCHv2] crypto: cesa: switch to non-devm IRQ to free it earlier
Posted by Rosen Penev 1 week ago
On Fri, Jul 17, 2026 at 1:06 AM Herbert Xu <herbert@gondor.apana.org.au> wrote:
>
> On Sun, Jul 12, 2026 at 08:15:32PM -0700, Rosen Penev wrote:
> > Switch the IRQ request from devm_request_threaded_irq() to
> > request_threaded_irq() so the IRQ is released explicitly, allowing it to
> > be freed earlier in the cleanup path rather than deferred to device
> > teardown.
> >
> > Add the matching free_irq() and irq_set_affinity_hint(NULL) calls in both
> > the probe error path and the remove function to release the IRQ and clear
> > the affinity hint set during probe.
> >
> > Fixes: f63601fd616ab ("crypto: marvell/cesa - add a new driver for Marvell's CESA")
> > Assisted-by: opencode:big-pickle
> > Signed-off-by: Rosen Penev <rosenp@gmail.com>
> > ---
> >  v2: fixed Fixes tag and reworded commit
> >  drivers/crypto/marvell/cesa/cesa.c | 13 +++++++++++--
> >  1 file changed, 11 insertions(+), 2 deletions(-)
>
> This makes the code more complicated.  You need to explain why this
> is desirable and the explanation needs to go into the patch description.
I agree. The goal was to backport to stable kernels. But probably
better to fix it by going full devm.
>
> 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