netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: Horatiu Vultur <horatiu.vultur@microchip.com>,
	Jakub Kicinski <kuba@kernel.org>,
	andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net,
	edumazet@google.com, pabeni@redhat.com, richardcochran@gmail.com,
	vadim.fedorenko@linux.dev, christophe.jaillet@wanadoo.fr,
	rosenp@gmail.com, steen.hegelund@microchip.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v2] phy: mscc: Fix PTP for vsc8574 and VSC8572
Date: Fri, 26 Sep 2025 11:19:52 +0100	[thread overview]
Message-ID: <aNZoyOPu3hUDadWv@shell.armlinux.org.uk> (raw)
In-Reply-To: <20250926095203.dqg2vkjr5tdwri7w@skbuf>

On Fri, Sep 26, 2025 at 12:52:03PM +0300, Vladimir Oltean wrote:
> On Fri, Sep 26, 2025 at 10:46:47AM +0100, Russell King (Oracle) wrote:
> > On Mon, Sep 22, 2025 at 02:33:01PM +0200, Horatiu Vultur wrote:
> > > Thanks for the advice.
> > > What about to make the PHY_ID_VSC8572 and PHY_ID_VSC8574 to use
> > > vsc8584_probe() and then in this function just have this check:
> > > 
> > > ---
> > > if ((phydev->phy_id & 0xfffffff0) != PHY_ID_VSC8572 &&
> > >     (phydev->phy_id & 0xfffffff0) != PHY_ID_VSC8574) {
> > > 	if ((phydev->phy_id & MSCC_DEV_REV_MASK) != VSC8584_REVB) {
> > > 		dev_err(&phydev->mdio.dev, "Only VSC8584 revB is supported.\n");
> > > 		return -ENOTSUPP;
> > > 	}
> > > }
> > 
> > Please, no, not like this. Have a look how the driver already compares
> > PHY IDs in the rest of the code.
> > 
> > When a PHY driver is matched, the PHY ID is compared using the
> > .phy_id and .phy_id_mask members of the phy_driver structure.
> > 
> > The .phy_id is normally stuff like PHY_ID_VSC8572 and PHY_ID_VSC8574.
> > 
> > When the driver is probed, phydev->drv is set to point at the
> > appropriate phy_driver structure. Thus, the tests can be simplified
> > to merely looking at phydev->drv->phy_id:
> > 
> > 	if (phydev->drv->phy_id != PHY_ID_VSC8572 &&
> > 	    phydev->drv->phy_id != PHY_ID_VSC8574 &&
> > 	    (phydev->phy_id & MSCC_DEV_REV_MASK) != VSC8584_REVB) {
> > ...
> > 
> > Alternatively, please look at the phy_id*() and phydev_id_compare()
> > families of functions.
> > 
> > -- 
> > RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
> > FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
> 
> The phydev->phy_id comparisons are problematic with clause 45 PHYs where
> this field is zero, but with clause 22 they should technically work.
> It's good to know coming from a phylib maintainer that it's preferable
> to use phydev->drv->phy_id everywhere (I also wanted to comment on this
> aspect, but because technically nothing is broken, I didn't).

Yes indeed, which is another reason to use phydev->drv->* as these
get matched against the C22 and C45 IDs during PHY probe.

If we wish to get more clever (in terms of wanthing to know the
revision without knowing how the driver was matched) we could store
the matched ID in phydev, as read from hardware. This would also get
around the problem that where the ID is provided in the DT compatible,
we would have the real hardware-read ID to check things like the
revision against, rather than a fixed value in DT.

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

  reply	other threads:[~2025-09-26 10:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-17 11:33 [PATCH net v2] phy: mscc: Fix PTP for vsc8574 and VSC8572 Horatiu Vultur
2025-09-18 23:09 ` Jakub Kicinski
2025-09-22 12:15   ` Vladimir Oltean
2025-09-22 12:33     ` Horatiu Vultur
2025-09-22 13:28       ` Vladimir Oltean
2025-09-23  7:19         ` Horatiu Vultur
2025-09-26  7:11           ` Horatiu Vultur
2025-09-26 12:20             ` Vladimir Oltean
2025-09-26 12:21               ` Horatiu Vultur
2025-09-26 12:27                 ` Vladimir Oltean
2025-09-26 12:27                   ` Horatiu Vultur
2025-09-26  9:46       ` Russell King (Oracle)
2025-09-26  9:52         ` Vladimir Oltean
2025-09-26 10:19           ` Russell King (Oracle) [this message]
2025-09-26 12:12             ` Horatiu Vultur

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=aNZoyOPu3hUDadWv@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=andrew@lunn.ch \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=rosenp@gmail.com \
    --cc=steen.hegelund@microchip.com \
    --cc=vadim.fedorenko@linux.dev \
    --cc=vladimir.oltean@nxp.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).