Skip to contentSkip to conversation

wifi: ath9k: fix the RX filter handling around spectral scans

PATCH In review Nerijus Bendžiūnas 3 participants 6 messages Sep 11 – Sep 14

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v3 cover wifi: ath9k: fix the RX filter handling around spectral scans

Patch 1 is v2
(https://lore.kernel.org/linux-wireless/[email protected]/)
with a shorter comment and message and the Assisted-by tag in the documented form. Patch 2 is new and needs the helper from patch 1.

Tested on an AR9271 (ath9k_htc) together with the pending spectral stats fix; ath9k is build-tested.

Nerijus Bendžiūnas (2):
wifi: ath9k: stop a failed register read from opening the RX filter
wifi: ath9k: clear the PHY error filter when a spectral scan is
disabled

 .../net/wireless/ath/ath9k/common-spectral.c  | 13 ++++--
 drivers/net/wireless/ath/ath9k/hw.c           | 46 +++++++++++++++++++
 drivers/net/wireless/ath/ath9k/hw.h           |  2 +
 3 files changed, 56 insertions(+), 5 deletions(-)

base-commit: c3bace8584ca707e34ba837f65c2e9d566af4c2c

Signature · 1 line
2.55.0
#1 lore raw

PATCH v3 1/2 wifi: ath9k: stop a failed register read from opening the RX filter

On USB a register read is a WMI round trip and a timeout returns -1. The spectral trigger reads AR_RX_FILTER back, ORs in the PHY error bits and writes it, so a timed-out read stores 0xffffffff and the device forwards every frame and PHY error to the host.

Add ath9k_hw_enable_rxfilter(), which sets the requested bits with REG_SET_BIT() and reads nothing back, and use it in the trigger. With firmware 1.4 and later the read-modify-write is done by the firmware; older firmware still reads from the host.

Fixes e93d083f42a1 ("ath9k: add spectral scan feature")
Assisted-by LLM
---
 .../net/wireless/ath/ath9k/common-spectral.c  |  7 ++----
 drivers/net/wireless/ath/ath9k/hw.c           | 23 +++++++++++++++++++
 drivers/net/wireless/ath/ath9k/hw.h           |  1 +
 3 files changed, 26 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath9k/common-spectral.c +2 -5
index ca01a07f6630..73c1eb4ebe0e 100644
@@ -716,7 +716,6 @@ void ath9k_cmn_spectral_scan_trigger(struct ath_common *common,
 				 struct ath_spec_scan_priv *spec_priv)
 {
 	struct ath_hw *ah = spec_priv->ah;
-	u32 rxfilter;
 
 	if (IS_ENABLED(CONFIG_ATH9K_TX99))
 		return;
@@ -730,10 +729,8 @@ void ath9k_cmn_spectral_scan_trigger(struct ath_common *common,
 		return;
 
 	ath_ps_ops(common)->wakeup(common);
-	rxfilter = ath9k_hw_getrxfilter(ah);
-	ath9k_hw_setrxfilter(ah, rxfilter |
-				 ATH9K_RX_FILTER_PHYRADAR |
-				 ATH9K_RX_FILTER_PHYERR);
+	ath9k_hw_enable_rxfilter(ah, ATH9K_RX_FILTER_PHYRADAR |
+				     ATH9K_RX_FILTER_PHYERR);
 
 	/* TODO: usually this should not be necessary, but for some reason
 	 * (or in some mode?) the trigger must be called after the
drivers/net/wireless/ath/ath9k/hw.c +23 -0
index e08ab73fcacb..d62b6ff00d41 100644
@@ -2905,6 +2905,29 @@ void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits)
 }
 EXPORT_SYMBOL(ath9k_hw_setrxfilter);
 
+/*
+ * Set bits in the RX filter without reading it back: on USB a failed read
+ * returns all ones, and writing that back would open every filter bit.
+ */
+void ath9k_hw_enable_rxfilter(struct ath_hw *ah, u32 bits)
+{
+	u32 phybits = 0;
+
+	if (bits & ATH9K_RX_FILTER_PHYRADAR)
+		phybits |= AR_PHY_ERR_RADAR;
+	if (bits & ATH9K_RX_FILTER_PHYERR)
+		phybits |= AR_PHY_ERR_OFDM_TIMING | AR_PHY_ERR_CCK_TIMING;
+
+	REG_SET_BIT(ah, AR_RX_FILTER, bits);
+
+	if (phybits) {
+		REG_SET_BIT(ah, AR_PHY_ERR, phybits);
+		/* PHY errors are reported in zero length frames. */
+		REG_SET_BIT(ah, AR_RXCFG, AR_RXCFG_ZLFDMA);
+	}
+}
+EXPORT_SYMBOL(ath9k_hw_enable_rxfilter);
+
 bool ath9k_hw_phy_disable(struct ath_hw *ah)
 {
 	if (ath9k_hw_mci_is_enabled(ah))
drivers/net/wireless/ath/ath9k/hw.h +1 -0
index b942b8303d8f..f102f73a0114 100644
@@ -1055,6 +1055,7 @@ void ath9k_hw_get_channel_centers(struct ath_hw *ah,
 				  struct chan_centers *centers);
 u32 ath9k_hw_getrxfilter(struct ath_hw *ah);
 void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits);
+void ath9k_hw_enable_rxfilter(struct ath_hw *ah, u32 bits);
 bool ath9k_hw_phy_disable(struct ath_hw *ah);
 bool ath9k_hw_disable(struct ath_hw *ah);
 void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test);
Signature · 1 line
2.55.0
#2 lore raw

Re: [PATCH v3 1/2] wifi: ath9k: stop a failed register read from opening the RX filter

drivers/net/wireless/ath/ath9k/hw.c void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits) · line 2912

Quoted 5 lines · Nerijus Bendžiūnas
drivers/net/wireless/ath/ath9k/hw.c +5 -0
+/*
+ * Set bits in the RX filter without reading it back: on USB a failed read
+ * returns all ones, and writing that back would open every filter bit.
+ */
+void ath9k_hw_enable_rxfilter(struct ath_hw *ah, u32 bits)

there is a standard for kernel function documentation

https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#function-documentation

#3 lore raw

Re: [PATCH v3 1/2] wifi: ath9k: stop a failed register read from opening the RX filter

Quoted 10 lines · Jeff Johnson

drivers/net/wireless/ath/ath9k/hw.c void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits) · line 2912

