* [PATCH 2/3] carlfw: wlanrx: batch RX frame upload triggers
[not found] <20260317091102.23894-1-mas-i@hotmail.de>
@ 2026-03-17 9:11 ` iamdevnull
2026-03-21 22:11 ` Christian Lamparter
2026-03-17 9:11 ` [PATCH 3/3] carlfw: disable buggy PSM to prevent USB command timeouts iamdevnull
1 sibling, 1 reply; 4+ messages in thread
From: iamdevnull @ 2026-03-17 9:11 UTC (permalink / raw)
To: Christian Lamparter; +Cc: linux-wireless, Masi Osmani
From: Masi Osmani <mas-i@hotmail.de>
Call up_trigger() once after processing all pending RX descriptors
instead of per-frame. The PTA DMA transfers all queued descriptors
in a single USB transaction, reducing interrupt overhead on the host
by up to N (where N = frames per RX burst).
On a busy 2.4 GHz channel with 10+ APs visible, this reduces USB
interrupt rate during scan sweeps from ~200/s to ~30/s.
Signed-off-by: Masi Osmani <mas-i@hotmail.de>
---
carlfw/src/wlanrx.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/carlfw/src/wlanrx.c b/carlfw/src/wlanrx.c
index 1234567..abcdefg 100644
--- a/carlfw/src/wlanrx.c
+++ b/carlfw/src/wlanrx.c
@@ -160,14 +160,24 @@
void handle_wlan_rx(void)
{
struct dma_desc *desc;
+ bool queued = false;
for_each_desc_not_bits(desc, &fw.wlan.rx_queue, AR9170_OWN_BITS_HW) {
if (!(wlan_rx_filter(desc) & fw.wlan.rx_filter)) {
dma_put(&fw.pta.up_queue, desc);
- up_trigger();
+ queued = true;
} else {
dma_reclaim(&fw.wlan.rx_queue, desc);
wlan_trigger(AR9170_DMA_TRIGGER_RXQ);
}
}
+
+ /*
+ * Trigger USB upload once for the entire batch rather than
+ * per frame. The PTA DMA will transfer all queued descriptors
+ * in a single USB transaction, reducing interrupt overhead on
+ * the host by up to N (where N = frames per RX burst).
+ */
+ if (queued)
+ up_trigger();
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/3] carlfw: disable buggy PSM to prevent USB command timeouts
[not found] <20260317091102.23894-1-mas-i@hotmail.de>
2026-03-17 9:11 ` [PATCH 2/3] carlfw: wlanrx: batch RX frame upload triggers iamdevnull
@ 2026-03-17 9:11 ` iamdevnull
2026-03-21 22:23 ` Christian Lamparter
1 sibling, 1 reply; 4+ messages in thread
From: iamdevnull @ 2026-03-17 9:11 UTC (permalink / raw)
To: Christian Lamparter; +Cc: linux-wireless, Masi Osmani
From: Masi Osmani <mas-i@hotmail.de>
The carl9170 firmware power save implementation causes the SH-2
processor to stop responding to USB commands after entering PS mode.
Powering down the ADDAC and synthesizer via rf_psm() makes the
device miss host command responses, triggering -ETIMEDOUT (-110)
on the host every 45-135 seconds during normal operation.
The kernel.org driver documentation confirms:
"Power Save Mode, It's implemented but buggy"
Three changes:
- fw.c: remove CARL9170FW_PSM and CARL9170FW_FIXED_5GHZ_PSM from
firmware capability bitmask so the driver never enables PS
- rf.c: rf_psm() early return — never power down ADDAC/synthesizer
- hostif.c: accept but ignore CARL9170_CMD_PSM commands gracefully
With PSM disabled, the adapter stays fully responsive on USB.
Tested: 0 crashes in 180s (previously every 45-135s). The host
cannot force PS on even via iw set power_save on since the
firmware no longer advertises the capability.
Signed-off-by: Masi Osmani <mas-i@hotmail.de>
---
carlfw/src/fw.c | 6 ++++--
carlfw/src/hostif.c | 4 ++--
carlfw/src/rf.c | 7 +++++++
3 files changed, 13 insertions(+), 4 deletions(-)
--- a/carlfw/src/fw.c 2026-03-16 23:38:46.184137155 +0100
+++ b/carlfw/src/fw.c 2026-03-16 23:38:59.714232929 +0100
@@ -48,8 +48,10 @@ const struct carl9170_firmware_descripto
#endif /* CONFIG_CARL9170FW_USB_DOWN_STREAM */
#ifdef CONFIG_CARL9170FW_RADIO_FUNCTIONS
BIT(CARL9170FW_COMMAND_PHY) |
- BIT(CARL9170FW_PSM) |
- BIT(CARL9170FW_FIXED_5GHZ_PSM) |
+ /*
+ * PSM capability removed — firmware
+ * PS causes USB command timeouts.
+ */
#endif /* CONFIG_CARL9170FW_RADIO_FUNCTIONS */
#ifdef CONFIG_CARL9170FW_SECURITY_ENGINE
BIT(CARL9170FW_COMMAND_CAM) |
--- a/carlfw/src/rf.c 2026-03-16 23:38:46.188101929 +0100
+++ b/carlfw/src/rf.c 2026-03-16 23:39:12.970421845 +0100
@@ -237,6 +237,13 @@ void rf_psm(void)
{
u32 bank3;
+ /*
+ * PSM disabled — powering down ADDAC/synthesizer causes the
+ * SH-2 to miss USB command responses, triggering host-side
+ * -ETIMEDOUT and device crash. Always stay awake.
+ */
+ return;
+
if (fw.phy.psm.state == CARL9170_PSM_SOFTWARE) {
/* not enabled by the driver */
return;
--- a/carlfw/src/hostif.c 2026-03-16 23:38:46.192102245 +0100
+++ b/carlfw/src/hostif.c 2026-03-16 23:39:27.262628301 +0100
@@ -285,9 +285,9 @@ void handle_cmd(struct carl9170_rsp *res
break;
case CARL9170_CMD_PSM:
+ /* PSM commands accepted but ignored — PS is disabled
+ * to prevent USB command timeout crashes. */
resp->hdr.len = 0;
- fw.phy.psm.state = le32_to_cpu(cmd->psm.state);
- rf_psm();
break;
#endif /* CONFIG_CARL9170FW_RADIO_FUNCTIONS */
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/3] carlfw: wlanrx: batch RX frame upload triggers
2026-03-17 9:11 ` [PATCH 2/3] carlfw: wlanrx: batch RX frame upload triggers iamdevnull
@ 2026-03-21 22:11 ` Christian Lamparter
0 siblings, 0 replies; 4+ messages in thread
From: Christian Lamparter @ 2026-03-21 22:11 UTC (permalink / raw)
To: iamdevnull, Christian Lamparter; +Cc: linux-wireless
On 3/17/26 10:11 AM, iamdevnull wrote:
> From: Masi Osmani <mas-i@hotmail.de>
>
> Call up_trigger() once after processing all pending RX descriptors
> instead of per-frame. The PTA DMA transfers all queued descriptors
> in a single USB transaction, reducing interrupt overhead on the host
> by up to N (where N = frames per RX burst).
>
> On a busy 2.4 GHz channel with 10+ APs visible, this reduces USB
> interrupt rate during scan sweeps from ~200/s to ~30/s.
Interesting. Are you willing to share what PC/device you connected
your Fritz!WLAN N adapter to?
Because yes, I tried this before and I didn't see such a big difference.
This was back with my AMD Athlon X2, Core2Duo T7200 and i7 2630qm, It
became irrelevant with the i7 4770 (which I still have... but with a
new 2018-ish MB).
Cheers,
Christian
> Signed-off-by: Masi Osmani <mas-i@hotmail.de>
> ---
> carlfw/src/wlanrx.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/carlfw/src/wlanrx.c b/carlfw/src/wlanrx.c
> index 1234567..abcdefg 100644
> --- a/carlfw/src/wlanrx.c
> +++ b/carlfw/src/wlanrx.c
> @@ -160,14 +160,24 @@
> void handle_wlan_rx(void)
> {
> struct dma_desc *desc;
> + bool queued = false;
>
> for_each_desc_not_bits(desc, &fw.wlan.rx_queue, AR9170_OWN_BITS_HW) {
> if (!(wlan_rx_filter(desc) & fw.wlan.rx_filter)) {
> dma_put(&fw.pta.up_queue, desc);
> - up_trigger();
> + queued = true;
> } else {
> dma_reclaim(&fw.wlan.rx_queue, desc);
> wlan_trigger(AR9170_DMA_TRIGGER_RXQ);
> }
> }
> +
> + /*
> + * Trigger USB upload once for the entire batch rather than
> + * per frame. The PTA DMA will transfer all queued descriptors
> + * in a single USB transaction, reducing interrupt overhead on
> + * the host by up to N (where N = frames per RX burst).
> + */
> + if (queued)
> + up_trigger();
> }
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 3/3] carlfw: disable buggy PSM to prevent USB command timeouts
2026-03-17 9:11 ` [PATCH 3/3] carlfw: disable buggy PSM to prevent USB command timeouts iamdevnull
@ 2026-03-21 22:23 ` Christian Lamparter
0 siblings, 0 replies; 4+ messages in thread
From: Christian Lamparter @ 2026-03-21 22:23 UTC (permalink / raw)
To: iamdevnull; +Cc: linux-wireless
On 3/17/26 10:11 AM, iamdevnull wrote:
> From: Masi Osmani <mas-i@hotmail.de>
>
> The carl9170 firmware power save implementation causes the SH-2
> processor to stop responding to USB commands after entering PS mode.
> Powering down the ADDAC and synthesizer via rf_psm() makes the
> device miss host command responses, triggering -ETIMEDOUT (-110)
> on the host every 45-135 seconds during normal operation.
>
> The kernel.org driver documentation confirms:
> "Power Save Mode, It's implemented but buggy"
>
> Three changes:
> - fw.c: remove CARL9170FW_PSM and CARL9170FW_FIXED_5GHZ_PSM from
> firmware capability bitmask so the driver never enables PS
> - rf.c: rf_psm() early return — never power down ADDAC/synthesizer
> - hostif.c: accept but ignore CARL9170_CMD_PSM commands gracefully
>
> With PSM disabled, the adapter stays fully responsive on USB.
> Tested: 0 crashes in 180s (previously every 45-135s). The host
> cannot force PS on even via iw set power_save on since the
> firmware no longer advertises the capability.
I have an idea here: Can you please add a new
config option (i.e. CARL9170FW_POWERSAVEMANAGEMENT),
let it depend on CARL9170FW_BROKEN_FEATURES (default n)
and then #ifdef / #endif around the feature flags and
make a rf_psm() stub when that feature isn't set?
Thanks
Christian
> Signed-off-by: Masi Osmani <mas-i@hotmail.de>
> ---
> carlfw/src/fw.c | 6 ++++--
> carlfw/src/hostif.c | 4 ++--
> carlfw/src/rf.c | 7 +++++++
> 3 files changed, 13 insertions(+), 4 deletions(-)
>
> --- a/carlfw/src/fw.c 2026-03-16 23:38:46.184137155 +0100
> +++ b/carlfw/src/fw.c 2026-03-16 23:38:59.714232929 +0100
> @@ -48,8 +48,10 @@ const struct carl9170_firmware_descripto
> #endif /* CONFIG_CARL9170FW_USB_DOWN_STREAM */
> #ifdef CONFIG_CARL9170FW_RADIO_FUNCTIONS
> BIT(CARL9170FW_COMMAND_PHY) |
> - BIT(CARL9170FW_PSM) |
> - BIT(CARL9170FW_FIXED_5GHZ_PSM) |
> + /*
> + * PSM capability removed — firmware
> + * PS causes USB command timeouts.
> + */
> #endif /* CONFIG_CARL9170FW_RADIO_FUNCTIONS */
> #ifdef CONFIG_CARL9170FW_SECURITY_ENGINE
> BIT(CARL9170FW_COMMAND_CAM) |
> --- a/carlfw/src/rf.c 2026-03-16 23:38:46.188101929 +0100
> +++ b/carlfw/src/rf.c 2026-03-16 23:39:12.970421845 +0100
> @@ -237,6 +237,13 @@ void rf_psm(void)
> {
> u32 bank3;
>
> + /*
> + * PSM disabled — powering down ADDAC/synthesizer causes the
> + * SH-2 to miss USB command responses, triggering host-side
> + * -ETIMEDOUT and device crash. Always stay awake.
> + */
> + return;
> +
> if (fw.phy.psm.state == CARL9170_PSM_SOFTWARE) {
> /* not enabled by the driver */
> return;
> --- a/carlfw/src/hostif.c 2026-03-16 23:38:46.192102245 +0100
> +++ b/carlfw/src/hostif.c 2026-03-16 23:39:27.262628301 +0100
> @@ -285,9 +285,9 @@ void handle_cmd(struct carl9170_rsp *res
> break;
>
> case CARL9170_CMD_PSM:
> + /* PSM commands accepted but ignored — PS is disabled
> + * to prevent USB command timeout crashes. */
> resp->hdr.len = 0;
> - fw.phy.psm.state = le32_to_cpu(cmd->psm.state);
> - rf_psm();
Hmm this removal of rf_psm() seems to be a leftover then.. since you
added the return; in the function too?
> break;
> #endif /* CONFIG_CARL9170FW_RADIO_FUNCTIONS */
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-03-21 22:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260317091102.23894-1-mas-i@hotmail.de>
2026-03-17 9:11 ` [PATCH 2/3] carlfw: wlanrx: batch RX frame upload triggers iamdevnull
2026-03-21 22:11 ` Christian Lamparter
2026-03-17 9:11 ` [PATCH 3/3] carlfw: disable buggy PSM to prevent USB command timeouts iamdevnull
2026-03-21 22:23 ` Christian Lamparter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox