linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] crypto: picoxcell: use non-devm request_irq and add missed tasklet_kill
@ 2019-11-22 11:25 Chuhong Yuan
  0 siblings, 0 replies; only message in thread
From: Chuhong Yuan @ 2019-11-22 11:25 UTC (permalink / raw)
  Cc: Jamie Iles, Herbert Xu, David S . Miller, linux-arm-kernel,
	linux-crypto, linux-kernel, Chuhong Yuan

This driver forgets to kill tasklet when probe fails and remove.

Since tasklet should not be killed until the IRQ handler has been
unregistered, we use non-devm request_irq instead to make it able
to control its unregistration.

Furthermore, tasklet should be initialized before registering IRQ
handler. So we adjust the order of calling to fix it.

Finally, we fix the missed tasklet_kill in both probe failure and
remove.

Fixes: ce92136843cb ("crypto: picoxcell - add support for the picoxcell crypto engines")
Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
---
Changes in v2:
  - Use non-devm request_irq.
  - Adjust the order of calling.
  - Modify commit message.

 drivers/crypto/picoxcell_crypto.c | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/drivers/crypto/picoxcell_crypto.c b/drivers/crypto/picoxcell_crypto.c
index 3cbefb41b099..b751822bb0cb 100644
--- a/drivers/crypto/picoxcell_crypto.c
+++ b/drivers/crypto/picoxcell_crypto.c
@@ -1655,10 +1655,14 @@ static int spacc_probe(struct platform_device *pdev)
 		return -ENXIO;
 	}
 
-	if (devm_request_irq(&pdev->dev, irq->start, spacc_spacc_irq, 0,
-			     engine->name, engine)) {
+	tasklet_init(&engine->complete, spacc_spacc_complete,
+		     (unsigned long)engine);
+
+	if (request_irq(irq->start, spacc_spacc_irq, 0, engine->name,
+			engine)) {
 		dev_err(engine->dev, "failed to request IRQ\n");
-		return -EBUSY;
+		ret = -EBUSY;
+		goto err_tasklet_kill;
 	}
 
 	engine->dev		= &pdev->dev;
@@ -1667,15 +1671,18 @@ static int spacc_probe(struct platform_device *pdev)
 
 	engine->req_pool = dmam_pool_create(engine->name, engine->dev,
 		MAX_DDT_LEN * sizeof(struct spacc_ddt), 8, SZ_64K);
-	if (!engine->req_pool)
-		return -ENOMEM;
+	if (!engine->req_pool) {
+		ret = -ENOMEM;
+		goto err_free_irq;
+	}
 
 	spin_lock_init(&engine->hw_lock);
 
 	engine->clk = clk_get(&pdev->dev, "ref");
 	if (IS_ERR(engine->clk)) {
 		dev_info(&pdev->dev, "clk unavailable\n");
-		return PTR_ERR(engine->clk);
+		ret = PTR_ERR(engine->clk);
+		goto err_free_irq;
 	}
 
 	if (clk_prepare_enable(engine->clk)) {
@@ -1712,8 +1719,6 @@ static int spacc_probe(struct platform_device *pdev)
 	INIT_LIST_HEAD(&engine->completed);
 	INIT_LIST_HEAD(&engine->in_progress);
 	engine->in_flight = 0;
-	tasklet_init(&engine->complete, spacc_spacc_complete,
-		     (unsigned long)engine);
 
 	platform_set_drvdata(pdev, engine);
 
@@ -1761,6 +1766,10 @@ static int spacc_probe(struct platform_device *pdev)
 	clk_disable_unprepare(engine->clk);
 err_clk_put:
 	clk_put(engine->clk);
+err_free_irq:
+	free_irq(irq->start, engine);
+err_tasklet_kill:
+	tasklet_kill(&engine->complete);
 
 	return ret;
 }
@@ -1770,6 +1779,7 @@ static int spacc_remove(struct platform_device *pdev)
 	struct spacc_aead *aead, *an;
 	struct spacc_alg *alg, *next;
 	struct spacc_engine *engine = platform_get_drvdata(pdev);
+	struct resource *irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 
 	del_timer_sync(&engine->packet_timeout);
 	device_remove_file(&pdev->dev, &dev_attr_stat_irq_thresh);
@@ -1786,6 +1796,8 @@ static int spacc_remove(struct platform_device *pdev)
 
 	clk_disable_unprepare(engine->clk);
 	clk_put(engine->clk);
+	free_irq(irq->start, engine);
+	tasklet_kill(&engine->complete);
 
 	return 0;
 }
-- 
2.24.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-11-22 11:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-22 11:25 [PATCH v2] crypto: picoxcell: use non-devm request_irq and add missed tasklet_kill Chuhong Yuan

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).