wifi: rtw89: 8922a: redo channel RFK on a bad DPK result
PATCH 1/1 wifi: rtw89: 8922a: redo channel RFK on a bad DPK result
On RTL8922AU the channel calibration at AP start sometimes leaves path B with a bad DPK result while the firmware reports success. The DPK TX AGC of path B is then far below path A, or path B is not ok, and the AP hardly gets frames to its clients until it is restarted. The TSSI and IQK results of path B are off in the same runs.
Keep the DPK report the firmware sends and redo the whole channel calibration when a path is not ok or timed out, or the TX AGC of the two paths differs by more than 5, at most three times. The check runs only when the PHY owns both paths.
Tested on RTL8922AU over USB in AP mode: 12 bad first calibrations in 145 AP starts, all good on the second try. No stall in 105 starts with a client, against 4 of 80 without the patch.
---
The check comes from one adapter. Is the DPK TX AGC gap, path_ok and is_timeout the right thing to look at, or is there a better result the driver should check? Or should the firmware handle this? The report is kept in rfk_wait for now. Would rtwdev->dpk be better, like rtwdev->iqk?
The older chips do it differently. RTL8852B runs DPK in the driver and switches DPD off on a failed path, and rtw88 does the same on RTL8822C after checking the coefficients. Neither redoes the calibration. Here the firmware reports the bad path as ok in most runs, and TSSI and IQK of that path are off as well, so this patch redoes the whole channel calibration. Would switching DPD off on path B be preferred, at least after the third bad try? The H2C has a dpk_enable byte, I did not try it.
Details, RTL8922AU (Cudy BE6500), firmware 0.35.80.3, backports 7.2 on Linux 6.18 (OpenWrt) unless noted:
- 5 to 15 percent of AP starts on channel 36 get the bad calibration, the rate varies over time. Every one I tested with a client stalled the AP (beacon loss on the client, a few Mbit/s). The rtw89 code of early November (morrownr/rtw89 f2ce66e) behaves the same.
- With that morrownr build, which has diag_rf, running only the channel calibration again fixed the same AP 3 of 3 times without a restart. 40 such runs in a row on a running AP (morrownr build on Turris OS) were all good, so it seems to hit only the first calibration shortly after the chip comes up. It also happens with the client powered off.
- Not the cause: skipping the PHY_1 channel setup in MLO 2+0 mode (5 of 40 starts still bad) and calling rfk_mlo_ctrl at the start of rfk_init_late as RTL8922D does (4 of 40 still bad).
- The firmware sends the DPK report also with RFK debug off. All reports I logged had is_timeout 0. RFK debug was on in all 145 starts of the test line. With it off, earlier versions of this patch ran 40 starts with a client without a stall, one of them with a visible retry.
- With RFK debug on, the DPK report came 0.01 to 0.04 ms after its RFK state report in 34 runs over USB. The driver already waits for every RFK state report on the one shared rfk_wait.completion, and the DPK report relies on the same assumption.
- DPK TX AGC A/B (hex), good: 37/34, 36/34 and 36/33 on channel 36, 38/39, 38/35 and 38/36 on channel 149, 37/37 on 2.4 GHz channel 6.
Bad: path B at 28 to 30, or 00 with path_ok 0. The DPK correlation of path B does not separate them (good 220 to 250, bad 166 to 241).
- Channel 149: no retry in 30 AP starts, but 3 of them had the TSSI alignment of path B done and path B at 35 or 36 instead of 39. Traffic on that channel is untested.
- No RFK step reported a failure in the 822 AP starts I have console logs for, so the decision uses only the DPK report.
- Only the whole sequence was tested as the retry. Redoing only DPK is untested. diag_rf records only the last try. The "no DPK report" path and the "DPK still bad" warning never ran.
- Built and run only as a backport to 7.2. This rtw-next version was not compiled.
- Tested only as an AP over USB with both antennas. Station mode, PCIe, 6 GHz, MLO, antenna masks and one-antenna boards are untested, although the function runs there too.
- A missing report is accepted as before, so firmware without the report and SER, where C2H events are not received, do not retry.
drivers/net/wireless/realtek/rtw89/core.c | 1 + drivers/net/wireless/realtek/rtw89/core.h | 8 +++ drivers/net/wireless/realtek/rtw89/phy.c | 7 ++ drivers/net/wireless/realtek/rtw89/rtw8922a.c | 67 +++++++++++++++++-- 4 files changed, 77 insertions(+), 6 deletions(-)
drivers/net/wireless/realtek/rtw89/core.c +1 -0
@@ -7113,6 +7113,7 @@ int rtw89_core_init(struct rtw89_dev *rtwdev)init_completion (&rtwdev->fw.req.completion);init_completion (&rtwdev->rfk_wait.completion); +init_completion (&rtwdev->rfk_wait.dpk_rpt.done);schedule_work (&rtwdev->load_firmware_work);
drivers/net/wireless/realtek/rtw89/core.h +8 -0
@@ -6742,11 +6742,19 @@ struct rtw89_rfk_record {enum rtw89_rfk_report_state states[NUM_OF_RTW89_RFK_REPORT_TYPES ]; }; +struct rtw89_rfk_dpk_rpt { +struct completion done; +u8 path_ok[2 ]; +u8 txagc[2 ]; +u8 is_timeout[2 ]; +}; +struct rtw89_rfk_wait_info {struct completion completion;ktime_t start_time;enum rtw89_rfk_report_state state;u8 version; +struct rtw89_rfk_dpk_rpt dpk_rpt;int record_idx;struct rtw89_rfk_record *record_ptr;
drivers/net/wireless/realtek/rtw89/phy.c +7 -0
@@ -3563,6 +3563,7 @@ static void rtw89_phy_c2h_rfk_rpt_log(struct rtw89_dev *rtwdev,struct rtw89_c2h_rf_dack_rpt_log *dack;struct rtw89_c2h_rf_tssi_rpt_log *tssi;struct rtw89_c2h_rf_dpk_rpt_log *dpk; +struct rtw89_rfk_dpk_rpt *dpk_rpt;struct rtw89_c2h_rf_iqk_rpt_log *iqk;int i, j, k;
@@ -3660,6 +3661,11 @@ static void rtw89_phy_c2h_rfk_rpt_log(struct rtw89_dev *rtwdev, goto out; dpk = content; + dpk_rpt = &rtwdev->rfk_wait.dpk_rpt; +memcpy (dpk_rpt->path_ok, dpk->path_ok,sizeof (dpk_rpt->path_ok)); +memcpy (dpk_rpt->txagc, dpk->txagc,sizeof (dpk_rpt->txagc)); +memcpy (dpk_rpt->is_timeout, dpk->is_timeout,sizeof (dpk_rpt->is_timeout)); +complete (&dpk_rpt->done);rtw89_debug (rtwdev,RTW89_DBG_RFK ,"DPK ver:%d idx:%2ph band:%2ph bw:%2ph ch:%2ph path:%2ph\n" , dpk->ver, dpk->idx, dpk->band, dpk->bw, dpk->ch, dpk->path_ok);
@@ -4258,6 +4264,7 @@ int rtw89_phy_rfk_dpk_and_wait(struct rtw89_dev *rtwdev,int ret;rtw89_phy_rfk_report_prep (rtwdev); +reinit_completion (&rtwdev->rfk_wait.dpk_rpt.done); ret =rtw89_fw_h2c_rf_dpk (rtwdev, phy_idx, chan);if (ret)
drivers/net/wireless/realtek/rtw89/rtw8922a.c +61 -6
84 lines not on this page · raw message
base-commit: 8b29fd95e2d3cb80564eb7cb34248b844422ba1e
Signature · 1 line
2.54.0 (Apple Git-157)