From nobody Sat Sep 26 22:01:47 2026 Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02E8335F170 for ; Sat, 29 Aug 2026 05:44:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787982257; cv=none; b=ptM7asz8zHioxUOKxI1TB3fuVoFsZU8NHUCy21rQSPDM43rZG/IdDPKUSZgsR9bVes44yonbUpY56GdaUqoq4Xt11sEMdH7+aSMVPuJQ+UaFKOBFJHRTDsSejlfW+OkHs5rv+R72QpiTg2wLPdAJZVqGeyTlYoAOa/5ZETPWQ+s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787982257; c=relaxed/simple; bh=Sx82Mbp5lO5DjoKy80dsNlSHsxmeRD7u8l6pGGCMoDw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MonkjzYcs/4yQAk0yRlK8MUC+BUamPm9SCXfzS7P5z2sLCOrcja8ZZ4hRYtTQ3Ve/DfPh3qcQ6nWBTyFAc+aCnZUL5KstCRVFWTeN3DKMTbEf79L+tGhwL5Xm8VwiC8bavgi6fBUWi08lrQe2d532+9SN5nQCe+nFen6nyQmjwM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=e78diXwd; arc=none smtp.client-ip=209.85.167.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="e78diXwd" Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-5b00d083818so2650927e87.1 for ; Fri, 28 Aug 2026 22:44:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787982254; x=1788587054; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to:content-type; bh=mKYBlq5Au3+HGNkg1vfOBKHH7P2alX9eeNg+UdnZVyg=; b=e78diXwdS7g5gUbpLAASowKGW1EdigBIid6IwdsKXL3wZwCAc5oH8Bj93zmBaLhXLS YxDdJ52dzeMKr0niuDkNuAHUhS3XFyqOc/nnfuzHTvsQL067zESg2Ffn/BBu9QUCia1t xii3oLLpJdizenTNDp+oOal0MBRlUO5VwZ++GK7lN671pGBxU36nmwkE/L4UnVrtooj0 l6OloYR/+1T6Gr0lf1KjaPy5Fco9YidMbLWTJONpTsrJ43A91Qt0OPbFW7AhEtcoarbY f4BW2gD/Fp/rlQDUvS6msHEf9+GhxsY/MGlnvD1t8Dw8nqMSKOdyvDd4evRWBtpF3EFS +hGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787982254; x=1788587054; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=mKYBlq5Au3+HGNkg1vfOBKHH7P2alX9eeNg+UdnZVyg=; b=d9rBPQZkYcQeaHrUNLqapUoomrqOp4onNeg7z2LKt3eViaicMis4R/J/qyFr5LOWmC 0HKBFFqAib2R7pfmwv3n6S9xwow5lTZmn5BbWKLiVWTPgjfml7wL4DGitUI3kb9yMgCf PJkDDx6klNA5CMs+U9ZRwPa9eCxxu1CVechzFDa7887ClGcLE3xpAM+MbChVlHF5JqDU UPEtX6DS75dnpXdE7dhjvObQ2UiInKarPBUcMLg9vVTaxoK2hCZZyKip2fapC0Cu1VXz TsAlIKRgsW0KIfR9IH3tKneSwwU2gKYu9K26NfSRvVo1GqsADTBNXNVAtwUIHiFue4Tq z47w== X-Gm-Message-State: AFuF++mtO8pXAfv7C6xe7Gn8CU+x3Zkuvtw3Hn931dPW2Lr3y8oU44ok yvrmHFb8tSeBMJmU+SO6rczAw6GGEHOvNn+8Wb49w24q1pfnOLx2qAw= X-Gm-Gg: AYBFou0WnqekPdwBWmKwfQU7LVMXiEjPkvaU8+aiyZp3krkL9Z1Cqp9/Nqh/mPlrSIb kmh9Ajy3iR+wknwVkrO7UCiAo4KejCAwKNo0wt0EMuSaJsL4dps1keXbctBJWzjE+L7l43UhhOz qmKiX2ZxEGAMDrFGufd2kJjp4Es2ZO/ZSt3wB5UFqg9kAdlNRNVFn+5FTs4HN6KVumi6unqVZTu PoEOhcazLpDcczQMXR4IJjEtK2YbTKyp0e6F2e7Wtlmd4oU7adZ/w9rGQuvJsBe73V5Vw68qEqs X0MUFceKO9oAqheV+BlapqU5q9P4krBgBjTP5cTvBVVzjEVtwCuFQcPFLSlOEBnuAqf81awPgpb a7gFDQC3vUEUovtE55VPbrjzJAea81a6e3jc8mG17BVLPeuHBMreRuHaoruH+kOwTmi3TjppLjw P1s/8W3sJEHQU+XzCXFWkVh7RKHl9HcMol2bcWgmQ42yxkmHNJGma2NcL9jBgR2G662QAW+6mvS t7RNjCB73kQVC2slDv30qxxt9HgK1ysQex36pluw+v3tU7yPHWadYw+BYQ/7zdJZ+UE08HcmbB2 6SmYOyCUCrS9Nd4= X-Received: by 2002:a05:6512:3984:b0:5b5:8382:7dbc with SMTP id 2adb3069b0e04-5b583827f4fmr4057128e87.10.1787982253727; Fri, 28 Aug 2026 22:44:13 -0700 (PDT) Received: from nn ([2001:1ab8:1003:0:5454:f357:ba89:4e22]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b5e89c5b86sm803040e87.12.2026.08.28.22.44.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2026 22:44:12 -0700 (PDT) Sender: N B From: =?UTF-8?q?Nerijus=20Bend=C5=BEi=C5=ABnas?= To: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= , linux-wireless@vger.kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 1/4] wifi: ath9k: name the register multi-read limit Date: Sat, 29 Aug 2026 08:43:58 +0300 Message-ID: <20260829054401.1198574-2-nerijus.bendziunas@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260829054401.1198574-1-nerijus.bendziunas@gmail.com> References: <20260829054401.1198574-1-nerijus.bendziunas@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable ath9k_multi_regread() converts the addresses and the results through fixed eight-entry arrays without checking the count it was given, so every REG_READ_MULTI() caller has to stay at or below eight to be safe over USB. Nothing says so. The only caller that exists today, ar9271_hw_pa_cal(), happens to ask for exactly eight. Give the limit a name next to REG_READ_MULTI(), size the arrays with it, and warn rather than write past them. Signed-off-by: Nerijus Bend=C5=BEi=C5=ABnas --- drivers/net/wireless/ath/ath9k/htc_drv_init.c | 7 +++++-- drivers/net/wireless/ath/ath9k/hw.h | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wi= reless/ath/ath9k/htc_drv_init.c index 6de78ae85726..7fdec25c76ef 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c @@ -258,10 +258,13 @@ static void ath9k_multi_regread(void *hw_priv, u32 *a= ddr, struct ath_hw *ah =3D hw_priv; struct ath_common *common =3D ath9k_hw_common(ah); struct ath9k_htc_priv *priv =3D common->priv; - __be32 tmpaddr[8]; - __be32 tmpval[8]; + __be32 tmpaddr[ATH9K_MULTI_READ_MAX]; + __be32 tmpval[ATH9K_MULTI_READ_MAX]; int i, ret; =20 + if (WARN_ON_ONCE(count > ATH9K_MULTI_READ_MAX)) + return; + for (i =3D 0; i < count; i++) { tmpaddr[i] =3D cpu_to_be32(addr[i]); } diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath= /ath9k/hw.h index b942b8303d8f..946c4d307b91 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -83,6 +83,13 @@ #define REG_READ(_ah, _reg) \ (_ah)->reg_ops.read((_ah), (_reg)) =20 +/* + * Registers a single REG_READ_MULTI() may ask for. The USB transport carr= ies + * the addresses and the results in one WMI command each, so its buffers p= ut a + * hard cap on the count; callers must split larger reads themselves. + */ +#define ATH9K_MULTI_READ_MAX 8 + #define REG_READ_MULTI(_ah, _addr, _val, _cnt) \ (_ah)->reg_ops.multi_read((_ah), (_addr), (_val), (_cnt)) =20 --=20 2.55.0 From nobody Sat Sep 26 22:01:47 2026 Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F318E35C696 for ; Sat, 29 Aug 2026 05:44:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787982260; cv=none; b=FkI2UOEOHXfZ9uQqkmLul9cE6p7dw4n273KVYouxPZluWJM+/r1UipqUM3wNwg43b4Lf+1+Keh4RjzWEZ7m/kYwgyLBIUZZXssh5Jvwvd0oHjIVqiHDaRcuv7kwSAJh8k9Ygf4oQ/PvYCiM+itBJNzpR8q4ZJggH7CUqRSOiYEc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787982260; c=relaxed/simple; bh=u5of8imVxGF2ew+VvUbCkTLZP4l169iFcid4ehUpxio=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PLyPQ21L3fLcyjSdQ1faw2tX/KHXXnCfLsOcrgwCJxgn8PSHntxS3xCP4SKc9kjgTIiYOt+DOgU9AnIJNzTQf7c41ncbQyMzKePRzX3ex5fnzHxH49kCPE4LpQj7Llt6iKQowBsEOlTpdUp+ZmuHee5fOaUnj5sdxu7iYB7d2BI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=T6R50mZm; arc=none smtp.client-ip=209.85.167.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="T6R50mZm" Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-5b5e1340faeso1537583e87.3 for ; Fri, 28 Aug 2026 22:44:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787982257; x=1788587057; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to:content-type; bh=b88tU/OTDjrhYgEzbmZ0ec+g11Uj0EOIUGAs/DiSWM0=; b=T6R50mZmkuYglRPN567HW2gNfUmpB1ukkNxmxu2I7rPKNsBHkUhnOXA+GfFXtRO3C7 XUoTIEDzOeR9trXF2Lh12GyCW7EwWplYNQ6W9nOA0z9TIJ44anoca0+kvMCPZigCqBhB nOd+Mb8hqgHAJYos7EhNa2UHkJUECKh8IFlVhtETOSyNTyehb5SJ1cr2ynoI7jTZWjZ9 tRmIzfWpqDZzYX6tPpnIYqtn3Vch0CwOpvyEnwUdFI/aRhHyxZpzXiHTBJLI8/EqMEBo SBsFfBebYVFBw+ByxI5CCT5qVG58yjmEHtG4UIsUNKAKIQjgXMFJp/xq3zDuX8KLlZyw h8Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787982257; x=1788587057; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=b88tU/OTDjrhYgEzbmZ0ec+g11Uj0EOIUGAs/DiSWM0=; b=ntHEhYpscVPi624d2RBNaH+QICgXixKlF0H7v9/TYd7PSqCPFXF+oggsuFQ4r5EFYS ak+kiFA7RdnPhooAR2ahmEAuNmiZJCglwwoCDBl+YAM3Rb6hEY+FaYgLZrhvvYw3kGI5 57QAjfShb6sqr/IiA1m2KPMW1eMKC7nr2I1KPja4ZpzFUS5oC3NGyelvKv+LgazZ44Ng rva2InmGmI4z1Lxqqtxa1z34MlgekNstny4+lMmyg1+LQMtOYsH1BNjG+jowVzsBm8An OcL2JaAtUrcQt1KD/29wEJ5EBQeIP7JmLA55Lw+oS8Q7r/86W+9oFE7pgZojRj3wLIdH phUA== X-Gm-Message-State: AFuF++ki7zTIDq4jQgj78bLhy3Qe7UjbVvxqbCk93deQAdH5Et3adpBK E6X/NGDqjhyuhPyMq59YKMDhNDtFrgN8WdiJwypq6ZIzKVn0Zc58fj4= X-Gm-Gg: AYBFou0prACBLvPDYtfuumLqhsBGPj2ERnzT3wkxVktbZi22GdnjgM6OPp1AVWd9heR x2xhx1SJ2mslGDvUo2MHFQMq0GfmbtmUWPPpDeXO+LBkKZWHbLXqvHoF8B6jahE4Yxe1Kyqj94k T7a+Vu90mb4yHdOY7BvnIxSc8ASXA/vltYNoGHi3b9GMibAPuuFByX8+yft1clqpybwCs1dEjaA Qr9Sd/xupYTNrnPaPVmJTvaC2brSEN9t7rwZwEglelcDrpNgIbtDqJketGZUoBke6N2GkXmWcvV uuBscek0RuB/zcNFWNrPxW9lU4coaYP4q6Ki8ur1Q8tuqVhUj6xpsLMS2Y0u6ZMuN2aCMSZpgaX bvPy5dxOv/flvP9xcB5mMhtm6ub6//SPhpw+Ac+r51gATPPNydtN895EGrzH6es+Xj360mbTaPT QNiqaBNTb0uym80pPQXD7Ys4f7tbLFEbAru6Q1P6ChuPuSlKsWGWhhaQgDOMu8ySwt55HZJbiwg 168u+6JMj0w/yK0zj+Vmf8KQHzwgWRCObC4vQzDxkj6HZk8FCQCeJCieLTuLRdiUWarbd3jy0hJ sx+r X-Received: by 2002:a05:6512:3b8f:b0:5b5:e2f1:e6f9 with SMTP id 2adb3069b0e04-5b5e68bc823mr3717496e87.11.1787982256843; Fri, 28 Aug 2026 22:44:16 -0700 (PDT) Received: from nn ([2001:1ab8:1003:0:5454:f357:ba89:4e22]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b5e89c5b86sm803040e87.12.2026.08.28.22.44.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2026 22:44:15 -0700 (PDT) Sender: N B From: =?UTF-8?q?Nerijus=20Bend=C5=BEi=C5=ABnas?= To: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= , linux-wireless@vger.kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 2/4] wifi: ath9k: check all tx queues with one multi-read Date: Sat, 29 Aug 2026 08:43:59 +0300 Message-ID: <20260829054401.1198574-3-nerijus.bendziunas@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260829054401.1198574-1-nerijus.bendziunas@gmail.com> References: <20260829054401.1198574-1-nerijus.bendziunas@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Before a channel change ath9k_hw_channel_change() asks ath9k_hw_numtxpending() about each of the ten queues in turn, and each call reads AR_QSTS and then AR_Q_TXE, so confirming a drained radio takes up to twenty register reads. On the USB devices those are twenty synchronous WMI round trips, paid on every hop before any tuning starts. Collect the ten queue status registers and AR_Q_TXE through REG_READ_MULTI() instead, split into chunks the transport can carry, and apply the same pending test to the results. PCI implements the multi-read as a loop of ordinary reads, so it sees no change beyond the loop moving. Signed-off-by: Nerijus Bend=C5=BEi=C5=ABnas --- drivers/net/wireless/ath/ath9k/hw.c | 13 +++++----- drivers/net/wireless/ath/ath9k/mac.c | 36 ++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath9k/mac.h | 1 + 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath= /ath9k/hw.c index e08ab73fcacb..d204cdf3fa8f 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -1547,7 +1547,7 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah, struct ath9k_hw_capabilities *pCap =3D &ah->caps; bool band_switch =3D false, mode_diff =3D false; u8 ini_reloaded =3D 0; - u32 qnum; + int qnum; int r; =20 if (pCap->hw_caps & ATH9K_HW_CAP_FCC_BAND_SWITCH) { @@ -1556,12 +1556,11 @@ static bool ath9k_hw_channel_change(struct ath_hw *= ah, mode_diff =3D !!(flags_diff & ~CHANNEL_HT); } =20 - for (qnum =3D 0; qnum < AR_NUM_QCU; qnum++) { - if (ath9k_hw_numtxpending(ah, qnum)) { - ath_dbg(common, QUEUE, - "Transmit frames pending on queue %d\n", qnum); - return false; - } + qnum =3D ath9k_hw_first_txpending(ah); + if (qnum >=3D 0) { + ath_dbg(common, QUEUE, + "Transmit frames pending on queue %d\n", qnum); + return false; } =20 if (!ath9k_hw_rfbus_req(ah)) { diff --git a/drivers/net/wireless/ath/ath9k/mac.c b/drivers/net/wireless/at= h/ath9k/mac.c index b070403e083f..0d8369bbbadf 100644 --- a/drivers/net/wireless/ath/ath9k/mac.c +++ b/drivers/net/wireless/ath/ath9k/mac.c @@ -77,6 +77,42 @@ u32 ath9k_hw_numtxpending(struct ath_hw *ah, u32 q) } EXPORT_SYMBOL(ath9k_hw_numtxpending); =20 +/* + * Asking ath9k_hw_numtxpending() about each queue in turn costs up to two + * register reads per queue, and on the USB devices every one of those is a + * synchronous WMI round trip. Collect the queue status registers and AR_Q= _TXE + * with the multi-read op instead, in chunks the transport can carry. + * + * Returns the first queue that still has frames pending, or -1 if they are + * all drained. + */ +int ath9k_hw_first_txpending(struct ath_hw *ah) +{ + u32 addr[AR_NUM_QCU + 1]; + u32 val[AR_NUM_QCU + 1]; + u32 q, txe, done =3D 0; + + for (q =3D 0; q < AR_NUM_QCU; q++) + addr[q] =3D AR_QSTS(q); + addr[AR_NUM_QCU] =3D AR_Q_TXE; + + while (done < ARRAY_SIZE(addr)) { + u32 count =3D min_t(u32, ARRAY_SIZE(addr) - done, + ATH9K_MULTI_READ_MAX); + + REG_READ_MULTI(ah, addr + done, val + done, count); + done +=3D count; + } + + txe =3D val[AR_NUM_QCU]; + for (q =3D 0; q < AR_NUM_QCU; q++) { + if ((val[q] & AR_Q_STS_PEND_FR_CNT) || (txe & BIT(q))) + return q; + } + + return -1; +} + /** * ath9k_hw_updatetxtriglevel - adjusts the frame trigger level * diff --git a/drivers/net/wireless/ath/ath9k/mac.h b/drivers/net/wireless/at= h/ath9k/mac.h index 16203e7ecf29..5b94ce087be2 100644 --- a/drivers/net/wireless/ath/ath9k/mac.h +++ b/drivers/net/wireless/ath/ath9k/mac.h @@ -721,6 +721,7 @@ u32 ath9k_hw_gettxbuf(struct ath_hw *ah, u32 q); void ath9k_hw_puttxbuf(struct ath_hw *ah, u32 q, u32 txdp); void ath9k_hw_txstart(struct ath_hw *ah, u32 q); u32 ath9k_hw_numtxpending(struct ath_hw *ah, u32 q); +int ath9k_hw_first_txpending(struct ath_hw *ah); bool ath9k_hw_updatetxtriglevel(struct ath_hw *ah, bool bIncTrigLevel); bool ath9k_hw_stop_dma_queue(struct ath_hw *ah, u32 q); void ath9k_hw_abort_tx_dma(struct ath_hw *ah); --=20 2.55.0 From nobody Sat Sep 26 22:01:47 2026 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E85E83515D6 for ; Sat, 29 Aug 2026 05:44:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787982263; cv=none; b=XdLcUtWxedFS4qa4D/+0FdApssk/ck4BK4bZ1fsgN8FR9L6g3MkvaSfYKxqpz8n0r6ZdIp+KF7fdSjCfnFx0xNQUNZPRFjJ3QLi9GC0sPVUSi7wG/RxaKPjs2VeqUFWTRJACGrmRUkeskOykgtLvC5W6vLjxEqjYNs3u205sjos= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787982263; c=relaxed/simple; bh=dxgTuRXIg9MafPzhR81UeFG4+538SkbvTi0siu7dZuQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sKbWkdw/lTGTqL/9L7AzYNP9vbC8rlrBs34MdoaOmFh2FVm+J3H5RMYOZaorRZFTDHd6MzV76smWaTnavybgQs8wkqjAx+efKlLaXnRjtpPhPz6fQhNcS3N7+2ypwHa0W2xnuAp7vDToHwnFFQC/jotijuJzh32HeY8cHMnabRE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=funJHjIM; arc=none smtp.client-ip=209.85.167.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="funJHjIM" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-5b28c91fba5so2039038e87.1 for ; Fri, 28 Aug 2026 22:44:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787982260; x=1788587060; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to:content-type; bh=UMmi9ENN2WjM1s9qjAy3S5/7V0uR4HETS3+LJLK/gWM=; b=funJHjIMlCps+wbJhrWDxzMm+mfvGAMqqON5iPV/kwemYytQ1L02+yFh5IvrKahdBX QKw6w+7dB7WXPqiHA+9nQUXv6ar0IfJZrMbBobyCquYIohZWv9x/fbcngh7jqp3UmuXi n0YrYH1SLCSzf0vQMPX7za+XyCocjeJ+wrIgtZiyzOiSCKYe+8vCtY+JHbaTVcB6bRud eK1kXSZ33xVeMQrlIqGWrwVl7g2MfixFc/3E9vikvdJJnyT80RrM9gI4r3cOYdJxOdET kkEMEmJmfphFlJOS6BRo4gNmP5PPyI1lODqf2dHQOOPxg1LvRo8hcrdsluM6KSOPmf0R 99vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787982260; x=1788587060; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=UMmi9ENN2WjM1s9qjAy3S5/7V0uR4HETS3+LJLK/gWM=; b=r/3X70G8Rcdt1iHCiPgjhOghlSPyRefIFuzURuDn0wX/6lXhko7HqX7bTPux8MqkVA 4qCvGQNq5/xXIHIorKw7mI+Hf7lmPGk56O39H9UHXQDJgY4q42toLn/eauRpA1zT+VaB 7HhafagtGJE3hjw00DZGbsN6m9/eUu/rrzbOVDJbdUGvYYRmec/8a8QIEMKdt562GItg 72/z7BPccVwY1ed1ANGECAn54xSJF60VtMkjxZ+xOOnfMY0PveV2VHE/sD33WbBZ+HnR NwVoeQpp20BU7PXHG4Ikf4w3TPb0d0VYAR9jc99RC0SyclXYrCcUwnNT4NETUzHvqJSA rVZw== X-Gm-Message-State: AFuF++lJNirwBrtmIYpxo+fjshRD/92ZWDSgA63Ecunf3coDhRwecdX1 lgteEx4ZQCQXyWKDqvYNZhIQmbu3mSKatqTv//xb7XgFqsVDe+h/YJE= X-Gm-Gg: AYBFou2x8zwvjXVRFh2lXaLHBgGqv45JvAiaifjduTKQifo8hHb0gCcjtlWGZ4Vql+g xAKB1gaJGf/gTl3BQWaM8e5/MfKi/nlmwmd6CNdMHowHBw3sF+UxoujXTgQEViI8L3rBRJE02so hvgywt9LFOIR6Wj05XeVmcoAjDH8xk2E60cRyUN1qP5cU7ohjQvqW5rMbMPWr9anRBS8K8fzl7S 8t9QjLARdPeVPr2AU7mi9r+gpB3IwCkddSOIPjRGGOpzD+GObyscjnz46d5HA+E0HFUbqkhA4Pz qOiqpBXmTxnNs2AOnGmmQ1LjXfsfDYJMU44NjlGRrFM7NAomqtVCfvYR1B8f3MS4dPO0OB5QAS1 iCJjYqmcmehOq1fkeh5YD6fipjlpj+aS4u8YQ1TE/8aTMhjXR5nuYdu+ZbyZTWhsNW51J+sGO/B 6gf2JHUsOMwTDn6rSLj5FBAhoHMqtSEPTDK6CtFwbznHUi2DqeGkMo/+1P60KzNewN7IuHoaNVv +0EsbsnxvqT0Rf3l0zEeHYbQZwFXdWYx1SbTDL3YfkCeFQUV02XgT5pa+9yeEfA+V9je7vHHziQ AVOSvWbxU/n7Sjg= X-Received: by 2002:a05:6512:33d5:b0:5ae:b5d7:7844 with SMTP id 2adb3069b0e04-5b5edba6aa3mr1113551e87.5.1787982259829; Fri, 28 Aug 2026 22:44:19 -0700 (PDT) Received: from nn ([2001:1ab8:1003:0:5454:f357:ba89:4e22]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b5e89c5b86sm803040e87.12.2026.08.28.22.44.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2026 22:44:18 -0700 (PDT) Sender: N B From: =?UTF-8?q?Nerijus=20Bend=C5=BEi=C5=ABnas?= To: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= , linux-wireless@vger.kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 3/4] wifi: ath9k: batch the read-modify-writes of a channel change Date: Sat, 29 Aug 2026 08:44:00 +0300 Message-ID: <20260829054401.1198574-4-nerijus.bendziunas@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260829054401.1198574-1-nerijus.bendziunas@gmail.com> References: <20260829054401.1198574-1-nerijus.bendziunas@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable ar5008_hw_set_delta_slope() and ath9k_hw_start_nfcal() both issue a run of read-modify-writes with nothing between them that reads a register back. Both run on every channel change, and on the USB devices each REG_RMW is its own WMI command. Wrap the two runs in the RMW buffer so the transport sends each as a single command. PCI does not install the buffer callbacks, so ENABLE_REG_RMW_BUFFER() and REG_RMW_BUFFER_FLUSH() are empty there and the writes are issued exactly as before. Signed-off-by: Nerijus Bend=C5=BEi=C5=ABnas --- drivers/net/wireless/ath/ath9k/ar5008_phy.c | 2 ++ drivers/net/wireless/ath/ath9k/calib.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/net/wireless/ath/ath9k/ar5008_phy.c b/drivers/net/wire= less/ath/ath9k/ar5008_phy.c index 7a45f5f62826..af05dcf95a61 100644 --- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c +++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c @@ -868,6 +868,7 @@ static void ar5008_hw_set_delta_slope(struct ath_hw *ah, ath9k_hw_get_delta_slope_vals(ah, coef_scaled, &ds_coef_man, &ds_coef_exp); =20 + ENABLE_REG_RMW_BUFFER(ah); REG_RMW_FIELD(ah, AR_PHY_TIMING3, AR_PHY_TIMING3_DSC_MAN, ds_coef_man); REG_RMW_FIELD(ah, AR_PHY_TIMING3, @@ -882,6 +883,7 @@ static void ar5008_hw_set_delta_slope(struct ath_hw *ah, AR_PHY_HALFGI_DSC_MAN, ds_coef_man); REG_RMW_FIELD(ah, AR_PHY_HALFGI, AR_PHY_HALFGI_DSC_EXP, ds_coef_exp); + REG_RMW_BUFFER_FLUSH(ah); } =20 static bool ar5008_hw_rfbus_req(struct ath_hw *ah) diff --git a/drivers/net/wireless/ath/ath9k/calib.c b/drivers/net/wireless/= ath/ath9k/calib.c index b4ab85bd7895..73c63ab32d53 100644 --- a/drivers/net/wireless/ath/ath9k/calib.c +++ b/drivers/net/wireless/ath/ath9k/calib.c @@ -224,6 +224,7 @@ void ath9k_hw_start_nfcal(struct ath_hw *ah, bool updat= e) if (ah->caldata) set_bit(NFCAL_PENDING, &ah->caldata->cal_flags); =20 + ENABLE_REG_RMW_BUFFER(ah); REG_SET_BIT(ah, AR_PHY_AGC_CONTROL(ah), AR_PHY_AGC_CONTROL_ENABLE_NF); =20 @@ -235,6 +236,7 @@ void ath9k_hw_start_nfcal(struct ath_hw *ah, bool updat= e) AR_PHY_AGC_CONTROL_NO_UPDATE_NF); =20 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL(ah), AR_PHY_AGC_CONTROL_NF); + REG_RMW_BUFFER_FLUSH(ah); } =20 int ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan) --=20 2.55.0 From nobody Sat Sep 26 22:01:47 2026 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E90A2353A72 for ; Sat, 29 Aug 2026 05:44:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787982266; cv=none; b=W31c8q6YMq+nldBX6NoqYuOk4/VizlhWb2yGcF5ks31IFzg3BYRC3BpbEivd2pSYyW9CZkD2NvDkknhYOFRj9jWRY1YOExT+TAX7I9QTKa19svAu9DLG7R7+DruXgpTTGweSH+9Q5uqjoF3i8r+Ywwsy5tCOB4kclXf55AUpXLg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787982266; c=relaxed/simple; bh=qsFwjBfu2NKtEcsDviKHxw63ntmppkT8r3P6UxlkbOc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mU+T9Ia+c19Narvo3gdzexWMEpYYlaMSIiRIHehqZYapkEIExmcRfSZeTLULeNUbhMWUX/aRRYwJNZg0VpNrPqkbJHAJbpAhoNe01VH2wpug1toDG0qMjCwpQTGISmzlCsTdUH+/aDpC4MQV/pGF56gH0ZzajkC9AYyOaPP4iKM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DwnJ6Xbu; arc=none smtp.client-ip=209.85.167.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DwnJ6Xbu" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-5b01910b499so1659202e87.0 for ; Fri, 28 Aug 2026 22:44:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787982263; x=1788587063; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to:content-type; bh=ShvhKa6MyfZ1jEWheQQ6SuhEnn7upG8Sh84fZvzR0n8=; b=DwnJ6XbuW9HyStr/+sjdmqX/1p3AwRzsRfcaXD+7D3hY5507Q3LcyEpzMljSfekt9D JY9UEtaVycKVOzZldxacosJEtlpNSpzoBd1R9R+D56FoOoZqPWJu5kZx/OJTZnSWg9r1 NzCnCnPXdOWyAQc9WBp7Y1tf2q81PWfPjDnwgknUHK5PnV+KYkXcJJHWNBC6E7eHB1K0 uLIh9NPl8pVlhqekUUKmCChpli2UCKFNw/BxvaQProsf+l3NbEy93sRQv9MhL8/jYjeT 2vuMNtHeBfmlfa4pThNnkpYqnnXMzbtDOoyfh2p5vSfEUoCHjrjCm7L4aqvsE6SrKgwC YARw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787982263; x=1788587063; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ShvhKa6MyfZ1jEWheQQ6SuhEnn7upG8Sh84fZvzR0n8=; b=C+hrH7VqP40+E9k+CX53SQucQjpouqYd2/JhKg/S5SfqDTaODtS+C8Brs1rFiOW304 Nt99JzgnpCMlhLlh0LSKuHXRnhtAwEZb5zeky/U9ladFTJ22krXazWRq2wZJFCplMgyR wApdx8tQNwhfJXJyCIwAHTkGDF262KlWSUB8if3ZvlpSeGSEbEQbtCu8nl8ECCsI/Iw9 0YeXT/7/QH/rqZQIERpbghum9d7gMm8mIjpnnGvfgv0DwpB9S28JNXiMujaiTnniqxsY UXaeniNPRUNiyFntsOE4nVaPxYJ5/eN2wYEkjk8yATGHy0+AaHE6O2zoQalHcvKCugG+ f9Kw== X-Gm-Message-State: AFuF++mSht/zjZiVFsYcpdrgLxfQv9H25EN1yaS/gT/Swd9PyR9akReU TqBjk138W0eaAuZAJkw74lIL2MIPOAuRH7jb7fWJDWF+eidvCFukUB4= X-Gm-Gg: AYBFou3imTQp7f+ipIKkWh666gF24YxoxzV6Zhf86steiXl4DGPe/j/DiW/j4qsCWKi knInlyWLU6X+pw6qaiBPxtkrRnKeZDuCHLFAYFM0ThScVyHz3o66ChFff0xoIgNpeMCl+s3OkyR uckuhY4bOk+F2GUY0loTCCh1xNJFdbQ3Ypz9DmHr4EvJyt3quCoZG3i70QhrvZ8G2OTGMGt8caU jx3NPM7w43cttlDbJQZLiGs4zS0i6+ENkKnIoySqKSuvQ07frz2F5paJTFx2eg1cGJO14UnCkzX j1i0TbBQqjrVlmlv5mjxS3W0iXtbR2LwkHglTkOy4uf29Q/FpSamCkn5lydAjgcqihfqaVx3ETR NDmwAYrMB7bsBlls4gB/cEmfZlIudpQSMrcUveZv/2gCIECA8KkAO9DmxTqORvfoob0/E2XLvJ7 YNlfqDgEEzKBrvHsMz2sWWUEG5toCbFo9XESVAi+h1X4RtPJfysgROh5dyJlqUGfoX+fDj32dnj oEsXNDFUg9KcjYv05pRiD32M0Xe4Y75gVxMBfsf0Cwpre/n7GPMo63x8b6hDkR49AeSQE869USH AHqd X-Received: by 2002:a05:6512:670b:b0:5b2:a22c:50ff with SMTP id 2adb3069b0e04-5b4afeedfe6mr4552889e87.19.1787982262802; Fri, 28 Aug 2026 22:44:22 -0700 (PDT) Received: from nn ([2001:1ab8:1003:0:5454:f357:ba89:4e22]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b5e89c5b86sm803040e87.12.2026.08.28.22.44.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2026 22:44:21 -0700 (PDT) Sender: N B From: =?UTF-8?q?Nerijus=20Bend=C5=BEi=C5=ABnas?= To: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= , linux-wireless@vger.kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 4/4] wifi: ath9k: skip the departing channel's noise floor on USB fast changes Date: Sat, 29 Aug 2026 08:44:01 +0300 Message-ID: <20260829054401.1198574-5-nerijus.bendziunas@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260829054401.1198574-1-nerijus.bendziunas@gmail.com> References: <20260829054401.1198574-1-nerijus.bendziunas@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable ath9k_hw_reset() reads the noise floor of the channel it is leaving so that channel's calibration history stays current. The readout is several register reads, which on the USB devices are as many synchronous WMI round trips, and a frequency-hopping monitor pays them on every hop for a value that only matters if the radio returns to that channel later. Leave the readout out when a fast channel change is asked for on a USB device. Periodic calibration refreshes the history while a channel is in use, and the arriving channel's noise floor is loaded either way, so only a channel that is left and revisited without calibrating in between sees an older history. Signed-off-by: Nerijus Bend=C5=BEi=C5=ABnas --- drivers/net/wireless/ath/ath9k/hw.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath= /ath9k/hw.c index d204cdf3fa8f..64fefbec46d5 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -1878,7 +1878,13 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_c= hannel *chan, if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) return -EIO; =20 - if (ah->curchan && !ah->chip_fullsleep) + /* + * Over USB the departing channel's noise-floor readout costs several + * round trips and only feeds its history; the fast path reloads the + * arriving channel's noise floor regardless. + */ + if (ah->curchan && !ah->chip_fullsleep && + !(fastcc && common->bus_ops->ath_bus_type =3D=3D ATH_USB)) ath9k_hw_getnf(ah, ah->curchan); =20 ah->caldata =3D caldata; --=20 2.55.0