Page MenuHomeFreeBSD

mtw(4): Fix warm reboot initialization failures for MT7601U
Needs ReviewPublic

Authored by guest-seuros on Sun, Jan 11, 10:00 PM.

Details

Reviewers
adrian
Summary

The mtw(4) driver works correctly on initial boot, but fails to initialize the MT7601U WiFi adapter after a warm reboot.
Users must either physically unplug and replug the USB adapter, or perform a full power cycle to restore functionality, if usb power is always powered (only a replug works)

The root cause is that warm reboot does not power-cycle USB devices, leaving the MT7601U in a stale state from the previous session.

The MCU retains its ready flag and the device ignores initialization commands, resulting in timeout waiting for MCU to initialize errors.

At the OS Level, pinging 1.1.1.1 will work, but the speed will be very flow . In addition in debug mode, we see thousand of error logs.

This patch addresses the issue by:

  1. Performing USB re-enumeration on attach to reset the device state
  2. Detecting when the MCU is already marked ready (stale from previous session) and forcing a reset of the MCU before loading firmware
  3. Increasing the firmware load timeout from 3s to 10s to accommodate slower initialization after reset
  4. Increasing MCU ready poll attempts from 100 to 300 with longer delays to handle devices that take longer to become ready after reset

Note: The increase was random, lower value might work.

Test Plan

Tested on MacBook Pro (late-2015) and a MacMini with MediaTek MT7601U USB adapter across multiple warm reboot cycles.

With the mac-mini and a another desktop, the issue happens only if connected via an always powered usb hub port in the monitor.
The laptop don't power cycle it power.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped