Re: [PATCH rtw-next v10 3/3] wifi: rtw88: time the countdown downloads from the TBTT
From: Luka Gejak
Date: Thu Nov 12 2026 - 07:16:29 EST
Hi Mehmet,
Thanks for the v10. Two comments below.
On November 11, 2026 1:15:25 PM GMT+01:00, 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..c30aa938f9a9 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);
As far as I can see rtw88 never writes the beacon interval register
(0x554), while rtlwifi writes it on BSS_CHANGED_BEACON_INT. So the
hardware probably keeps its default, and the TBTTs computed here from
bss_conf.beacon_int would only match the air at 100 TU.
Could you check the beacon spacing in a capture with beacon_int=200? If
it stays at 100 TU, that is a separate bug. Would you be willing to send
a fix for that too?
[ ... ]
> + delay = rtwdev->csa_tbtt + RTW_CSA_TBTT_MARGIN_US - tsf;
> + if (delay > interval + RTW_CSA_TBTT_MARGIN_US ||
> + delay < -(s64)interval) {
> + /* the TSF jumped: restart from the next TBTT */
> + div_u64_rem(tsf, interval, &rem);
> + rtwdev->csa_tbtt = tsf - rem + interval;
> + delay = rtwdev->csa_tbtt + RTW_CSA_TBTT_MARGIN_US - tsf;
> + }
rtw88 sets BIT_DIS_TSF_UDT for AP and IBSS and has no reset_tsf op, so I
think this mostly catches a download that ran more than a beacon
interval late, not a TSF jump. Maybe say that in the comment?
The start case computes the same next TBTT, so it could share this
branch:
rtwdev->csa_tbtt += interval;
delay = rtwdev->csa_tbtt + RTW_CSA_TBTT_MARGIN_US - tsf;
if (start || delay > interval + RTW_CSA_TBTT_MARGIN_US ||
delay < -(s64)interval) {
Best regards,
Luka Gejak