Quoted 5 lines · Nerijus Bendžiūnas
drivers/net/wireless/ath/ath9k/hw.c +5 -0
+/*
+ * Set bits in the RX filter without reading it back: on USB a failed read
+ * returns all ones, and writing that back would open every filter bit.
+ */
+void ath9k_hw_enable_rxfilter(struct ath_hw *ah, u32 bits)

there is a standard for kernel function documentation

https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#function-documentation

Thanks, I will change this to kernel-doc.

Per Toke's request on the cover letter, this patch and the other ath9k fixes will come back as one series once, with the dependencies and the testing explained, rather than as a v4 on this thread.

Nerijus

#4 lore raw

PATCH v3 2/2 wifi: ath9k: clear the PHY error filter when a spectral scan is disabled

In reply to Nerijus Bendžiūnas

Triggering a spectral scan sets the PHY error bits in AR_RX_FILTER and AR_PHY_ERR and sets AR_RXCFG_ZLFDMA. Disabling it clears none of them, and ath9k_htc carries the hardware bits into every later filter update. An idle AR9271 in monitor mode then keeps forwarding every PHY error as a zero-length frame.

Clear all three on SPECTRAL_DISABLED unless radar detection is enabled, which needs the same bits. AR_RXCFG_ZLFDMA must go too: with it set the frames keep coming after the PHY error mask is cleared. As with the enable path, firmware older than 1.4 still reads from the host.

Fixes e93d083f42a1 ("ath9k: add spectral scan feature")
Assisted-by LLM
---
 .../net/wireless/ath/ath9k/common-spectral.c  |  6 +++++
 drivers/net/wireless/ath/ath9k/hw.c           | 23 +++++++++++++++++++
 drivers/net/wireless/ath/ath9k/hw.h           |  1 +
 3 files changed, 30 insertions(+)
