Skip to contentSkip to conversation

thermal/drivers/airoha: Request the EN7581 IRQ after zone registration

PATCH Applied Vitaliy Sochnev 3 participants 3 messages Sep 15 – Oct 14 Thermal

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thermal/drivers/airoha: Request the EN7581 IRQ after zone registration

The EN7581 IRQ is requested before the thermal zone is registered, and the handler passes priv->tz to thermal_zone_device_update(). Unbind leaves the monitor interrupt enabled, so an interrupt pending on the next bind fires while priv->tz is NULL. On a Nokia XG-040G-MD this oopses in thermal_zone_device_update(). On unbind, devres also frees the zone before the IRQ.

Request the IRQ in post_probe, after zone registration.

Fixes 42de37f40e1b ("thermal/drivers: Add support for Airoha EN7581 thermal sensor")

---
Independent of the AN7583 series v2:
https://lore.kernel.org/all/[email protected]/

 drivers/thermal/airoha_thermal.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/thermal/airoha_thermal.c +13 -11
index 77b3a1af271f..ea3e2649c280 100644
@@ -528,7 +528,7 @@ static int en7581_thermal_probe(struct platform_device *pdev,
 	struct device_node *chip_scu_np;
 	struct device *dev = &pdev->dev;
 	void __iomem *base;
-	int i, irq, ret;
+	int i;
 
 	base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(base))
@@ -567,16 +567,6 @@ static int en7581_thermal_probe(struct platform_device *pdev,
 	of_address_to_resource(chip_scu_np, 0, &priv->scu_adc_res);
 	of_node_put(chip_scu_np);
 
-	irq = platform_get_irq(pdev, 0);
-	if (irq < 0)
-		return irq;
-
-	ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
-					en7581_thermal_irq, IRQF_ONESHOT,
-					pdev->name, priv);
-	if (ret)
-		return ret;
-
 	en7581_thermal_setup_monitor(priv);
 	en7581_thermal_setup_adc_val(dev, priv);
 
@@ -586,6 +576,18 @@ static int en7581_thermal_probe(struct platform_device *pdev,
 static int en7581_thermal_post_probe(struct platform_device *pdev)
 {
 	struct airoha_thermal_priv *priv = platform_get_drvdata(pdev);
+	int irq, ret;
+
+	/* After zone registration: the handler uses priv->tz */
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0)
+		return irq;
+
+	ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
+					en7581_thermal_irq, IRQF_ONESHOT,
+					pdev->name, priv);
+	if (ret)
+		return ret;
 
 	/* Enable LOW and HIGH interrupt (if supported) */
 	regmap_write(priv->map, EN7581_TEMPMONINT,

base-commit: b115930d716defc3a7daa2bc2ae2465d864b7114

Signature · 1 line
2.55.0
#1 lore raw
Quoted 7 lines · Vitaliy Sochnev

The EN7581 IRQ is requested before the thermal zone is registered, and the handler passes priv->tz to thermal_zone_device_update(). Unbind leaves the monitor interrupt enabled, so an interrupt pending on the next bind fires while priv->tz is NULL. On a Nokia XG-040G-MD this oopses in thermal_zone_device_update(). On unbind, devres also frees the zone before the IRQ.

Quoted 5 lines

Request the IRQ in post_probe, after zone registration.

Fixes 42de37f40e1b ("thermal/drivers: Add support for Airoha EN7581 thermal sensor")

---

Applied, thanks

#2 lore raw
In reply to Vitaliy Sochnev
The following commit has been merged into the thermal/linux-next branch of thermal:

The following commit has been merged into the thermal/linux-next branch of thermal:

Commit-ID:     7efceedd23678cd58e98b2c64d4b2b7be03f6cf9
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//7efceedd23678cd58e98b2c64d4b2b7be03f6cf9
Author:        Vitaliy Sochnev <[email protected]>
AuthorDate:    Tue, 15 Sep 2026 20:41:28 +01:00
Committer:     Daniel Lezcano <[email protected]>
CommitterDate: Fri, 18 Sep 2026 11:23:33 +02:00

thermal/drivers/airoha: Request the EN7581 IRQ after zone registration

The EN7581 IRQ is requested before the thermal zone is registered, and the handler passes priv->tz to thermal_zone_device_update(). Unbind leaves the monitor interrupt enabled, so an interrupt pending on the next bind fires while priv->tz is NULL. On a Nokia XG-040G-MD this oopses in thermal_zone_device_update(). On unbind, devres also frees the zone before the IRQ.

Request the IRQ in post_probe, after zone registration.

Fixes 42de37f40e1b ("thermal/drivers: Add support for Airoha EN7581 thermal sensor")
---
 drivers/thermal/airoha_thermal.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/thermal/airoha_thermal.c +13 -11
index 77b3a1a..ea3e264 100644
@@ -528,7 +528,7 @@ static int en7581_thermal_probe(struct platform_device *pdev,
 	struct device_node *chip_scu_np;
 	struct device *dev = &pdev->dev;
 	void __iomem *base;
-	int i, irq, ret;
+	int i;
 
 	base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(base))
@@ -567,16 +567,6 @@ static int en7581_thermal_probe(struct platform_device *pdev,
 	of_address_to_resource(chip_scu_np, 0, &priv->scu_adc_res);
 	of_node_put(chip_scu_np);
 
-	irq = platform_get_irq(pdev, 0);
-	if (irq < 0)
-		return irq;
-
-	ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
-					en7581_thermal_irq, IRQF_ONESHOT,
-					pdev->name, priv);
-	if (ret)
-		return ret;
-
 	en7581_thermal_setup_monitor(priv);
 	en7581_thermal_setup_adc_val(dev, priv);
 
@@ -586,6 +576,18 @@ static int en7581_thermal_probe(struct platform_device *pdev,
 static int en7581_thermal_post_probe(struct platform_device *pdev)
 {
 	struct airoha_thermal_priv *priv = platform_get_drvdata(pdev);
+	int irq, ret;
+
+	/* After zone registration: the handler uses priv->tz */
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0)
+		return irq;
+
+	ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
+					en7581_thermal_irq, IRQF_ONESHOT,
+					pdev->name, priv);
+	if (ret)
+		return ret;
 
 	/* Enable LOW and HIGH interrupt (if supported) */
 	regmap_write(priv->map, EN7581_TEMPMONINT,