diff mbox series

[net-next] net: phy: qca807x: move interface mode check to .config_init_once

Message ID 20240212115043.1725918-1-robimarko@gmail.com (mailing list archive)
State Not Applicable
Headers show
Series [net-next] net: phy: qca807x: move interface mode check to .config_init_once | expand

Commit Message

Robert Marko Feb. 12, 2024, 11:49 a.m. UTC
Currently, we are checking whether the PHY package mode matches the
individual PHY interface modes at PHY package probe time, but at that time
we only know the PHY package mode and not the individual PHY interface
modes as of_get_phy_mode() that populates it will only get called once the
netdev to which PHY-s are attached to is being probed and thus this check
will always fail and return -EINVAL.

So, lets move this check to .config_init_once as at that point individual
PHY interface modes should be populated.

Fixes: d1cb613efbd3 ("net: phy: qcom: add support for QCA807x PHY Family")
Signed-off-by: Robert Marko <robimarko@gmail.com>
---
 drivers/net/phy/qcom/qca807x.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Andrew Lunn Feb. 12, 2024, 2:51 p.m. UTC | #1
On Mon, Feb 12, 2024 at 12:49:34PM +0100, Robert Marko wrote:
> Currently, we are checking whether the PHY package mode matches the
> individual PHY interface modes at PHY package probe time, but at that time
> we only know the PHY package mode and not the individual PHY interface
> modes as of_get_phy_mode() that populates it will only get called once the
> netdev to which PHY-s are attached to is being probed and thus this check
> will always fail and return -EINVAL.
> 
> So, lets move this check to .config_init_once as at that point individual
> PHY interface modes should be populated.

Just for my own understanding, not directly about this patch...

priv->package_mode is about PSGMII vs QSGMII for one of the SERDES
interfaces? We expect the individual PHYs sharing that interface to
also indicate PSGMII or QSGMII?

But what about the other SERDES, which can be connected to an SFP
cage. You would normally set that to SGMII, or 1000BaseX. When an SFP
module is inserted, the correct interface mode is then determined from
the contests of the EEPROM and the PCS needs to be reconfigured. So
i'm just wondering how this check works in this situation?

    Andrew
Robert Marko Feb. 12, 2024, 6:09 p.m. UTC | #2
On Mon, 12 Feb 2024 at 15:51, Andrew Lunn <andrew@lunn.ch> wrote:
>
> On Mon, Feb 12, 2024 at 12:49:34PM +0100, Robert Marko wrote:
> > Currently, we are checking whether the PHY package mode matches the
> > individual PHY interface modes at PHY package probe time, but at that time
> > we only know the PHY package mode and not the individual PHY interface
> > modes as of_get_phy_mode() that populates it will only get called once the
> > netdev to which PHY-s are attached to is being probed and thus this check
> > will always fail and return -EINVAL.
> >
> > So, lets move this check to .config_init_once as at that point individual
> > PHY interface modes should be populated.
>
> Just for my own understanding, not directly about this patch...
>
> priv->package_mode is about PSGMII vs QSGMII for one of the SERDES
> interfaces? We expect the individual PHYs sharing that interface to
> also indicate PSGMII or QSGMII?

Yes, that is the idea, all of the individual PHY-s in the package
should be indicating
the same PHY interface mode.

>
> But what about the other SERDES, which can be connected to an SFP
> cage. You would normally set that to SGMII, or 1000BaseX. When an SFP
> module is inserted, the correct interface mode is then determined from
> the contests of the EEPROM and the PCS needs to be reconfigured. So
> i'm just wondering how this check works in this situation?

I just went to retest SFP support and it works as intended, as soon as the SFP
is inserted, PHY will get reconfigured to "combo" mode so that fifth PHY can
support both fiber (100Base-FX or 1000Base-X) or regular copper connections.

So, the check will not interfere with SFP support.

Regards,
Robert
>
>     Andrew
Andrew Lunn Feb. 12, 2024, 7:48 p.m. UTC | #3
On Mon, Feb 12, 2024 at 07:09:04PM +0100, Robert Marko wrote:
> On Mon, 12 Feb 2024 at 15:51, Andrew Lunn <andrew@lunn.ch> wrote:
> >
> > On Mon, Feb 12, 2024 at 12:49:34PM +0100, Robert Marko wrote:
> > > Currently, we are checking whether the PHY package mode matches the
> > > individual PHY interface modes at PHY package probe time, but at that time
> > > we only know the PHY package mode and not the individual PHY interface
> > > modes as of_get_phy_mode() that populates it will only get called once the
> > > netdev to which PHY-s are attached to is being probed and thus this check
> > > will always fail and return -EINVAL.
> > >
> > > So, lets move this check to .config_init_once as at that point individual
> > > PHY interface modes should be populated.
> >
> > Just for my own understanding, not directly about this patch...
> >
> > priv->package_mode is about PSGMII vs QSGMII for one of the SERDES
> > interfaces? We expect the individual PHYs sharing that interface to
> > also indicate PSGMII or QSGMII?
> 
> Yes, that is the idea, all of the individual PHY-s in the package
> should be indicating
> the same PHY interface mode.
> 
> >
> > But what about the other SERDES, which can be connected to an SFP
> > cage. You would normally set that to SGMII, or 1000BaseX. When an SFP
> > module is inserted, the correct interface mode is then determined from
> > the contests of the EEPROM and the PCS needs to be reconfigured. So
> > i'm just wondering how this check works in this situation?
> 
> I just went to retest SFP support and it works as intended, as soon as the SFP
> is inserted, PHY will get reconfigured to "combo" mode so that fifth PHY can
> support both fiber (100Base-FX or 1000Base-X) or regular copper connections.
> 
> So, the check will not interfere with SFP support.

So for the port with the SFP you also have phy-mode of PSGMII or
QSGMII? That then gets changed when the SFP is hot plugged?

	Andrew
Robert Marko Feb. 13, 2024, 10:16 a.m. UTC | #4
On Mon, 12 Feb 2024 at 20:48, Andrew Lunn <andrew@lunn.ch> wrote:
>
> On Mon, Feb 12, 2024 at 07:09:04PM +0100, Robert Marko wrote:
> > On Mon, 12 Feb 2024 at 15:51, Andrew Lunn <andrew@lunn.ch> wrote:
> > >
> > > On Mon, Feb 12, 2024 at 12:49:34PM +0100, Robert Marko wrote:
> > > > Currently, we are checking whether the PHY package mode matches the
> > > > individual PHY interface modes at PHY package probe time, but at that time
> > > > we only know the PHY package mode and not the individual PHY interface
> > > > modes as of_get_phy_mode() that populates it will only get called once the
> > > > netdev to which PHY-s are attached to is being probed and thus this check
> > > > will always fail and return -EINVAL.
> > > >
> > > > So, lets move this check to .config_init_once as at that point individual
> > > > PHY interface modes should be populated.
> > >
> > > Just for my own understanding, not directly about this patch...
> > >
> > > priv->package_mode is about PSGMII vs QSGMII for one of the SERDES
> > > interfaces? We expect the individual PHYs sharing that interface to
> > > also indicate PSGMII or QSGMII?
> >
> > Yes, that is the idea, all of the individual PHY-s in the package
> > should be indicating
> > the same PHY interface mode.
> >
> > >
> > > But what about the other SERDES, which can be connected to an SFP
> > > cage. You would normally set that to SGMII, or 1000BaseX. When an SFP
> > > module is inserted, the correct interface mode is then determined from
> > > the contests of the EEPROM and the PCS needs to be reconfigured. So
> > > i'm just wondering how this check works in this situation?
> >
> > I just went to retest SFP support and it works as intended, as soon as the SFP
> > is inserted, PHY will get reconfigured to "combo" mode so that fifth PHY can
> > support both fiber (100Base-FX or 1000Base-X) or regular copper connections.
> >
> > So, the check will not interfere with SFP support.
>
> So for the port with the SFP you also have phy-mode of PSGMII or
> QSGMII? That then gets changed when the SFP is hot plugged?

Yes, that is correct and when SFP is plugged in it will be reconfigured
by the driver into combo mode as that port can actually be used for fiber and
copper at the same time by changing the priority.

Regards,
Robert
>
>         Andrew
Christian Marangi Feb. 13, 2024, 1:02 p.m. UTC | #5
On Tue, Feb 13, 2024 at 11:16:47AM +0100, Robert Marko wrote:
> On Mon, 12 Feb 2024 at 20:48, Andrew Lunn <andrew@lunn.ch> wrote:
> >
> > On Mon, Feb 12, 2024 at 07:09:04PM +0100, Robert Marko wrote:
> > > On Mon, 12 Feb 2024 at 15:51, Andrew Lunn <andrew@lunn.ch> wrote:
> > > >
> > > > On Mon, Feb 12, 2024 at 12:49:34PM +0100, Robert Marko wrote:
> > > > > Currently, we are checking whether the PHY package mode matches the
> > > > > individual PHY interface modes at PHY package probe time, but at that time
> > > > > we only know the PHY package mode and not the individual PHY interface
> > > > > modes as of_get_phy_mode() that populates it will only get called once the
> > > > > netdev to which PHY-s are attached to is being probed and thus this check
> > > > > will always fail and return -EINVAL.
> > > > >
> > > > > So, lets move this check to .config_init_once as at that point individual
> > > > > PHY interface modes should be populated.
> > > >
> > > > Just for my own understanding, not directly about this patch...
> > > >
> > > > priv->package_mode is about PSGMII vs QSGMII for one of the SERDES
> > > > interfaces? We expect the individual PHYs sharing that interface to
> > > > also indicate PSGMII or QSGMII?
> > >
> > > Yes, that is the idea, all of the individual PHY-s in the package
> > > should be indicating
> > > the same PHY interface mode.
> > >
> > > >
> > > > But what about the other SERDES, which can be connected to an SFP
> > > > cage. You would normally set that to SGMII, or 1000BaseX. When an SFP
> > > > module is inserted, the correct interface mode is then determined from
> > > > the contests of the EEPROM and the PCS needs to be reconfigured. So
> > > > i'm just wondering how this check works in this situation?
> > >
> > > I just went to retest SFP support and it works as intended, as soon as the SFP
> > > is inserted, PHY will get reconfigured to "combo" mode so that fifth PHY can
> > > support both fiber (100Base-FX or 1000Base-X) or regular copper connections.
> > >
> > > So, the check will not interfere with SFP support.
> >
> > So for the port with the SFP you also have phy-mode of PSGMII or
> > QSGMII? That then gets changed when the SFP is hot plugged?
> 
> Yes, that is correct and when SFP is plugged in it will be reconfigured
> by the driver into combo mode as that port can actually be used for fiber and
> copper at the same time by changing the priority.
>

Hi Andrew, just to make sure this doesn't get confused.

There is a HW limitation here and it's described in Documentation:

- In QSGMII mode the SFP Cage can't be connected or mounted physically
  as in this mode only 5 copper port can be connected, it would go
  against the HW design of the chip. In this configuration the first 4
  port are qsgmii and the 5th port is sgmii. (we enforce qsgmii on all
  ports out of simplicity to make sure we have a sane configuration in
  DT)

- In PSGMII mode the 5th port is always a combo port that can either be
  a copper port or a fiber port (with SFP cage). To set the 5th port to
  fiber mode, the mode has to be switched but the other 4 port are
  always copper.
  Also it's ok to set the initial PSGMII mode to 5 copper port as it
  will be changed as soon as a SFP cage is connected. (can't happen to
  have a device with both a copper port and a SFP cage connected to the
  5th port, it's one or the other. Again it would go against the HW
  design.

Hope it's clear now why the check was introduced and the HW limitation
of it as with the previous message one might think the 5th port is
totally separated and can go to his own mode (PSGMII or QSGMII)
Andrew Lunn Feb. 13, 2024, 1:27 p.m. UTC | #6
> > Yes, that is correct and when SFP is plugged in it will be reconfigured
> > by the driver into combo mode as that port can actually be used for fiber and
> > copper at the same time by changing the priority.
> >
> 
> Hi Andrew, just to make sure this doesn't get confused.
> 
> There is a HW limitation here and it's described in Documentation:
> 
> - In QSGMII mode the SFP Cage can't be connected or mounted physically
>   as in this mode only 5 copper port can be connected, it would go
>   against the HW design of the chip. In this configuration the first 4
>   port are qsgmii and the 5th port is sgmii. (we enforce qsgmii on all
>   ports out of simplicity to make sure we have a sane configuration in
>   DT)
> 
> - In PSGMII mode the 5th port is always a combo port that can either be
>   a copper port or a fiber port (with SFP cage). To set the 5th port to
>   fiber mode, the mode has to be switched but the other 4 port are
>   always copper.
>   Also it's ok to set the initial PSGMII mode to 5 copper port as it
>   will be changed as soon as a SFP cage is connected. (can't happen to
>   have a device with both a copper port and a SFP cage connected to the
>   5th port, it's one or the other. Again it would go against the HW
>   design.
> 
> Hope it's clear now why the check was introduced and the HW limitation
> of it as with the previous message one might think the 5th port is
> totally separated and can go to his own mode (PSGMII or QSGMII)

Thanks for the explanation

I'm more used to it being like:

&eth2 {
        /* ethernet@34000 */
        bm,pool-long = <3>;
        bm,pool-short = <1>;
        buffer-manager = <&bm>;
        managed = "in-band-status";
        phys = <&comphy5 1>;
        phy-mode = "sgmii";
        sfp = <&sfp0>;
        status = "okay";
};

Here phy-mode is set to one of the modes the SFP will use, either
sgmii or 1000baseX. But i don't think it matters what value is used.

      Andrew
Andrew Lunn Feb. 14, 2024, 5:59 p.m. UTC | #7
On Mon, Feb 12, 2024 at 12:49:34PM +0100, Robert Marko wrote:
> Currently, we are checking whether the PHY package mode matches the
> individual PHY interface modes at PHY package probe time, but at that time
> we only know the PHY package mode and not the individual PHY interface
> modes as of_get_phy_mode() that populates it will only get called once the
> netdev to which PHY-s are attached to is being probed and thus this check
> will always fail and return -EINVAL.
> 
> So, lets move this check to .config_init_once as at that point individual
> PHY interface modes should be populated.
> 
> Fixes: d1cb613efbd3 ("net: phy: qcom: add support for QCA807x PHY Family")
> Signed-off-by: Robert Marko <robimarko@gmail.com>

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

    Andrew
patchwork-bot+netdevbpf@kernel.org Feb. 15, 2024, 10:50 a.m. UTC | #8
Hello:

This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Mon, 12 Feb 2024 12:49:34 +0100 you wrote:
> Currently, we are checking whether the PHY package mode matches the
> individual PHY interface modes at PHY package probe time, but at that time
> we only know the PHY package mode and not the individual PHY interface
> modes as of_get_phy_mode() that populates it will only get called once the
> netdev to which PHY-s are attached to is being probed and thus this check
> will always fail and return -EINVAL.
> 
> [...]

Here is the summary with links:
  - [net-next] net: phy: qca807x: move interface mode check to .config_init_once
    https://git.kernel.org/netdev/net-next/c/3be0d950b628

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/phy/qcom/qca807x.c b/drivers/net/phy/qcom/qca807x.c
index 01815f947060..780c28e2e4aa 100644
--- a/drivers/net/phy/qcom/qca807x.c
+++ b/drivers/net/phy/qcom/qca807x.c
@@ -562,6 +562,11 @@  static int qca807x_phy_package_config_init_once(struct phy_device *phydev)
 	struct qca807x_shared_priv *priv = shared->priv;
 	int val, ret;
 
+	/* Make sure PHY follow PHY package mode if enforced */
+	if (priv->package_mode != PHY_INTERFACE_MODE_NA &&
+	    phydev->interface != priv->package_mode)
+		return -EINVAL;
+
 	phy_lock_mdio_bus(phydev);
 
 	/* Set correct PHY package mode */
@@ -718,11 +723,6 @@  static int qca807x_probe(struct phy_device *phydev)
 	shared = phydev->shared;
 	shared_priv = shared->priv;
 
-	/* Make sure PHY follow PHY package mode if enforced */
-	if (shared_priv->package_mode != PHY_INTERFACE_MODE_NA &&
-	    phydev->interface != shared_priv->package_mode)
-		return -EINVAL;
-
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;