be7136b375154ef3767511ab61709a6244e2d2e0
[openwrt/staging/wigyori.git] /
1 From 68d5cd09e8919679ce13b85950debea4b2e98e04 Mon Sep 17 00:00:00 2001
2 From: Daniel Golle <daniel@makrotopia.org>
3 Date: Thu, 10 Oct 2024 14:07:26 +0100
4 Subject: [PATCH 4/5] net: phy: realtek: change order of calls in C22
5 read_status()
6
7 Always call rtlgen_read_status() first, so genphy_read_status() which
8 is called by it clears bits in case auto-negotiation has not completed.
9 Also clear 10GBT link-partner advertisement bits in case auto-negotiation
10 is disabled or has not completed.
11
12 Suggested-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
13 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
14 Link: https://patch.msgid.link/b15929a41621d215c6b2b57393368086589569ec.1728565530.git.daniel@makrotopia.org
15 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
16 ---
17 drivers/net/phy/realtek.c | 22 +++++++++++++++-------
18 1 file changed, 15 insertions(+), 7 deletions(-)
19
20 --- a/drivers/net/phy/realtek.c
21 +++ b/drivers/net/phy/realtek.c
22 @@ -949,17 +949,25 @@ static void rtl822xb_update_interface(st
23
24 static int rtl822x_read_status(struct phy_device *phydev)
25 {
26 - if (phydev->autoneg == AUTONEG_ENABLE) {
27 - int lpadv = phy_read_paged(phydev, 0xa5d, 0x13);
28 + int lpadv, ret;
29
30 - if (lpadv < 0)
31 - return lpadv;
32 + ret = rtlgen_read_status(phydev);
33 + if (ret < 0)
34 + return ret;
35
36 - mii_10gbt_stat_mod_linkmode_lpa_t(phydev->lp_advertising,
37 - lpadv);
38 + if (phydev->autoneg == AUTONEG_DISABLE ||
39 + !phydev->autoneg_complete) {
40 + mii_10gbt_stat_mod_linkmode_lpa_t(phydev->lp_advertising, 0);
41 + return 0;
42 }
43
44 - return rtlgen_read_status(phydev);
45 + lpadv = phy_read_paged(phydev, 0xa5d, 0x13);
46 + if (lpadv < 0)
47 + return lpadv;
48 +
49 + mii_10gbt_stat_mod_linkmode_lpa_t(phydev->lp_advertising, lpadv);
50 +
51 + return 0;
52 }
53
54 static int rtl822xb_read_status(struct phy_device *phydev)