Skip to contentSkip to conversation

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

PATCH In review Rosen Penev 2 participants 3 messages Jul 13 – Jul 18

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 crypto: cesa: switch to non-devm IRQ to free it earlier

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

---
v2: fixed Fixes tag and reworded commit

 drivers/crypto/marvell/cesa/cesa.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/crypto/marvell/cesa/cesa.c +11 -2
index 75d8ba23d9a2..57c9295be711 100644
@@ -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[] = {
Signature · 1 line
2.55.0
maintainer
#1 lore raw
Quoted 9 lines · Rosen Penev

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.

Quoted 7 lines
Fixes f63601fd616ab ("crypto: marvell/cesa - add a new driver for Marvell's CESA")
Assisted-by opencode:big-pickle

---
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,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#2 lore raw
Quoted 19 lines · Herbert Xu
Quoted 9 lines · Rosen Penev

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.

Quoted 7 lines
Fixes f63601fd616ab ("crypto: marvell/cesa - add a new driver for Marvell's CESA")
Assisted-by opencode:big-pickle

---
v2: fixed Fixes tag and reworded commit

 drivers/crypto/marvell/cesa/cesa.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
Quoted 2 lines

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.

Quoted 6 lines

Thanks,
--
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt