netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Lukasz Majewski <lukma@denx.de>
Cc: Tristram.Ha@microchip.com, Eric Dumazet <edumazet@google.com>,
	Andrew Lunn <andrew@lunn.ch>,
	davem@davemloft.net, Woojung Huh <woojung.huh@microchip.com>,
	Vladimir Oltean <olteanv@gmail.com>,
	Oleksij Rempel <o.rempel@pengutronix.de>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	UNGLinuxDriver@microchip.com,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Michael Walle <michael@walle.cc>,
	Horatiu Vultur <horatiu.vultur@microchip.com>,
	Arun Ramadoss <arun.ramadoss@microchip.com>,
	Oleksij Rempel <linux@rempel-privat.de>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] net: phy: Provide Module 4 KSZ9477 errata (DS80000754C)
Date: Thu, 31 Aug 2023 11:28:00 +0100	[thread overview]
Message-ID: <ZPBrMMPiWubgFEZ0@shell.armlinux.org.uk> (raw)
In-Reply-To: <20230831072527.537839-1-lukma@denx.de>

On Thu, Aug 31, 2023 at 09:25:27AM +0200, Lukasz Majewski wrote:
> diff --git a/include/linux/micrel_phy.h b/include/linux/micrel_phy.h
> index 8bef1ab62bba..eed474fc7308 100644
> --- a/include/linux/micrel_phy.h
> +++ b/include/linux/micrel_phy.h
> @@ -44,6 +44,7 @@
>  #define MICREL_PHY_50MHZ_CLK	0x00000001
>  #define MICREL_PHY_FXEN		0x00000002
>  #define MICREL_KSZ8_P1_ERRATA	0x00000003
> +#define MICREL_NO_EEE	0x00000004

Erm... Maybe someone should clarify this... we have in the code the
following tests for these "flags":

	/* Support legacy board-file configuration */
	if (phydev->dev_flags & MICREL_PHY_50MHZ_CLK) {
	        priv->rmii_ref_clk_sel = true;
	        priv->rmii_ref_clk_sel_val = true;
	}

	/* Skip auto-negotiation in fiber mode */
	if (phydev->dev_flags & MICREL_PHY_FXEN) {
	        phydev->speed = SPEED_100;
	        return 0;
	}

	if (phydev->dev_flags & MICREL_KSZ8_P1_ERRATA)
		return -EOPNOTSUPP;

	/* According to KSZ9477 Errata DS80000754C (Module 4) all EEE modes
	 * in this switch shall be regarded as broken.
	 */
	if (phydev->dev_flags & MICREL_NO_EEE)
	        phydev->eee_broken_modes = -1;

Is it intentional that setting MICREL_PHY_50MHZ_CLK on its own also
activates the MICREL_KSZ8_P1_ERRATA and vice versa? Is it intentional
that setting MICREL_PHY_FXEN also activates MICREL_KSZ8_P1_ERRATA and
vice versa?

To me, this looks horribly broken, and this patch just perpetuates the
brokenness (but at least 0x4 doesn't overlap with the other flags.)

If it is intentional, then MICREL_KSZ8_P1_ERRATA should be defined to
make it explicit - in other words, as
(MICREL_PHY_FXEN|MICREL_PHY_50MHZ_CLK). If not, all these flags should
be defined using (1 << n) or BIT() to make it explicit that they're a
bit, and not just a hex number that gets incremented when the next flag
is added.

Thanks.

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

  parent reply	other threads:[~2023-08-31 10:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-31  7:25 [PATCH v3] net: phy: Provide Module 4 KSZ9477 errata (DS80000754C) Lukasz Majewski
2023-08-31  7:51 ` Oleksij Rempel
2023-08-31 10:28 ` Russell King (Oracle) [this message]
2023-08-31 10:37   ` 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=ZPBrMMPiWubgFEZ0@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=Tristram.Ha@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=arun.ramadoss@microchip.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rempel-privat.de \
    --cc=lukma@denx.de \
    --cc=michael@walle.cc \
    --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).