* [PATCH net] net: phy: fix save wrong speed and duplex problem if autoneg is on
@ 2021-02-26 7:44 Huazhong Tan
2021-02-26 23:56 ` Jakub Kicinski
2021-02-27 0:53 ` Andrew Lunn
0 siblings, 2 replies; 5+ messages in thread
From: Huazhong Tan @ 2021-02-26 7:44 UTC (permalink / raw)
To: andrew, f.fainelli, hkallweit1, davem, kuba
Cc: netdev, linux-kernel, Guangbin Huang, Huazhong Tan
From: Guangbin Huang <huangguangbin2@huawei.com>
If phy uses generic driver and autoneg is on, enter command
"ethtool -s eth0 speed 50" will not change phy speed actually, but
command "ethtool eth0" shows speed is 50Mb/s because phydev->speed
has been set to 50 and no update later.
And duplex setting has same problem too.
However, if autoneg is on, phy only changes speed and duplex according to
phydev->advertising, but not phydev->speed and phydev->duplex. So in this
case, phydev->speed and phydev->duplex don't need to be set in function
phy_ethtool_ksettings_set() if autoneg is on.
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
---
drivers/net/phy/phy.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 1be07e4..fc2e7cb 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -276,14 +276,16 @@ int phy_ethtool_ksettings_set(struct phy_device *phydev,
phydev->autoneg = autoneg;
- phydev->speed = speed;
+ if (autoneg == AUTONEG_DISABLE) {
+ phydev->speed = speed;
+ phydev->duplex = duplex;
+ }
linkmode_copy(phydev->advertising, advertising);
linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
phydev->advertising, autoneg == AUTONEG_ENABLE);
- phydev->duplex = duplex;
phydev->master_slave_set = cmd->base.master_slave_cfg;
phydev->mdix_ctrl = cmd->base.eth_tp_mdix_ctrl;
--
2.7.4
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH net] net: phy: fix save wrong speed and duplex problem if autoneg is on
2021-02-26 7:44 [PATCH net] net: phy: fix save wrong speed and duplex problem if autoneg is on Huazhong Tan
@ 2021-02-26 23:56 ` Jakub Kicinski
2021-02-27 1:27 ` Huazhong Tan
2021-02-27 0:53 ` Andrew Lunn
1 sibling, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2021-02-26 23:56 UTC (permalink / raw)
To: Huazhong Tan
Cc: andrew, f.fainelli, hkallweit1, davem, netdev, linux-kernel,
Guangbin Huang
On Fri, 26 Feb 2021 15:44:42 +0800 Huazhong Tan wrote:
> From: Guangbin Huang <huangguangbin2@huawei.com>
>
> If phy uses generic driver and autoneg is on, enter command
> "ethtool -s eth0 speed 50" will not change phy speed actually, but
> command "ethtool eth0" shows speed is 50Mb/s because phydev->speed
> has been set to 50 and no update later.
>
> And duplex setting has same problem too.
>
> However, if autoneg is on, phy only changes speed and duplex according to
> phydev->advertising, but not phydev->speed and phydev->duplex. So in this
> case, phydev->speed and phydev->duplex don't need to be set in function
> phy_ethtool_ksettings_set() if autoneg is on.
Can we get a Fixes tag for this one? How far back does this behavior
date?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] net: phy: fix save wrong speed and duplex problem if autoneg is on
2021-02-26 23:56 ` Jakub Kicinski
@ 2021-02-27 1:27 ` Huazhong Tan
0 siblings, 0 replies; 5+ messages in thread
From: Huazhong Tan @ 2021-02-27 1:27 UTC (permalink / raw)
To: Jakub Kicinski
Cc: andrew, f.fainelli, hkallweit1, davem, netdev, linux-kernel,
Guangbin Huang
On 2021/2/27 7:56, Jakub Kicinski wrote:
> On Fri, 26 Feb 2021 15:44:42 +0800 Huazhong Tan wrote:
>> From: Guangbin Huang <huangguangbin2@huawei.com>
>>
>> If phy uses generic driver and autoneg is on, enter command
>> "ethtool -s eth0 speed 50" will not change phy speed actually, but
>> command "ethtool eth0" shows speed is 50Mb/s because phydev->speed
>> has been set to 50 and no update later.
>>
>> And duplex setting has same problem too.
>>
>> However, if autoneg is on, phy only changes speed and duplex according to
>> phydev->advertising, but not phydev->speed and phydev->duplex. So in this
>> case, phydev->speed and phydev->duplex don't need to be set in function
>> phy_ethtool_ksettings_set() if autoneg is on.
> Can we get a Fixes tag for this one? How far back does this behavior
> date?
will add a fixes tag in V2, thanks.
> .
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] net: phy: fix save wrong speed and duplex problem if autoneg is on
2021-02-26 7:44 [PATCH net] net: phy: fix save wrong speed and duplex problem if autoneg is on Huazhong Tan
2021-02-26 23:56 ` Jakub Kicinski
@ 2021-02-27 0:53 ` Andrew Lunn
2021-02-27 1:27 ` Huazhong Tan
1 sibling, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2021-02-27 0:53 UTC (permalink / raw)
To: Huazhong Tan
Cc: f.fainelli, hkallweit1, davem, kuba, netdev, linux-kernel,
Guangbin Huang
On Fri, Feb 26, 2021 at 03:44:42PM +0800, Huazhong Tan wrote:
> From: Guangbin Huang <huangguangbin2@huawei.com>
>
> If phy uses generic driver and autoneg is on, enter command
> "ethtool -s eth0 speed 50" will not change phy speed actually, but
> command "ethtool eth0" shows speed is 50Mb/s because phydev->speed
> has been set to 50 and no update later.
>
> And duplex setting has same problem too.
>
> However, if autoneg is on, phy only changes speed and duplex according to
> phydev->advertising, but not phydev->speed and phydev->duplex. So in this
> case, phydev->speed and phydev->duplex don't need to be set in function
> phy_ethtool_ksettings_set() if autoneg is on.
>
> Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
I'm not sure, but i think this happens after
commit 51e2a3846eab18711f4eb59cd0a4c33054e2980a
Author: Trent Piepho <tpiepho@freescale.com>
Date: Wed Sep 24 10:55:46 2008 +0000
PHY: Avoid unnecessary aneg restarts
The PHY's aneg is configured and restarted whenever the link is brought up,
e.g. when DHCP is started after the kernel has booted. This can take the
link down for several seconds while auto-negotiation is redone.
If the advertised features haven't changed, then it shouldn't be necessary
to bring down the link and start auto-negotiation over again.
genphy_config_advert() is enhanced to return 0 when the advertised features
haven't been changed and >0 when they have been.
genphy_config_aneg() then uses this information to not call
genphy_restart_aneg() if there has been no change.
Before then, i think autoneg was unconditionally restarted, and so the
speed would get overwritten when autoneg completed. After this patch,
since autoneg is not being changed when only speed is set, autoneg is
not triggered.
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH net] net: phy: fix save wrong speed and duplex problem if autoneg is on
2021-02-27 0:53 ` Andrew Lunn
@ 2021-02-27 1:27 ` Huazhong Tan
0 siblings, 0 replies; 5+ messages in thread
From: Huazhong Tan @ 2021-02-27 1:27 UTC (permalink / raw)
To: Andrew Lunn
Cc: f.fainelli, hkallweit1, davem, kuba, netdev, linux-kernel,
Guangbin Huang
On 2021/2/27 8:53, Andrew Lunn wrote:
> On Fri, Feb 26, 2021 at 03:44:42PM +0800, Huazhong Tan wrote:
>> From: Guangbin Huang <huangguangbin2@huawei.com>
>>
>> If phy uses generic driver and autoneg is on, enter command
>> "ethtool -s eth0 speed 50" will not change phy speed actually, but
>> command "ethtool eth0" shows speed is 50Mb/s because phydev->speed
>> has been set to 50 and no update later.
>>
>> And duplex setting has same problem too.
>>
>> However, if autoneg is on, phy only changes speed and duplex according to
>> phydev->advertising, but not phydev->speed and phydev->duplex. So in this
>> case, phydev->speed and phydev->duplex don't need to be set in function
>> phy_ethtool_ksettings_set() if autoneg is on.
>>
>> Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
>> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
> I'm not sure, but i think this happens after
>
> commit 51e2a3846eab18711f4eb59cd0a4c33054e2980a
> Author: Trent Piepho <tpiepho@freescale.com>
> Date: Wed Sep 24 10:55:46 2008 +0000
>
> PHY: Avoid unnecessary aneg restarts
>
> The PHY's aneg is configured and restarted whenever the link is brought up,
> e.g. when DHCP is started after the kernel has booted. This can take the
> link down for several seconds while auto-negotiation is redone.
>
> If the advertised features haven't changed, then it shouldn't be necessary
> to bring down the link and start auto-negotiation over again.
>
> genphy_config_advert() is enhanced to return 0 when the advertised features
> haven't been changed and >0 when they have been.
>
> genphy_config_aneg() then uses this information to not call
> genphy_restart_aneg() if there has been no change.
>
> Before then, i think autoneg was unconditionally restarted, and so the
> speed would get overwritten when autoneg completed. After this patch,
> since autoneg is not being changed when only speed is set, autoneg is
> not triggered.
>
> Andrew
Thanks.
> .
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-02-27 1:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-26 7:44 [PATCH net] net: phy: fix save wrong speed and duplex problem if autoneg is on Huazhong Tan
2021-02-26 23:56 ` Jakub Kicinski
2021-02-27 1:27 ` Huazhong Tan
2021-02-27 0:53 ` Andrew Lunn
2021-02-27 1:27 ` Huazhong Tan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®