Skip to contentSkip to conversation

wifi: rtw89: phy: increase RF calibration timeouts for USB transport

PATCH In review Louis Kotze 3 participants 4 messages Apr 16 – Apr 29 Realtek wireless driver (rtw89)

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 wifi: rtw89: phy: increase RF calibration timeouts for USB transport

USB transport adds significant latency to H2C/C2H round-trips used by RF calibration. The existing timeout values were designed for PCIe and are too tight for USB, causing "failed to wait RF DACK", "failed to wait RF TSSI" and similar errors on USB adapters.

Apply a 4x timeout multiplier when the device uses USB transport. The multiplier is applied in rtw89_phy_rfk_report_wait() so all calibrations benefit without changing any call sites or PCIe timeout values.

The 4x multiplier was chosen based on measured data from two independent testers (RTL8922AU, 6GHz MLO and 2.4/5GHz):

Calibration PCIe timeout Max measured (USB) 4x timeout
PRE_NTFY 5ms 1ms 20ms
DACK 58ms 72ms 232ms
RX_DCK 128ms 374ms 512ms

  TSSI normal       20ms             24ms              80ms
  TSSI scan          6ms             14ms              24ms
  TXGAPK            54ms             18ms             216ms
  IQK               84ms             53ms             336ms
  DPK               34ms             30ms             136ms

Tested with RTL8922AU on 6GHz MLO (5GHz + 6GHz simultaneous):
25 connect/disconnect cycles with zero failures.

The 4x multiplier was also verified under adverse host conditions on 5GHz. 5 cycles per scenario, stress-ng as the load generator, max observed time per calibration:

Calibration PCIe 4x Baseline CPU stress Mem stress Combined
PRE_NTFY 5 20 0 0 0 1

  DACK          58  232    71 (!)    71 (!)      71 (!)      71 (!)
  RX_DCK       128  512    23        22          22          23
  IQK           84  336    53        53          53          53
  DPK           34  136    23        23          26          23
  TSSI          20   80     6         9          14           9
  TXGAPK        54  216    16        16          16          16

Legend: (!) = exceeds PCIe budget but within 4x budget.

Two observations from that matrix:

1. DACK exceeds the stock PCIe budget (58ms) in baseline on 5GHz on this hardware. Without the 4x multiplier, DACK fails -ETIMEDOUT deterministically on every connect, no stress needed. This is the condition the patch addresses.

2. Calibration times appear dominated by USB transport round-trip latency rather than host load, though hardware and external component factors may also contribute. DACK stays at 71ms across all four scenarios. Host-side stress has essentially zero effect on observed calibration duration. Bumping the multiplier above 4x would not address a failure mode that this stress matrix produces.

---
Changes since v2:
- Reword commit message per Ping-Ke review: remove v1 reference from permanent changelog, use "condition" instead of "bug", acknowledge hardware factors in calibration timing rather than asserting I/O bound.
- Add Tested-by tags from Devin Wittmayer across 4 chipsets

    (RTL8922AU, RTL8852AU, RTL8852BU, RTL8852CU) on Framework 13 +
    Fedora 43 (6.19.11) and Raspberry Pi 5 + Pi OS (6.12.47).

- Add Reported-by for independent confirmation including xHCI hard lockup evidence (CPU5 deadlock in usb_unanchor_urb after DACK timeout triggered driver recovery).

v2: https://lore.kernel.org/linux-wireless/[email protected]/
v1: https://lore.kernel.org/linux-wireless/[email protected]/

 drivers/net/wireless/realtek/rtw89/phy.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/wireless/realtek/rtw89/phy.c +8 -0
