Skip to contentSkip to conversation

net: broadcom: Improve IRQ error handling

PATCH In review [email protected] 5 participants 12 messages Aug 20 – Aug 21

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover net: broadcom: Improve IRQ error handling

From: bui duc phuc <[email protected]>

Hi all,

This series improves IRQ error handling in several Broadcom Ethernet drivers by propagating IRQ lookup and request errors instead of silently ignoring them.

The changes were found by manual code inspection and compile-tested only.

Best regards,
Phuc

bui duc phuc (4):
net: bcmasp: Use platform_get_irq() for IRQ lookup
net: bcmasp: Propagate WoL IRQ errors from probe
net: systemport: Propagate IRQ lookup errors
net: bcmgenet: Propagate WoL IRQ errors

 drivers/net/ethernet/broadcom/asp2/bcmasp.c    | 17 +++++++++--------
 drivers/net/ethernet/broadcom/bcmsysport.c     | 12 ++++++++++--
 drivers/net/ethernet/broadcom/genet/bcmgenet.c |  8 +++++---
 3 files changed, 24 insertions(+), 13 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/4 net: bcmasp: Use platform_get_irq() for IRQ lookup

From: bui duc phuc <[email protected]>

The platform_get_irq_optional() function currently returns all negative error values without distinguishing between the case where no IRQ is available and actual errors occurring during the IRQ lookup.

Use platform_get_irq() instead, as it matches the existing error handling by propagating any error encountered during the IRQ lookup.

Found by manual code inspection.

---
 drivers/net/ethernet/broadcom/asp2/bcmasp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/broadcom/asp2/bcmasp.c +1 -1
index 972474893a6b..d66a8bbd6e38 100644
@@ -1094,7 +1094,7 @@ static int bcmasp_get_and_request_irq(struct bcmasp_priv *priv, int i)
 	struct platform_device *pdev = priv->pdev;
 	int irq, ret;
 
-	irq = platform_get_irq_optional(pdev, i);
+	irq = platform_get_irq(pdev, i);
 	if (irq < 0)
 		return irq;
 
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/4 net: bcmasp: Propagate WoL IRQ errors from probe

In reply to [email protected]

From: bui duc phuc <[email protected]>

bcmasp_init_wol() currently ignores errors returned by bcmasp_get_and_request_irq() and allows the probe to continue.

Return the error from bcmasp_init_wol() and propagate it to the probe function instead of silently ignoring the failure to initialize the WoL IRQ.

Found by manual code inspection.

---
 drivers/net/ethernet/broadcom/asp2/bcmasp.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/net/ethernet/broadcom/asp2/bcmasp.c +8 -7
index d66a8bbd6e38..02e88adf4939 100644
@@ -1106,21 +1106,20 @@ static int bcmasp_get_and_request_irq(struct bcmasp_priv *priv, int i)
 	return irq;
 }
 
-static void bcmasp_init_wol(struct bcmasp_priv *priv)
+static int bcmasp_init_wol(struct bcmasp_priv *priv)
 {
 	struct platform_device *pdev = priv->pdev;
-	struct device *dev = &pdev->dev;
 	int irq;
 
 	irq = bcmasp_get_and_request_irq(priv, 1);
-	if (irq < 0) {
-		dev_warn(dev, "Failed to init WoL irq: %d\n", irq);
-		return;
-	}
+	if (irq < 0)
+		return irq;
 
 	priv->wol_irq = irq;
 	priv->wol_irq_enabled_mask = 0;
 	device_set_wakeup_capable(&pdev->dev, 1);
+
+	return 0;
 }
 
 void bcmasp_enable_wol(struct bcmasp_intf *intf, bool en)
@@ -1321,7 +1320,9 @@ static int bcmasp_probe(struct platform_device *pdev)
 
 	bcmasp_core_init_filters(priv);
 
-	bcmasp_init_wol(priv);
+	ret = bcmasp_init_wol(priv);
+	if (ret)
+		goto err_clock_disable;
 
 	ports_node = of_find_node_by_name(dev->of_node, "ethernet-ports");
 	if (!ports_node) {
Signature · 1 line
2.43.0
#3 lore raw

PATCH 3/4 net: systemport: Propagate IRQ lookup errors

In reply to [email protected]

From: bui duc phuc <[email protected]>

Propagate the error codes returned by platform_get_irq() and platform_get_irq_optional() instead of converting them to -EINVAL.

For the optional WoL IRQ, allow -ENXIO to indicate that the IRQ is not available, but propagate any other error returned by the IRQ lookup.

Found by manual code inspection.

---
 drivers/net/ethernet/broadcom/bcmsysport.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bcmsysport.c +10 -2
index 4d06c6ba6641..2acaffccdb08 100644
@@ -2499,14 +2499,22 @@ static int bcm_sysport_probe(struct platform_device *pdev)
 	priv->num_rx_desc_words = params->num_rx_desc_words;
 
 	priv->irq0 = platform_get_irq(pdev, 0);
+	if (priv->irq0 < 0) {
+		ret = priv->irq0;
+		goto err_free_netdev;
+	}
 	if (!priv->is_lite) {
 		priv->irq1 = platform_get_irq(pdev, 1);
 		priv->wol_irq = platform_get_irq_optional(pdev, 2);
 	} else {
 		priv->wol_irq = platform_get_irq_optional(pdev, 1);
 	}
-	if (priv->irq0 <= 0 || (priv->irq1 <= 0 && !priv->is_lite)) {
-		ret = -EINVAL;
+	if (priv->irq1 < 0 && !priv->is_lite) {
+		ret = priv->irq1;
+		goto err_free_netdev;
+	}
+	if (priv->wol_irq < 0 && priv->wol_irq != -ENXIO) {
+		ret = priv->wol_irq;
 		goto err_free_netdev;
 	}
 
Signature · 1 line
2.43.0
#4 lore raw

PATCH 4/4 net: bcmgenet: Propagate WoL IRQ errors

In reply to [email protected]

From: bui duc phuc <[email protected]>

Propagate errors from platform_get_irq_optional() instead of only handling -EPROBE_DEFER. Allow -ENXIO to indicate that the optional WoL IRQ is not available.

Also propagate errors from devm_request_irq() instead of continuing the probe when the WoL IRQ cannot be requested.

Found by manual code inspection.

---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +5 -3
index a2305e6428d1..c1c66a52efd0 100644
@@ -3993,7 +3993,7 @@ static int bcmgenet_probe(struct platform_device *pdev)
 		goto err;
 	}
 	priv->wol_irq = platform_get_irq_optional(pdev, 2);
-	if (priv->wol_irq == -EPROBE_DEFER) {
+	if (priv->wol_irq < 0 && priv->wol_irq != -ENXIO) {
 		err = priv->wol_irq;
 		goto err;
 	}
@@ -4033,8 +4033,10 @@ static int bcmgenet_probe(struct platform_device *pdev)
 	if (priv->wol_irq > 0) {
 		err = devm_request_irq(&pdev->dev, priv->wol_irq,
 				       bcmgenet_wol_isr, 0, dev->name, priv);
-		if (!err)
-			device_set_wakeup_capable(&pdev->dev, 1);
+		if (err)
+			goto err;
+
+		device_set_wakeup_capable(&pdev->dev, 1);
 	}
 
 	/* Set the needed headroom to account for any possible
Signature · 1 line
2.43.0
maintainer
#5 lore raw
In reply to [email protected]
Quoted 10 lines · On 8/20/26 1:14 PM, [email protected] wrote:

From: bui duc phuc <[email protected]>

Hi all,

This series improves IRQ error handling in several Broadcom Ethernet drivers by propagating IRQ lookup and request errors instead of silently ignoring them.

The changes were found by manual code inspection and compile-tested only.

## Form letter - net-next-closed

We have already submitted our pull request with net-next material for v7.3, and therefore net-next is closed for new drivers, features, code refactoring and optimizations. We are currently accepting bug fixes only.

Please repost when net-next reopens after Aug 31st.

RFC patches sent for review only are obviously welcome at any time.

See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle

maintainer
#6 lore raw
Quoted 17 lines · Paolo Abeni
Quoted 10 lines · On 8/20/26 1:14 PM, [email protected] wrote:

From: bui duc phuc <[email protected]>

Hi all,

This series improves IRQ error handling in several Broadcom Ethernet drivers by propagating IRQ lookup and request errors instead of silently ignoring them.

The changes were found by manual code inspection and compile-tested only.

## Form letter - net-next-closed

We have already submitted our pull request with net-next material for v7.3, and therefore net-next is closed for new drivers, features, code refactoring and optimizations. We are currently accepting bug fixes only.

Quoted 6 lines

Please repost when net-next reopens after Aug 31st.

RFC patches sent for review only are obviously welcome at any time.

See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle

Not seeing much value in these patches, to be honest.

Signature · 1 line
Florian
maintainer
#7 lore raw
Quoted 18 lines · Florian Fainelli
Quoted 17 lines · Paolo Abeni
Quoted 10 lines · On 8/20/26 1:14 PM, [email protected] wrote:

From: bui duc phuc <[email protected]>

Hi all,

This series improves IRQ error handling in several Broadcom Ethernet drivers by propagating IRQ lookup and request errors instead of silently ignoring them.

The changes were found by manual code inspection and compile-tested only.

## Form letter - net-next-closed

We have already submitted our pull request with net-next material for v7.3, and therefore net-next is closed for new drivers, features, code refactoring and optimizations. We are currently accepting bug fixes only.

Quoted 8 lines
Quoted 6 lines

Please repost when net-next reopens after Aug 31st.

RFC patches sent for review only are obviously welcome at any time.

See: https://www.kernel.org/doc/html/next/process/maintainer- netdev.html#development-cycle

Not seeing much value in these patches, to be honest.

Agreed. I prefer the current behavior. Even if the optional WoL IRQ exist, but fails to initialize correctly, the rest of the network functions will still work. No need to take down everything in this case.

Thanks,
Justin

#8 lore raw

Hi Florian, Chen,

Thank you for your feedback.

Quoted 3 lines
Quoted 2 lines

Not seeing much value in these patches, to be honest.

I was looking at how platform_get_irq_optional() is handled in other network drivers, such as the Xilinx and TI drivers:
Xilinx :
https://elixir.bootlin.com/linux/v7.2/source/drivers/net/ethernet/xilinx/xilinx_axienet_main.c#L3020
TI :
https://elixir.bootlin.com/linux/v7.2/source/drivers/net/ethernet/ti/davinci_emac.c#L1444

Both drivers explicitly handle errors returned by platform_get_irq_optional() rather than treating every negative value as "no IRQ".
I wonder if they handled it this way because their hardware and software are already solid. I used these implementations as references when considering the error handling in these patches.

Quoted 4 lines

Agreed. I prefer the current behavior. Even if the optional WoL IRQ exist, but fails to initialize correctly, the rest of the network functions will still work. No need to take down everything in this case.

What about -EPROBE_DEFER? Do you also want to ignore it and not give the driver a chance to probe again?

Best regards,
Phuc

#9 lore raw
Quoted 2 lines

What about -EPROBE_DEFER? Do you also want to ignore it and not give the driver a chance to probe again?

Please do some git research. How long has the code been this way?

If -EPROBE_DEFER was a problem, why has nobody reported it?

Andrew

#10 lore raw

Hi Andrew,

Thank you for your feedback.

Quoted 8 lines
Quoted 3 lines

What about -EPROBE_DEFER? Do you also want to ignore it and not give the driver a chance to probe again?

Please do some git research. How long has the code been this way?

If -EPROBE_DEFER was a problem, why has nobody reported it?

I did some git research as suggested and found commit 6b77c06655b8 ("net: bcmgenet: Check for Wake-on-LAN interrupt probe deferral") written by Florian back in 2022:

https://lore.kernel.org/r/[email protected]

In that commit, Florian specifically highlighted that the interrupt controller (irq-bcm7038-l1.c) might be probed after the Ethernet driver, requiring an explicit check for -EPROBE_DEFER to ensure the interrupt is eventually fetched.

This commit clearly shows that probe deferral and IRQ lookup issues on these Broadcom controllers are real-world problems rather than theoretical edge cases.

Best regards,
Phuc

#11 lore raw
In reply to Paolo Abeni

Hi Paolo,

Quoted 6 lines

## Form letter - net-next-closed

We have already submitted our pull request with net-next material for v7.3, and therefore net-next is closed for new drivers, features, code refactoring and optimizations. We are currently accepting bug fixes only.

Quoted 6 lines

Please repost when net-next reopens after Aug 31st.

RFC patches sent for review only are obviously welcome at any time.

See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle

Thanks for clarifying this.
I wasn't aware of this process and only knew that patches could be sent for review.
I may send the patches as RFCs for now, in line with the guidelines.

Best regards,
Phuc