All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 0/2] Fix 88x3310 leaving power save mode
@ 2020-04-14 18:29 Russell King - ARM Linux admin
  2020-04-14 18:30 ` [PATCH net 1/2] net: marvell10g: report firmware version Russell King
  2020-04-14 18:30 ` [PATCH net 2/2] net: marvell10g: soft-reset the PHY when coming out of low power Russell King
  0 siblings, 2 replies; 6+ messages in thread
From: Russell King - ARM Linux admin @ 2020-04-14 18:29 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, Heiner Kallweit
  Cc: David S. Miller, Matteo Croce, netdev

Hi,

This series fixes a problem with the 88x3310 PHY on Macchiatobin
coming out of powersave mode noticed by Matteo Croce.  It seems
that certain PHY firmwares do not properly exit powersave mode,
resulting in a fibre link not coming up.

The solution appears to be to soft-reset the PHY after clearing
the powersave bit.

We add support for reporting the PHY firmware version to the kernel
log, and use it to trigger this new behaviour if we have v0.3.x.x
or more recent firmware on the PHY.  This, however, is a guess as
the firmware revision documentation does not mention this issue,
and we know that v0.2.1.0 works without this fix but v0.3.3.0 and
later does not.

 drivers/net/phy/marvell10g.c | 39 ++++++++++++++++++++++++++++++++++++---
 1 file changed, 36 insertions(+), 3 deletions(-)

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 10.2Mbps down 587kbps up

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net 1/2] net: marvell10g: report firmware version
  2020-04-14 18:29 [PATCH net 0/2] Fix 88x3310 leaving power save mode Russell King - ARM Linux admin
@ 2020-04-14 18:30 ` Russell King
  2020-04-14 18:47   ` Andrew Lunn
  2020-04-14 18:30 ` [PATCH net 2/2] net: marvell10g: soft-reset the PHY when coming out of low power Russell King
  1 sibling, 1 reply; 6+ messages in thread
From: Russell King @ 2020-04-14 18:30 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, Heiner Kallweit
  Cc: Matteo Croce, David S. Miller, netdev

Report the firmware version when probing the PHY to allow issues
attributable to firmware to be diagnosed.

Tested-by: Matteo Croce <mcroce@redhat.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/net/phy/marvell10g.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c
index 7621badae64d..ee60417cdc55 100644
--- a/drivers/net/phy/marvell10g.c
+++ b/drivers/net/phy/marvell10g.c
@@ -33,6 +33,8 @@
 #define MV_PHY_ALASKA_NBT_QUIRK_REV	(MARVELL_PHY_ID_88X3310 | 0xa)
 
 enum {
+	MV_PMA_FW_VER0		= 0xc011,
+	MV_PMA_FW_VER1		= 0xc012,
 	MV_PMA_BOOT		= 0xc050,
 	MV_PMA_BOOT_FATAL	= BIT(0),
 
@@ -83,6 +85,8 @@ enum {
 };
 
 struct mv3310_priv {
+	u32 firmware_ver;
+
 	struct device *hwmon_dev;
 	char *hwmon_name;
 };
@@ -355,6 +359,23 @@ static int mv3310_probe(struct phy_device *phydev)
 
 	dev_set_drvdata(&phydev->mdio.dev, priv);
 
+	ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MV_PMA_FW_VER0);
+	if (ret < 0)
+		return ret;
+
+	priv->firmware_ver = ret << 16;
+
+	ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MV_PMA_FW_VER1);
+	if (ret < 0)
+		return ret;
+
+	priv->firmware_ver |= ret;
+
+	dev_info(&phydev->mdio.dev,
+		 "Firmware version %u.%u.%u.%u\n",
+		 priv->firmware_ver >> 24, (priv->firmware_ver >> 16) & 255,
+		 (priv->firmware_ver >> 8) & 255, priv->firmware_ver & 255);
+
 	/* Powering down the port when not in use saves about 600mW */
 	ret = mv3310_power_down(phydev);
 	if (ret)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net 2/2] net: marvell10g: soft-reset the PHY when coming out of low power
  2020-04-14 18:29 [PATCH net 0/2] Fix 88x3310 leaving power save mode Russell King - ARM Linux admin
  2020-04-14 18:30 ` [PATCH net 1/2] net: marvell10g: report firmware version Russell King
@ 2020-04-14 18:30 ` Russell King
  2020-04-14 18:48   ` Andrew Lunn
  1 sibling, 1 reply; 6+ messages in thread
From: Russell King @ 2020-04-14 18:30 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, Heiner Kallweit
  Cc: Matteo Croce, David S. Miller, netdev

Soft-reset the PHY when coming out of low power mode, which seems to
be necessary with firmware versions 0.3.3.0 and 0.3.10.0.

