netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: Eric Dumazet <edumazet@google.com>, Andrew Lunn <andrew@lunn.ch>,
	davem@davemloft.net, Woojung Huh <woojung.huh@microchip.com>,
	Vladimir Oltean <olteanv@gmail.com>,
	Tristram.Ha@microchip.com,
	Florian Fainelli <f.fainelli@gmail.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	UNGLinuxDriver@microchip.com,
	Russell King <linux@armlinux.org.uk>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] net: phy: Provide Module 4 KSZ9477 errata (DS80000754C)
Date: Wed, 30 Aug 2023 13:51:51 +0200	[thread overview]
Message-ID: <20230830135151.683303db@wsk> (raw)
In-Reply-To: <20230830105941.GH31399@pengutronix.de>

[-- Attachment #1: Type: text/plain, Size: 4621 bytes --]

Hi Oleksij,

> On Wed, Aug 30, 2023 at 12:52:24PM +0200, Lukasz Majewski wrote:
> > Hi Oleksij,
> >   
> > > On Wed, Aug 30, 2023 at 11:21:19AM +0200, Lukasz Majewski wrote:  
> > > > 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 <lukma@denx.de>
> > > > ---
> > > >  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,    
> > > 
> > > Sorry, i didn't described all details how to implement it.
> > > 
> > > This code will break EEE support for the KSZ8563R switch.
> > >   
> > 
> > And then another switch (KSZ8563R) pops up.... with regression....  
> 
> Initially ksz9477_get_features() was introduced to fix KSZ8563R.
> 
> > In the micrel.c the ksz9477_get_features was only present in:
> > https://elixir.bootlin.com/linux/latest/source/drivers/net/phy/micrel.c#L4832
> > https://elixir.bootlin.com/linux/latest/source/drivers/net/phy/micrel.c#L4874
> > so I only changed it there.
> > 
> > Apparently the KSZ8563R re-uses the KSZ9477 code.  
> 
> Most (all?) switch variant support by the ksz9477 DSA driver share
> the same PHYid, so it is not possible to identify it by the micrel.c
> PHY driver. As far as a know, the only commonly accepted way to
> notify about some quirks between this both drivers is not user
> dev_flags.
> 

We would need another idea on fixing this problem as there is following
order of function calls:

-> ksz9477_setup
-> ksz9477_get_features  (here we are supposed to use the MICREL_NO_EEE
flag)
-> ksz_get_phy_flags  (here we are supposed to set the MICREL_NO_EEE
flag)

The ksz9477_get_features is called early. 



It looks like the most optimal solution would be the one proposed by
Tristam:
https://www.spinics.net/lists/netdev/msg932044.html

It would clear the 7.60 per-port register with two ksz_write16
functions.

That exactly follows the recommendation for KSZ9477 Errata Module4.

> Regards,
> Oleskij




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2023-08-30 11:52 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-30  9:21 [PATCH 1/2] net: phy: Rename KSZ9477 get features function (to ksz9131_get_features) Lukasz Majewski
2023-08-30  9:21 ` [PATCH 2/2] net: phy: Provide Module 4 KSZ9477 errata (DS80000754C) Lukasz Majewski
2023-08-30  9:48   ` Michal Swiatkowski
2023-08-30 10:37     ` Lukasz Majewski
2023-08-30 10:18   ` Oleksij Rempel
2023-08-30 10:52     ` Lukasz Majewski
2023-08-30 10:59       ` Oleksij Rempel
2023-08-30 11:51         ` Lukasz Majewski [this message]
2023-08-30 12:17           ` Oleksij Rempel
2023-08-30 12:35             ` Russell King (Oracle)
2023-08-30 13:06               ` Oleksij Rempel
2023-08-30 13:30                 ` Russell King (Oracle)
2023-08-30 14:26                   ` Oleksij Rempel
2023-08-30 14:38                     ` Russell King (Oracle)
2023-08-30 14:48                       ` Oleksij Rempel
2023-08-30 16:38                     ` Lukasz Majewski
2023-08-31  4:40                       ` Oleksij Rempel
2023-08-31  7:13                         ` Russell King (Oracle)
2023-08-30 13:23             ` Lukasz Majewski
2023-08-30 11:20     ` Russell King (Oracle)
2023-08-30 11:08   ` Russell King (Oracle)
2023-08-30 11:20     ` Oleksij Rempel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230830135151.683303db@wsk \
    --to=lukma@denx.de \
    --cc=Tristram.Ha@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=woojung.huh@microchip.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).