* [PATCH net v1 0/2] Fix 'ethtool --show-eee' during initial stage
@ 2024-11-14 8:16 Choong Yong Liang
2024-11-14 8:16 ` [PATCH net v1 1/2] net: phy: set eee_cfg based on PHY configuration Choong Yong Liang
2024-11-14 8:16 ` [PATCH net v1 2/2] net: stmmac: set initial EEE policy configuration Choong Yong Liang
0 siblings, 2 replies; 9+ messages in thread
From: Choong Yong Liang @ 2024-11-14 8:16 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit, Russell King, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexandre Torgue,
Jose Abreu, Maxime Coquelin, Oleksij Rempel
Cc: netdev, linux-kernel, linux-stm32, linux-arm-kernel
The commit 49168d1980e2
("net: phy: Add phy_support_eee() indicating MAC support EEE") introduced
phy_support_eee() to set eee_cfg.tx_lpi_enabled and eee_cfg.eee_enabled to
true as the default value. However, not all PHYs have EEE enabled by default.
For example, Marvell PHYs are designed to have EEE hardware disabled during
the initial state, and it needs to be configured to turn it on again.
When the MAC boots up with a Marvell PHY and phy_support_eee() is implemented,
the 'ethtool --show-eee' command shows that EEE is enabled, but in actuality,
the driver side is disabled. If we try to enable EEE through
'ethtool --set-eee' for a Marvell PHY, nothing happens because the eee_cfg
matches the setting required to enable EEE in ethnl_set_eee().
This patch series will read the PHY configuration and set it as the initial
value for eee_cfg.tx_lpi_enabled and eee_cfg.eee_enabled, allowing
'ethtool --show-eee' to display the correct value during the initial stage.
Choong Yong Liang (2):
net: phy: set eee_cfg based on PHY configuration
net: stmmac: set initial EEE policy configuration
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
drivers/net/phy/phy_device.c | 7 +++++--
2 files changed, 6 insertions(+), 3 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net v1 1/2] net: phy: set eee_cfg based on PHY configuration
2024-11-14 8:16 [PATCH net v1 0/2] Fix 'ethtool --show-eee' during initial stage Choong Yong Liang
@ 2024-11-14 8:16 ` Choong Yong Liang
2024-11-14 9:23 ` Russell King (Oracle)
2024-11-14 8:16 ` [PATCH net v1 2/2] net: stmmac: set initial EEE policy configuration Choong Yong Liang
1 sibling, 1 reply; 9+ messages in thread
From: Choong Yong Liang @ 2024-11-14 8:16 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit, Russell King, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexandre Torgue,
Jose Abreu, Maxime Coquelin, Oleksij Rempel
Cc: netdev, linux-kernel, linux-stm32, linux-arm-kernel
Not all PHYs have EEE enabled by default. For example, Marvell PHYs are
designed to have EEE hardware disabled during the initial state, and it
needs to be configured to turn it on again.
This patch reads the PHY configuration and sets it as the initial value for
eee_cfg.tx_lpi_enabled and eee_cfg.eee_enabled instead of having them set to
true by default.
Fixes: 49168d1980e2 ("net: phy: Add phy_support_eee() indicating MAC support EEE")
Cc: <stable@vger.kernel.org>
Signed-off-by: Choong Yong Liang <yong.liang.choong@linux.intel.com>
---
drivers/net/phy/phy_device.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 499797646580..b4fa40c2371a 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -3010,9 +3010,12 @@ EXPORT_SYMBOL_GPL(phy_advertise_eee_all);
*/
void phy_support_eee(struct phy_device *phydev)
{
+ bool is_enabled = true;
+
+ genphy_c45_eee_is_active(phydev, NULL, NULL, &is_enabled);
linkmode_copy(phydev->advertising_eee, phydev->supported_eee);
- phydev->eee_cfg.tx_lpi_enabled = true;
- phydev->eee_cfg.eee_enabled = true;
+ phydev->eee_cfg.tx_lpi_enabled = is_enabled;
+ phydev->eee_cfg.eee_enabled = is_enabled;
}
EXPORT_SYMBOL(phy_support_eee);
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net v1 2/2] net: stmmac: set initial EEE policy configuration
2024-11-14 8:16 [PATCH net v1 0/2] Fix 'ethtool --show-eee' during initial stage Choong Yong Liang
2024-11-14 8:16 ` [PATCH net v1 1/2] net: phy: set eee_cfg based on PHY configuration Choong Yong Liang
@ 2024-11-14 8:16 ` Choong Yong Liang
2024-11-14 14:19 ` Andrew Lunn
1 sibling, 1 reply; 9+ messages in thread
From: Choong Yong Liang @ 2024-11-14 8:16 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit, Russell King, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexandre Torgue,
Jose Abreu, Maxime Coquelin, Oleksij Rempel
Cc: netdev, linux-kernel, linux-stm32, linux-arm-kernel
Set the initial eee_cfg values to have 'ethtool --show-eee ' display
the initial EEE configuration.
Fixes: 49168d1980e2 ("net: phy: Add phy_support_eee() indicating MAC support EEE")
Cc: <stable@vger.kernel.org>
Signed-off-by: Choong Yong Liang <yong.liang.choong@linux.intel.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 7bf275f127c9..5fce52a9412e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1204,7 +1204,7 @@ static int stmmac_init_phy(struct net_device *dev)
netdev_err(priv->dev, "no phy at addr %d\n", addr);
return -ENODEV;
}
-
+ phy_support_eee(phydev);
ret = phylink_connect_phy(priv->phylink, phydev);
} else {
fwnode_handle_put(phy_fwnode);
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH net v1 1/2] net: phy: set eee_cfg based on PHY configuration
2024-11-14 8:16 ` [PATCH net v1 1/2] net: phy: set eee_cfg based on PHY configuration Choong Yong Liang
@ 2024-11-14 9:23 ` Russell King (Oracle)
2024-11-14 10:05 ` Russell King (Oracle)
0 siblings, 1 reply; 9+ messages in thread
From: Russell King (Oracle) @ 2024-11-14 9:23 UTC (permalink / raw)
To: Choong Yong Liang
Cc: Andrew Lunn, Heiner Kallweit, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Alexandre Torgue, Jose Abreu,
Maxime Coquelin, Oleksij Rempel, netdev, linux-kernel,
linux-stm32, linux-arm-kernel
On Thu, Nov 14, 2024 at 04:16:52PM +0800, Choong Yong Liang wrote:
> Not all PHYs have EEE enabled by default. For example, Marvell PHYs are
> designed to have EEE hardware disabled during the initial state, and it
> needs to be configured to turn it on again.
>
> This patch reads the PHY configuration and sets it as the initial value for
> eee_cfg.tx_lpi_enabled and eee_cfg.eee_enabled instead of having them set to
> true by default.
eee_cfg.tx_lpi_enabled is something phylib tracks, and it merely means
that LPI needs to be enabled at the MAC if EEE was negotiated:
* @tx_lpi_enabled: Whether the interface should assert its tx lpi, given
* that eee was negotiated.
eee_cfg.eee_enabled means that EEE mode was enabled - which is user
configuration:
* @eee_enabled: EEE configured mode (enabled/disabled).
phy_probe() reads the initial PHY state and sets things up
appropriately.
However, there is a point where the EEE configuration (advertisement,
and therefore eee_enabled state) is written to the PHY, and that should
be config_aneg(). Looking at the Marvell driver, it's calling
genphy_config_aneg() which eventually calls
genphy_c45_an_config_eee_aneg() which does this (via
__genphy_config_aneg()).
Please investigate why the hardware state is going out of sync with the
software state.
Thanks.
> void phy_support_eee(struct phy_device *phydev)
> {
> + bool is_enabled = true;
> +
> + genphy_c45_eee_is_active(phydev, NULL, NULL, &is_enabled);
> linkmode_copy(phydev->advertising_eee, phydev->supported_eee);
> - phydev->eee_cfg.tx_lpi_enabled = true;
> - phydev->eee_cfg.eee_enabled = true;
> + phydev->eee_cfg.tx_lpi_enabled = is_enabled;
> + phydev->eee_cfg.eee_enabled = is_enabled;
This is almost certainly incorrect, because eee_enabled should only
be set when phydev->advertising_eee (which should track the hardware
EEE advertisement programmed into the PHY) is non-zero.
Note that phy_support_eee() must be called _before_ phy_start(). I
haven't checked whether stmmac does this.
Thanks.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net v1 1/2] net: phy: set eee_cfg based on PHY configuration
2024-11-14 9:23 ` Russell King (Oracle)
@ 2024-11-14 10:05 ` Russell King (Oracle)
2024-11-14 10:16 ` Russell King (Oracle)
0 siblings, 1 reply; 9+ messages in thread
From: Russell King (Oracle) @ 2024-11-14 10:05 UTC (permalink / raw)
To: Choong Yong Liang
Cc: Andrew Lunn, Heiner Kallweit, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Alexandre Torgue, Jose Abreu,
Maxime Coquelin, Oleksij Rempel, netdev, linux-kernel,
linux-stm32, linux-arm-kernel
On Thu, Nov 14, 2024 at 09:23:48AM +0000, Russell King (Oracle) wrote:
> On Thu, Nov 14, 2024 at 04:16:52PM +0800, Choong Yong Liang wrote:
> > Not all PHYs have EEE enabled by default. For example, Marvell PHYs are
> > designed to have EEE hardware disabled during the initial state, and it
> > needs to be configured to turn it on again.
> >
> > This patch reads the PHY configuration and sets it as the initial value for
> > eee_cfg.tx_lpi_enabled and eee_cfg.eee_enabled instead of having them set to
> > true by default.
>
> eee_cfg.tx_lpi_enabled is something phylib tracks, and it merely means
> that LPI needs to be enabled at the MAC if EEE was negotiated:
>
> * @tx_lpi_enabled: Whether the interface should assert its tx lpi, given
> * that eee was negotiated.
>
> eee_cfg.eee_enabled means that EEE mode was enabled - which is user
> configuration:
>
> * @eee_enabled: EEE configured mode (enabled/disabled).
>
> phy_probe() reads the initial PHY state and sets things up
> appropriately.
>
> However, there is a point where the EEE configuration (advertisement,
> and therefore eee_enabled state) is written to the PHY, and that should
> be config_aneg(). Looking at the Marvell driver, it's calling
> genphy_config_aneg() which eventually calls
> genphy_c45_an_config_eee_aneg() which does this (via
> __genphy_config_aneg()).
>
> Please investigate why the hardware state is going out of sync with the
> software state.
I think I've found the issue.
We have phydev->eee_enabled and phydev->eee_cfg.eee_enabled, which looks
like a bug to me. We write to phydev->eee_cfg.eee_enabled in
phy_support_eee(), leaving phydev->eee_enabled untouched.
However, most other places are using phydev->eee_enabled.
This is (a) confusing and (b) wrong, and having the two members leads
to this confusion, and makes the code more difficult to follow (unless
one has already clocked that there are these two different things both
called eee_enabled).
This is my untested prototype patch to fix this - it may cause breakage
elsewhere:
diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
index c1b3576c307f..2d64d3f293e5 100644
--- a/drivers/net/phy/phy-c45.c
+++ b/drivers/net/phy/phy-c45.c
@@ -943,7 +943,7 @@ EXPORT_SYMBOL_GPL(genphy_c45_read_eee_abilities);
*/
int genphy_c45_an_config_eee_aneg(struct phy_device *phydev)
{
- if (!phydev->eee_enabled) {
+ if (!phydev->eee_cfg.eee_enabled) {
__ETHTOOL_DECLARE_LINK_MODE_MASK(adv) = {};
return genphy_c45_write_eee_adv(phydev, adv);
@@ -1576,8 +1576,6 @@ int genphy_c45_ethtool_set_eee(struct phy_device *phydev,
}
}
- phydev->eee_enabled = data->eee_enabled;
-
ret = genphy_c45_an_config_eee_aneg(phydev);
if (ret > 0) {
ret = phy_restart_aneg(phydev);
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index bc24c9f2786b..b26bb33cd1d4 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -3589,12 +3589,12 @@ static int phy_probe(struct device *dev)
/* There is no "enabled" flag. If PHY is advertising, assume it is
* kind of enabled.
*/
- phydev->eee_enabled = !linkmode_empty(phydev->advertising_eee);
+ phydev->eee_cfg.eee_enabled = !linkmode_empty(phydev->advertising_eee);
/* Some PHYs may advertise, by default, not support EEE modes. So,
* we need to clean them.
*/
- if (phydev->eee_enabled)
+ if (phydev->eee_cfg.eee_enabled)
linkmode_and(phydev->advertising_eee, phydev->supported_eee,
phydev->advertising_eee);
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 1e4127c495c0..33905e9672a7 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -601,7 +601,6 @@ struct macsec_ops;
* @adv_old: Saved advertised while power saving for WoL
* @supported_eee: supported PHY EEE linkmodes
* @advertising_eee: Currently advertised EEE linkmodes
- * @eee_enabled: Flag indicating whether the EEE feature is enabled
* @enable_tx_lpi: When True, MAC should transmit LPI to PHY
* @eee_cfg: User configuration of EEE
* @lp_advertising: Current link partner advertised linkmodes
@@ -721,7 +720,6 @@ struct phy_device {
/* used for eee validation and configuration*/
__ETHTOOL_DECLARE_LINK_MODE_MASK(supported_eee);
__ETHTOOL_DECLARE_LINK_MODE_MASK(advertising_eee);
- bool eee_enabled;
/* Host supported PHY interface types. Should be ignored if empty. */
DECLARE_PHY_INTERFACE_MASK(host_interfaces);
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH net v1 1/2] net: phy: set eee_cfg based on PHY configuration
2024-11-14 10:05 ` Russell King (Oracle)
@ 2024-11-14 10:16 ` Russell King (Oracle)
2024-11-15 1:46 ` Choong Yong Liang
0 siblings, 1 reply; 9+ messages in thread
From: Russell King (Oracle) @ 2024-11-14 10:16 UTC (permalink / raw)
To: Choong Yong Liang
Cc: Andrew Lunn, Heiner Kallweit, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Alexandre Torgue, Jose Abreu,
Maxime Coquelin, Oleksij Rempel, netdev, linux-kernel,
linux-stm32, linux-arm-kernel
On Thu, Nov 14, 2024 at 10:05:52AM +0000, Russell King (Oracle) wrote:
> On Thu, Nov 14, 2024 at 09:23:48AM +0000, Russell King (Oracle) wrote:
> > On Thu, Nov 14, 2024 at 04:16:52PM +0800, Choong Yong Liang wrote:
> > > Not all PHYs have EEE enabled by default. For example, Marvell PHYs are
> > > designed to have EEE hardware disabled during the initial state, and it
> > > needs to be configured to turn it on again.
> > >
> > > This patch reads the PHY configuration and sets it as the initial value for
> > > eee_cfg.tx_lpi_enabled and eee_cfg.eee_enabled instead of having them set to
> > > true by default.
> >
> > eee_cfg.tx_lpi_enabled is something phylib tracks, and it merely means
> > that LPI needs to be enabled at the MAC if EEE was negotiated:
> >
> > * @tx_lpi_enabled: Whether the interface should assert its tx lpi, given
> > * that eee was negotiated.
> >
> > eee_cfg.eee_enabled means that EEE mode was enabled - which is user
> > configuration:
> >
> > * @eee_enabled: EEE configured mode (enabled/disabled).
> >
> > phy_probe() reads the initial PHY state and sets things up
> > appropriately.
> >
> > However, there is a point where the EEE configuration (advertisement,
> > and therefore eee_enabled state) is written to the PHY, and that should
> > be config_aneg(). Looking at the Marvell driver, it's calling
> > genphy_config_aneg() which eventually calls
> > genphy_c45_an_config_eee_aneg() which does this (via
> > __genphy_config_aneg()).
> >
> > Please investigate why the hardware state is going out of sync with the
> > software state.
>
> I think I've found the issue.
>
> We have phydev->eee_enabled and phydev->eee_cfg.eee_enabled, which looks
> like a bug to me. We write to phydev->eee_cfg.eee_enabled in
> phy_support_eee(), leaving phydev->eee_enabled untouched.
>
> However, most other places are using phydev->eee_enabled.
>
> This is (a) confusing and (b) wrong, and having the two members leads
> to this confusion, and makes the code more difficult to follow (unless
> one has already clocked that there are these two different things both
> called eee_enabled).
>
> This is my untested prototype patch to fix this - it may cause breakage
> elsewhere:
As mentioned in the other thread:
Without a call to phy_support_eee():
EEE settings for eth2:
EEE status: disabled
Tx LPI: disabled
Supported EEE link modes: 100baseT/Full
1000baseT/Full
Advertised EEE link modes: Not reported
Link partner advertised EEE link modes: 100baseT/Full
1000baseT/Full
With a call to phy_support_eee():
EEE settings for eth2:
EEE status: enabled - active
Tx LPI: 0 (us)
Supported EEE link modes: 100baseT/Full
1000baseT/Full
Advertised EEE link modes: 100baseT/Full
1000baseT/Full
Link partner advertised EEE link modes: 100baseT/Full
1000baseT/Full
So the EEE status is now behaving correctly, and the Marvell PHY is
being programmed with the advertisement correctly.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net v1 2/2] net: stmmac: set initial EEE policy configuration
2024-11-14 8:16 ` [PATCH net v1 2/2] net: stmmac: set initial EEE policy configuration Choong Yong Liang
@ 2024-11-14 14:19 ` Andrew Lunn
2024-11-15 1:45 ` Choong Yong Liang
0 siblings, 1 reply; 9+ messages in thread
From: Andrew Lunn @ 2024-11-14 14:19 UTC (permalink / raw)
To: Choong Yong Liang
Cc: Heiner Kallweit, Russell King, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Alexandre Torgue, Jose Abreu,
Maxime Coquelin, Oleksij Rempel, netdev, linux-kernel,
linux-stm32, linux-arm-kernel
On Thu, Nov 14, 2024 at 04:16:53PM +0800, Choong Yong Liang wrote:
> Set the initial eee_cfg values to have 'ethtool --show-eee ' display
> the initial EEE configuration.
>
> Fixes: 49168d1980e2 ("net: phy: Add phy_support_eee() indicating MAC support EEE")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Choong Yong Liang <yong.liang.choong@linux.intel.com>
> ---
> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 7bf275f127c9..5fce52a9412e 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -1204,7 +1204,7 @@ static int stmmac_init_phy(struct net_device *dev)
> netdev_err(priv->dev, "no phy at addr %d\n", addr);
> return -ENODEV;
> }
> -
> + phy_support_eee(phydev);
> ret = phylink_connect_phy(priv->phylink, phydev);
Is supporting EEE a synthesis option, or is it always available?
Some EEE code is guarded by:
if (!priv->dma_cap.eee)
return -EOPNOTSUPP;
Andrew
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net v1 2/2] net: stmmac: set initial EEE policy configuration
2024-11-14 14:19 ` Andrew Lunn
@ 2024-11-15 1:45 ` Choong Yong Liang
0 siblings, 0 replies; 9+ messages in thread
From: Choong Yong Liang @ 2024-11-15 1:45 UTC (permalink / raw)
To: Andrew Lunn
Cc: Heiner Kallweit, Russell King, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Alexandre Torgue, Jose Abreu,
Maxime Coquelin, Oleksij Rempel, netdev, linux-kernel,
linux-stm32, linux-arm-kernel
On 14/11/2024 10:19 pm, Andrew Lunn wrote:
> On Thu, Nov 14, 2024 at 04:16:53PM +0800, Choong Yong Liang wrote:
>> Set the initial eee_cfg values to have 'ethtool --show-eee ' display
>> the initial EEE configuration.
>>
>> Fixes: 49168d1980e2 ("net: phy: Add phy_support_eee() indicating MAC support EEE")
>> Cc: <stable@vger.kernel.org>
>> Signed-off-by: Choong Yong Liang <yong.liang.choong@linux.intel.com>
>> ---
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>> index 7bf275f127c9..5fce52a9412e 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>> @@ -1204,7 +1204,7 @@ static int stmmac_init_phy(struct net_device *dev)
>> netdev_err(priv->dev, "no phy at addr %d\n", addr);
>> return -ENODEV;
>> }
>> -
>> + phy_support_eee(phydev);
>> ret = phylink_connect_phy(priv->phylink, phydev);
>
> Is supporting EEE a synthesis option, or is it always available?
>
> Some EEE code is guarded by:
>
> if (!priv->dma_cap.eee)
> return -EOPNOTSUPP;
>
> Andrew
It's a synthesis option that should check priv->dma_cap.eee before setting
EEE. I will update it in the next version.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net v1 1/2] net: phy: set eee_cfg based on PHY configuration
2024-11-14 10:16 ` Russell King (Oracle)
@ 2024-11-15 1:46 ` Choong Yong Liang
0 siblings, 0 replies; 9+ messages in thread
From: Choong Yong Liang @ 2024-11-15 1:46 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Andrew Lunn, Heiner Kallweit, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Alexandre Torgue, Jose Abreu,
Maxime Coquelin, Oleksij Rempel, netdev, linux-kernel,
linux-stm32, linux-arm-kernel
On 14/11/2024 6:16 pm, Russell King (Oracle) wrote:
> On Thu, Nov 14, 2024 at 10:05:52AM +0000, Russell King (Oracle) wrote:
>> On Thu, Nov 14, 2024 at 09:23:48AM +0000, Russell King (Oracle) wrote:
>>> On Thu, Nov 14, 2024 at 04:16:52PM +0800, Choong Yong Liang wrote:
>>>> Not all PHYs have EEE enabled by default. For example, Marvell PHYs are
>>>> designed to have EEE hardware disabled during the initial state, and it
>>>> needs to be configured to turn it on again.
>>>>
>>>> This patch reads the PHY configuration and sets it as the initial value for
>>>> eee_cfg.tx_lpi_enabled and eee_cfg.eee_enabled instead of having them set to
>>>> true by default.
>>>
>>> eee_cfg.tx_lpi_enabled is something phylib tracks, and it merely means
>>> that LPI needs to be enabled at the MAC if EEE was negotiated:
>>>
>>> * @tx_lpi_enabled: Whether the interface should assert its tx lpi, given
>>> * that eee was negotiated.
>>>
>>> eee_cfg.eee_enabled means that EEE mode was enabled - which is user
>>> configuration:
>>>
>>> * @eee_enabled: EEE configured mode (enabled/disabled).
>>>
>>> phy_probe() reads the initial PHY state and sets things up
>>> appropriately.
>>>
>>> However, there is a point where the EEE configuration (advertisement,
>>> and therefore eee_enabled state) is written to the PHY, and that should
>>> be config_aneg(). Looking at the Marvell driver, it's calling
>>> genphy_config_aneg() which eventually calls
>>> genphy_c45_an_config_eee_aneg() which does this (via
>>> __genphy_config_aneg()).
>>>
>>> Please investigate why the hardware state is going out of sync with the
>>> software state.
>>
>> I think I've found the issue.
>>
>> We have phydev->eee_enabled and phydev->eee_cfg.eee_enabled, which looks
>> like a bug to me. We write to phydev->eee_cfg.eee_enabled in
>> phy_support_eee(), leaving phydev->eee_enabled untouched.
>>
>> However, most other places are using phydev->eee_enabled.
>>
>> This is (a) confusing and (b) wrong, and having the two members leads
>> to this confusion, and makes the code more difficult to follow (unless
>> one has already clocked that there are these two different things both
>> called eee_enabled).
>>
>> This is my untested prototype patch to fix this - it may cause breakage
>> elsewhere:
>
> As mentioned in the other thread:
>
> Without a call to phy_support_eee():
>
> EEE settings for eth2:
> EEE status: disabled
> Tx LPI: disabled
> Supported EEE link modes: 100baseT/Full
> 1000baseT/Full
> Advertised EEE link modes: Not reported
> Link partner advertised EEE link modes: 100baseT/Full
> 1000baseT/Full
>
> With a call to phy_support_eee():
>
> EEE settings for eth2:
> EEE status: enabled - active
> Tx LPI: 0 (us)
> Supported EEE link modes: 100baseT/Full
> 1000baseT/Full
> Advertised EEE link modes: 100baseT/Full
> 1000baseT/Full
> Link partner advertised EEE link modes: 100baseT/Full
> 1000baseT/Full
>
> So the EEE status is now behaving correctly, and the Marvell PHY is
> being programmed with the advertisement correctly.
>
Thank you for all the suggestions, the provided prototype, and the tested
results.
I will study the suggestions in depth, test the provided prototype, and
provide more feedback.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-11-15 1:47 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-14 8:16 [PATCH net v1 0/2] Fix 'ethtool --show-eee' during initial stage Choong Yong Liang
2024-11-14 8:16 ` [PATCH net v1 1/2] net: phy: set eee_cfg based on PHY configuration Choong Yong Liang
2024-11-14 9:23 ` Russell King (Oracle)
2024-11-14 10:05 ` Russell King (Oracle)
2024-11-14 10:16 ` Russell King (Oracle)
2024-11-15 1:46 ` Choong Yong Liang
2024-11-14 8:16 ` [PATCH net v1 2/2] net: stmmac: set initial EEE policy configuration Choong Yong Liang
2024-11-14 14:19 ` Andrew Lunn
2024-11-15 1:45 ` Choong Yong Liang
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).