index e70d0e283..1f249c297 100644
@@ -3956,6 +3956,14 @@ int rtw89_phy_rfk_report_wait(struct rtw89_dev *rtwdev, const char *rfk_name,
 	struct rtw89_rfk_wait_info *wait = &rtwdev->rfk_wait;
 	unsigned long time_left;
 
+	/*
+	 * USB transport adds latency to H2C/C2H round-trips, so RF
+	 * calibrations take longer than on PCIe. Apply a 4x multiplier
+	 * to avoid spurious timeouts.
+	 */
+	if (rtwdev->hci.type == RTW89_HCI_TYPE_USB)
+		ms *= 4;
+
 	/* Since we can't receive C2H event during SER, use a fixed delay. */
 	if (test_bit(RTW89_FLAG_SER_HANDLING, rtwdev->flags)) {
 		fsleep(1000 * ms / 2);

base-commit: 1e33ef7657531b2361d53cca25f375b5626e76a9

Signature · 1 line
2.53.0
#1 lore raw

Thanks for driving this through three rounds, Louis. And thanks to Ping-Ke and Bitterblue for the review cycle. With v3 applied the DACK timeouts stop across every rtw89 USB chipset I had on the bench.

--
Devin Wittmayer

maintainer
#2 lore raw
Quoted 4 lines · Devin Wittmayer

Thanks for driving this through three rounds, Louis. And thanks to Ping-Ke and Bitterblue for the review cycle. With v3 applied the DACK timeouts stop across every rtw89 USB chipset I had on the bench.

I also thank all you for patch and test. :)
I'll merge this patch after merge window (~1.5 weeks later).

Ping-Ke

maintainer
#3 lore raw
In reply to Louis Kotze
Quoted 56 lines · Louis Kotze

USB transport adds significant latency to H2C/C2H round-trips used by RF calibration. The existing timeout values were designed for PCIe and are too tight for USB, causing "failed to wait RF DACK", "failed to wait RF TSSI" and similar errors on USB adapters.

Apply a 4x timeout multiplier when the device uses USB transport. The multiplier is applied in rtw89_phy_rfk_report_wait() so all calibrations benefit without changing any call sites or PCIe timeout values.

The 4x multiplier was chosen based on measured data from two independent testers (RTL8922AU, 6GHz MLO and 2.4/5GHz):

Calibration PCIe timeout Max measured (USB) 4x timeout
PRE_NTFY 5ms 1ms 20ms
DACK 58ms 72ms 232ms
RX_DCK 128ms 374ms 512ms

  TSSI normal       20ms             24ms              80ms
  TSSI scan          6ms             14ms              24ms
  TXGAPK            54ms             18ms             216ms
  IQK               84ms             53ms             336ms
  DPK               34ms             30ms             136ms

Tested with RTL8922AU on 6GHz MLO (5GHz + 6GHz simultaneous):
25 connect/disconnect cycles with zero failures.

The 4x multiplier was also verified under adverse host conditions on 5GHz. 5 cycles per scenario, stress-ng as the load generator, max observed time per calibration:

Calibration PCIe 4x Baseline CPU stress Mem stress Combined
PRE_NTFY 5 20 0 0 0 1

  DACK          58  232    71 (!)    71 (!)      71 (!)      71 (!)
  RX_DCK       128  512    23        22          22          23
  IQK           84  336    53        53          53          53
  DPK           34  136    23        23          26          23
  TSSI          20   80     6         9          14           9
  TXGAPK        54  216    16        16          16          16

Legend: (!) = exceeds PCIe budget but within 4x budget.

Two observations from that matrix:

1. DACK exceeds the stock PCIe budget (58ms) in baseline on 5GHz on this hardware. Without the 4x multiplier, DACK fails -ETIMEDOUT deterministically on every connect, no stress needed. This is the condition the patch addresses.

2. Calibration times appear dominated by USB transport round-trip latency rather than host load, though hardware and external component factors may also contribute. DACK stays at 71ms across all four scenarios. Host-side stress has essentially zero effect on observed calibration duration. Bumping the multiplier above 4x would not address a failure mode that this stress matrix produces.

Quoted 9 lines

1 patch(es) applied to rtw-next branch of rtw.git, thanks.

5055188134c3 wifi: rtw89: phy: increase RF calibration timeouts for USB transport

---
https://github.com/pkshih/rtw.git