Re: [PATCH rtw-next v9 3/3] wifi: rtw88: time the countdown downloads from the TBTT
From: Luka Gejak
Date: Fri Oct 30 2026 - 12:23:08 EST
Hi Mehmet,
Looking at this patch again, I found something I missed on v8.
October 26, 2026 at 4:29 PM, "Mehmet Fide" <mehmet.fide@xxxxxxxxx> wrote:
> diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c
> index 2d81aaeed0d7..9ba4f1c244ec 100644
> --- a/drivers/net/wireless/realtek/rtw88/fw.c
> +++ b/drivers/net/wireless/realtek/rtw88/fw.c
[ ... ]
> +static void rtw_fw_csa_queue(struct rtw_dev *rtwdev, struct ieee80211_vif *vif,
> + bool start)
> {
> u32 interval = ieee80211_tu_to_usec(vif->bss_conf.beacon_int);
> + u64 tsf = rtw_fw_read_tsf(rtwdev);
> s64 delay;
> + u32 rem;
> +
> + if (start) {
> + div_u64_rem(tsf, interval, &rem);
> + rtwdev->csa_tbtt = tsf - rem + interval;
> + /* a TBTT just passed may have sent the first count */
> + if (rem < RTW_CSA_TBTT_MARGIN_US)
> + rtwdev->csa_tbtt -= interval;
As far as I can see, the TSF is only read here once the whole page
download and the H2C are done:
rtw_ops_bss_info_changed()
rtw_fw_download_rsvd_page()
rtw_send_rsvd_page_h2c()
rtw_fw_csa_start()
rtw_fw_csa_queue(rtwdev, vif, true)
You measured about 3.3 ms for a download on USB, and on PCIe it is just a
DMA and some register polling. So most of the 10 ms margin lies before
the download started. A TBTT there sent the old beacon, but it is still
taken as the one that sent the first count, and with the usual beacon
interval the work replaces that count before it is ever sent.
With a count of 2 the first fetch already carries count 1. So if I read
it right, the work then finds ieee80211_beacon_cntdwn_is_complete() true
and calls ieee80211_csa_finish() before any beacon with the CSA element
went out. Before this patch the first work ran a full interval after the
download, so the count 1 beacon went out first. With bigger counts the
first count just gets lost.
Could the TSF also be read before rtw_fw_download_rsvd_page(), so that
only a TBTT after the download started is taken as one that may have
sent the first count? Maybe this could also be checked on the 8822CE
once it arrives.
Best regards,
Luka Gejak