Skip to content

wifi: brcmfmac: shared-memory version 9 firmware, and the BCM4383 (Pixel 9a) - #56

Closed
W4HO-ham wants to merge 4 commits into
derekross:omamobile-intfrom
W4HO-ham:tegu-brcmfmac-api9
Closed

W4HO-ham wants to merge 4 commits into
derekross:omamobile-intfrom
W4HO-ham:tegu-brcmfmac-api9

Conversation

@W4HO-ham

Copy link
Copy Markdown
Contributor

The brcmfmac side of Wi-Fi on the Pixel 9a, in the order from #28 (omarchy-mobile): first the generic part, then the chip.

  1. wifi: brcmfmac: pcie: support shared-memory version 9 firmware: the API9 handshake keyed on the version the firmware reports (EWP info check, bounded ring-info reads, early host ready and the aggregation capability byte, no-DAR doorbells by the same test; version 8 stays refused). For the BCM4389 nothing changes: brcmf_pcie_early_hostready() is true for it by device id as before, and the version 9 checks don't run on its version 7 firmware. That is the claim you wanted a cheetah boot for.
  2. wifi: brcmfmac: add BCM4383 PCIe support: ids, SYSMEM base, firmware name, and the two quirks keyed on the chip instead of module parameters: JOIN_V1 by the same WLC version test as the 4389, and FWSUP/SAE/FWAUTH off because the 20.123.13 firmware refuses the PSK.

Based on omamobile-int rather than omamobile: the version 9 code builds on the BCM4389 PCIe work (early host ready, host capabilities, the TCM copy helpers) that is in the integration snapshot but not on omamobile yet. Retarget as you see fit once that lands.

Tested on the Pixel 9a today with this exact branch built as a module against the kernel it runs: loaded with no parameters, wlan0 comes up, iwd joins the WPA2 network, traffic flows, and the restricted DMA pool from #28 shows the bounce buffers in use (/sys/kernel/debug/swiotlb/wifi-dma-pool/io_tlb_used). checkpatch --strict clean, W=1 clean. Not booted on the Pixel 7 Pro.

Still to come, separately: the zumapro PCIe host glue (with the ASPM-off rationale and evidence) and the tegu DT.

The Pixel 9a's BCM4383 firmware (20.123.13) speaks shared-memory
("PCIe IPC") version 9. Accept it next to version 7, keyed on the version
the firmware reports rather than on a chip, and do what Broadcom's
driver does for it:

 - read the EWP info block the shared area points to (offset 128) and
   refuse to go on unless the firmware says its initialisation ended,
   so a stalled firmware fails cleanly instead of leaving rings pointing
   nowhere;
 - bound every ring-info read and the fallback TCM index arrays to the
   chip's RAM before trusting them;
 - ring host-ready right after the common rings are set up, before any
   buffer is posted (the 4389 path, now keyed on the version too), and
   leave the aggregation host capability byte (offset 133) at zero;
 - the no-DAR doorbells by the same test.

Version 8 stays refused: its layout is not known here. For the BCM4389
nothing changes: brcmf_pcie_early_hostready() is true for it by device
id as before, and the version 9 checks do not run on its version 7
firmware.

Tested on the Pixel 9a (BCM4383, API9): the firmware comes up, scans,
joins a WPA2 network and passes traffic. Not yet booted on the Pixel 7
Pro.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
The BCM4383 (PCI 14e4:4449, chip id 0x4383, rev 2) is the Wi-Fi chip in
the Pixel 9a. Add its ids, its SYSMEM base (0x6e0000, from the firmware's
load address) and the firmware name "brcmfmac4383-pcie" with the CLM
blob, and two firmware-keyed quirks for its 20.123.13 firmware:

 - it takes only the versioned "join" parameters: the unversioned iovar
   and SET_SSID both fail with -52, so enable BRCMF_FEAT_JOIN_V1 by the
   same WLC version test as for the BCM4389;
 - it advertises the supplicant offload but refuses the key
   ("failed to change PSK in firmware"), so leave FWSUP, SAE and FWAUTH
   off and let the host do the handshakes.

Tested on the Pixel 9a with the owner's firmware set: wlan0 comes up,
scans, joins a WPA2 network through iwd and passes traffic, with no
module parameters.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
@derekross

Copy link
Copy Markdown
Owner

