diff mbox series

PA Semi PWRficient Gigabit Ethernet doesn't work anymore since the first networking updates for the kernel 4.16

Message ID 9e8e906d-b2b7-f11c-30ed-ccdf91ac563c@xenosoft.de (mailing list archive)
State Not Applicable
Headers show
Series PA Semi PWRficient Gigabit Ethernet doesn't work anymore since the first networking updates for the kernel 4.16 | expand

Commit Message

Christian Zigotzky Feb. 4, 2018, 4:47 p.m. UTC
Hello,

The PA Semi PWRficient Gigabit Ethernet doesn't work anymore since the 
first networking updates [1] for the kernel 4.16.

Error messages:

[    0.634241] libphy: pasemi gpio mdio bus: probed
[    0.634749] pasemi gpio mdio bus: Cannot register as MDIO bus, err -38
[    2.311496] pasemi_mac 0000:00:14.0: runtime IRQ mapping not provided 
by arch
[    2.311554] pasemi_mac 0000:00:14.1: runtime IRQ mapping not provided 
by arch
[    2.311599] pasemi_mac 0000:00:14.2: runtime IRQ mapping not provided 
by arch
[    2.311641] pasemi_mac 0000:00:14.3: runtime IRQ mapping not provided 
by arch
[    2.312276] pasemi_mac 0000:00:15.0: runtime IRQ mapping not provided 
by arch
[    2.312903] pasemi_mac 0000:00:15.1: runtime IRQ mapping not provided 
by arch
[    3.817420] i2c-pasemi 0000:00:1c.0: runtime IRQ mapping not provided 
by arch
[    3.817616] i2c-pasemi 0000:00:1c.1: runtime IRQ mapping not provided 
by arch
[    3.817809] i2c-pasemi 0000:00:1c.2: runtime IRQ mapping not provided 
by arch
[    4.299984] pasemi_edac 0000:00:04.0: runtime IRQ mapping not 
provided by arch
[    4.300281] pasemi_edac 0000:00:05.0: runtime IRQ mapping not 
provided by arch
[   39.633565] pasemi_mac 0000:00:14.3: PHY init failed: -19.
[   39.633569] pasemi_mac 0000:00:14.3: Defaulting to 1Gbit full duplex

I figured out that the problematic code is in the mdio bus changes of 
the networking updates. [1]

I found the problematic code in the file 'drivers/net/phy/mdio_bus.c'. I 
created a patch which solves the problem with the PA Semi PWRficient 
Gigabit Ethernet. (attached)

Could you please check the changes in the file 'drivers/net/phy/mdio_bus.c'?

Thanks,
Christian

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b2fe5fa68642860e7de76167c3111623aa0d5de1

Comments

Andrew Lunn Feb. 4, 2018, 5:16 p.m. UTC | #1
On Sun, Feb 04, 2018 at 05:47:03PM +0100, Christian Zigotzky wrote:
> Hello,
> 
> The PA Semi PWRficient Gigabit Ethernet doesn't work anymore since the first
> networking updates [1] for the kernel 4.16.
> 
> Error messages:
> 
> [    0.634241] libphy: pasemi gpio mdio bus: probed
> [    0.634749] pasemi gpio mdio bus: Cannot register as MDIO bus, err -38

-38 is ENOSYS.

> --- a/drivers/net/phy/mdio_bus.c	2018-02-03 17:34:46.973045321 +0100
> +++ b/drivers/net/phy/mdio_bus.c	2018-02-04 11:03:14.909093360 +0100
> @@ -47,41 +47,11 @@
>  
>  #include "mdio-boardinfo.h"
>  
> -static int mdiobus_register_gpiod(struct mdio_device *mdiodev)
> -{
> -	struct gpio_desc *gpiod = NULL;
> -
> -	/* Deassert the optional reset signal */
> -	if (mdiodev->dev.of_node)
> -		gpiod = fwnode_get_named_gpiod(&mdiodev->dev.of_node->fwnode,
> -					       "reset-gpios", 0, GPIOD_OUT_LOW,
> -					       "PHY reset");

So i think you don't have GPIOLIB enabled. Hence you are hitting

http://elixir.free-electrons.com/linux/latest/source/include/linux/gpio/consumer.h#L470

static inline
struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
					 const char *propname, int index,
					 enum gpiod_flags dflags,
					 const char *label)
{
	return ERR_PTR(-ENOSYS);
}

