Skip to contentSkip to conversation

crypto: talitos: fix probe IRQ ordering

PATCH Superseded Rosen Penev 2 participants 2 messages Sep 24 – Oct 2 Crypto API

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 crypto: talitos: fix probe IRQ ordering

The talitos interrupt handlers schedule priv->done_task[] via tasklet_schedule(). In probe(), talitos_probe_irq() ran before tasklet_init(), so an interrupt arriving during that window (a shared IRQ, or a completion pending from an earlier transmission) would schedule an uninitialized tasklet.

Resolve the IRQ numbers before the tasklet_init() calls so the done_task[] selection can see the secondary IRQ, and only request the IRQs after the channel fifos are allocated and the device is initialized. Every structure the handlers touch is then fully set up before interrupts are enabled. This matches remove(), which frees the IRQs before killing the tasklets.

Assisted-by LLM

---
v2: reshuffle code to avoid NULL derefs

 drivers/crypto/talitos.c | 33 +++++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)
drivers/crypto/talitos.c +23 -10
index 41a87d7c30a0..b9dfa2b7ccbb 100644
@@ -3346,28 +3346,36 @@ static struct talitos_crypto_alg *talitos_alg_alloc(struct device *dev,
 	return t_alg;
 }
 
-static int talitos_probe_irq(struct platform_device *ofdev)
+static int talitos_get_irqs(struct platform_device *ofdev)
 {
 	struct device *dev = &ofdev->dev;
 	struct talitos_private *priv = dev_get_drvdata(dev);
-	int err;
-	bool is_sec1 = has_ftr_sec1(priv);
 
 	priv->irq[0] = platform_get_irq(ofdev, 0);
 	if (priv->irq[0] < 0)
 		return priv->irq[0];
 
+	priv->irq[1] = platform_get_irq_optional(ofdev, 1);
+	if (priv->irq[1] == -EPROBE_DEFER)
+		return priv->irq[1];
+
+	return 0;
+}
+
+static int talitos_probe_irq(struct platform_device *ofdev)
+{
+	struct device *dev = &ofdev->dev;
+	struct talitos_private *priv = dev_get_drvdata(dev);
+	int err;
+	bool is_sec1 = has_ftr_sec1(priv);
+
 	if (is_sec1) {
 		err = request_irq(priv->irq[0], talitos1_interrupt_4ch, 0,
 				  dev_driver_string(dev), priv);
 		goto primary_out;
 	}
 
-	priv->irq[1] = platform_get_irq_optional(ofdev, 1);
-	if (priv->irq[1] == -EPROBE_DEFER)
-		return priv->irq[1];
-
-	/* get the primary irq line */
+	/* single (or primary) irq line */
 	if (priv->irq[1] < 0) {
 		err = request_irq(priv->irq[0], talitos2_interrupt_4ch, 0,
 				  dev_driver_string(dev), priv);
@@ -3379,7 +3387,7 @@ static int talitos_probe_irq(struct platform_device *ofdev)
 	if (err)
 		goto primary_out;
 
-	/* get the secondary irq line */
+	/* secondary irq line */
 	err = request_irq(priv->irq[1], talitos2_interrupt_ch1_3, 0,
 			  dev_driver_string(dev), priv);
 	if (err) {
@@ -3481,7 +3489,7 @@ static int talitos_probe(struct platform_device *ofdev)
 		stride = TALITOS2_CH_STRIDE;
 	}
 
-	err = talitos_probe_irq(ofdev);
+	err = talitos_get_irqs(ofdev);
 	if (err)
 		goto err_out;
 
@@ -3540,6 +3548,11 @@ static int talitos_probe(struct platform_device *ofdev)
 		goto err_out;
 	}
 
+	/* enable interrupts once the channel fifos and tasklets are set up */
+	err = talitos_probe_irq(ofdev);
+	if (err)
+		goto err_out;
+
 	/* register the RNG, if available */
 	if (hw_supports(dev, DESC_HDR_SEL0_RNG)) {
 		err = talitos_register_rng(dev);
Signature · 1 line
2.55.0
maintainer
#1 lore raw
Quoted 13 lines · Rosen Penev

The talitos interrupt handlers schedule priv->done_task[] via tasklet_schedule(). In probe(), talitos_probe_irq() ran before tasklet_init(), so an interrupt arriving during that window (a shared IRQ, or a completion pending from an earlier transmission) would schedule an uninitialized tasklet.

Resolve the IRQ numbers before the tasklet_init() calls so the done_task[] selection can see the secondary IRQ, and only request the IRQs after the channel fifos are allocated and the device is initialized. Every structure the handlers touch is then fully set up before interrupts are enabled. This matches remove(), which frees the IRQs before killing the tasklets.

Quoted 6 lines
Assisted-by LLM

---
v2: reshuffle code to avoid NULL derefs

 drivers/crypto/talitos.c | 33 +++++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

Please check

https://sashiko.dev/#/patchset/20260924235119.141323-1-rosenp%40gmail.com

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