Skip to contentSkip to conversation

thermal/drivers/rcar_gen3: Handle -ENXIO from optional IRQ lookup

PATCH Superseded [email protected] 3 participants 6 messages Aug 7

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 thermal/drivers/rcar_gen3: Handle -ENXIO from optional IRQ lookup

From: bui duc phuc <[email protected]>

platform_get_irq_optional() returns -ENXIO when the optional IRQ is not specified. Treat -ENXIO as a valid absence of an optional IRQ, while propagating other errors.

---
 drivers/thermal/renesas/rcar_gen3_thermal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/renesas/rcar_gen3_thermal.c +1 -1
index 94804816e9e1..6204fb163ad7 100644
@@ -491,7 +491,7 @@ static int rcar_gen3_thermal_request_irqs(struct rcar_gen3_thermal_priv *priv,
 
 	for (i = 0; i < 2; i++) {
 		irq = platform_get_irq_optional(pdev, i);
-		if (irq < 0)
+		if (irq < 0 && irq != -ENXIO)
 			return irq;
 
 		irqname = devm_kasprintf(dev, GFP_KERNEL, "%s:ch%d",
Signature · 1 line
2.43.0
#1 lore raw

PATCH 2/2 thermal/drivers/brcmstb_thermal: Propagate errors from optional IRQ lookup

From: bui duc phuc <[email protected]>

platform_get_irq_optional() returns a positive IRQ number on success or a negative error code on failure. For an optional IRQ, -ENXIO indicates that no IRQ is available, while other errors should be propagated.

Propagate errors such as -EPROBE_DEFER and -EINVAL instead of continuing probe without the IRQ.

---
 drivers/thermal/broadcom/brcmstb_thermal.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/thermal/broadcom/brcmstb_thermal.c +3 -1
index a9ffa596f7c0..477d078ce326 100644
@@ -350,7 +350,9 @@ static int brcmstb_thermal_probe(struct platform_device *pdev)
 	priv->thermal = thermal;
 
 	irq = platform_get_irq_optional(pdev, 0);
-	if (irq >= 0) {
+	if (irq < 0 && irq != -ENXIO)
+		return irq;
+	if (irq > 0) {
 		ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
 						brcmstb_tmon_irq_thread,
 						IRQF_ONESHOT,
Signature · 1 line
2.43.0
#2 lore raw
In reply to [email protected]

Hi Phuc,

Quoted 7 lines · On Fri, 7 Aug 2026 at 11:31, <[email protected]> wrote:

From: bui duc phuc <[email protected]>

platform_get_irq_optional() returns -ENXIO when the optional IRQ is not specified. Treat -ENXIO as a valid absence of an optional IRQ, while propagating other errors.

Thanks for your patch!

drivers/thermal/renesas/rcar_gen3_thermal.c static int rcar_gen3_thermal_request_irqs(struct rcar_gen3_thermal_priv *priv, · line 496

Quoted 10 lines
drivers/thermal/renesas/rcar_gen3_thermal.c +1 -1
@@ -491,7 +491,7 @@ static int rcar_gen3_thermal_request_irqs(struct rcar_gen3_thermal_priv *priv,
 
        for (i = 0; i < 2; i++) {
                irq = platform_get_irq_optional(pdev, i);
-               if (irq < 0)
+               if (irq < 0 && irq != -ENXIO)
                        return irq;
 

So the code may continue using -ENXIO as an interrupt number (and fail)?

Why is this change needed at all?
The caller of rcar_gen3_thermal_request_irqs() knows how to handle failures, as IRQs are optional.

drivers/thermal/renesas/rcar_gen3_thermal.c static int rcar_gen3_thermal_request_irqs(struct rcar_gen3_thermal_priv *priv, · line 497

Quoted 1 line
drivers/thermal/renesas/rcar_gen3_thermal.c +0 -0
                irqname = devm_kasprintf(dev, GFP_KERNEL, "%s:ch%d",

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#3 lore raw

Hi Geert,

Thank you for your feedback.

Quoted 8 lines

drivers/thermal/renesas/rcar_gen3_thermal.c static int rcar_gen3_thermal_request_irqs(struct rcar_gen3_thermal_priv *priv, · line 495

Quoted 5 lines
                irq = platform_get_irq_optional(pdev, i);
drivers/thermal/renesas/rcar_gen3_thermal.c +1 -1
-               if (irq < 0)
+               if (irq < 0 && irq != -ENXIO)
                        return irq;

So the code may continue using -ENXIO as an interrupt number (and fail)?

Yes, you are right. We should probably handle it similarly to:
https://elixir.bootlin.com/linux/v7.2-rc6/source/drivers/thermal/renesas/rcar_thermal.c#L422
and only assign the IRQ when the return value is positive:
if (ret > 0)
irq = ret;

Quoted 4 lines

Why is this change needed at all?
The caller of rcar_gen3_thermal_request_irqs() knows how to handle failures, as IRQs are optional.

Regarding the caller, I only found rcar_gen3_thermal_request_irqs() being called here:
https://elixir.bootlin.com/linux/v7.2-rc6/source/drivers/thermal/renesas/rcar_gen3_thermal.c#L530
It does not appear to handle the error return there, so I don't think the caller currently handles these failures explicitly.

Best regards,
Phuc

#4 lore raw
Quoted 24 lines · Bui Duc Phuc

Hi Geert,

Thank you for your feedback.

Quoted 8 lines

drivers/thermal/renesas/rcar_gen3_thermal.c static int rcar_gen3_thermal_request_irqs(struct rcar_gen3_thermal_priv *priv, · line 495

Quoted 5 lines
                irq = platform_get_irq_optional(pdev, i);
drivers/thermal/renesas/rcar_gen3_thermal.c +1 -1
-               if (irq < 0)
+               if (irq < 0 && irq != -ENXIO)
                        return irq;

So the code may continue using -ENXIO as an interrupt number (and fail)?

Yes, you are right. We should probably handle it similarly to:
https://elixir.bootlin.com/linux/v7.2-rc6/source/drivers/thermal/renesas/rcar_thermal.c#L422
and only assign the IRQ when the return value is positive:
if (ret > 0)
irq = ret;

Quoted 4 lines

Why is this change needed at all?
The caller of rcar_gen3_thermal_request_irqs() knows how to handle failures, as IRQs are optional.

Quoted 5 lines

Regarding the caller, I only found rcar_gen3_thermal_request_irqs() being called here:
https://elixir.bootlin.com/linux/v7.2-rc6/source/drivers/thermal/renesas/rcar_gen3_thermal.c#L530
It does not appear to handle the error return there, so I don't think the caller currently handles these failures explicitly.

Yes it does. If it can't get the optional interrupts the driver does not support setting trip-points in hardware. No?

Quoted 3 lines

Best regards,
Phuc

Signature · 2 lines
Kind Regards,
Niklas Söderlund
#5 lore raw

Hi Niklas Söderlund,

Thank you for your feedback .

Quoted 9 lines
Quoted 5 lines

Regarding the caller, I only found rcar_gen3_thermal_request_irqs() being called here:
https://elixir.bootlin.com/linux/v7.2-rc6/source/drivers/thermal/renesas/rcar_gen3_thermal.c#L530
It does not appear to handle the error return there, so I don't think the caller currently handles these failures explicitly.

Yes it does. If it can't get the optional interrupts the driver does not support setting trip-points in hardware. No?

Yes, for -ENXIO, you're right.
The caller treats it as the absence of optional IRQs and disables hardware trip-point support.
However, this also means that -EPROBE_DEFER, -EINVAL, and other errors are currently treated the same way.
The caller does not distinguish these errors from -ENXIO, so the probe continues instead of propagating the actual error.

I think the caller should distinguish -ENXIO from other errors:
keep the current behavior for -ENXIO, but propagate -EPROBE_DEFER, -EINVAL, and other errors.

ret = rcar_gen3_thermal_request_irqs(priv, pdev);

if (ret == -ENXIO) {
        priv->ops.set_trips = NULL;
} else if (ret) {
        return ret;
}

Best regards,
Phuc