Re: [PATCH rtw-next v13 2/3] wifi: rtw88: support channel switch in AP mode
From: Luka Gejak
Date: Fri Nov 20 2026 - 09:16:28 EST
Hi Mehmet,
Thanks for the v13. Four comments below.
On November 19, 2026 12:19:39 AM 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 e0f3e1adb13f..9d5df3e65b97 100644
> --- a/drivers/net/wireless/realtek/rtw88/fw.c
> +++ b/drivers/net/wireless/realtek/rtw88/fw.c
[ ... ]
> + rtwdev->csa_due = ktime_add_us(rtwdev->csa_due, interval);
> + delay = ktime_us_delta(rtwdev->csa_due, ktime_get());
> + ieee80211_queue_delayed_work(rtwdev->hw, &rtwdev->csa_beacon_work,
> + usecs_to_jiffies(max(delay, 0)));
I think this can finish before the last count gets a TBTT if the work
runs a full interval late. With a count of 2, the work installs count 1
and queues the finish immediately because csa_due has already passed.
Patch 3 measures the next TBTT after the download. Could the countdown
use that pacing from the commit that enables CSA?
[ ... ]
> + rtwdev->csa_retry = !!rtw_fw_download_rsvd_page(rtwdev);
> + if (!rtwdev->csa_retry)
> + rtw_send_rsvd_page_h2c(rtwdev);
> + rtw_fw_csa_queue(rtwdev, vif);
What happens if the page can never fit? On RTL8821C the driver has
eight 128 byte pages. A beacon that fits before the switch can exceed
that space after adding the CSA element. The builder then returns an
error every time, so the switch stays pending and a request with
block_tx keeps the queues stopped.
Could we reject a template that cannot fit before committing to the
switch, or give up and stop the AP if the download keeps failing?
[ ... ]
> diff --git a/drivers/net/wireless/realtek/rtw88/mac80211.c b/drivers/net/wireless/realtek/rtw88/mac80211.c
> index 3029fbdb288a..c9ac2685437e 100644
> --- a/drivers/net/wireless/realtek/rtw88/mac80211.c
> +++ b/drivers/net/wireless/realtek/rtw88/mac80211.c
[ ... ]
> if (changed & BSS_CHANGED_BEACON) {
> rtw_set_dtim_period(rtwdev, conf->dtim_period);
> - rtw_fw_download_rsvd_page(rtwdev);
> + ret = rtw_fw_download_rsvd_page(rtwdev);
> rtw_send_rsvd_page_h2c(rtwdev);
[ ... ]
> + if (conf->csa_active)
> + rtw_fw_csa_start(rtwdev, vif, !!ret);
> + else
> + rtw_fw_csa_stop(rtwdev, vif);
Could we retry the first beacon download after the switch too?
mac80211 has already changed the channel when it hands us that beacon.
If the page buffer allocation fails here, the old page still holds the
last CSA beacon. As far as I can see, the switch can be reported complete
while the new beacon is still waiting for another update.
[ ... ]
> + } else {
> + /* what a countdown may have held back */
> + rtw_fw_download_rsvd_page(rtwdev);
> + rtw_send_rsvd_page_h2c(rtwdev);
> + }
There seems to be a similar case when the AP stops. If the station
associates during the countdown and the AP stops before the next step,
this is the first chance to install the station's new reserved page
contents. A failed allocation here can leave a PS Poll template with
the AID it had before the association, even though the station stays
connected.
Could we queue a retry for the station if this refresh fails?
Best regards,
Luka Gejak