Re: [PATCH net v2] r8152: Use BMSR to detect the link state

From: Linmao Li

Date: Mon Oct 12 2026 - 22:37:37 EST



在 2026/10/9 20:22, Andrew Lunn 写道:
Hi Hayes, Andrew,

Thanks. Since the newer ICs notify only when the link status changes,
the driver cannot rely on another link up notification after the link
has settled, so v2 can leave the carrier off when the first read
returns the latched link down.

Before sending v3, which approach would you prefer? Both fixed the
problem in my tests on an RTL8153B with v7.3-rc6:

a) Keep carrier detection on PLA_PHYSTATUS and read BMSR once before
   carrier on, only to clear the latch. This is the option I asked
   about on v1.

b) Detect carrier from BMSR and read it again when the first read
   returns link down, as genphy_update_link() does in interrupt mode.

Neither depends on another notification. Neither reports a short link
drop that recovers before the link work runs: with a) a later speed
query still sees the latched link down, with b) the latch is cleared.

Hayes, for b): is BMSR_LSTATUS reliable as the carrier source on all
chips supported by r8152?
Ideally we want a list of devices which correctly do notification on
every change of link state, and which are broken.

For those that work, read the BMSR once and report the down, and then
later on the second event, report the up.

For those devices which are broken, double read the BMSR. The danger
is, somebody who quickly unplugs and replugs the cable is not going to
get the down notification. The dhcp client will not restart, so the
old IP address will be used, for the next hour to day, and the network
is broken.

Andrew
Hi Andrew,

Thanks. In tests on my RTL8153B, down and up notifications were about
3.1 s apart after a quick cable replug, and about 3.4 s apart after
ethtool -r. A double read should still report down if the link work
runs during that interval, but I have not verified this directly.
These results do not cover shorter link interruptions or other chips.

Since this fixes a regression for net and stable, would you accept a)
there, keeping PLA_PHYSTATUS and reading BMSR once before an off-to-on
carrier transition, and moving carrier detection to BMSR with per-chip
handling as a follow-up for net-next, once the chip behaviour is known?

Hayes, to build that list: which ICs notify only on link changes? And
on any of them, does reading BMSR, which clears the latched link down,
trigger another notification? The single read depends on that. Birger
tested v2 on an RTL8157 and an RTL8153A without problems, so it would
also help to know how the RTL8157 notifies.

Thanks,
Linmao