linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/5] r8152: Avoid writing garbage to the adapter's registers
@ 2023-10-19 21:20 Douglas Anderson
  2023-10-19 21:20 ` [PATCH v4 1/5] r8152: Increase USB control msg timeout to 5000ms as per spec Douglas Anderson
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Douglas Anderson @ 2023-10-19 21:20 UTC (permalink / raw)
  To: Jakub Kicinski, Hayes Wang, David S . Miller
  Cc: Grant Grundler, Edward Hill, linux-usb, Simon Horman, Laura Nao,
	Alan Stern, Douglas Anderson, Bjørn Mork, Eric Dumazet,
	Paolo Abeni, linux-kernel, netdev

This series is the result of a cooperative debug effort between
Realtek and the ChromeOS team. On ChromeOS, we've noticed that Realtek
Ethernet adapters can sometimes get so wedged that even a reboot of
the host can't get them to enumerate again, assuming that the adapter
was on a powered hub and din't lose power when the host rebooted. This
is sometimes seen in the ChromeOS automated testing lab. The only way
to recover adapters in this state is to manually power cycle them.

I managed to reproduce one instance of this wedging (unknown if this
is truly related to what the test lab sees) by doing this:
1. Start a flood ping from a host to the device.
2. Drop the device into kdb.
3. Wait 90 seconds.
4. Resume from kdb (the "g" command).
5. Wait another 45 seconds.

Upon analysis, Realtek realized this was happening:

1. The Linux driver was getting a "Tx timeout" after resuming from kdb
   and then trying to reset itself.
2. As part of the reset, the Linux driver was attempting to do a
   read-modify-write of the adapter's registers.
3. The read would fail (due to a timeout) and the driver pretended
   that the register contained all 0xFFs. See commit f53a7ad18959
   ("r8152: Set memory to all 0xFFs on failed reg reads")
4. The driver would take this value of all 0xFFs, modify it, and
   attempt to write it back to the adapter.
5. By this time the USB channel seemed to recover and thus we'd
   successfully write a value that was mostly 0xFFs to the adpater.
6. The adapter didn't like this and would wedge itself.

Another Engineer also managed to reproduce wedging of the Realtek
Ethernet adpater during a reboot test on an AMD Chromebook. In that
case he was sometimes seeing -EPIPE returned from the control
transfers.

This patch series fixes both issues.

Changes in v4:
- Took out some unnecessary locks/unlocks of the control mutex.
- Added comment about reading version causing probe fail if 3 fails.
- Added text to commit msg about the potential unbind/bind loop.

Changes in v3:
- Fixed v2 changelog ending up in the commit message.
- farmework -> framework in comments.

Changes in v2:
- ("Check for unplug in rtl_phy_patch_request()") new for v2.
- ("Check for unplug in r8153b_ups_en() / r8153c_ups_en()") new for v2.
- ("Rename RTL8152_UNPLUG to RTL8152_INACCESSIBLE") new for v2.
- Reset patch no longer based on retry patch, since that was dropped.
- Reset patch should be robust even if failures happen in probe.
- Switched booleans to bits in the "flags" variable.
- Check for -ENODEV instead of "udev->state == USB_STATE_NOTATTACHED"

Douglas Anderson (5):
  r8152: Increase USB control msg timeout to 5000ms as per spec
  r8152: Check for unplug in rtl_phy_patch_request()
  r8152: Check for unplug in r8153b_ups_en() / r8153c_ups_en()
  r8152: Rename RTL8152_UNPLUG to RTL8152_INACCESSIBLE
  r8152: Block future register access if register access fails

 drivers/net/usb/r8152.c | 269 +++++++++++++++++++++++++++++++---------
 1 file changed, 210 insertions(+), 59 deletions(-)

-- 
2.42.0.758.gaed0368e0e-goog


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-10-20 21:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-19 21:20 [PATCH v4 0/5] r8152: Avoid writing garbage to the adapter's registers Douglas Anderson
2023-10-19 21:20 ` [PATCH v4 1/5] r8152: Increase USB control msg timeout to 5000ms as per spec Douglas Anderson
2023-10-19 21:20 ` [PATCH v4 2/5] r8152: Check for unplug in rtl_phy_patch_request() Douglas Anderson
2023-10-19 21:20 ` [PATCH v4 3/5] r8152: Check for unplug in r8153b_ups_en() / r8153c_ups_en() Douglas Anderson
2023-10-19 21:20 ` [PATCH v4 4/5] r8152: Rename RTL8152_UNPLUG to RTL8152_INACCESSIBLE Douglas Anderson
2023-10-19 21:20 ` [PATCH v4 5/5] r8152: Block future register access if register access fails Douglas Anderson
2023-10-20 11:31   ` Hayes Wang
2023-10-20 15:42     ` Doug Anderson
2023-10-20 21:10       ` Doug Anderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).