2023-08-31 00:15:45

by Lukasz Majewski

[permalink] [raw]
Subject: [PATCH 2/2] net: phy: Provide Module 4 KSZ9477 errata (DS80000754C)

The KSZ9477 errata points out (in 'Module 4') the link up/down problem
when EEE (Energy Efficient Ethernet) is enabled in the device to which
the KSZ9477 tries to auto negotiate.

The suggested workaround is to clear advertisement of EEE for PHYs in
this chip driver.

Signed-off-by: Lukasz Majewski <[email protected]>
---
drivers/net/phy/micrel.c | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 87b090ad2874..469dcd8a5711 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -1418,6 +1418,35 @@ static int ksz9131_get_features(struct phy_device *phydev)
return 0;
}

+static int ksz9477_get_features(struct phy_device *phydev)
+{
+ __ETHTOOL_DECLARE_LINK_MODE_MASK(zero) = { 0, };
+ int ret;
+
+ ret = genphy_read_abilities(phydev);
+ if (ret)
+ return ret;
+
+ /* KSZ9477 Errata DS80000754C
+ *
+ * Module 4: Energy Efficient Ethernet (EEE) feature select must be
+ * manually disabled
+ * The EEE feature is enabled by default, but it is not fully
+ * operational. It must be manually disabled through register
+ * controls. If not disabled, the PHY ports can auto-negotiate
+ * to enable EEE, and this feature can cause link drops when linked
+ * to another device supporting EEE.
+ *
+ * Although, the KSZ9477 MMD register
+ * (MMD_DEVICE_ID_EEE_ADV.MMD_EEE_ADV) advertise that EEE is
+ * operational one needs to manualy clear them to follow the chip
+ * errata.
+ */
+ linkmode_and(phydev->supported_eee, phydev->supported, zero);
+
+ return 0;
+}
+
#define KSZ8873MLL_GLOBAL_CONTROL_4 0x06
#define KSZ8873MLL_GLOBAL_CONTROL_4_DUPLEX BIT(6)
#define KSZ8873MLL_GLOBAL_CONTROL_4_SPEED BIT(4)
@@ -4871,7 +4900,7 @@ static struct phy_driver ksphy_driver[] = {
.handle_interrupt = kszphy_handle_interrupt,
.suspend = genphy_suspend,
.resume = genphy_resume,
- .get_features = ksz9131_get_features,
+ .get_features = ksz9477_get_features,
} };

module_phy_driver(ksphy_driver);
--
2.20.1



2023-08-31 06:04:58

by Oleksij Rempel

[permalink] [raw]
Subject: Re: [PATCH 2/2] net: phy: Provide Module 4 KSZ9477 errata (DS80000754C)

Hi Lukasz,

On Wed, Aug 30, 2023 at 06:38:18PM +0200, Lukasz Majewski wrote:
> Hi Oleksij,

> The implementation as you suggested seems to work :-)
>
> The ksz_get_phy_flags() - where the MICREL_NO_EEE is set is executed
> before ksz9477_config_init().
>
> And then the eee_broken_modes are taken into account.
>
> # ethtool --show-eee lan1
> EEE Settings for lan1:
> EEE status: disabled
> Tx LPI: 0 (us)
> Supported EEE link modes: 100baseT/Full
> 1000baseT/Full
> Advertised EEE link modes: Not reported
> Link partner advertised EEE link modes: Not reported
>
> I will prepare tomorrow a proper patch.

can you please by the way remove this line:
https://elixir.bootlin.com/linux/v6.5/source/drivers/net/phy/micrel.c#L1803

it is obsolet by eee_broken_modes.

Regards,
Oleksij
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |

2023-08-31 18:20:16

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH 2/2] net: phy: Provide Module 4 KSZ9477 errata (DS80000754C)

On Thu, Aug 31, 2023 at 06:40:04AM +0200, Oleksij Rempel wrote:
> Hi Lukasz,
>
> On Wed, Aug 30, 2023 at 06:38:18PM +0200, Lukasz Majewski wrote:
> > Hi Oleksij,
>
> > The implementation as you suggested seems to work :-)
> >
> > The ksz_get_phy_flags() - where the MICREL_NO_EEE is set is executed
> > before ksz9477_config_init().
> >
> > And then the eee_broken_modes are taken into account.
> >
> > # ethtool --show-eee lan1
> > EEE Settings for lan1:
> > EEE status: disabled
> > Tx LPI: 0 (us)
> > Supported EEE link modes: 100baseT/Full
> > 1000baseT/Full
> > Advertised EEE link modes: Not reported
> > Link partner advertised EEE link modes: Not reported
> >
> > I will prepare tomorrow a proper patch.
>
> can you please by the way remove this line:
> https://elixir.bootlin.com/linux/v6.5/source/drivers/net/phy/micrel.c#L1803
>
> it is obsolet by eee_broken_modes.

... and if possible verify on the link partner side that indeed no
EEE modes are being advertised by the Micrel device.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!