From 7c1e6e6adcd0ff3d0b72f925bb52fec855caa35f Mon Sep 17 00:00:00 2001 From: Lef Date: Mon, 2 Nov 2026 09:27:29 +0200 Subject: [PATCH] wifi: brcmfmac: msgbuf: leave one rx packet ID of slack for the refill 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 --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c index 93eebe6ceb..ba1744a44c 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c @@ -1886,10 +1886,14 @@ int brcmf_proto_msgbuf_attach(struct brcmf_pub *drvr) msgbuf->max_eventbuf = BRCMF_MSGBUF_MAX_EVENTBUF_POST; /* Data, ioctl response and event buffers share the rx packet IDs - * (ID 0 is never used): leave enough for the control buffers. + * (ID 0 is never used): leave enough for the control buffers, plus + * one ID of slack. A completed rx buffer still holds its ID when + * the refill runs (brcmf_msgbuf_process_rx_complete updates the + * post count before it frees the ID), so a refill of N buffers + * needs N free IDs while N - 1 are available. */ msgbuf->max_rxbufpost = min_t(u32, if_msgbuf->max_rxbufpost, - NR_RX_PKTIDS - 1 - + NR_RX_PKTIDS - 2 - 2 * (msgbuf->max_ioctlrespbuf + msgbuf->max_eventbuf));