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

From: Linmao Li

Date: Fri Oct 09 2026 - 03:19:30 EST



在 2026/10/6 2:32, Birger Koblitz 写道:
Hi Linmao,

On 05/10/2026 12:52 pm, Linmao Li wrote:
r8152 detects carrier from PLA_PHYSTATUS without reading BMSR, so
BMSR_LSTATUS can still be latched low when the carrier comes up.
Since commit f6f2e946aa4d ("net: mii: Fix the Speed display when the
network cable is not connected"), the first speed query after link up
can then report SPEED_UNKNOWN, leaving NetworkManager at 0 Mb/s until
the next carrier change.

Use BMSR_LSTATUS in set_carrier() and rtl8152_runtime_resume(), so the
driver consumes the latched link down itself. If the first read still
reports link down, the next link-up notification triggers another read
and brings the carrier up.

Tested on an RTL8153B with a 6.6-based kernel. In 5 rebinds and 6 cable
replugs, the first read returned LSTATUS=0, a second link-up
notification came about 32 ms later, the second read returned
LSTATUS=1 and the carrier went up; NetworkManager reported 1000 Mb/s.
Runtime suspend/resume with the link up did not change the carrier.

I have been trying to reproduce the issue with the following adapter:
driver: r8152
version: 7.1.8+deb13-amd64
firmware-version: rtl8153a-4 v2 02/07/20

But I am not able to do so. Both after a link-up after a plugin event and after a system resume, ethtool always reports that the correct link speed and state. Could you explain, what you actually do, exactly? Or is the wrong link information only there for 32ms and I am just too slow?

Birger
Hi Birger,

Thanks for testing. Only the first BMSR read after link up returns the
latched value, so ethtool shows the problem only if nothing else reads
the PHY first. On my systems NetworkManager reads it right after
carrier up, so a later ethtool reports 1000Mb/s while NetworkManager
keeps the unknown speed it read.

With an RTL8153B on v7.3-rc6, stopping NetworkManager was enough for
ethtool alone to show it after 3 of 3 USB rebinds:

  # systemctl stop NetworkManager
  # (rebind the device, bring the interface up, wait for carrier)
  # ethtool <iface> | grep Speed
          Speed: Unknown!
  # ethtool <iface> | grep Speed
          Speed: 1000Mb/s

I got the same result with cable replugs on a 6.6-based kernel. The
latch does not time out: the first ethtool still reported Unknown 3 s
after carrier up. On the 6.6-based system, the network service of a
Chromium-based browser also read the PHY first, so other tools may
need to be stopped too. I have not checked your setup and have not
tested an RTL8153A.

Thanks,
Linmao