🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
2 messages
2 total messages Started by Marc Kleine-Budde Wed, 18 Nov 2026 09:11
[PATCH net-next 06/12] can: sun4i_can: don't discard the IRQ lookup error in probe
#18409
Author: Marc Kleine-Budde
Date: Wed, 18 Nov 2026 09:11
48 lines
12176 bytes
From: Chaosheng Qu <chaosheng.qu.linux@gmail.com>

sun4ican_probe() collapses every failure of platform_get_irq() into
-ENODEV:

	irq = platform_get_irq(pdev, 0);
	if (irq < 0) {
		err = -ENODEV;
		goto exit_put_clk;
	}

The driver matches through an of_match_table, so of_irq_get() returns
-EPROBE_DEFER while the interrupt controller has not been probed. The
probe overwrites it and the driver core stops retrying, leaving the
device unbound even though the interrupt controller appears later.

Return the lookup error unchanged, which is what the neighbouring CAN
platform drivers do, e.g. previous commit ("can: cc770: don't discard the
IRQ lookup error in probe").

A device tree without an interrupt now reports -ENXIO rather than
-ENODEV; the driver core treats both as a failed probe.

Build tested on x86_64.

Signed-off-by: Chaosheng Qu <chaosheng.qu.linux@gmail.com>
Link: https://patch.msgid.link/2a7cb6e4e1b494efd4da512abbf307c19d9d1467.1792118040.git.chaosheng.qu.linux@gmail.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/sun4i_can.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/sun4i_can.c b/drivers/net/can/sun4i_can.c
index af52285d5a4e..80be48d0593d 100644
--- a/drivers/net/can/sun4i_can.c
+++ b/drivers/net/can/sun4i_can.c
@@ -853,7 +853,7 @@ static int sun4ican_probe(struct platform_device *pdev)
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
-		err = -ENODEV;
+		err = irq;
 		goto exit;
 	}
 
-- 
2.53.0
Re: [PATCH net-next 06/12] can: sun4i_can: don't discard the IRQ lookup error in probe
#19076
Author: netdev-bot+sashiko
Date: Thu, 19 Nov 2026 09:54
151 lines
13510 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] In drivers/net/can/sun4i_can.c, sun4ican_probe() takes a clock
  reference with of_clk_get(np, 0) at line 847 and never releases it on…
- [Medium] The patch fixes the IRQ path.
- [Low] The commit message does not match the code.

--

can: sun4i_can: don't discard the IRQ lookup error in probe

This patch makes sun4ican_probe() return the error from platform_get_irq()
as is, instead of replacing it with -ENODEV. The goal is to let
-EPROBE_DEFER from of_irq_get() reach the driver core, so the probe is
retried once the interrupt controller appears.

Link: https://patch.msgid.link/2a7cb6e4e1b494efd4da512abbf307c19d9d1467.1792118040.git.chaosheng.qu.linux@gmail.com

> sun4ican_probe() collapses every failure of platform_get_irq() into
> -ENODEV:
>
>         irq = platform_get_irq(pdev, 0);
>         if (irq < 0) {
>                 err = -ENODEV;
>                 goto exit_put_clk;
>         }
>
> The driver matches through an of_match_table, so of_irq_get() returns
> -EPROBE_DEFER while the interrupt controller has not been probed. The
> probe overwrites it and the driver core stops retrying, leaving the
> device unbound even though the interrupt controller appears later.

[Severity: Low]
Is the quoted pre-patch code accurate? In this tree, the IRQ error path in
sun4ican_probe() does goto exit. There is no exit_put_clk label, and there
is no clk_put() anywhere in drivers/net/can/sun4i_can.c:

exit_free:
	free_candev(dev);
exit:
	return err;

The quote makes it look like the clock is released on this path, but it
is not.

Can the deferral described here happen with the in-tree device trees?
sun4i-a10.dtsi, sun7i-a20.dtsi, sun8i-r40.dtsi and sunxi-d1s-t113.dtsi
route the CAN interrupt to sun4i-ic, the GIC or the D1 PLIC. All of these
register early through IRQCHIP_DECLARE, for example:

IRQCHIP_DECLARE(riscv, "allwinner,sun20i-d1-plic", plic_early_probe);

So the irq domain should already exist by the time this driver probes.

If this is meant as a bug fix, should it carry a Fixes: tag for
0738eff14d81 ("can: Allwinner A10/A20 CAN Controller support - Kernel
module"), which added the -ENODEV? If it is a robustness and consistency
cleanup instead, could the message say the issue has not been seen on real
hardware, as the sibling commit "can: cc770: don't discard the IRQ lookup
error in probe" does?

> diff --git a/drivers/net/can/sun4i_can.c b/drivers/net/can/sun4i_can.c
> index af52285d5a4e0..80be48d0593db 100644
> --- a/drivers/net/can/sun4i_can.c
> +++ b/drivers/net/can/sun4i_can.c
> @@ -853,7 +853,7 @@ static int sun4ican_probe(struct platform_device *pdev)
>  
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0) {
> -		err = -ENODEV;
> +		err = irq;
>  		goto exit;
>  	}

[Severity: Medium]
Does this error path leak the clock reference taken by of_clk_get()?

sun4ican_probe() does this just before the IRQ lookup:

	clk = of_clk_get(np, 0);

The goto exit path only returns err, and nothing in the driver calls
clk_put().

Before this patch, an IRQ failure turned into -ENODEV and the probe gave
up, so the reference leaked only once. Now -EPROBE_DEFER from of_irq_get()
is passed through:

of_irq_get()
    domain = irq_find_host(oirq.np);
    if (!domain) {
        rc = -EPROBE_DEFER;
        goto out;
    }

As a result, the device goes on the deferred probe list, and
sun4ican_probe() runs again each time deferred probing is triggered.

Each retry calls of_clk_get()->__of_clk_get()->clk_hw_create_clk(). That
allocates a new struct clk, takes kref_get(&core->ref), and links the
consumer into the clk_core. If the CCU is a module, it also pins the
provider module with try_module_get(). The retry then defers again at
platform_get_irq() and all of these references leak.

The in-tree DTs use early irqchips, but the binding allows any interrupt
parent. One example is interrupts-extended pointing at a GPIO irqchip that
probes late. Would this leak then repeat for as long as the interrupt
parent stays missing?

[Severity: Medium]
The clock lookup just above this hunk discards its error in the same way
the commit message describes for the IRQ lookup:

	clk = of_clk_get(np, 0);
	if (IS_ERR(clk)) {
		dev_err(&pdev->dev, "unable to request clock\n");
		err = -ENODEV;
		goto exit;
	}

The binding (allwinner,sun4i-a10-can.yaml) lists clocks as required.
of_clk_get_hw_from_clkspec() returns -EPROBE_DEFER when the provider has
not registered yet:

	struct clk_hw *hw = ERR_PTR(-EPROBE_DEFER);

The clock comes from a sunxi-ng CCU. Those drivers (ccu-sun4i-a10.c,
ccu-sun8i-r40.c, ccu-sun20i-d1.c) are tristate module_platform_driver
drivers, so they can register after the CAN probe. fw_devlink normally
orders this, but not with fw_devlink=off or fw_devlink=permissive.

If the CCU binds late, won't the probe still fail permanently with
-ENODEV before it ever reaches the IRQ lookup fixed here? The reset lookup
and the ioremap already return PTR_ERR(), so this is the only lookup left
that discards the error.

Since the clk leak above needs a respin anyway, could that version also
use err = PTR_ERR(clk), or switch to devm_clk_get()?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118092955.1283165-2-mkl%40pengutronix.de
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads