6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Linmao Li [ Upstream commit 85b4bc79dde77aadda0929a22f3532b208a3e1f8 ] r8152 detects carrier from PLA_PHYSTATUS without reading BMSR, so BMSR_LSTATUS can remain latched low after link up. Since commit f6f2e946aa4d ("net: mii: Fix the Speed display when the network cable is not connected"), the first speed query can then report SPEED_UNKNOWN, which applications such as NetworkManager may cache until the next carrier change. Use BMSR_LSTATUS in set_carrier() so a latched link down can turn carrier off after the link has recovered. If BMSR reports down but PLA_PHYSTATUS reports up, reschedule the link work to read the current state without waiting for another notification. Tested on an RTL8153B: NetworkManager reported 1000 Mb/s after 3 of 3 rebinds, instead of an unknown speed. Fixes: f6f2e946aa4d ("net: mii: Fix the Speed display when the network cable is not connected") Cc: stable@vger.kernel.org Suggested-by: Hayes Wang Signed-off-by: Linmao Li Reviewed-by: Hayes Wang Link: https://patch.msgid.link/20261026012345.1902285-1-lilinmao@kylinos.cn Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- drivers/net/usb/r8152.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 8cf4e81f8f882..7b9923b6480e6 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -6785,11 +6785,8 @@ static void set_carrier(struct r8152 *tp) { struct net_device *netdev = tp->netdev; struct napi_struct *napi = &tp->napi; - u16 speed; - - speed = rtl8152_get_speed(tp); - if (speed & LINK_STATUS) { + if (r8152_mdio_read(tp, MII_BMSR) & BMSR_LSTATUS) { if (!netif_carrier_ok(netdev)) { tp->rtl_ops.enable(tp); netif_stop_queue(netdev); @@ -6815,6 +6812,11 @@ static void set_carrier(struct r8152 *tp) tasklet_enable(&tp->tx_tl); netif_info(tp, link, netdev, "carrier off\n"); } + + if (rtl8152_get_speed(tp) & LINK_STATUS) { + set_bit(RTL8152_LINK_CHG, &tp->flags); + schedule_delayed_work(&tp->schedule, 0); + } } } -- 2.53.0