drivers/net/wireless/ath/ath9k/common-spectral.c +6 -0
index 73c1eb4ebe0e..841075d904f8 100644
@@ -776,6 +776,12 @@ int ath9k_cmn_spectral_scan_config(struct ath_common *common,
 
 	ath_ps_ops(common)->wakeup(common);
 	ath9k_hw_ops(ah)->spectral_scan_config(ah, &spec_priv->spec_config);
+
+	/* Radar detection needs the same bits. */
+	if (spectral_mode == SPECTRAL_DISABLED &&
+	    !common->hw->conf.radar_enabled)
+		ath9k_hw_disable_rxfilter(ah, ATH9K_RX_FILTER_PHYRADAR |
+					      ATH9K_RX_FILTER_PHYERR);
 	ath_ps_ops(common)->restore(common);
 
 	spec_priv->spectral_mode = spectral_mode;
drivers/net/wireless/ath/ath9k/hw.c +23 -0
index d62b6ff00d41..6f86a8967548 100644
@@ -2928,6 +2928,29 @@ void ath9k_hw_enable_rxfilter(struct ath_hw *ah, u32 bits)
 }
 EXPORT_SYMBOL(ath9k_hw_enable_rxfilter);
 
+/*
+ * Counterpart of ath9k_hw_enable_rxfilter(). AR_RXCFG_ZLFDMA goes with the
+ * PHY error mask or the frames keep coming; callers clear all the PHY error
+ * bits together, as checking for a remaining one would need a read.
+ */
+void ath9k_hw_disable_rxfilter(struct ath_hw *ah, u32 bits)
+{
+	u32 phybits = 0;
+
+	if (bits & ATH9K_RX_FILTER_PHYRADAR)
+		phybits |= AR_PHY_ERR_RADAR;
+	if (bits & ATH9K_RX_FILTER_PHYERR)
+		phybits |= AR_PHY_ERR_OFDM_TIMING | AR_PHY_ERR_CCK_TIMING;
+
+	REG_CLR_BIT(ah, AR_RX_FILTER, bits);
+
+	if (phybits) {
+		REG_CLR_BIT(ah, AR_PHY_ERR, phybits);
+		REG_CLR_BIT(ah, AR_RXCFG, AR_RXCFG_ZLFDMA);
+	}
+}
+EXPORT_SYMBOL(ath9k_hw_disable_rxfilter);
+
 bool ath9k_hw_phy_disable(struct ath_hw *ah)
 {
 	if (ath9k_hw_mci_is_enabled(ah))
drivers/net/wireless/ath/ath9k/hw.h +1 -0
index f102f73a0114..983146208f26 100644
@@ -1056,6 +1056,7 @@ void ath9k_hw_get_channel_centers(struct ath_hw *ah,
 u32 ath9k_hw_getrxfilter(struct ath_hw *ah);
 void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits);
 void ath9k_hw_enable_rxfilter(struct ath_hw *ah, u32 bits);
+void ath9k_hw_disable_rxfilter(struct ath_hw *ah, u32 bits);
 bool ath9k_hw_phy_disable(struct ath_hw *ah);
 bool ath9k_hw_disable(struct ath_hw *ah);
 void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test);
Signature · 1 line
2.55.0
#5 lore raw
In reply to Nerijus Bendžiūnas
Quoted 7 lines · Nerijus Bendžiūnas

Patch 1 is v2
(https://lore.kernel.org/linux-wireless/[email protected]/)
with a shorter comment and message and the Assisted-by tag in the documented form. Patch 2 is new and needs the helper from patch 1.

Tested on an AR9271 (ath9k_htc) together with the pending spectral stats fix; ath9k is build-tested.

You're resending new versions of patches faster than anyone has a chance to look at them, with series boundaries that keep changing and have weird dependencies between them. Please don't do that. If you're still working on patches so that they require changes, then you sent them off too early; this is not a race, don't submit things until you're confident in them.

I'm dropping all patches from you from patchwork; if you have a series of dependent patches, please resend as one series, explaining how they relate to each other and how you tested them, and then *wait for someone to look at them before resending*.

-Toke