So rather than just deleting all this code, breaking other platforms
that need this gpio, lets try a real fix. Please try this. If it
works, i will formally submit it.

   Andrew

From a4210ba306948497d7360927c1e532eb903c58b2 Mon Sep 17 00:00:00 2001
From: Andrew Lunn <andrew@lunn.ch>
Date: Sun, 4 Feb 2018 11:09:20 -0600
Subject: [PATCH] net: phy: Handle not having GPIO enabled in the kernel

If CONFIG_GPIOLIB is disabled, fwnode_get_named_gpiod() becomes a stub
function, which return -ENOSYS. Handle this in the same way as
-ENOENT, i.e. assume there is no GPIO used to reset the PHYs.

Reported-by: Christian Zigotzky <chzigotzky@xenosoft.de>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/phy/mdio_bus.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 88272b3ac2e2..24b5511222c8 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -56,7 +56,8 @@ static int mdiobus_register_gpiod(struct mdio_device *mdiodev)
 		gpiod = fwnode_get_named_gpiod(&mdiodev->dev.of_node->fwnode,
 					       "reset-gpios", 0, GPIOD_OUT_LOW,
 					       "PHY reset");
-	if (PTR_ERR(gpiod) == -ENOENT)
+	if (PTR_ERR(gpiod) == -ENOENT ||
+	    PTR_ERR(gpiod) == -ENOSYS)
 		gpiod = NULL;
 	else if (IS_ERR(gpiod))
 		return PTR_ERR(gpiod);
Florian Fainelli Feb. 4, 2018, 8:01 p.m. UTC | #2
On 02/04/2018 09:16 AM, Andrew Lunn wrote:
> On Sun, Feb 04, 2018 at 05:47:03PM +0100, Christian Zigotzky wrote:
>> Hello,
>>
>> The PA Semi PWRficient Gigabit Ethernet doesn't work anymore since the first
>> networking updates [1] for the kernel 4.16.
>>
>> Error messages:
>>
>> [    0.634241] libphy: pasemi gpio mdio bus: probed
>> [    0.634749] pasemi gpio mdio bus: Cannot register as MDIO bus, err -38
> 
> -38 is ENOSYS.
> 
>> --- a/drivers/net/phy/mdio_bus.c	2018-02-03 17:34:46.973045321 +0100
>> +++ b/drivers/net/phy/mdio_bus.c	2018-02-04 11:03:14.909093360 +0100
>> @@ -47,41 +47,11 @@
>>  
>>  #include "mdio-boardinfo.h"
>>  
>> -static int mdiobus_register_gpiod(struct mdio_device *mdiodev)
>> -{
>> -	struct gpio_desc *gpiod = NULL;
>> -
>> -	/* Deassert the optional reset signal */
>> -	if (mdiodev->dev.of_node)
>> -		gpiod = fwnode_get_named_gpiod(&mdiodev->dev.of_node->fwnode,
>> -					       "reset-gpios", 0, GPIOD_OUT_LOW,
>> -					       "PHY reset");
> 
> So i think you don't have GPIOLIB enabled. Hence you are hitting
> 
> http://elixir.free-electrons.com/linux/latest/source/include/linux/gpio/consumer.h#L470
> 
> static inline
> struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
> 					 const char *propname, int index,
> 					 enum gpiod_flags dflags,
> 					 const char *label)
> {
> 	return ERR_PTR(-ENOSYS);
> }
> 
> So rather than just deleting all this code, breaking other platforms
> that need this gpio, lets try a real fix. Please try this. If it
> works, i will formally submit it.
> 
>    Andrew
> 
> From a4210ba306948497d7360927c1e532eb903c58b2 Mon Sep 17 00:00:00 2001
> From: Andrew Lunn <andrew@lunn.ch>
> Date: Sun, 4 Feb 2018 11:09:20 -0600
> Subject: [PATCH] net: phy: Handle not having GPIO enabled in the kernel
> 
> If CONFIG_GPIOLIB is disabled, fwnode_get_named_gpiod() becomes a stub
> function, which return -ENOSYS. Handle this in the same way as
> -ENOENT, i.e. assume there is no GPIO used to reset the PHYs.
> 
> Reported-by: Christian Zigotzky <chzigotzky@xenosoft.de>
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Fixes: bafbdd527d56 ("phylib: Add device reset GPIO support")

