From: luka.gejak@linux.dev
To: Ping-Ke Shih <pkshih@realtek.com>
Cc: Luka Gejak <luka.gejak@linux.dev>,
linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
Michael Straube <straube.linux@gmail.com>,
Peter Robinson <pbrobinson@gmail.com>,
Bitterblue Smith <rtl8821cerfe2@gmail.com>
Subject: Re: [PATCH v2 07/11] wifi: rtw88: sdio: track free TX pages and OQT credits for RTL8723BS
Date: Thu, 30 Jul 2026 07:45:00 +0000 [thread overview]
Message-ID: <20260730074504.19725-6-luka.gejak@linux.dev> (raw)
In-Reply-To: <cc9251b01235422e8b5a22fc0997b0f7@realtek.com>
From: Luka Gejak <luka.gejak@linux.dev>
On 27/07/2026 08:52, Ping-Ke Shih wrote:
>> output queue token count that rtw88 does not track at all.
>
> Does OQT mean Output Queue Token? Could you explain a little bit?
Yes. REG_SDIO_OQT_FREE_PG is how many more descriptors the chip's SDIO
output queue can still accept. On this part the chip discards a write
that arrives when the count is zero, silently, so the frame is lost
rather than retried. The vendor driver polls the register before every
port write; this patch caches the count and only re-reads when the
cached value is exhausted. I have rewritten that paragraph of the
commit message to spell it out and dropped the "OQT" abbreviation from
the prose.
> I think this can largely improve SDIO. Please share the performance
> numbers before/after this patch.
Added to the commit message. Measured against an iperf3 server one hop
behind the AP, using the wlan0 byte counters as ground truth because
eth0 on the test box shares the same subnet:
without this patch: TCP and UDP both 0 bit/s in either direction
with this patch: TCP 25.3 Mbit/s up, 37.3 Mbit/s down
UDP 25.0 Mbit/s up at 0% loss
To be clear about the "before" number: on the generic path the
association itself still completes, but no data gets through at all, so
this is not a tuning patch. The transfer sizing in the third hunk is
the part that matters most there; without the block size padding the
chip stops accepting writes entirely.
>> +static void rtw_sdio_init_free_txpg(struct rtw_dev *rtwdev)
>> +static void rtw_sdio_sync_free_txpg(struct rtw_dev *rtwdev)
>
> _8723bs_ specific so add to the function name
Renamed, along with rtw_sdio_wait_tx_oqt() ->
rtw_sdio_8723bs_wait_tx_oqt(). The shared field decoding is now
rtw_sdio_8723bs_store_free_txpg().
> It is clear that bit masks of REG_SDIO_FREE_TXPG are PG_{HIGH, NORMAL, LOW,
> PUB}. Let's define them in reg.h, and use u32_get_bits() to read out the
> values.
Done, in sdio.h next to REG_SDIO_FREE_TXPG since that is where the
register lives:
#define BIT_FREE_TXPG_HIGH GENMASK(7, 0)
#define BIT_FREE_TXPG_NORMAL GENMASK(15, 8)
#define BIT_FREE_TXPG_LOW GENMASK(23, 16)
#define BIT_FREE_TXPG_PUB GENMASK(31, 24)
and read with u32_get_bits(). That also removed the duplicated decode,
which is what let me answer your next question properly.
>> + dedicated = rtw_sdio_8723bs_free_txpg(rtwdev, queue);
>
> Why do you check ` dedicated < 0` for this case?
There was no good reason; the queue does not change between the two
calls so the second result could not have been an error. Rather than
add a second check, rtw_sdio_8723bs_free_txpg() now returns the
atomic_t * for the queue, so the mapping is resolved once, NULL is
checked once with a warning, and the resync path just re-reads the same
counter.
>> + bool rtl8723bs = rtw_is_8723bs(rtwdev);
>
> reverse X'mas tree
Fixed.
>> + if (!ret && rtl8723bs) {
>
> move to else-branch below?
Done, it is now if (ret) { warn } else if (rtl8723bs) { account }.
>> + if (fifo->acq_pg_num <= pg_tbl->hq_num + pg_tbl->lq_num +
>
> second and third lines don't align.
The sum was computed twice with different formatting, so it is now a
reserved_num local used in both places.
>> + rtw_sdio_8723bs_check_rqpn(rtwdev);
>
> Should we check chip is RTL8723BS before calling?
> I'd have consistent the calling rule -- callers check?
Agreed, and applied across the series. rtw_sdio_start() now has the
test and both helpers assume it.
>> + atomic_t free_pg_high;
>
> Could I know the reason why these should be atomic_t? Which context are
> they running?
Two contexts. The usual one is the TX work, which is single threaded
(create_singlethread_workqueue), so on its own it would not need them.
But rtw_sdio_write_port() is also reached from rtw_sdio_write_data()
for H2C commands and reserved page uploads, which runs in process
context under rtwdev->mutex and does not go through the TX workqueue.
Those two share no lock.
The counters are a fast path hint rather than an authority: whenever
they claim there is not enough room, rtw_sdio_8723bs_sync_free_txpg()
re-reads REG_SDIO_FREE_TXPG before the caller gives up, so a lost
update costs one extra register read and nothing else. I have put that
reasoning in a comment above the helpers. If you would rather have a
spinlock around the group I can do that instead, it is not a hot path
in the sense that would make the lock cost anything.
Best regards,
Luka Gejak
next prev parent reply other threads:[~2026-07-30 7:45 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-25 15:04 [PATCH v2 00/11] wifi: rtw88: preparations for RTL8723B/RTL8723BS luka.gejak
2026-07-25 15:04 ` [PATCH v2 01/11] wifi: rtw88: add the RTL8723B chip type and SDIO helper luka.gejak
2026-07-27 7:12 ` Ping-Ke Shih
2026-07-27 13:25 ` Luka Gejak
2026-07-30 6:27 ` Luka Gejak
2026-07-30 9:21 ` Ping-Ke Shih
2026-07-30 7:44 ` luka.gejak
2026-07-30 9:17 ` Ping-Ke Shih
2026-07-25 15:04 ` [PATCH v2 02/11] wifi: rtw88: rx: mark zero length packets on RTL8723BS luka.gejak
2026-07-27 7:14 ` Ping-Ke Shih
2026-07-30 7:44 ` luka.gejak
2026-07-25 15:04 ` [PATCH v2 03/11] wifi: rtw88: fw: add the GNT_BT firmware command luka.gejak
2026-07-25 15:04 ` [PATCH v2 04/11] wifi: rtw88: fw: fix the reserved page upload on RTL8723BS luka.gejak
2026-07-27 7:37 ` Ping-Ke Shih
2026-07-30 7:44 ` luka.gejak
2026-07-25 15:04 ` [PATCH v2 05/11] wifi: rtw88: coex: add the RTL8723BS scan antenna workaround luka.gejak
2026-07-27 7:58 ` Ping-Ke Shih
2026-07-30 7:44 ` luka.gejak
2026-07-25 15:04 ` [PATCH v2 06/11] wifi: rtw88: coex: reassert the antenna path when associating luka.gejak
2026-07-27 8:21 ` Ping-Ke Shih
2026-07-30 7:44 ` luka.gejak
2026-07-25 15:04 ` [PATCH v2 07/11] wifi: rtw88: sdio: track free TX pages and OQT credits for RTL8723BS luka.gejak
2026-07-27 8:52 ` Ping-Ke Shih
2026-07-30 7:45 ` luka.gejak [this message]
2026-07-25 15:04 ` [PATCH v2 08/11] wifi: rtw88: sdio: set up RX aggregation and interrupts " luka.gejak
2026-07-27 8:59 ` Ping-Ke Shih
2026-07-30 7:45 ` luka.gejak
2026-07-25 15:04 ` [PATCH v2 09/11] wifi: rtw88: sdio: add TX back-pressure and retry on page starvation luka.gejak
2026-07-27 9:21 ` Ping-Ke Shih
2026-07-30 7:45 ` luka.gejak
2026-07-30 9:02 ` Ping-Ke Shih
2026-07-25 15:04 ` [PATCH v2 10/11] wifi: rtw88: record beacons from the target BSSID before authenticating luka.gejak
2026-07-27 9:27 ` Ping-Ke Shih
2026-07-30 7:45 ` luka.gejak
2026-07-25 15:04 ` [PATCH v2 11/11] wifi: rtw88: run the RTL8723BS association register sequence luka.gejak
2026-07-27 9:33 ` Ping-Ke Shih
2026-07-30 7:45 ` luka.gejak
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=20260730074504.19725-6-luka.gejak@linux.dev \
--to=luka.gejak@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=pbrobinson@gmail.com \
--cc=pkshih@realtek.com \
--cc=rtl8821cerfe2@gmail.com \
--cc=straube.linux@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