Skip to content

wifi: brcmfmac: msgbuf: leave one rx packet ID of slack for the refill - #235

Merged
derekross merged 1 commit into
derekross:omamobilefrom
Somnius:husky-pktid-slack-1109
Nov 9, 2026
Merged

derekross merged 1 commit into
derekross:omamobilefrom
Somnius:husky-pktid-slack-1109

Conversation

@Somnius

@Somnius Somnius commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

This is the one-line packet-ID slack from the thread on #156, as its own PR now that #187 landed with the msgbuf commits. @derekross, @greenbrettmichael and @W4HO-ham, it goes right after "msgbuf: give control buffers the lowest packet IDs".

Without it the BCM4398 on the 8 Pro logs "No PKTID available !!" about once per 15.7 received packets (13,250 lines for 208,529 packets in a 300 MB download), because a refill needs N free IDs while the completed buffer still holds one. The change caps max_rxbufpost one lower (NR_RX_PKTIDS - 2), with a comment saying why. On my 8 Pro four runs of the same download gave 0 new lines (details in #156 (comment)), with the same packet counts and about the same time. On the 7 Pro it changes nothing, its firmware asks for 1535 buffers, so the min_t still picks 1535 (as @derekross worked out, #156 (comment)).

What I checked on this rebased commit: it's cherry-picked unchanged onto current omamobile (1a882ca), checkpatch --strict is clean, and msgbuf.o builds with W=1 and no warnings (clang r547379, my test kernel's config). What I haven't done is boot a kernel built from this exact rebase: the four runs above were on my earlier e1 tree with the same one-line change.

The rx packet IDs are shared by the data, ioctl response and event
buffers. max_rxbufpost is capped so that the data buffers get IDs
nr_ctrl + 1 .. NR_RX_PKTIDS - 1, exactly as many IDs as buffers that
may be posted. That is one too few when the ring is refilled.

brcmf_msgbuf_process_rx_complete() calls
brcmf_msgbuf_update_rxbufpost_count() before it frees the completed
buffer's ID with brcmf_msgbuf_get_pktid(). When the posted count drops
to max_rxbufpost - BRCMF_MSGBUF_RXBUFPOST_THRESHOLD, the refill tries
to post 32 buffers while the buffer being completed still holds its
ID, so only 31 IDs are free and the 32nd allocation fails with
"No PKTID available". The refill posts 31 and logs, and the retry for the
last buffer logs again. The posted count then sits one under the cap,
so the next refill, 31 completions later, is short the same way: two
lines for every 31 received buffers.

On a BCM4398 (Pixel 8 Pro) a 300 MB download produced one
"No PKTID available !!" line per 15.7 received packets (13,250 lines
for 208,529 packets); the refill reading predicts one per 15.5.
I saw no throughput problem, which fits: each short refill leaves at
most one buffer unposted.

Cap max_rxbufpost one lower so a full refill always finds an ID.

Signed-off-by: Lef <me@lefteros.com>
@derekross

Copy link
Copy Markdown
Owner

Thank you, @Somnius, for splitting this out so cleanly, and for the
measurements behind it. I followed the refill path on the base and your
arithmetic holds: with the cap at exactly the number of data IDs, the refill
at 1983 posted wants 32 while the completing buffer still holds its ID, so
the 32nd fails and the batch's retry logs a second line, every 31
completions.

Your note that you hadn't booted this exact rebase: the msgbuf.c you
tested (ba1744a44c0f, from 93eebe6cebbf) is byte-for-byte the file this
commit produces on today's omamobile, and the two patches have the same
patch-id, so your four runs stand for it.

On my 7 Pro: I built msgbuf.o before and after with our config, and the
only difference is the cap's constant in brcmf_proto_msgbuf_attach (2015
to 2014). The 7 Pro's firmware asks for 1535 rx buffers (every one of the 20
max rx buf post lines in my logs), so the min_t picks 1535 either way and
nothing changes there. No run on my phone is needed before this goes in.

One optional thing, only if you're touching it anyway: a Fixes: line
naming 9106475d6016 ("give control buffers the lowest packet IDs") would
help whoever lines the msgbuf commits up for upstream later. Not a
requirement.

I'll merge it as it is. Thanks again!

@derekross
derekross merged commit 395ef17 into derekross:omamobile Nov 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants