Fix PHY handle no longer parsing
Subsystems (4)
v2 cover Fix PHY handle no longer parsing
After the fixed link support was introduced, it is observed that PHY no longer attach to the MAC properly.
This patch series fixes the issue and maintains fixed-link capability.
Michael Sit Wei Hong (2):
net: stmmac: fix PHY handle parsing
net: stmmac: move fixed-link support fixup code
.../net/ethernet/stmicro/stmmac/dwmac-intel.c | 11 --------- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 24 +++++++++++++++++-- 2 files changed, 22 insertions(+), 13 deletions(-)
v2: Initialize fwnode before using the variable
Signature · 1 line
2.34.1
PATCH v2 1/2 net: stmmac: fix PHY handle parsing
phylink_fwnode_phy_connect returns 0 when set to MLO_AN_INBAND. This causes the PHY handle parsing to skip and the PHY will not be attached to the MAC.
Add additional check for PHY handle parsing when set to MLO_AN_INBAND.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +6 -2
@@ -1134,6 +1134,7 @@ static void stmmac_check_pcs_mode(struct stmmac_priv *priv)static int stmmac_init_phy (struct net_device *dev) {struct stmmac_priv *priv =netdev_priv (dev); +struct fwnode_handle *fixed_node;struct fwnode_handle *fwnode;int ret;
@@ -1141,13 +1142,16 @@ static int stmmac_init_phy(struct net_device *dev)if (!fwnode) fwnode =dev_fwnode (priv->device); -if (fwnode) +if (fwnode) { + fixed_node =fwnode_get_named_child_node (fwnode,"fixed-link" ); +fwnode_handle_put (fixed_node); ret =phylink_fwnode_phy_connect (priv->phylink, fwnode,0 ); + }/* Some DT bindings do not set-up the PHY handle. Let's try to * manually parse it */ -if (!fwnode || ret) { +if (!fwnode || ret || !fixed_node) {int addr = priv->plat->phy_addr;struct phy_device *phydev;
Signature · 1 line
2.34.1
Re: [PATCH net v2 1/2] net: stmmac: fix PHY handle parsing
Quoted 9 lines · Michael Sit Wei Hong
phylink_fwnode_phy_connectreturns 0 when set toMLO_AN_INBAND. This causes the PHY handle parsing to skip and the PHY will not be attached to the MAC.Add additional check for PHY handle parsing when set to
MLO_AN_INBAND.Fixes ab21cf920928 ("net: stmmac: make mdio register skips PHY scanning for fixed-link")Signed-off-by Michael Sit Wei Hong <[email protected]>Signed-off-by Lai Peter Jun Ann <[email protected]>
Jakub Kicinski
maintainerRe: [PATCH net v2 1/2] net: stmmac: fix PHY handle parsing
In reply to Michael Sit Wei Hongdrivers/net/ethernet/stmicro/stmmac/stmmac_main.c static int stmmac_init_phy(struct net_device *dev) · line 1147
Quoted 2 lines · On Tue, 14 Mar 2023 15:02:07 +0800 Michael Sit Wei Hong wrote:
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2
-0+ fixed_node =fwnode_get_named_child_node (fwnode,"fixed-link" ); +fwnode_handle_put (fixed_node);
fwnode_property_present() ?
RE: [PATCH net v2 1/2] net: stmmac: fix PHY handle parsing
Quoted 21 lines
-----Original Message-----
From: Jakub Kicinski <[email protected]>
Sent: Friday, March 17, 2023 8:00 AM
To: Sit, Michael Wei Hong <[email protected]>
Cc: Giuseppe Cavallaro <[email protected]>; Alexandre Torgue <[email protected]>; Jose Abreu <[email protected]>; David S . Miller <[email protected]>; Eric Dumazet <[email protected]>; Paolo Abeni <[email protected]>; Maxime Coquelin <[email protected]>; Ong, Boon Leong <[email protected]>; [email protected]; [email protected]; linux-arm- [email protected]; [email protected]; Looi, Hong Aun <[email protected]>; Voon, Weifeng <[email protected]>; Lai, Peter Jun Ann <[email protected]>
Subject: Re: [PATCH net v2 1/2] net: stmmac: fix PHY handle parsing
Quoted 6 lines
Review
Quoted 1 line · On Tue, 14 Mar 2023 15:02:07 +0800 Michael Sit Wei Hong wrote:
(quoted diff) +1
-0+ fixed_node =
fwnode_get_named_child_node(fwnode, "fixed-link");drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static int stmmac_init_phy(struct net_device *dev) · line 1147
Quoted 1 line
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-0+fwnode_handle_put (fixed_node);
fwnode_property_present()?
Good suggestion, will modify and submit in next revision.
Re: [PATCH net v2 1/2] net: stmmac: fix PHY handle parsing
In reply to Michael Sit Wei HongQuoted 3 lines · Michael Sit Wei Hong
phylink_fwnode_phy_connectreturns 0 when set toMLO_AN_INBAND. This causes the PHY handle parsing to skip and the PHY will not be attached to the MAC.
Please could you expand the commit message because i'm having trouble following this.
phylink_fwnode_phy_connect() says:
/* Fixed links and 802.3z are handled without needing a PHY */ if (pl->cfg_link_an_mode == MLO_AN_FIXED || (pl->cfg_link_an_mode == MLO_AN_INBAND && phy_interface_mode_is_8023z(pl->link_interface))) return 0;
So your first statement is not true. It should be MLO_AN_INBAND and phy_interface_mode_is_8023z.
Quoted 1 line
Add additional check for PHY handle parsing when set to
MLO_AN_INBAND.
Looking at the patch, there is no reference to MLO_AN_INBAND, or managed = "in-band-status";
Andrew
Re: [PATCH net v2 1/2] net: stmmac: fix PHY handle parsing
Quoted 16 lines · Andrew Lunn
Quoted 3 lines · Michael Sit Wei Hong
phylink_fwnode_phy_connectreturns 0 when set toMLO_AN_INBAND. This causes the PHY handle parsing to skip and the PHY will not be attached to the MAC.Please could you expand the commit message because i'm having trouble following this.
phylink_fwnode_phy_connect()says:/* Fixed links and 802.3z are handled without needing a PHY */ if (pl->cfg_link_an_mode == MLO_AN_FIXED || (pl->cfg_link_an_mode == MLO_AN_INBAND && phy_interface_mode_is_8023z(pl->link_interface))) return 0;
Quoted 7 lines
So your first statement is not true. It should be
MLO_AN_INBANDandphy_interface_mode_is_8023z.Quoted 1 line
Add additional check for PHY handle parsing when set to
MLO_AN_INBAND.Looking at the patch, there is no reference to
MLO_AN_INBAND, or managed = "in-band-status";
That's the pesky "xpcs_an_inband" which ends up as phylink's "ovr_an_inband"... I'm sure these are random renames of stuff to make sure that people struggle to follow the code.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
RE: [PATCH net v2 1/2] net: stmmac: fix PHY handle parsing
Quoted 52 lines
-----Original Message-----
From: Russell King <[email protected]>
Sent: Saturday, March 18, 2023 4:58 AM
To: Andrew Lunn <[email protected]>
Cc: Sit, Michael Wei Hong <[email protected]>; Giuseppe Cavallaro <[email protected]>; Alexandre Torgue <[email protected]>; Jose Abreu <[email protected]>; David S . Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Maxime Coquelin <[email protected]>; Ong, Boon Leong <[email protected]>; [email protected]; linux- [email protected]; linux-arm- [email protected]; [email protected]; Looi, Hong Aun <[email protected]>; Voon, Weifeng <[email protected]>; Lai, Peter Jun Ann <[email protected]>
Subject: Re: [PATCH net v2 1/2] net: stmmac: fix PHY handle parsingQuoted 1 line · Andrew Lunn
On Tue, Mar 14, 2023 at 03:02:07PM +0800, Michael Sit Wei
Quoted 1 line · Hong
Quoted 1 line
phylink_fwnode_phy_connectreturns 0 when set to
MLO_AN_INBAND.Quoted 1 line
Quoted 1 line
This causes the PHY handle parsing to skip and the PHY will not
be
Quoted 3 lines
Quoted 1 line
attached to the MAC.
Please could you expand the commit message because i'm
having trouble
Quoted 5 lines
following this.
phylink_fwnode_phy_connect()says:/* Fixed links and 802.3z are handled without needing aPHY */
Quoted 6 lines
if (pl->cfg_link_an_mode == MLO_AN_FIXED || (pl->cfg_link_an_mode == MLO_AN_INBAND && phy_interface_mode_is_8023z(pl->link_interface))) return 0;So your first statement is not true. It should be
MLO_AN_INBANDandQuoted 3 lines
phy_interface_mode_is_8023z.Quoted 1 line
Add additional check for PHY handle parsing when set to
MLO_AN_INBAND.Quoted 1 line
Quoted 8 lines
Quoted 1 line
Looking at the patch, there is no reference to
MLO_AN_INBAND, orQuoted 1 line
managed = "in-band-status";
That's the pesky "
xpcs_an_inband" which ends up as phylink's "ovr_an_inband"... I'm sure these are random renames of stuff to make sure that people struggle to follow the code.
It is as mentioned above, the "xpcs_an_inband" will end up as "ovr_an_inband" which will then
set pl->cfg_link_an_mode = MLO_AN_INBAND in the phylink_parse_mode() in phylink.c
The phylink_fwnode_phy_connect() checks if both MLO_AN_INBAND && phy_interface_mode_is_8023z() true before returning 0.
But in our case, we only have MLO_AN_INBAND is true, which then goes to the next part of the code.
phy_fwnode = fwnode_get_phy_node(fwnode);
if (IS_ERR(phy_fwnode)) {
if (pl->cfg_link_an_mode == MLO_AN_PHY)
return -ENODEV;
return 0;
}Where here the IS_ERR(phy_fwnode) returns true, then it Checks for MLO_AN_PHY, which in our case is not, so it returns a 0.
When returned 0, our driver will then skip the manual phy parsing due to if (!fwnode || ret)
Quoted 5 lines
--
RMK's Patch system:
https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH net v2 1/2] net: stmmac: fix PHY handle parsing
Quoted 56 lines · Michael Wei Hong
Quoted 56 lines
-----Original Message-----
From: Russell King <[email protected]>
Sent: Saturday, March 18, 2023 4:58 AM
To: Andrew Lunn <[email protected]>
Cc: Sit, Michael Wei Hong <[email protected]>; Giuseppe Cavallaro <[email protected]>; Alexandre Torgue <[email protected]>; Jose Abreu <[email protected]>; David S . Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Maxime Coquelin <[email protected]>; Ong, Boon Leong <[email protected]>; [email protected]; linux- [email protected]; linux-arm- [email protected]; [email protected]; Looi, Hong Aun <[email protected]>; Voon, Weifeng <[email protected]>; Lai, Peter Jun Ann <[email protected]>
Subject: Re: [PATCH net v2 1/2] net: stmmac: fix PHY handle parsingQuoted 1 line · Andrew Lunn
On Tue, Mar 14, 2023 at 03:02:07PM +0800, Michael Sit Wei
Quoted 1 line · Hong
Quoted 1 line
phylink_fwnode_phy_connectreturns 0 when set to
MLO_AN_INBAND.Quoted 1 line
Quoted 1 line
This causes the PHY handle parsing to skip and the PHY will not
be
Quoted 3 lines
Quoted 1 line
attached to the MAC.
Please could you expand the commit message because i'm
having trouble
Quoted 5 lines
following this.
phylink_fwnode_phy_connect()says:/* Fixed links and 802.3z are handled without needing aPHY */
Quoted 6 lines
if (pl->cfg_link_an_mode == MLO_AN_FIXED || (pl->cfg_link_an_mode == MLO_AN_INBAND && phy_interface_mode_is_8023z(pl->link_interface))) return 0;So your first statement is not true. It should be
MLO_AN_INBANDandQuoted 3 lines
phy_interface_mode_is_8023z.Quoted 1 line
Add additional check for PHY handle parsing when set to
MLO_AN_INBAND.Quoted 2 lines
Looking at the patch, there is no reference to
MLO_AN_INBAND, orQuoted 1 line
managed = "in-band-status";
Quoted 8 lines
Quoted 4 lines
That's the pesky "
xpcs_an_inband" which ends up as phylink's "ovr_an_inband"... I'm sure these are random renames of stuff to make sure that people struggle to follow the code.It is as mentioned above, the "
xpcs_an_inband" will end up as "ovr_an_inband" which will then
setpl->cfg_link_an_mode=MLO_AN_INBANDin thephylink_parse_mode()inphylink.c
Let me make my comment more clear, because I don't think you understood it correctly.
Please rename "xpcs_an_inband" to "ovr_an_inband" or "phylink_ovr_an_inband" so it's obvious what it is and where it ends up.
Thanks.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
PATCH v2 2/2 net: stmmac: move fixed-link support fixup code
In reply to Michael Sit Wei Hongxpcs_an_inband value is updated in the speed_mode_2500 function which turns on the xpcs_an_inband mode.
Moving the fixed-link fixup code to right before phylink setup to ensure no more fixup will affect the fixed-link mode configurations.
--- .../net/ethernet/stmicro/stmmac/dwmac-intel.c | 11 ----------- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 11 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +0 -11
@@ -592,17 +592,6 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, plat->mdio_bus_data->xpcs_an_inband = true; } -/* For fixed-link setup, we clear xpcs_an_inband */ -if (fwnode) { -struct fwnode_handle *fixed_node; - - fixed_node =fwnode_get_named_child_node (fwnode,"fixed-link" ); -if (fixed_node) - plat->mdio_bus_data->xpcs_an_inband = false; - -fwnode_handle_put (fixed_node); - } -/* Ensure mdio bus scan skips intel serdes and pcs-xpcs */ plat->mdio_bus_data->phy_mask =1 <<INTEL_MGBE_ADHOC_ADDR ; plat->mdio_bus_data->phy_mask |=1 <<INTEL_MGBE_XPCS_ADDR ;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +16 -0
@@ -7064,6 +7064,7 @@ int stmmac_dvr_probe(struct device *device, struct stmmac_resources *res) {struct net_device *ndev =NULL ; +struct fwnode_handle *fwnode;struct stmmac_priv *priv;u32 rxq;int i, ret =0 ;
@@ -7306,6 +7307,21 @@ int stmmac_dvr_probe(struct device *device, goto error_xpcs_setup; } +/* For fixed-link setup, we clear xpcs_an_inband */ + fwnode =of_fwnode_handle (priv->plat->phylink_node); +if (!fwnode) + fwnode =dev_fwnode (priv->device); + +if (fwnode) { +struct fwnode_handle *fixed_node; + + fixed_node =fwnode_get_named_child_node (fwnode,"fixed-link" ); +if (fixed_node) + priv->plat->mdio_bus_data->xpcs_an_inband = false; + +fwnode_handle_put (fixed_node); + } + ret =stmmac_phy_setup (priv);if (ret) {netdev_err (ndev,"failed to setup phy (%d)\n" , ret);
Signature · 1 line
2.34.1
Re: [PATCH net v2 2/2] net: stmmac: move fixed-link support fixup code
Quoted 8 lines · Michael Sit Wei Hong
xpcs_an_inbandvalue is updated in thespeed_mode_2500function which turns on thexpcs_an_inbandmode.Moving the fixed-link fixup code to right before phylink setup to ensure no more fixup will affect the fixed-link mode configurations.
Fixes 72edaf39fc65 ("stmmac: intel: add phy-mode and fixed-link ACPI _DSD setting support")Signed-off-by Michael Sit Wei Hong <[email protected]>
Jakub Kicinski
maintainerRe: [PATCH net v2 2/2] net: stmmac: move fixed-link support fixup code
In reply to Michael Sit Wei HongQuoted 8 lines · On Tue, 14 Mar 2023 15:02:08 +0800 Michael Sit Wei Hong wrote:
xpcs_an_inbandvalue is updated in thespeed_mode_2500function which turns on thexpcs_an_inbandmode.Moving the fixed-link fixup code to right before phylink setup to ensure no more fixup will affect the fixed-link mode configurations.
Fixes 72edaf39fc65 ("stmmac: intel: add phy-mode and fixed-link ACPI _DSD setting support")Signed-off-by Michael Sit Wei Hong <[email protected]>
Ong Boon, since you added the code which gets moved - could we get an ack/review tag from you? Helps increase the confidence in the change.
Re: [PATCH net v2 2/2] net: stmmac: move fixed-link support fixup code
In reply to Michael Sit Wei HongQuoted 5 lines · Michael Sit Wei Hong
xpcs_an_inbandvalue is updated in thespeed_mode_2500function which turns on thexpcs_an_inbandmode.Moving the fixed-link fixup code to right before phylink setup to ensure no more fixup will affect the fixed-link mode configurations.
Please could you explain why this is correct, when you could simple not set priv->plat->mdio_bus_data->xpcs_an_inband = true; in intel_speed_mode_2500()?
This all seems like hacks, rather than a clean design.
Andrew
RE: [PATCH net v2 2/2] net: stmmac: move fixed-link support fixup code
Quoted 33 lines
-----Original Message-----
From: Andrew Lunn <[email protected]>
Sent: Saturday, March 18, 2023 4:03 AM
To: Sit, Michael Wei Hong <[email protected]>
Cc: Giuseppe Cavallaro <[email protected]>; Alexandre Torgue <[email protected]>; Jose Abreu <[email protected]>; David S . Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Maxime Coquelin <[email protected]>; Ong, Boon Leong <[email protected]>; [email protected]; linux- [email protected]; linux-arm- [email protected]; [email protected]; Looi, Hong Aun <[email protected]>; Voon, Weifeng <[email protected]>; Lai, Peter Jun Ann <[email protected]>
Subject: Re: [PATCH net v2 2/2] net: stmmac: move fixed-link support fixup codeQuoted 1 line · Michael Sit Wei Hong
xpcs_an_inbandvalue is updated in thespeed_mode_2500function which
Quoted 3 lines
turns on the
xpcs_an_inbandmode.Moving the fixed-link fixup code to right before phylink setup
to
Quoted 1 line
ensure no more fixup will affect the fixed-link mode
configurations.
Quoted 7 lines
Please could you explain why this is correct, when you could simple not set
priv->plat->mdio_bus_data->xpcs_an_inband= true; inintel_speed_mode_2500()?This all seems like hacks, rather than a clean design.
Andrew
Makes sense, will test out with your suggestion and submit the changes in next version, will feedback if there is any findings.
Quoted 2 lines · Michael Sit Wei Hong
After the fixed link support was introduced, it is observed that PHY no longer attach to the MAC properly.
You are aware, I hope, that fixed-link and having a PHY are mutually exclusive?
In other words, you can't use fixed-link to specify parameters for a PHY.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Quoted 24 lines
-----Original Message-----
From: Russell King <[email protected]>
Sent: Saturday, March 18, 2023 4:54 AM
To: Sit, Michael Wei Hong <[email protected]>
Cc: Giuseppe Cavallaro <[email protected]>; Alexandre Torgue <[email protected]>; Jose Abreu <[email protected]>; David S . Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Maxime Coquelin <[email protected]>; Ong, Boon Leong <[email protected]>; [email protected]; linux- [email protected]; linux-arm- [email protected]; [email protected]; Looi, Hong Aun <[email protected]>; Voon, Weifeng <[email protected]>; Lai, Peter Jun Ann <[email protected]>
Subject: Re: [PATCH net v2 0/2] Fix PHY handle no longer parsingQuoted 1 line · Michael Sit Wei Hong
After the fixed link support was introduced, it is observed that
Quoted 9 lines
PHY
Quoted 1 line
no longer attach to the MAC properly.
You are aware, I hope, that fixed-link and having a PHY are mutually exclusive?
In other words, you can't use fixed-link to specify parameters for a PHY.
Yes but when the fixed-link support code was added, all our non fixed-link devices are not attaching the PHYs to the MACs, hence the reason for this patch series, to ensure both fixed-link and non fixed-link scenarios work properly.
Quoted 5 lines
--
RMK's Patch system:
https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 30 lines · Michael Wei Hong
Quoted 30 lines
-----Original Message-----
From: Russell King <[email protected]>
Sent: Saturday, March 18, 2023 4:54 AM
To: Sit, Michael Wei Hong <[email protected]>
Cc: Giuseppe Cavallaro <[email protected]>; Alexandre Torgue <[email protected]>; Jose Abreu <[email protected]>; David S . Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Maxime Coquelin <[email protected]>; Ong, Boon Leong <[email protected]>; [email protected]; linux- [email protected]; linux-arm- [email protected]; [email protected]; Looi, Hong Aun <[email protected]>; Voon, Weifeng <[email protected]>; Lai, Peter Jun Ann <[email protected]>
Subject: Re: [PATCH net v2 0/2] Fix PHY handle no longer parsingQuoted 1 line · Michael Sit Wei Hong
After the fixed link support was introduced, it is observed that
PHY
Quoted 1 line
no longer attach to the MAC properly.
You are aware, I hope, that fixed-link and having a PHY are mutually exclusive?
Quoted 7 lines
Quoted 3 lines
In other words, you can't use fixed-link to specify parameters for a PHY.
Yes but when the fixed-link support code was added, all our non fixed-link devices are not attaching the PHYs to the MACs, hence the reason for this patch series, to ensure both fixed-link and non fixed-link scenarios work properly.
Ah, it's the "there should be a PHY here" case you're trying to cater for, rather than actually a fixed-link.
So, how about adding a helper that is basically:
bool phylink_expects_phy(struct phylink *phylink)
{
return pl->cfg_link_an_mode == MLO_AN_PHY;
}EXPORT_SYMBOL_GPL(phylink_expects_phy);
and use that to test whether you need to manually find a PHY to attach, rather than trying to detect whether a fixed-link stanza appears in firmware?
Thanks.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!