> ---
>  drivers/net/phy/mdio_bus.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> index 88272b3ac2e2..24b5511222c8 100644
> --- a/drivers/net/phy/mdio_bus.c
> +++ b/drivers/net/phy/mdio_bus.c
> @@ -56,7 +56,8 @@ static int mdiobus_register_gpiod(struct mdio_device *mdiodev)
>  		gpiod = fwnode_get_named_gpiod(&mdiodev->dev.of_node->fwnode,
>  					       "reset-gpios", 0, GPIOD_OUT_LOW,
>  					       "PHY reset");
> -	if (PTR_ERR(gpiod) == -ENOENT)
> +	if (PTR_ERR(gpiod) == -ENOENT ||
> +	    PTR_ERR(gpiod) == -ENOSYS)
>  		gpiod = NULL;
>  	else if (IS_ERR(gpiod))
>  		return PTR_ERR(gpiod);
>
Christian Zigotzky Feb. 5, 2018, 9:38 a.m. UTC | #3
Hello Andrew,

Many thanks for your patch. I compiled the latest git kernel today and 
the PA Semi PWRficient Gigabit Ethernet works with your patch.

Have a nice week!

Thanks,
Christian


On 04 February 2018 at 6:16PM, Andrew Lunn wrote:
 > On Sun, Feb 04, 2018 at 05:47:03PM +0100, Christian Zigotzky wrote:
 >> Hello,
 >>
 >> The PA Semi PWRficient Gigabit Ethernet doesn't work anymore since 
the first
 >> networking updates [1] for the kernel 4.16.
 >>
 >> Error messages:
 >>
 >> [    0.634241] libphy: pasemi gpio mdio bus: probed
 >> [    0.634749] pasemi gpio mdio bus: Cannot register as MDIO bus, 
err -38
 >
 > -38 is ENOSYS.
 >
 >> --- a/drivers/net/phy/mdio_bus.c    2018-02-03 17:34:46.973045321 +0100
 >> +++ b/drivers/net/phy/mdio_bus.c    2018-02-04 11:03:14.909093360 +0100
 >> @@ -47,41 +47,11 @@
 >>
 >>  #include "mdio-boardinfo.h"
 >>
 >> -static int mdiobus_register_gpiod(struct mdio_device *mdiodev)
 >> -{
 >> -    struct gpio_desc *gpiod = NULL;
 >> -
 >> -    /* Deassert the optional reset signal */
 >> -    if (mdiodev->dev.of_node)
 >> -        gpiod = fwnode_get_named_gpiod(&mdiodev->dev.of_node->fwnode,
 >> -                           "reset-gpios", 0, GPIOD_OUT_LOW,
 >> -                           "PHY reset");
 >
 > So i think you don't have GPIOLIB enabled. Hence you are hitting
 >
 > 
http://elixir.free-electrons.com/linux/latest/source/include/linux/gpio/consumer.h#L470
 >
 > static inline
 > struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
 >                      const char *propname, int index,
 >                      enum gpiod_flags dflags,
 >                      const char *label)
 > {
 >     return ERR_PTR(-ENOSYS);
 > }
 >
 > So rather than just deleting all this code, breaking other platforms
 > that need this gpio, lets try a real fix. Please try this. If it
 > works, i will formally submit it.
 >
 >    Andrew
 >
 > >From a4210ba306948497d7360927c1e532eb903c58b2 Mon Sep 17 00:00:00 2001
 > From: Andrew Lunn <andrew@lunn.ch>
 > Date: Sun, 4 Feb 2018 11:09:20 -0600
 > Subject: [PATCH] net: phy: Handle not having GPIO enabled in the kernel
 >
 > If CONFIG_GPIOLIB is disabled, fwnode_get_named_gpiod() becomes a stub
 > function, which return -ENOSYS. Handle this in the same way as
 > -ENOENT, i.e. assume there is no GPIO used to reset the PHYs.
 >
 > Reported-by: Christian Zigotzky <chzigotzky@xenosoft.de>
 > Signed-off-by: Andrew Lunn <andrew@lunn.ch>
 > ---
 >  drivers/net/phy/mdio_bus.c | 3 ++-
 >  1 file changed, 2 insertions(+), 1 deletion(-)
 >
 > diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
 > index 88272b3ac2e2..24b5511222c8 100644
 > --- a/drivers/net/phy/mdio_bus.c
 > +++ b/drivers/net/phy/mdio_bus.c
 > @@ -56,7 +56,8 @@ static int mdiobus_register_gpiod(struct 
mdio_device *mdiodev)
 >          gpiod = fwnode_get_named_gpiod(&mdiodev->dev.of_node->fwnode,
 >                             "reset-gpios", 0, GPIOD_OUT_LOW,
 >                             "PHY reset");
 > -    if (PTR_ERR(gpiod) == -ENOENT)
 > +    if (PTR_ERR(gpiod) == -ENOENT ||
 > +        PTR_ERR(gpiod) == -ENOSYS)
 >          gpiod = NULL;
 >      else if (IS_ERR(gpiod))
 >          return PTR_ERR(gpiod);
