From nobody Sun Nov 01 18:35:34 2026 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jHk6Z3LgPz6xjgw for ; Sun, 01 Nov 2026 18:35:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jHk6Z2twSz3KQq for ; Sun, 01 Nov 2026 18:35:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793558134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hGtX0lZzKhAbEXsJSXa2FPyXBZMkk4BtqxOkiJyVbu8=; b=bNnvNvfLOoPj99VBfOGlpdx1uEjlnffBXvTvCvo7GeMlUwGFSx1CcH+vBpazBv/b/oN+FF nx1NVisVCbkFVLai1Hlci+MQDHdU6K7DgRCMz1LqZRT3EkwurISgbrIPZ1CZMJNCmsRc8U 4veJKgpvz+BjiX6PpyKHeEVuDorRj+4HoKAd5Uj4PmbpON8YJpoQs9w/807fSSqzJEN9xk eIgn8Qyzuw7l9jbiW2J3GUkPT/ubyCHutBZg1ibQ/KipAJ9JJNlXd9+Z+dk43kehZcS+15 8GJu9czkXoUpaw2xaOLpKzerlBni55KQafZmu+jYuTm1CaVCm+Lg4X+h2Q9ocw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793558134; b=i6CFHF2wTU9/Q67qmi+JTnyDZfeSPQj/pZfbUwiOfT+4q/ccfmSOJgzldtb8+ae0T0xqv8 HzGiLnoavFnreMLZPRXWWwbwi9bvrLrN+n6iKUS2g6xNi6v4fB2uQSx6u0LQJeBS1oEbnk +KtKGpCKhgwdiYBYAFmwmMmQ+OG50N7JF+kAmMpxwl+1UoG7sv/uZzo1VMXzxld4Mlhfyh gnXPVyznRVb2wwlPstNaUg6OPmJ7q057tsk0gDlpibnWxlsM1BNcoX1DeYF/pCu9biQLUE 1UPJt70yPHgddP+/kiGzPKt1BBIFJe1d2R3hwCPtCGjX4IZ+/m1wnc5w7B0mww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793558134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hGtX0lZzKhAbEXsJSXa2FPyXBZMkk4BtqxOkiJyVbu8=; b=C9oeyUEZaTCF3Qr85k74lnGA/0dwqeyux3A3J19l4KHYvaS0Ccdl8kJpLdZaKAgKjY6NCz JO3HletDlh57KFwMarivQxmxAW+a6kO4229gcVfLrUYbHSMOa/bddoRKnRrro7e+EIhs0n 7PUazMTz+13aDIRlCZxMHiNoWxBP7UulgiE5cl9sgJFbz9F6v5dzZNKN/D9VhmQhk55v3c D0dsTH2lU7sdnfrjvgHhFjPDzxYgDi/e3QmQFOtLucOc493CNmSjDdkNeLktiAdlqQPAzF 0VyhLrK7EY/lev6FAnZn7giJ7xVCmIggGOLA3lmGv1XE3gXGE3yu99E658AZrg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jHk6Z2Fc0z19G6 for ; Sun, 01 Nov 2026 18:35:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 21be9 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 01 Nov 2026 18:35:34 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Abdelkader Boudih Subject: git: f0cbd0b360c4 - stable/15 - mtw(4): Fix warm reboot initialization failures for MT7601U List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: Commits to the stable branches of the FreeBSD src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: seuros X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: f0cbd0b360c4b79a67ce1fabc2ea60d9cf47c0bf Auto-Submitted: auto-generated Date: Sun, 01 Nov 2026 18:35:34 +0000 Message-Id: <6ae78676.21be9.3bebcabd@gitrepo.freebsd.org> The branch stable/15 has been updated by seuros: URL: https://cgit.FreeBSD.org/src/commit/?id=f0cbd0b360c4b79a67ce1fabc2ea60d9cf47c0bf commit f0cbd0b360c4b79a67ce1fabc2ea60d9cf47c0bf Author: Abdelkader Boudih AuthorDate: 2026-01-14 02:35:53 +0000 Commit: Abdelkader Boudih CommitDate: 2026-11-01 16:59:38 +0000 mtw(4): Fix warm reboot initialization failures for MT7601U 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 slow. In addition in debug mode, we see thousand of error logs. This patch addresses the issue by: * Performing USB re-enumeration on attach to reset the device state * Detecting when the MCU is already marked ready (stale from previous session) and forcing a reset of the MCU before loading firmware * Increasing the firmware load timeout from 3s to 10s to accommodate slower initialization after reset * 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. Differential Revision: https://reviews.freebsd.org/D54659 Reviewed by: adrian (cherry picked from commit a24166d23d2e93e787165064fac75215d4383c65) --- sys/dev/usb/wlan/if_mtw.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/sys/dev/usb/wlan/if_mtw.c b/sys/dev/usb/wlan/if_mtw.c index 137590651948..b6d22eb65c7b 100644 --- a/sys/dev/usb/wlan/if_mtw.c +++ b/sys/dev/usb/wlan/if_mtw.c @@ -64,6 +64,7 @@ #include #include +#include #include "usbdevs.h" @@ -525,6 +526,15 @@ mtw_attach(device_t self) sc->sc_dev = self; sc->sc_sent = 0; + /* + * Reset the device to clear any stale state left over from + * a previous warm reboot. Some MT7601U devices fail otherwise. + */ + error = usbd_req_re_enumerate(uaa->device, NULL); + if (error != 0) + device_printf(self, "USB re-enumerate failed, continuing\n"); + DELAY(100000); /* 100ms settle time */ + mtx_init(&sc->sc_mtx, device_get_nameunit(sc->sc_dev), MTX_NETWORK_LOCK, MTX_DEF); @@ -585,7 +595,7 @@ mtw_attach(device_t self) sc->mac_rev = tmp & 0xffff; mtw_load_microcode(sc); - ret = msleep(&sc->fwloading, &sc->sc_mtx, 0, "fwload", 3 * hz); + ret = msleep(&sc->fwloading, &sc->sc_mtx, 0, "fwload", 10 * hz); if (ret == EWOULDBLOCK || sc->fwloading != 1) { device_printf(sc->sc_dev, "timeout waiting for MCU to initialize\n"); @@ -1104,11 +1114,22 @@ mtw_load_microcode(void *arg) // int ntries; int dlen, ilen; device_printf(sc->sc_dev, "version:0x%hx\n", sc->asic_ver); - /* is firmware already running? */ + /* + * Firmware may still be running from a previous warm reboot. + * Force a reset of the MCU to ensure a clean state. + */ mtw_read_cfg(sc, MTW_MCU_DMA_ADDR, &tmp); if (tmp == MTW_MCU_READY) { - return; + device_printf(sc->sc_dev, "MCU already running, resetting\n"); + mtw_write(sc, MTW_MCU_RESET_CTL, MTW_RESET); + DELAY(10000); + mtw_write(sc, MTW_MCU_RESET_CTL, 0); + DELAY(10000); + /* Clear ready flag */ + mtw_write_cfg(sc, MTW_MCU_DMA_ADDR, 0); + DELAY(1000); } + if (sc->asic_ver == 0x7612) { fwname = "mtw-mt7662u_rom_patch"; @@ -2847,7 +2868,7 @@ mtw_fw_callback(struct usb_xfer *xfer, usb_error_t error) } mtw_delay(sc, 10); - for (ntries = 0; ntries < 100; ntries++) { + for (ntries = 0; ntries < 300; ntries++) { if ((error = mtw_read_cfg(sc, MTW_MCU_DMA_ADDR, &tmp)) != 0) { device_printf(sc->sc_dev, @@ -2861,9 +2882,9 @@ mtw_fw_callback(struct usb_xfer *xfer, usb_error_t error) break; } - mtw_delay(sc, 10); + mtw_delay(sc, 30); } - if (ntries == 100) + if (ntries == 300) sc->fwloading = 0; wakeup(&sc->fwloading); return;