From nobody Tue Nov 19 04:52:54 2024 X-Original-To: dev-commits-src-all@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 4XssYy51Ljz5dYJq; Tue, 19 Nov 2024 04:52:54 +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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XssYy3X8Tz4Cb7; Tue, 19 Nov 2024 04:52:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731991974; 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=JqrFOSBilJd6fYprUq4SuKOyXTux8UFohDMulHmRXiE=; b=bIM0Kx2SONq8zU9c493Y6f+KWUjzon6Ln1PzQkdTJ020kHFMyoS1krhMOt/vG2lsbctK8P XsQ7ujkVEflY88vIfW6EPsg5+tKlZj2QlNMEp0MucUYvLrPG3Gjxcm8XZ7C1Cl05lyClI/ uIMjFdYppNlZaDyRXFjEzgUS0rmB7YjaQeh3RLZ29/dF3sYyUOAPwWFJxqA6VnBk0LhjOK bgLG8zq92EgQcQgP116Zk5miGWq3sH7kt6jn4JyDHJ6xOD3IC/JyrenaiJ6PjNDmKUbStb UYmhP7Qv6ld3vJL6dwQxDE7Sx3rB+C/T5Dow/lAkA5vyT0N5Q6ewNBAvofeCWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731991974; 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=JqrFOSBilJd6fYprUq4SuKOyXTux8UFohDMulHmRXiE=; b=YxlX3PetzKEitWN5HSvFmqBXZ3Lu7oPCY+enQ9sA0FTekYZJ63wvAoka/8Bnhq3+YWqWnL RAudFyF7RWfjWColJuDQHQc3BLe7pLOwlsG/QPkzm2BWq0lL+2lJEsDwDHduP4EFi6GDXg jQtIua4VCO/DPlp6hWh0hR4NVyD7LnMGFLQZBLZqX0SjiIDfJJX6/Yy6OIf3Mtjd1WojwT og9OovJR8b+kkqB/ONTuMMJcmMfTqCNQ6UEUHboviAbYM7/CZ1q+2VwOFps1B7LOdCHWTW HPea/5L/rZBIfPmf9o8jjBGOVk5VGt4ziw7DLtElvS3szOY4dBbXzMEYXJzMtw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1731991974; a=rsa-sha256; cv=none; b=o8clJVoVgDuZqiK/5sbIxcUniiWnthooRfQMLqDYWl2eZLxhGbR5aCtGbaCfHm0hu9+35G qyWT8gv5jrBJ/GxqW2t+oO1Mrxuwb4fdntJpLAc1LWL8SCYZojUadRqLtEACnrpCeszShE wFTEI9iNd4a742VdJ5kR4iAhJtwUCLMfyMU6olaqeyjqUZAmefR4GQ3U5p1Mq5Tl8L89L3 agZgJ7l2H9lt6e814QCFnBYv/1ULYBrjshlYMc5I+M6hYi+2gk6y3gjJ7KcZL0Aho6UNog cf49k57colDFi3TzHKp/Y2Wz7pt+lnqp1COGZvLauKXmZwLwDG/kT7lkF/s6bQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XssYy36Y4z19fN; Tue, 19 Nov 2024 04:52:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4AJ4qsnm066475; Tue, 19 Nov 2024 04:52:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4AJ4qsAe066472; Tue, 19 Nov 2024 04:52:54 GMT (envelope-from git) Date: Tue, 19 Nov 2024 04:52:54 GMT Message-Id: <202411190452.4AJ4qsAe066472@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Adrian Chadd Subject: git: 842a2c1ad396 - main - uath: flush data/commands to the firmware before changing channel / state List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: adrian X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 842a2c1ad39637e91547bf725e8b4ce8773c5935 Auto-Submitted: auto-generated The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=842a2c1ad39637e91547bf725e8b4ce8773c5935 commit 842a2c1ad39637e91547bf725e8b4ce8773c5935 Author: Adrian Chadd AuthorDate: 2024-11-18 05:12:10 +0000 Commit: Adrian Chadd CommitDate: 2024-11-19 04:50:41 +0000 uath: flush data/commands to the firmware before changing channel / state The driver wasn't stable - it would start fine, but during scan it would eventually hang and no further command endpoint transfers would complete. After adding some debugging and looking at the logs I noticed that things went sideways once a /data/ frame was sent. The channel change config happened between the data frame being sent and being completed. My guess is that the firmware doesn't like a channel change and reset whilst there's pending data frames. Checking the Linux driver I found that it was doing a flush before a channel change, and we're doing it afterwards. This acts like a fence around ensuring scheduled TX work has completed. In net80211 the transmit path and the control path aren't serialised, so it's very often the case that ioctls, state changes, etc occur whilst in parallel there are frame transmits being scheduled. This seems to happen more frequently on a more recent, high core (8) machine with XHCI. I remember testing this driver years ago on single and dual core CPU laptops with no problems. So, add some flushes - before a channel change, and during a transition to AUTH when the BSS config is being programmed into the firmware. These two fences seem enough to reliably associate as a 2GHz and 5GHz STA. Note that this isn't entirely blocking all newly queued transmit work from occuring until after the NIC has finished configuration. That will need some further investigation. Locally tested: * Wistron NuWeb AR5523 dual-band NIC, STA mode, 2/5GHz Differential Revision: https://reviews.freebsd.org/D47655 --- sys/dev/usb/wlan/if_uath.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/dev/usb/wlan/if_uath.c b/sys/dev/usb/wlan/if_uath.c index 580022f5a0c5..32e3c0325c6e 100644 --- a/sys/dev/usb/wlan/if_uath.c +++ b/sys/dev/usb/wlan/if_uath.c @@ -1831,6 +1831,8 @@ uath_set_channel(struct ieee80211com *ic) UATH_UNLOCK(sc); return; } + /* flush data & control requests into the target */ + (void)uath_flush(sc); (void)uath_switch_channel(sc, ic->ic_curchan); UATH_UNLOCK(sc); } @@ -2015,6 +2017,8 @@ uath_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) break; case IEEE80211_S_AUTH: + /* flush data & control requests into the target */ + (void)uath_flush(sc); /* XXX good place? set RTS threshold */ uath_config(sc, CFG_USER_RTS_THRESHOLD, vap->iv_rtsthreshold); /* XXX bad place */