This depends on ("net: marvell10g: report firmware version")

Fixes: c9cc1c815d36 ("net: phy: marvell10g: place in powersave mode at probe")
Reported-by: Matteo Croce <mcroce@redhat.com>
Tested-by: Matteo Croce <mcroce@redhat.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/net/phy/marvell10g.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c
index ee60417cdc55..5865b563cc94 100644
--- a/drivers/net/phy/marvell10g.c
+++ b/drivers/net/phy/marvell10g.c
@@ -75,7 +75,8 @@ enum {
 
 	/* Vendor2 MMD registers */
 	MV_V2_PORT_CTRL		= 0xf001,
-	MV_V2_PORT_CTRL_PWRDOWN = 0x0800,
+	MV_V2_PORT_CTRL_SWRST	= BIT(15),
+	MV_V2_PORT_CTRL_PWRDOWN = BIT(11),
 	MV_V2_TEMP_CTRL		= 0xf08a,
 	MV_V2_TEMP_CTRL_MASK	= 0xc000,
 	MV_V2_TEMP_CTRL_SAMPLE	= 0x0000,
@@ -239,8 +240,19 @@ static int mv3310_power_down(struct phy_device *phydev)
 
 static int mv3310_power_up(struct phy_device *phydev)
 {
-	return phy_clear_bits_mmd(phydev, MDIO_MMD_VEND2, MV_V2_PORT_CTRL,
-				  MV_V2_PORT_CTRL_PWRDOWN);
+	struct mv3310_priv *priv = dev_get_drvdata(&phydev->mdio.dev);
+	int ret;
+
+	ret = phy_clear_bits_mmd(phydev, MDIO_MMD_VEND2, MV_V2_PORT_CTRL,
+				 MV_V2_PORT_CTRL_PWRDOWN);
+
+	if (priv->firmware_ver < 0x00030000)
+		return ret;
+
+	ret = phy_set_bits_mmd(phydev, MDIO_MMD_VEND2, MV_V2_PORT_CTRL,
+			       MV_V2_PORT_CTRL_SWRST);
+
+	return ret;
 }
 
 static int mv3310_reset(struct phy_device *phydev, u32 unit)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net 1/2] net: marvell10g: report firmware version
  2020-04-14 18:30 ` [PATCH net 1/2] net: marvell10g: report firmware version Russell King
@ 2020-04-14 18:47   ` Andrew Lunn
  2020-04-14 19:45     ` Russell King - ARM Linux admin
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Lunn @ 2020-04-14 18:47 UTC (permalink / raw)
  To: Russell King
  Cc: Florian Fainelli, Heiner Kallweit, Matteo Croce, David S. Miller, netdev

On Tue, Apr 14, 2020 at 07:30:15PM +0100, Russell King wrote:
> Report the firmware version when probing the PHY to allow issues
> attributable to firmware to be diagnosed.
> 
> Tested-by: Matteo Croce <mcroce@redhat.com>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
>  drivers/net/phy/marvell10g.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c
> index 7621badae64d..ee60417cdc55 100644
> --- a/drivers/net/phy/marvell10g.c
> +++ b/drivers/net/phy/marvell10g.c
> @@ -33,6 +33,8 @@
>  #define MV_PHY_ALASKA_NBT_QUIRK_REV	(MARVELL_PHY_ID_88X3310 | 0xa)
>  
>  enum {
> +	MV_PMA_FW_VER0		= 0xc011,
> +	MV_PMA_FW_VER1		= 0xc012,
>  	MV_PMA_BOOT		= 0xc050,
>  	MV_PMA_BOOT_FATAL	= BIT(0),
>  
> @@ -83,6 +85,8 @@ enum {
>  };
>  
>  struct mv3310_priv {
> +	u32 firmware_ver;
> +
>  	struct device *hwmon_dev;
>  	char *hwmon_name;
>  };
> @@ -355,6 +359,23 @@ static int mv3310_probe(struct phy_device *phydev)
>  
>  	dev_set_drvdata(&phydev->mdio.dev, priv);
>  
> +	ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MV_PMA_FW_VER0);
> +	if (ret < 0)
> +		return ret;
> +
> +	priv->firmware_ver = ret << 16;
> +
> +	ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MV_PMA_FW_VER1);
> +	if (ret < 0)
> +		return ret;
> +
> +	priv->firmware_ver |= ret;
> +
> +	dev_info(&phydev->mdio.dev,
> +		 "Firmware version %u.%u.%u.%u\n",
> +		 priv->firmware_ver >> 24, (priv->firmware_ver >> 16) & 255,
> +		 (priv->firmware_ver >> 8) & 255, priv->firmware_ver & 255);
> +

Hi Russell

Did you consider using phydev_info()? Or is it too early, and you
don't get a sensible name?

      Andrew

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net 2/2] net: marvell10g: soft-reset the PHY when coming out of low power
  2020-04-14 18:30 ` [PATCH net 2/2] net: marvell10g: soft-reset the PHY when coming out of low power Russell King
@ 2020-04-14 18:48   ` Andrew Lunn
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2020-04-14 18:48 UTC (permalink / raw)
  To: Russell King
  Cc: Florian Fainelli, Heiner Kallweit, Matteo Croce, David S. Miller, netdev

On Tue, Apr 14, 2020 at 07:30:20PM +0100, Russell King wrote:
> Soft-reset the PHY when coming out of low power mode, which seems to
> be necessary with firmware versions 0.3.3.0 and 0.3.10.0.
> 
> This depends on ("net: marvell10g: report firmware version")
> 
> Fixes: c9cc1c815d36 ("net: phy: marvell10g: place in powersave mode at probe")
> Reported-by: Matteo Croce <mcroce@redhat.com>
> Tested-by: Matteo Croce <mcroce@redhat.com>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net 1/2] net: marvell10g: report firmware version
  2020-04-14 18:47   ` Andrew Lunn
@ 2020-04-14 19:45     ` Russell King - ARM Linux admin
  0 siblings, 0 replies; 6+ messages in thread
From: Russell King - ARM Linux admin @ 2020-04-14 19:45 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Florian Fainelli, Heiner Kallweit, Matteo Croce, David S. Miller, netdev

On Tue, Apr 14, 2020 at 08:47:39PM +0200, Andrew Lunn wrote:
> On Tue, Apr 14, 2020 at 07:30:15PM +0100, Russell King wrote:
> > Report the firmware version when probing the PHY to allow issues
> > attributable to firmware to be diagnosed.
> > 
> > Tested-by: Matteo Croce <mcroce@redhat.com>
> > Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> > ---
> >  drivers/net/phy/marvell10g.c | 21 +++++++++++++++++++++
> >  1 file changed, 21 insertions(+)
> > 
> > diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c
> > index 7621badae64d..ee60417cdc55 100644
> > --- a/drivers/net/phy/marvell10g.c
> > +++ b/drivers/net/phy/marvell10g.c
> > @@ -33,6 +33,8 @@
> >  #define MV_PHY_ALASKA_NBT_QUIRK_REV	(MARVELL_PHY_ID_88X3310 | 0xa)
> >  
> >  enum {
> > +	MV_PMA_FW_VER0		= 0xc011,
> > +	MV_PMA_FW_VER1		= 0xc012,
> >  	MV_PMA_BOOT		= 0xc050,
> >  	MV_PMA_BOOT_FATAL	= BIT(0),
> >  
> > @@ -83,6 +85,8 @@ enum {
> >  };
> >  
> >  struct mv3310_priv {
> > +	u32 firmware_ver;
> > +
> >  	struct device *hwmon_dev;
> >  	char *hwmon_name;
> >  };
> > @@ -355,6 +359,23 @@ static int mv3310_probe(struct phy_device *phydev)
> >  
> >  	dev_set_drvdata(&phydev->mdio.dev, priv);
> >  
> > +	ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MV_PMA_FW_VER0);
> > +	if (ret < 0)
> > +		return ret;
> > +
> > +	priv->firmware_ver = ret << 16;
> > +
> > +	ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MV_PMA_FW_VER1);
> > +	if (ret < 0)
> > +		return ret;
> > +
> > +	priv->firmware_ver |= ret;
> > +
> > +	dev_info(&phydev->mdio.dev,
> > +		 "Firmware version %u.%u.%u.%u\n",
> > +		 priv->firmware_ver >> 24, (priv->firmware_ver >> 16) & 255,
> > +		 (priv->firmware_ver >> 8) & 255, priv->firmware_ver & 255);
> > +
> 
> Hi Russell
> 
> Did you consider using phydev_info()? Or is it too early, and you
> don't get a sensible name?

No, I keep forgetting those exist!  I'll resend shortly.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 10.2Mbps down 587kbps up

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-04-14 19:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-14 18:29 [PATCH net 0/2] Fix 88x3310 leaving power save mode Russell King - ARM Linux admin
2020-04-14 18:30 ` [PATCH net 1/2] net: marvell10g: report firmware version Russell King
2020-04-14 18:47   ` Andrew Lunn
2020-04-14 19:45     ` Russell King - ARM Linux admin
2020-04-14 18:30 ` [PATCH net 2/2] net: marvell10g: soft-reset the PHY when coming out of low power Russell King
2020-04-14 18:48   ` Andrew Lunn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.