Re: [PATCH rtw-next v14 2/3] wifi: rtw88: support channel switch in AP mode
From: Luka Gejak
Date: Mon Nov 23 2026 - 19:25:22 EST
Hi Mehmet,
Thanks for the v14. Six comments below.
On November 21, 2026 8:36:43 PM GMT+01:00, Mehmet Fide
<mehmet.fide@xxxxxxxxx> wrote:
> + 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)));
With a count of 2, if the work runs more than one interval late, it can
install count 1 and queue the finish with no delay. It can then switch
before a TBTT has had a chance to send the count. Your v13 test with the
150 ms delay showed this with patch 2 alone.
Could the TBTT pacing from patch 3 go in here so the commit that enables
CSA also waits for that last TBTT?
https://lore.kernel.org/linux-wireless/20261120170322.375333-1-mehmet.fide@xxxxxxxxx/
[ ... ]
> + 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);
As far as I can see, mac80211 can stop the queues before the size check
in rtw_build_rsvd_page(). The hostapd message size limit covers that
client. nl80211_channel_switch() has no check against the chip's page
limit.
If the countdown beacon needs more pages than the chip has, retrying
the same count can't make it fit. The switch then stays pending, and
block_tx keeps the queues stopped. Could the driver reject a template
that cannot fit, or stop the AP if the download keeps failing?
[ ... ]
> 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);
I think the download here has a different consequence after a switch
than in an ordinary beacon update. mac80211 has already changed the
channel. If building the page fails, the new beacon never reaches the
firmware, but mac80211 reports completion and the countdown work stops.
Could this path retry the new beacon when the download fails?
[ ... ]
> + if (conf->csa_active)
> + rtw_fw_csa_start(rtwdev, vif, !!ret);
This also makes the mac80211 IBSS fix a dependency. The cover
letter says it was in the test tree, but this rtw-next range is missing
12f97c692dcb. Leaving an IBSS clears the driver work and leaves
csa_active set. On the next join, this starts work on the new beacon,
which has no countdown and starts with a zero counter.
Could we make sure the mac80211 fix is in the target tree before
enabling CSA here?
https://lore.kernel.org/linux-wireless/20261025193615.1123718-1-mehmet.fide@xxxxxxxxx/
[ ... ]
> + } else {
> + rtw_fw_download_rsvd_page(rtwdev);
> + rtw_send_rsvd_page_h2c(rtwdev);
> + }
If the station's association download was deferred and the AP stops
before the next countdown download, this is the first attempt to update
the station's templates. The builder replaces the AP beacon with a
dummy page and recalculates the station page locations before it
allocates the download buffer. If that allocation fails and the AP
beacon used more than one page, the H2C can advertise new locations
while the firmware still has the old layout.
Could we send the locations only after a successful download and
retry the download if it fails?
[ ... ]
> + WIPHY_FLAG_HAS_CHANNEL_SWITCH;
What happens if the AP on an RTL8822C changes channel while the station
interface is associated on the old channel? So if I read it right,
mac80211 reserves a replacement for the shared context and the
combination check accepts it. At the end of the countdown, the old
context still has a station that did not reserve the new one, so
ieee80211_vif_use_reserved_switch() fails and mac80211 requests an AP
stop.
Could the driver reject this before it starts announcing the switch?
Best regards,
Luka Gejak