mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Luka Gejak" <luka.gejak@linux.dev>
To: "Mehmet Fide" <mehmet.fide@gmail.com>,
	"Ping-Ke Shih" <pkshih@realtek.com>
Cc: "Bitterblue Smith" <rtl8821cerfe2@gmail.com>,
	linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	mehmet.fide@screeningeagle.com
Subject: Re: [PATCH rtw-next v9 3/3] wifi: rtw88: time the countdown downloads from the TBTT
Date: Fri, 30 Oct 2026 16:23:01 +0000	[thread overview]
Message-ID: <6a4c37826646abbf833e49aadee7701a3dd4e96a@linux.dev> (raw)
In-Reply-To: <20261026152940.1274382-4-mehmet.fide@gmail.com>

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@gmail.com> 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

      reply	other threads:[~2026-10-30 16:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26 15:29 [PATCH rtw-next v9 0/3] wifi: rtw88: channel switch in AP mode Mehmet Fide
2026-10-26 15:29 ` [PATCH rtw-next v9 1/3] wifi: rtw88: download the beacon the reserved page was built with Mehmet Fide
2026-10-26 15:29 ` [PATCH rtw-next v9 2/3] wifi: rtw88: support channel switch in AP mode Mehmet Fide
2026-10-30 16:18   ` Luka Gejak
2026-10-26 15:29 ` [PATCH rtw-next v9 3/3] wifi: rtw88: time the countdown downloads from the TBTT Mehmet Fide
2026-10-30 16:23   ` Luka Gejak [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6a4c37826646abbf833e49aadee7701a3dd4e96a@linux.dev \
    --to=luka.gejak@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=mehmet.fide@gmail.com \
    --cc=mehmet.fide@screeningeagle.com \
    --cc=pkshih@realtek.com \
    --cc=rtl8821cerfe2@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®