Repository navigation
wifi: brcmfmac: msgbuf: receive into pages that hold only receive buffers - #3205
Conversation
…fers A 2 KiB receive skb comes from a page fragment, and the IOMMU maps the whole page it sits in: 16 KiB with 16K pages. Besides the 2 KiB it was given, the device can then write that skb's shared info, the other skbs in the page, and skbs already handed to the stack while a buffer from the same page is still posted. Post receive buffers from two pools of pages that hold nothing but receive buffers and stay mapped while the rings exist: 2 KiB data buffers and 8 KiB control buffers. A completed buffer is copied into a new skb of the reported length and goes back to its pool, so an skb is never mapped for receive. This also drops the map and unmap of every received packet. An ioctl response is now copied out when it completes rather than when its waiter wakes, so a response that arrives after its request timed out returns its buffer instead of holding it. Signed-off-by: Dj <[email protected]>
… header A data or event completion whose reported length is below ETH_HLEN reaches eth_type_trans(), which pulls ETH_HLEN bytes and wraps skb->len. A monitor frame that short makes brcmf_netif_mon_rx() trim past its start. A reported length beyond the receive buffer has already been cut by the copy and no longer matches the frame. Drop both, count them in rx_errors and rx_length_errors of the interface, and warn, rate-limited. Signed-off-by: Dj <[email protected]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
Update: the repeat runs show no post-sleep TX drop. The candidate's 188.8 Mb/s after sleep in the single run below was radio variance. Code tested: #3205 at How it was run: two more guarded one-shots on the default cmdline, the same day on the same Mac and the same 5 GHz access point (5785 MHz).
The order was AB (control boot, then candidate boot), not ABBA. Each boot ran:
Figures are Mb/s.
The 50 MB round right after wake: TX 249.6 (control) vs 245.6 (candidate), RX 194.0 vs 203.3. Each arm has one or two dips of 15–30 % in either direction; the candidate's lowest single round is before sleep. The candidate's medians are 3–7 % lower in three of the four columns, but there's only one boot per arm (AB, not ABBA) and single rounds swing far more than that, so I wouldn't read it as a regression. Post-sleep TX medians are equal. Health:
Both boots returned to the stock kernel, and the kits were removed from the Mac. Earlier run (single rounds): J773g (M4 Mac mini, BCM4388) at How it was run: two guarded one-shots on the default cmdline.
Test: BCM4388, Wi-Fi only, 5 GHz (5785 MHz) on the same access point for both boots. iperf3 isn't installed on the mini or the peer, so throughput comes from a minimal TCP sender/receiver run against a LAN peer: 200 MB each way, then one RTC s2idle sleep/wake, then 50 MB each way.
These are single over-the-air runs with no repeats, so the spread (±20 %) is radio variance: no direction is consistently lower on the candidate.
|
|
Verdict at Blockers: none. My first-pass blocker (red Checked
Not blockers:
Evidence
|
|
J516s (MacBook Pro 16" M3 Pro, BCM4388/4, 16K pages, 27.2 stub) row for #3210 at |
…etion brcmf_msgbuf_query_dcmd_len() now takes its response skb from msgbuf->ioctl_resp with xchg() instead of looking up a packet id. The association and recovery controls compile it against their own struct brcmf_msgbuf, which still had ioctl_resp_pktid, and the association controls had no xchg(). Give both stubs the ioctl_resp field, and have the stubbed send hand over its response there, holding the reported length, as the completion now does. Drop the brcmf_msgbuf_get_pktid() stubs, which nothing calls. Signed-off-by: DjDeveloperr <[email protected]>
|
Independent J316s (M1 Pro, BCM4387) row on #3210's head |
There was a problem hiding this comment.
Verdict: MERGE at a0ab00a7 (once cancelled CI checks are rerun green)
Blockers: none (code, host tests, and three-generation hardware rows are ready; rerun the 4 cancelled CI checks before merge).
Checked:
drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c: verifiedbrcmf_msgbuf_rxpoolallocates dedicatedPAGE_ALIGN(buf_size)noncoherent DMA chunks so 16K IOMMU mappings never exposesk_buffor unrelated kernel memory; verifieddma_sync_single_for_deviceon init/repost anddma_sync_single_for_cpubefore copying into fresh skbs; verifiedoffset > sizebounds checks,min(len, pool->buf_size - offset)clamping, andbrcmf_msgbuf_rx_len_ok()dropping frames< ETH_HLENor truncated (skb->len != len) beforeeth_type_trans()/brcmf_netif_mon_rx().- Verified
ioctl_respusesxchg(&msgbuf->ioctl_resp, ...)so timed-out ioctl responses cannot leak buffers or race completions. - Verified host tests (
brcmf-assoc-tests.py,brcmf-recovery-tests.py, 46/46 passing) and hardware rows across J773g (M4), J516s (M3 Pro, BCM4388), and J316s (M1 Pro, BCM4387, 256 MiB sha256 verified both directions pre/post s2idle).
Evidence
- Diff reviewed at
a0ab00a7(all 3 files, 671 lines). - CI at review time: 3 passed, 0 failed, 4 cancelled.
|
Merge-train status at |
|
Merge-train: everything else is ready (App approval, J773g + J516s + J316s rows, Dj pinged). The only red check is |
|
Merging under the 6-point rule at |
What: brcmfmac posts 2 KiB receive skbs carved from page fragments, and with 16K pages the IOMMU maps the whole 16 KiB page, so the device can also write the skb's shared info and the other skbs in that page. Receive buffers now come from two pools of pages that hold only receive buffers and stay mapped; each completed buffer is copied into a new skb of the reported length. A second commit drops received frames shorter than an Ethernet header, or longer than their buffer, before
eth_type_trans()sees them.Tested: J773g (M4 mini) row PASS at
a0ab00a770c0: it ran764aec53fd69, and this head only adds a host-test commit, so the driver code is unchanged (#3205 (comment)). The brcmf host tests pass at this head (46/46, all mutations killed), andmsgbuf.obuilds with W=1 on 16K pages.Risk: two-way · Macs with Broadcom PCIe Wi-Fi: M1, M2, M3, M4.
Not yet: The J516s (M3 Pro) row. M1 and M2 rows after merge. (The M4 mini's repeated runs, 4 before and 3 after sleep per arm, show no change after sleep: transmit medians 251.8 on main and 251.4 here.)
Details
brcmu_pkt_buf_get_skb()usesdev_alloc_skb(), which for these sizes takes the head frompage_frag_alloc(): several skb heads share one page, each with itsskb_shared_inforight after its data.dma_map_single()maps the page-aligned range around the buffer, and the IOMMU's page is the kernel's page, so the device can reach the whole page.min(max_rxbufpost, NR_RX_PKTIDS)× 2048 bytes; control buffers (ioctl responses and events) are 8 + 8 × 8192 bytes. Each pool is allocated in page-sizeddma_alloc_noncoherent()chunks, zeroed and synced for the device once, with the same receive direction as before (bidirectional on BCM4378, BCM4387 and BCM4388). The free list is host memory.dma_map_single()and adma_unmap_single()per packet. Memory is about what the posted skbs used: 32 pages for 255 data buffers plus 8 for control on 16K pages.skb->datathe same way and has nothing that keeps receive mappings inside the buffer.ETH_HLENreachedeth_type_trans(), which pullsETH_HLENand wrapsskb->len; a monitor frame that short makesbrcmf_netif_mon_rx()trim past its start. Those, and frames longer than their buffer, are now dropped and counted inrx_errorsandrx_length_errors, with a rate-limited warning. The shortest monitor frame (10-byte header plus the 4-byte trailer) is exactlyETH_HLEN.Evidence
./linux-build/build kernel linux-pciewifi-fixes -- -j3 W=1 drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.owithCONFIG_ARM64_16K_PAGES=y,CONFIG_BRCMFMAC=m,CONFIG_BRCMFMAC_PCIE=y: no warnings.scripts/checkpatch.pl --strict: no errors or warnings; only "multiple blank lines" checks, which follow the file's existing two-line spacing between functions.40e5e29cc915.