Skip to contentSkip to conversation

net: stmmac: Handle different error codes from platform_get_irq_byname

PATCH Superseded Chen-Yu Tsai 2 participants 4 messages May 27, 2014 – May 28, 2014

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: stmmac: Handle different error codes from platform_get_irq_byname

The following patch moved device tree interrupt resolution into platform_get_irq_byname:

ad69674 of/irq: do irq resolution in platform_get_irq_byname()

As a result, the function no longer only return -ENXIO on error. This breaks DT based probing of stmmac, as seen in test runs of linux-next next-20140526 cubie2-sunxi_defconfig:

http://lists.linaro.org/pipermail/kernel-build-reports/2014-May/003659.html

This patch makes the stmmac_platform probe function properly handle error codes, such as returning for deferred probing, and other codes returned by of_irq_get_by_name.

---
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c    | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +15 -5
index 46aef510..9562b18 100644
@@ -237,10 +237,12 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
 
 	/* Get the MAC information */
 	priv->dev->irq = platform_get_irq_byname(pdev, "macirq");
-	if (priv->dev->irq == -ENXIO) {
-		pr_err("%s: ERROR: MAC IRQ configuration "
-		       "information not found\n", __func__);
-		return -ENXIO;
+	if (priv->dev->irq < 0) {
+		if (priv->wol_irq != -EPROBE_DEFER) {
+			pr_err("%s: ERROR: MAC IRQ configuration "
+			       "information not found\n", __func__);
+		}
+		return priv->dev->irq;
 	}
 
 	/*
@@ -252,10 +254,18 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
 	 * so the driver will continue to use the mac irq (ndev->irq)
 	 */
 	priv->wol_irq = platform_get_irq_byname(pdev, "eth_wake_irq");
-	if (priv->wol_irq == -ENXIO)
+	if (priv->wol_irq < 0) {
+		if (priv->wol_irq == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
 		priv->wol_irq = priv->dev->irq;
+	}
 
 	priv->lpi_irq = platform_get_irq_byname(pdev, "eth_lpi");
+	if (priv->lpi_irq < 0) {
+		if (priv->wol_irq == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
+		priv->lpi_irq = -ENXIO;
+	}
 
 	platform_set_drvdata(pdev, priv->dev);
 
Signature · 1 line
2.0.0.rc2
#1 lore raw
Quoted 9 lines · Chen-Yu Tsai

The following patch moved device tree interrupt resolution into platform_get_irq_byname:

ad69674 of/irq: do irq resolution in platform_get_irq_byname()

As a result, the function no longer only return -ENXIO on error. This breaks DT based probing of stmmac, as seen in test runs of linux-next next-20140526 cubie2-sunxi_defconfig:

Quoted 5 lines

http://lists.linaro.org/pipermail/kernel-build-reports/2014-May/003659.html

This patch makes the stmmac_platform probe function properly handle error codes, such as returning for deferred probing, and other codes returned by of_irq_get_by_name.

ST u8500 is also broken as reported by Kevin Hilman.

Quoted 11 lines
---
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c    | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0 -0
index 46aef510..9562b18 100644

drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c static int stmmac_pltfr_probe(struct platform_device *pdev) · line 241

Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +2 -4
@@ -237,10 +237,12 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
 
        /* Get the MAC information */
        priv->dev->irq = platform_get_irq_byname(pdev, "macirq");
-       if (priv->dev->irq == -ENXIO) {
-               pr_err("%s: ERROR: MAC IRQ configuration "
-                      "information not found\n", __func__);
-               return -ENXIO;
+       if (priv->dev->irq < 0) {
+               if (priv->wol_irq != -EPROBE_DEFER) {

s/wol_irq/dev->irq/

drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c static int stmmac_pltfr_probe(struct platform_device *pdev) · line 242

Quoted 1 line
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +1 -0
+                       pr_err("%s: ERROR: MAC IRQ configuration "

netdev_err

drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c static int stmmac_pltfr_probe(struct platform_device *pdev) · line 243

Quoted 1 line
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +1 -0
+                              "information not found\n", __func__);

Don't split strings.

Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +2 -0
+               }
+               return priv->dev->irq;
        }
 
        /*
@@ -252,10 +254,18 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
         * so the driver will continue to use the mac irq (ndev->irq)
         */

drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c static int stmmac_pltfr_probe(struct platform_device *pdev) · line 264

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +5 -1
        priv->wol_irq = platform_get_irq_byname(pdev, "eth_wake_irq");
-       if (priv->wol_irq == -ENXIO)
+       if (priv->wol_irq < 0) {
+               if (priv->wol_irq == -EPROBE_DEFER)
+                       return -EPROBE_DEFER;
                priv->wol_irq = priv->dev->irq;
+       }
 
        priv->lpi_irq = platform_get_irq_byname(pdev, "eth_lpi");
+       if (priv->lpi_irq < 0) {

You don't need this if.

drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c static int stmmac_pltfr_probe(struct platform_device *pdev) · line 265

Quoted 1 line
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +1 -0
+               if (priv->wol_irq == -EPROBE_DEFER)

s/wol_irq/lpi_irq/

Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +3 -1
+                       return -EPROBE_DEFER;
+               priv->lpi_irq = -ENXIO;
+       }
 
        platform_set_drvdata(pdev, priv->dev);
 
--

2.0.0.rc2

#2 lore raw
Quoted 10 lines · Rob Herring
Quoted 9 lines · Chen-Yu Tsai

The following patch moved device tree interrupt resolution into platform_get_irq_byname:

ad69674 of/irq: do irq resolution in platform_get_irq_byname()

As a result, the function no longer only return -ENXIO on error. This breaks DT based probing of stmmac, as seen in test runs of linux-next next-20140526 cubie2-sunxi_defconfig:

Quoted 7 lines
Quoted 5 lines

http://lists.linaro.org/pipermail/kernel-build-reports/2014-May/003659.html

This patch makes the stmmac_platform probe function properly handle error codes, such as returning for deferred probing, and other codes returned by of_irq_get_by_name.

ST u8500 is also broken as reported by Kevin Hilman.

Saw the mail today.

Quoted 12 lines
Quoted 12 lines
---
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c    | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0 -0
index 46aef510..9562b18 100644
@@ -237,10 +237,12 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
 
Quoted 10 lines

drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c static int stmmac_pltfr_probe(struct platform_device *pdev) · line 241

Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +2 -4
        /* Get the MAC information */
        priv->dev->irq = platform_get_irq_byname(pdev, "macirq");
-       if (priv->dev->irq == -ENXIO) {
-               pr_err("%s: ERROR: MAC IRQ configuration "
-                      "information not found\n", __func__);
-               return -ENXIO;
+       if (priv->dev->irq < 0) {
+               if (priv->wol_irq != -EPROBE_DEFER) {

s/wol_irq/dev->irq/

Copy paste error :(

Quoted 7 lines

drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c static int stmmac_pltfr_probe(struct platform_device *pdev) · line 242

Quoted 1 line
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +1 -0
+                       pr_err("%s: ERROR: MAC IRQ configuration "

netdev_err

drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c static int stmmac_pltfr_probe(struct platform_device *pdev) · line 243

Quoted 1 line
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +1 -0
+                              "information not found\n", __func__);

Don't split strings.

It was in the original code. Will fix.

Quoted 16 lines
Quoted 16 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +6 -1
+               }
+               return priv->dev->irq;
        }
 
        /*
@@ -252,10 +254,18 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
         * so the driver will continue to use the mac irq (ndev->irq)
         */
        priv->wol_irq = platform_get_irq_byname(pdev, "eth_wake_irq");
-       if (priv->wol_irq == -ENXIO)
+       if (priv->wol_irq < 0) {
+               if (priv->wol_irq == -EPROBE_DEFER)
+                       return -EPROBE_DEFER;
                priv->wol_irq = priv->dev->irq;
+       }
 
Quoted 4 lines

drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c static int stmmac_pltfr_probe(struct platform_device *pdev) · line 264

Quoted 2 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +1 -0
        priv->lpi_irq = platform_get_irq_byname(pdev, "eth_lpi");
+       if (priv->lpi_irq < 0) {

You don't need this if.

stmmac core driver checks lpi_irq != -ENXIO for valid interrupt. Might as well change that check to lpi_irq >= 0.
(0 is a valid interrupt, correct?)

Interestingly, stmmac_pci never sets lpi_irq, there might be a glitch there.

Quoted 3 lines

drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c static int stmmac_pltfr_probe(struct platform_device *pdev) · line 265

Quoted 1 line
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +1 -0
+               if (priv->wol_irq == -EPROBE_DEFER)

s/wol_irq/lpi_irq/

ditto

Quoted 9 lines
Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +3 -1
+                       return -EPROBE_DEFER;
+               priv->lpi_irq = -ENXIO;
+       }
 
        platform_set_drvdata(pdev, priv->dev);
 
--

2.0.0.rc2

Thanks
ChenYu

#3 lore raw
Quoted 10 lines · Chen-Yu Tsai
Quoted 9 lines · Rob Herring
Quoted 8 lines · Chen-Yu Tsai

The following patch moved device tree interrupt resolution into platform_get_irq_byname:

ad69674 of/irq: do irq resolution in platform_get_irq_byname()

As a result, the function no longer only return -ENXIO on error. This breaks DT based probing of stmmac, as seen in test runs of linux-next next-20140526 cubie2-sunxi_defconfig:

[...]

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
        priv->lpi_irq = platform_get_irq_byname(pdev, "eth_lpi");

+ if (priv->lpi_irq < 0) {

You don't need this if.

stmmac core driver checks lpi_irq != -ENXIO for valid interrupt. Might as well change that check to lpi_irq >= 0.
(0 is a valid interrupt, correct?)

No. NO_IRQ is defined to 0 (preferred) or -1 depending on the arch. You should be testing for "> 0" for valid irq rather than only ENXIO.

My comment still stands. If lpi_irq is already <0, then there is no reason to set it to -ENXIO (again). If there are other error codes returned, changing the error code is not good practice.

Quoted 2 lines

Interestingly, stmmac_pci never sets lpi_irq, there might be a glitch there.

I believe they would have to be combined to a single interrrupt for PCI.

Rob