RE: [PATCH net v2] r8152: Use BMSR to detect the link state
From: Hayes Wang
Date: Mon Oct 19 2026 - 08:16:04 EST
Linmao Li <lilinmao@xxxxxxxxxx>
> Sent: Friday, October 16, 2026 3:16 PM
[...]
> Option a) addresses only the speed regression. It keeps the existing
> PLA_PHYSTATUS carrier detection and does not improve reporting of short link
> drops that recover before the link work runs.
>
> I plan to post a) as v3 for net next week, keeping that scope explicit. Please let
> me know if you see a problem with this approach.
I tested the following patch, and it works for me. It might be useful as a reference.
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index f61686433031..398d35f6fb7b 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -6979,11 +6979,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);
@@ -7009,6 +7006,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);
+ }
}
}
Best Regards,
Hayes