Thank you for this, and for splitting it the way I asked. I went through the version 9 commit
line by line for the Pixel 7 Pro's BCM4389, and your claim holds: on version 7 firmware every
new branch is either keyed on the device id, as before, or on version 9 and skipped. The only
new check that runs on every chip is the 4-byte alignment of the shared-area address, and all
18 addresses in my BCM4389 logs pass it. So cheetah gets no new register or TCM access at all.
I also checked your offsets against Google's own BCM4383 driver: ewp_info_addr at 128, the
aggregation hostcap byte at 133, the 140-byte shared area, EWP_INFO_VER 1 and
EWP_HW_STATE_INIT_END 2, version 8 refused as Google refuses it, and 0x4449 and 0x6e0000 too
(bcmdevs.h, sbchipc.h CR4_4383_RAM_BASE). checkpatch --strict and W=1 are clean here as
well.

The base. I can't merge into omamobile-int. On GitHub it's a chain of snapshot commits I
regenerate, CI never runs there, and nothing merged into it would reach omamobile. My plan:

  1. I boot cheetah with your two commits on top of my integration branch (they apply as is).
  2. I publish the BCM4389 series to omamobile through its own PR. Your code depends on most of
    it: the TCM copy helpers, the no-DAR doorbells, the host capabilities, early host ready and
    the versioned join.
  3. Then, please rebase onto omamobile and switch the base (gh pr edit 56 --base omamobile).
    Expect two small conflicts in pcie.c: the curated series drops the ring-index debug print
    after the ring-info read in brcmf_pcie_init_ringbuffers(), and rewords the preinit
    comment.

I'll post here when step 2 is up.

Before merge, please add to the description: the 9a's uname -r; the blob ids of the
pcie.c and feature.c you loaded (git rev-parse HEAD:<path>; I get 8f33b8c4 and 145b5763);
the brcmfmac lines from load to wlan0, with MACs, BSSIDs and SSIDs removed; and a
tools/phone-smoke report.

Small things, none blocking:

  • Please keep the why in the preinit and setup comments. The 4389's firmware traps on a
    second host ready, and Broadcom's driver rings it once the common rings are set up
    (hostrdy_after_init). Otherwise someone will "fix" the single host ready later.
  • The new -EINVAL returns for a misaligned shared address and for bad ring info are silent.
    A brcmf_err with the value would make a bad firmware easy to diagnose.
  • A named BRCMF_PCIE_SHARED_VERSION_8 (or a comment) instead of the bare 8.
  • In the messages: cite Google's files for the version 9 offsets (bcmpcie.h
    pciedev_shared_t, ewp.h) and for the BCM4383 ids and RAM base. The second commit calls
    both quirks "firmware-keyed", but the supplicant one is keyed on the chip for every firmware.
    That's fine with me; just say so. Also mention that clearing SAE leaves the 4383 without
    WPA3-SAE for now.
  • Upstream will probably want a revision in the firmware name (4383xN, as 4389c1); fine for
    now.

Nice work getting the 9a online.

…l ones

brcmf_pcie_bus_console_read() reads the firmware's console write index
and walks read_idx up to it, wrapping at bufsize. When the device is
gone the index reads 0xffffffff, which read_idx never reaches, and the
walk never ends.

Seen on a BCM4383 after s2idle on the Pixel 9a: the chip does not come
back, the reset work entered this loop from brcmf_pcie_reset() and spun
one CPU at 100 % with a stream of "CONSOLE:" lines of 0xff bytes. A
later rmmod then blocked in cancel_work_sync() for good, holding the
device lock, so the next shutdown would have hung in device_shutdown().

Return when the write index is outside the console buffer.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Added a third commit: bound the firmware console read when the device reads all ones.

On the 9a the BCM4383 does not survive s2idle (it reads 0xff afterwards; the D3 path is still open). The driver's reset work then entered brcmf_pcie_bus_console_read() with a write index of 0xffffffff, which read_idx never reaches, and spun a CPU at 100 % printing CONSOLE: lines of 0xff bytes; a later rmmod blocked in cancel_work_sync() holding the device lock, so the next shutdown would have hung. The fix returns when the write index is outside the console buffer. Rebuilt and loaded on the palmtop; sleeping with the driver unloaded and reloading it afterwards brings the chip back and it scans.

@derekross

Copy link
Copy Markdown
Owner

Thanks for the third commit, and for writing up how you found it. A console read that never ends because a dead link reads all ones is a nasty one to hit, and the fix is right. read_idx wraps at bufsize, so any write index at or above it can never be reached, and >= is the correct bound. On the Pixel 7 Pro a healthy BCM4389 always reports an index inside the buffer, so there the change is one comparison after the read the driver already did. And the Pixel 7 Pro has the same open D3 problem, so it would have spun the same way. The gate passes on the three commits (sign-offs, checkpatch --strict, W=1 of all three files) on top of omamobile-int.