Andrew Lunn Feb. 5, 2018, 2:29 p.m. UTC | #4
On Mon, Feb 05, 2018 at 10:38:34AM +0100, Christian Zigotzky wrote:
> Hello Andrew,
> 
> Many thanks for your patch. I compiled the latest git kernel today and the
> PA Semi PWRficient Gigabit Ethernet works with your patch.

Great.

Can i add a tested-by:

Thanks
	Andrew
Christian Zigotzky Feb. 5, 2018, 3:27 p.m. UTC | #5
Yes, you can.

Christian

On 05 February 2018 at 3:29PM, Andrew Lunn wrote:
> On Mon, Feb 05, 2018 at 10:38:34AM +0100, Christian Zigotzky wrote:
>> Hello Andrew,
>>
>> Many thanks for your patch. I compiled the latest git kernel today and the
>> PA Semi PWRficient Gigabit Ethernet works with your patch.
> Great.
>
> Can i add a tested-by:
>
> Thanks
> 	Andrew
>
diff mbox series

Patch

--- a/drivers/net/phy/mdio_bus.c	2018-02-03 17:34:46.973045321 +0100
+++ b/drivers/net/phy/mdio_bus.c	2018-02-04 11:03:14.909093360 +0100
@@ -47,41 +47,11 @@ 
 
 #include "mdio-boardinfo.h"
 
-static int mdiobus_register_gpiod(struct mdio_device *mdiodev)
-{
-	struct gpio_desc *gpiod = NULL;
-
-	/* Deassert the optional reset signal */
-	if (mdiodev->dev.of_node)
-		gpiod = fwnode_get_named_gpiod(&mdiodev->dev.of_node->fwnode,
-					       "reset-gpios", 0, GPIOD_OUT_LOW,
-					       "PHY reset");
-	if (PTR_ERR(gpiod) == -ENOENT)
-		gpiod = NULL;
-	else if (IS_ERR(gpiod))
-		return PTR_ERR(gpiod);
-
-	mdiodev->reset = gpiod;
-
-	/* Assert the reset signal again */
-	mdio_device_reset(mdiodev, 1);
-
-	return 0;
-}
-
 int mdiobus_register_device(struct mdio_device *mdiodev)
 {
-	int err;
-
 	if (mdiodev->bus->mdio_map[mdiodev->addr])
 		return -EBUSY;
 
-	if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY) {
-		err = mdiobus_register_gpiod(mdiodev);
-		if (err)
-			return err;
-	}
-
 	mdiodev->bus->mdio_map[mdiodev->addr] = mdiodev;
 
 	return 0;