Skip to contentSkip to conversation

net: xilinx: axienet: Fix IRQ error handling

PATCH Superseded [email protected] 2 participants 7 messages Aug 21 – Aug 24

Subsystems (4)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover net: xilinx: axienet: Fix IRQ error handling

From: bui duc phuc <[email protected]>

Hi all,

This series fixes IRQ error handling in the Xilinx AXI Ethernet driver

Handle errors from optional IRQ lookup and preserve the original error codes instead of returning -ENOMEM.

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

Link v1 :
https://lore.kernel.org/all/[email protected]/
Link v2 :
https://lore.kernel.org/all/[email protected]/
Link v3 :
https://lore.kernel.org/all/[email protected]/

Changes in v2 :
- Split one patch from v1 into two patches.
Changes in v3 :
- Move the lp->eth_irq check below instead of handling it immediately after platform_get_irq_optional()
- Add error handling for platform_get_irq()
Changes in v4 :
- Add Reviewed-by tags
- Add error handling for irq_of_parse_and_map()

Best regards,
Phuc

bui duc phuc (3):
net: xilinx: axienet: Propagate errors from optional IRQ lookup
net: xilinx: axienet: Handle optional IRQ return value correctly
net: xilinx: axienet: Fix IRQ error handling

 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v4 1/3 net: xilinx: axienet: 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 optional IRQ is available, while other errors should be propagated.

Propagate all error codes returned by platform_get_irq_optional() other than -ENXIO.

Another call to platform_get_irq_optional() in the same function already handles the return value this way. Apply the same error handling to this call site for consistency.

Fixes d6349e3e14c7 ("net: axienet: Mark eth_irq as optional")
---
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +2 -0
index 1722b7038f34..207aecb5f8b9 100644
@@ -2975,6 +2975,8 @@ static int axienet_probe(struct platform_device *pdev)
 			dev_err(&pdev->dev, "could not determine irqs\n");
 			return -ENOMEM;
 		}
+		if (lp->eth_irq < 0 && lp->eth_irq != -ENXIO)
+			return lp->eth_irq;
 
 		/* Reset core now that clocks are enabled, prior to accessing MDIO */
 		ret = __axienet_device_reset(lp);
Signature · 1 line
2.43.0
#2 lore raw

PATCH v4 2/3 net: xilinx: axienet: Handle optional IRQ return value correctly

In reply to [email protected]

From: bui duc phuc <[email protected]>

lp->eth_irq is assigned from platform_get_irq_optional(), which returns a non-zero interrupt number on success or a negative error number on failure. Errors other than -ENXIO are handled before this check, so -ENXIO is the only error value that can reach this point.

Check for a negative value instead of treating 0 as an undefined IRQ.

Fixes 522856cefaf0 ("net: axienet: Add optional support for Ethernet core interrupt")
---
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1 -1
index 207aecb5f8b9..3927ababf833 100644
@@ -3052,7 +3052,7 @@ static int axienet_probe(struct platform_device *pdev)
 		ndev->ethtool_ops = &axienet_ethtool_ops;
 	}
 	/* Check for Ethernet core IRQ (optional) */
-	if (lp->eth_irq <= 0)
+	if (lp->eth_irq < 0)
 		dev_info(&pdev->dev, "Ethernet core IRQ not defined\n");
 
 	/* Retrieve the MAC address */
Signature · 1 line
2.43.0
#3 lore raw

PATCH v4 3/3 net: xilinx: axienet: Fix IRQ error handling

In reply to [email protected]

From: bui duc phuc <[email protected]>

irq_of_parse_and_map() returns 0 when parsing or mapping an IRQ fails, while platform_get_irq() returns a negative error code on failure. Handle both cases and preserve the original IRQ lookup errors instead of returning -ENOMEM.

Fixes 28ef9ebdb64c ("net: axienet: make use of axistream-connected attribute optional")

---

Changes in v4 :
- Add error handling for irq_of_parse_and_map()

 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +5 -1
index 3927ababf833..68b580191508 100644
@@ -2971,10 +2971,14 @@ static int axienet_probe(struct platform_device *pdev)
 			dev_err(&pdev->dev, "could not map DMA regs\n");
 			return PTR_ERR(lp->dma_regs);
 		}
-		if (lp->rx_irq <= 0 || lp->tx_irq <= 0) {
+		if (!lp->rx_irq || !lp->tx_irq) {
 			dev_err(&pdev->dev, "could not determine irqs\n");
 			return -ENOMEM;
 		}
+		if (lp->rx_irq < 0)
+			return lp->rx_irq;
+		if (lp->tx_irq < 0)
+			return lp->tx_irq;
 		if (lp->eth_irq < 0 && lp->eth_irq != -ENXIO)
 			return lp->eth_irq;
 
Signature · 1 line
2.43.0
#4 lore raw
Quoted 22 lines · On 8/21/2026 6:02 PM, [email protected] wrote:

From: bui duc phuc <[email protected]>

irq_of_parse_and_map() returns 0 when parsing or mapping an IRQ fails, while platform_get_irq() returns a negative error code on failure. Handle both cases and preserve the original IRQ lookup errors instead of returning -ENOMEM.

Fixes 28ef9ebdb64c ("net: axienet: make use of axistream-connected attribute optional")

---

Changes in v4 :
- Add error handling for irq_of_parse_and_map()

  drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0 -0
index 3927ababf833..68b580191508 100644

drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_probe(struct platform_device *pdev) · line 2977

Quoted 8 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1 -1
@@ -2971,10 +2971,14 @@ static int axienet_probe(struct platform_device *pdev)
  			dev_err(&pdev->dev, "could not map DMA regs\n");
  			return PTR_ERR(lp->dma_regs);
  		}
-		if (lp->rx_irq <= 0 || lp->tx_irq <= 0) {
+		if (!lp->rx_irq || !lp->tx_irq) {
  			dev_err(&pdev->dev, "could not determine irqs\n");
  			return -ENOMEM;
  		}

ENOMEM is a slightly misleading errno for "IRQ not found" on the OF path -EINVAL/-ENXIO would be more accurate. Since we are here, better to correct that also.

Regards,
Suraj

Quoted 7 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +4 -0
+		if (lp->rx_irq < 0)
+			return lp->rx_irq;
+		if (lp->tx_irq < 0)
+			return lp->tx_irq;
  		if (lp->eth_irq < 0 && lp->eth_irq != -ENXIO)
  			return lp->eth_irq;
 
#5 lore raw

Hi Gupta,

Quoted 5 lines

ENOMEM is a slightly misleading errno for "IRQ not found" on the OF path -EINVAL/-ENXIO would be more accurate. Since we are here, better to correct that also.

Thanks for pointing this out. I agree that -ENOMEM is misleading here. I'll address this separately.

Best regards,
Phuc

#6 lore raw

Hi Paolo, Radhey, Gupta.

Quoted 9 lines
Quoted 5 lines

ENOMEM is a slightly misleading errno for "IRQ not found" on the OF path -EINVAL/-ENXIO would be more accurate. Since we are here, better to correct that also.

Thanks for pointing this out. I agree that -ENOMEM is misleading here. I'll address this separately.

I initially planned to make a separate series for fixing the returned error codes,
but I think it is better to include those changes in this series.

I would also like to withdraw this series from net and resend it to net-next after August 31.
Since there have been no reported issues and these were found through code review,
I think net-next is more appropriate.

Best regards,
Phuc