One suggestion: this commit has nothing to do with version 9 or the BCM4383, and the loop has been unbounded since brcmfmac's PCIe support first went in (it still is in linux-next). It also cherry-picks cleanly onto omamobile. Could you send it as its own PR against omamobile, with Fixes: 9e37f045d5e7 ("brcmfmac: Adding PCIe bus layer support.")? It gets CI there and can merge straight away, without waiting for the rest of this PR. If you ever see the new "console write index … out of range" line on the 9a with the module still loaded, pasting it would be nice evidence, but it isn't needed.

Where this PR stands on my side: I haven't done steps 1 and 2 yet. I'll do the Pixel 7 Pro boot with all of your commits, and then publish the BCM4389 series to omamobile. I'll post here when that's up, and then the rebase and gh pr edit 56 --base omamobile from my last comment apply. When you add the test evidence to the description, note that pcie.c's blob at this head is 9a74a2d4, so please give the blob of whatever you actually tested.

(The commit's author date has the same -0647 offset as on #59, in case you want to fix your git config.)

@derekross

Copy link
Copy Markdown
Owner

Step 1 is done: I booted my Pixel 7 Pro with your three commits on top of the kernel it runs (7.3.0-rc6-omamobile-push1-00588-gcd72ae58ee47; the brcmfmac files identical to this head). The BCM4389 came up as before: no new brcmf messages (the two it prints at every boot, a roam-trigger -52 and the p2p interface, are the same on the previous kernel), Wi-Fi joined, 20 of 20 pings, a 20 MB download at about 24 MB/s, and the restricted DMA pool in use. No oopses, warnings or UFS errors, and tools/phone-smoke passed every check. So the Pixel 7 Pro side of your claim holds on hardware too.

Step 2, publishing the BCM4389 series to omamobile, is next on my side. I'll post here when it's up.

@derekross

Copy link
Copy Markdown
Owner

Step 2 is done: the BCM4389 series is on omamobile (9080c4a), and your #65 landed on top of it today. This branch is still based on the integration tree, though, so it doesn't apply to omamobile as it stands (the gate reports a conflict in nearly every file the integration branch carries, pcie.c among them). Could you rebase the three commits onto today's omamobile? They should go on cleanly now that the series they build on is there, and #65's change to brcmf_pcie_setup is the only thing in pcie.c to merge around. Once CI is green on the rebased head I'll merge it; the Pixel 7 Pro result from the 26th stands.

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Thanks for running step 1 and publishing step 2. I tried the rebase, and it isn't a clean one. The BCM4389 series on omamobile is the curated version, and my three commits were written on the integration snapshot's pcie.c, which carries more around them. The api9 commit conflicts in six places, and on its side those hunks use things omamobile doesn't have: the TCM ring-index pointers, mailbox data as control messages (mb_ctrlmsg), the no-DAR doorbell register set, the polling flag, and brcmf_pcie_copy_mem_todev(). So it needs a real port: either bring those pieces in as their own commits first, or rewrite api9 on the curated base. I'll do the port, build it as brcmfmac for the 9a's running kernel, check that the BCM4383 still joins, scans and survives a suspend with it, and then push the rebased branch with that result. Until then, please hold this one.

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

I looked closer, and the gap isn't in my commits: omamobile has 9080c4a (the BCM4389 ID and RAM base), but none of the rest of the BCM4389 work that the integration snapshot's pcie.c carries. In omamobile, pcie.c has none of these, and the snapshot has all of them:

  • brcmf_pcie_set_host_cap() and BRCMF_SHARED_HOST_CAP_OFFSET;
  • host ready right after the common rings (and the BCM4389's 0x12345678 value);
  • brcmf_reginfo_64_nodar and BRCMF_PCIE_SHARED_DAR;
  • poll_enabled;
  • the TCM ring-index pointers (tcm_h2d_w_idx …);
  • mailbox data as control messages (mb_ctrlmsg, the D3 series).

My three commits generalise exactly those BCM4389 paths to API9 firmware, so they can only sit on top of them. omamobile-int is a squashed snapshot, so I can't base on your individual commits.

Two ways forward, your choice:

  1. You publish the rest of your BCM4389 series to omamobile, and I rebase onto it (it should then be close to clean, as you expected).
  2. I split those pieces out of the snapshot into a series, keep your authorship where they're yours, and put my three on top. I'd test it on the 9a, but you'd need to boot it on the 7 Pro.

I'd lean to 1, since they're your commits and you've run them on the 7 Pro.

@derekross

Copy link
Copy Markdown
Owner

You're right, and I'm sorry for sending you off to rebase. I checked after your reply: omamobile has only the BCM4389 ID and RAM base commit (and your #65). Host capabilities, the no-DAR doorbells, poll_enabled, the TCM ring-index pointers and the D3 control-message series are all still only in the integration snapshot, so your three commits have nothing to sit on.

I'll go with your option 1. They're my commits and they've run on the 7 Pro, so I'll curate the rest of the BCM4389 series (minus the debug-only commits) and publish it to omamobile, then let you know here. After that your rebase should be close to clean, and the 9a join, scan and suspend check you described is exactly what I'd want with it. Until then I'll leave this one as it is, so there's nothing for you to do.

@W4HO-ham

W4HO-ham commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

One more commit: "wifi: brcmfmac: cfg80211: skip a BSS on a channel the wiphy doesn't list". On the palmtop (BCM4383), a boot of this branch's brcmfmac oopsed twice in the scan handler. brcmf_inform_single_bss() picks the band from the channel number alone and hands cfg80211 the unchecked result of ieee80211_get_channel(), so a BSS on a channel the wiphy lacks gives a NULL channel, and cfg80211_inform_single_bss_data() dereferences it. The trace is in the message. A rebuilt module with the check ran a boot with six rescans and no oops (details on omarchy-mobile#238). That doesn't prove the check fired, but the bug is plain from the code, and the same code is in mainline.

@derekross

Copy link
Copy Markdown
Owner

Thank you, @W4HO-ham, for the fourth commit and for the clear write-up. The NULL channel is plain from the code: brcmf_inform_single_bss() picks the band from the control channel number alone and passes ieee80211_get_channel()'s result to cfg80211 unchecked. The same lines are on omamobile today (7.3-rc6), so the bug isn't specific to the 9a. Skipping the BSS is the right minimal fix.

An update from my side, which I owe you from the 27th: the rest of the BCM4389 series is now curated as #143 (host capabilities, the no-DAR doorbells, early host ready, the ring-index fallback and the D3 control messages). It's still a draft and its head may move while I fix it, but the parts your commits build on are there. I tried it: I put your four commits on #143's head (45bb8e163533), and only one hunk conflicts, the one I expected. In brcmf_pcie_init_ringbuffers(), #143 doesn't carry the integration tree's tcm_h2d_*/tcm_d2h_* pointers or their debug print. The resolution is to keep your version 9 check right after the ring-info copy and drop the four devinfo->tcm_* assignments and the brcmf_dbg that prints them:

	brcmf_pcie_copy_dev_tomem(devinfo, devinfo->shared.ring_info_addr,
				  &ringinfo, sizeof(ringinfo));
	if (devinfo->shared.version == BRCMF_PCIE_SHARED_VERSION_9 &&
	    !brcmf_pcie_api9_valid_ringinfo(devinfo, &ringinfo))
		return -EINVAL;
	if (devinfo->shared.version >= 6) {

With that, the other three commits apply as they are, and the gate on the result builds all four touched files with W=1, with checkpatch --strict clean apart from the trace line in the new message (which is fine). Could you rebase onto curated/4-wifi and switch the base (gh pr edit 56 --base curated/4-wifi), the way #173 sits on curated/5-modem? Then it lands right after #143. CI only runs against omamobile, so I'll run the checks myself until #143 lands.

Before it merges:

  1. A Signed-off-by: on the new commit. It has none, and the gate stops on it. (Its author date still has the -0647 offset too, if you want to fix your git config.)
  2. The test record I asked for on the 26th, in the description, from a boot of the rebased branch: the 9a's uname -r, the blob ids of the pcie.c, feature.c, chip.c and cfg80211.c you loaded, the brcmfmac lines from load to wlan0 (with MACs, BSSIDs and SSIDs removed), the join, scan and suspend check you described on the 27th, and a tools/phone-smoke report.
  3. The Pixel 7 Pro. The new commit changes a path the BCM4389 runs on every scan, and the 7 Pro's chip supports 6 GHz too. It only changes what happens where the old code would have oopsed, but under our rules a shared-driver change like this runs on the 7 Pro before merge. I'll boot the rebased series on mine, as I did on the 26th.

A suggestion for the new commit, not a blocker: on #143, decchspec() decodes the 6 GHz band (BRCMU_CHAN_BAND_6G). A 6 GHz BSS whose control channel happens to match a valid 5 GHz channel (149, say) would get through your NULL check and show up as a 5 GHz BSS that isn't there. Skipping on the decoded band first, with the NULL check kept as the backstop, would catch both. And your commit message says "such as a 6 GHz BSS". If you have the chanspec of the BSS that triggered the oops, putting it in the message would turn "such as" into the actual cause.

The console-read fix and this one apply cleanly to omamobile on their own, so they could still go as a separate small PR with Fixes: tags and land straight away, as I suggested on the 26th. Your choice; keeping them here is fine too. The small points from my first review (the why in the preinit comment, a brcmf_err on the new -EINVAL returns, a named version 8) are still open in the first commit, and the rebase is a good moment for them.

@derekross

Copy link
Copy Markdown
Owner

7 Pro check done: your four brcmfmac commits on my phone's integration kernel (7.3.0-rc6-omamobile-push1-g291da0df9327; one conflict in brcmf_pcie_init_ringbuffers(), the ring-index print, resolved by keeping your API9 check). The BCM4389 loads as before, connects, scans and passes traffic, with no new brcmfmac errors. One more thing for the series: wifi: brcmfmac: cfg80211: skip a BSS on a channel the wiphy doesn't list (2305473) has no Signed-off-by yet.

brcmf_inform_single_bss() picks the band from the control channel number
alone (2.4 GHz up to channel 14, 5 GHz above) and passes the result of
ieee80211_get_channel() to cfg80211 unchecked. For a BSS whose channel has
no entry in the wiphy's bands, such as a 6 GHz BSS taken for a 5 GHz
channel number that doesn't exist, the channel is NULL, and
cfg80211_inform_single_bss_data() dereferences it:

  Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
  pc : cfg80211_inform_single_bss_data+0xb0/0x4fc [cfg80211]
  Call trace:
   cfg80211_inform_single_bss_data+0xb0/0x4fc [cfg80211] (P)
   cfg80211_inform_bss_data+0xbc/0x12d4 [cfg80211]
   brcmf_inform_single_bss+0x190/0x20c [brcmfmac]
   brcmf_cfg80211_escan_handler+0x2b0/0x474 [brcmfmac]
   brcmf_fweh_event_worker+0x384/0x520 [brcmfmac]

This happened twice in one boot of a Pixel 9a (BCM4383) during scans,
each time killing the event worker. Skip such a BSS with a debug message,
as nothing can be reported for a channel the wiphy doesn't have.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
@derekross

Copy link
Copy Markdown
Owner

Thank you, @W4HO-ham. The scan fix has its Signed-off-by: now, and the commit is otherwise unchanged. checkpatch --strict has only the long trace line in the message, which is fine.

Things have moved since my comment this afternoon, so here's where I think this PR stands. #156's stack, as you rebased it under #178, already carries your first three commits: shared-memory version 9, the BCM4383 ID, and the bounded console read. They're the same patches, with the version 9 check placed after the ring-info copy as I suggested. So once #156 lands, they're in, and the rebase onto curated/4-wifi I asked for isn't needed any more. Sorry for the back and forth. The small points from my first review of the version 9 commit (the why in the preinit comment, a brcmf_err on the new -EINVAL returns, a named version 8) are still open in that copy. They can come as a small follow-up after #156.

That leaves the fourth commit, the NULL-channel fix. It isn't in #156 or #178, and the bug is in both, as well as on omamobile today. It applies cleanly to omamobile on its own and to #178's head. I've asked on #178 for it to go there, or in a small PR on omamobile with a Fixes: tag that lands first. Either way, this PR can close once #156 is in. Before it lands wherever you put it:

  • The 6 GHz suggestion from this afternoon: skip on the decoded band first, with the NULL check kept as the backstop. If you still have the chanspec of the BSS behind the oops, put it in the message.
  • A short test note from the 9a with it: uname -r, the cfg80211.c blob id, and the scans with no oops.

The Pixel 7 Pro run I did this afternoon covers the commit as it is.

@W4HO-ham

W4HO-ham commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

The NULL-channel fix is now #191 on omamobile, with the 6 GHz skip on the decoded band first, the NULL check as backstop, and a Fixes: tag. So this PR can close once #156 is in, as you said.

@derekross

Copy link
Copy Markdown
Owner

Thank you, @W4HO-ham. With the scan fix now in #191, and the first three commits riding in #187's stack, everything here has a home on omamobile. I'll close this PR when #187 lands and link both. The three small points from my first review of the version 9 commit (the why in the preinit comment, a brcmf_err on the new -EINVAL returns, a named version 8 instead of the literal 8) are still open in that copy, and they're still fine as a small follow-up afterwards.

@derekross

Copy link
Copy Markdown
Owner

Closing: these commits landed through #187 (rebase-merged today), with your authorship and sign-offs kept. Thank you, @W4HO-ham.

@derekross derekross closed this Nov 9, 2026
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