Skip to content

Pixel 8 Pro Wi-Fi: zuma's PCIe and the BCM4398 (stacked on #153, #143, #56) - #156

Closed
greenbrettmichael wants to merge 75 commits into
derekross:omamobilefrom
greenbrettmichael:omamobile-zuma-husky-wifi
Closed

greenbrettmichael wants to merge 75 commits into
derekross:omamobilefrom
greenbrettmichael:omamobile-zuma-husky-wifi

Conversation

@greenbrettmichael

@greenbrettmichael greenbrettmichael commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

The Pixel 8 Pro's Wi-Fi works on this branch. The BCM4398 on zuma's pcie_1 comes up at boot and joins with NetworkManager, and the driver can be unloaded and reloaded without a reboot.

Stacking: this is a draft because it sits on three open PRs. Only the last 21 commits are new here (from arm64: dts: exynos: google: zuma: add the HSI2 and FAR_ALIVE pin controllers on). Below them:

The stack rebases away as those land. If you'd rather have the zuma PCIe part (7 commits) as its own PR first, I can split it.

zuma's PCIe (7 commits)

  • The PHY is new: zuma's Gen3 PHY isn't gs201's. phy-zuma-pcie.c programs it from stock's tables (exynos_pcie_rc_phy_all_pwrdn* and pcie_phy_config for channel 1). It takes the PHY's isolation (PMU 0x3ec8) through the PMU, which is why gs101-pmu's zuma table gains that register.
  • The host is gs201's driver: a zuma compatible with its own soc data. zuma needs the controller's soft reset before the PHY comes up (ctrl_reset_before_phy).
  • The DT:
    • the HSI2 and FAR_ALIVE pin controllers, from stock;
    • pcie_1 and its PHY. The soc bus ranges grow to 2 GiB to reach pcie_1's config space at 0x60ffe000;
    • on husky, WL_REG_ON (gph3-4) as a fixed regulator, and PERST, CLKREQ, dev_wake and host_wake as on stock.

The link trains at Gen3 x1 (8 GT/s) on the first try.

brcmfmac for the BCM4398 (14 commits)

  • The chip uses Broadcom's newer NCI backplane (socitype 6), not AI. chip.c learns to walk its EROM (EROM2 from chipcommon, EROM1 and OOBR derived from it), find the cores and their wrappers, and halt and release the ARM through the DMP control register.
  • Firmware 24.100 (shared-memory API 9) needs:
    • event_msgs_ext;
    • a 4-entry bandlist;
    • escan v3/v4;
    • v114 BSS info;
    • the versioned join, without firmware supplicant (FWSUP, SAE, FWAUTH off), so NetworkManager's wpa_supplicant does the handshake.
  • msgbuf:
    • Control buffers get the lowest packet IDs (the firmware traps on an ID above its control map).
    • D2H items are read only once the firmware has finished them (the XOR checksum and epoch sync in the item's last byte). Without that the driver read stale items under load.
  • pcie:
    • The 4398 takes the 4389's paths from Wi-Fi on gs201: PCIe, SysMMU and BCM4389 brcmfmac (curated 4/8) #143 (host capabilities, FLR, polling, the 802.3/LLC TX header on the host).
    • It waits for the firmware's boot interrupt before reading the shared address; before that, the address is an interim one.
    • The reload fix: on remove, the driver rings doorbell 7 with 0xdead0002 when the firmware advertises it, the same as bcmdhd's DHD_DONGLE_TRAP_IN_DETACH. The chip's always-on domain keeps the firmware's state across WL_REG_ON, FLR and a PMU watchdog. Without the trap, a second load got no boot interrupt until the phone rebooted.

Firmware: none of it is in linux-firmware. The driver asks for brcmfmac4398d0-pcie.google,zuma-husky.{bin,txt,clm_blob,txcap_blob}. On my phone these are stock's fw_bcmdhd.bin_4398_d0, bcmdhd.cal_MMW, bcmdhd_clm.blob_4398_d0 and bcmdhd_txcap.blob_4398_d0 from the OTA's vendor image (24.100.671.86.2). They're installed under /usr/lib/firmware/updates/brcm. derekross/omarchy-mobile#214 stages them from the owner's image (tools/extract-vendor-firmware -d husky -s SKU, with the NVRAM picked by SKU as stock does) and adds CONFIG_PHY_ZUMA_PCIE=m to husky's config. derekross/omarchy-mobile#216 has the notes.

Tested on husky (tag husky-test-20261031-w11; the head since differs only by the join fix above, tested by loading its brcmfmac):

  • Boot: link up at 4.0 s, Gen3 x1. The firmware is up at 5.5 s, and the phone is connected without help.
  • Reloads: two brcmfmac reloads and one pcie_gs201 + brcmfmac reload each reconnect in 17–18 s, with no traps or Timeout on response.
  • Throughput: on 2.4 GHz (channel 2, -42 dBm, 195/172 Mbit/s link rates), 50–87 Mbit/s down and 47–70 up across runs. A Pixel 9 on Android gets 95 down on the same network. The scan sees 5 GHz networks; I haven't joined one yet.
  • The rest of the phone: touch (sense echo yes) and ACPM (16 of 16 channels) are unchanged.

tools/kernel-pr-check --build on the 21 commits:

  • every commit is signed off and has a subsystem prefix;
  • checkpatch --strict has no errors. It has 5 items to read: log strings over 100 columns, which shouldn't be split; one MAINTAINERS note, since the PHY binding's entry arrives with its driver; and a udelay(10) in brcmfmac's core-reset idiom;
  • W=1 builds of the 10 touched C files pass;
  • 8 device trees build with no new dtbs_check warnings;
  • dt_binding_check passes on both bindings.

Known gaps:

  • P2P: brcmf_p2p_create_p2pdev: timeout occurred at load. The firmware never confirms the P2P device interface. Station mode doesn't need it.
  • Crash recovery is untested: a firmware that has already crashed can't take the doorbell-7 trap, so a reload after a real crash may still need a reboot.
  • Bluetooth (BT_REG_ON, gpn8-0) isn't wired.

🤖 Generated with Claude Code

greenbrettmichael and others added 30 commits October 31, 2026 11:49
The channel loop skips a channel that gets no mailbox, so that one bad
channel doesn't fail the rest. -EPROBE_DEFER isn't such a channel: it
only means the mailbox driver hasn't probed yet. When ACPM probes
first, every channel is skipped, the probe succeeds with "16 channels,
0 usable" and never retries, and everything behind ACPM fails for the
whole boot. On the Pixel 8 Pro the touchscreen then can't enable its
supply ("error -ENODEV: enabling vdd").

This happens when a module load or `udevadm trigger` binds ACPM ahead
of the mailbox, or with fw_devlink=permissive, which drops the
supplier ordering.

Return -EPROBE_DEFER from the probe instead, so it runs again once the
mailbox is there. Keep skipping the channels for any other error, and
the ones whose queues are outside the SRAM. The channels already
requested are freed by the devm action, and the per-channel buffers
are devm allocations.

Fixes: c8e4c99 ("firmware: samsung: acpm: skip channels the AP cannot use")
Assisted-by: LLM
Signed-off-by: Brett-Michael Green <brett@bmgvisualtech.com>
Document zuma's (Tensor G3) CMU_TOP and CMU_HSI0 as far as the
touchscreen's SPI needs them: CMU_TOP's HSI0 NoC and peripheral clocks,
and CMU_HSI0's USI2 clocks with the NoC path its bus clock comes from.
HSI0 takes the board-level ALT clock as an input.

Assisted-by: LLM
Signed-off-by: Brett-Michael Green <brett@bmgvisualtech.com>
zuma has no clock driver, and the bootloader leaves HSI0's USI2, the
touchscreen's SPI, at 399.36 MHz (PLL_SHARED2 / 2). The SPI controller
takes its rate from the CMU, so the bus would run at a quarter of that,
far above the 10 MHz stock gives the touch controller.

Describe the path from CMU_TOP's shared PLLs to USI2, with registers and
parents from Google's GPL CMUCAL tables for zuma. Only USI2's divider and
its three gates are written; the PLLs, muxes and the other dividers and
gates are read-only and keep their firmware settings.

Assisted-by: LLM
Signed-off-by: Brett-Michael Green <brett@bmgvisualtech.com>
Add the 24.576 MHz oscillator, HSI0's ALT input at the CAL's nominal
213 MHz, and the TOP and HSI0 clock controllers. Nothing consumes them
yet; the touchscreen's SPI will.

Assisted-by: LLM
Signed-off-by: Brett-Michael Green <brett@bmgvisualtech.com>
zuma's (Tensor G3) AP-to-APM mailbox is gs101's, as on gs201 and
Tensor G4: same registers, one interrupt and one bus clock. Document
it with gs101's compatible as the fallback.

Assisted-by: LLM
Signed-off-by: Brett-Michael Green <brett@bmgvisualtech.com>
zuma's (Tensor G3) ACPM firmware speaks the same protocol, from the same
shared memory layout, as Tensor G4's, and its main PMIC is the same
S2MPG14. Document its compatible, with the S2MPG14 as its main PMIC.

Assisted-by: LLM
Signed-off-by: Brett-Michael Green <brett@bmgvisualtech.com>
The Pixel 8 Pro's (Tensor G3) main PMIC is the S2MPG14, at the same
ACPM channel and with the same touchscreen rails on LDO4M and LDO25M.

Assisted-by: LLM
Signed-off-by: Brett-Michael Green <brett@bmgvisualtech.com>
zuma's ACPM firmware keeps its channel table at 0xa000 in the APM SRAM,
as stock's device tree gives it (initdata-base). Add zuma's match data.
No driver binds its clocks device yet.

Assisted-by: LLM
Signed-off-by: Brett-Michael Green <brett@bmgvisualtech.com>
Add CMU_APM, the AP-to-APM mailbox (SPI 80), the APM SRAM and the ACPM
firmware node, at the addresses stock's acpm_ipc node gives them. CMU_APM
is read-only: it only names the mailbox's and the SRAM's clocks, which
the always-on domain keeps running.

Assisted-by: LLM
Signed-off-by: Brett-Michael Green <brett@bmgvisualtech.com>
Describe the S2MPG14 behind ACPM. No regulators yet: each will come with
its consumer, starting with the touchscreen's.

Assisted-by: LLM
Signed-off-by: Brett-Michael Green <brett@bmgvisualtech.com>
zuma's (Tensor G3) USI blocks are Exynos850-style, like Tensor G4's:
the mode lives in a system register, and the block's own control sits
at offset 0xc0. Document zuma's compatible with the Exynos850 fallback.

Assisted-by: LLM
Signed-off-by: Brett-Michael Green <brett@bmgvisualtech.com>
HSI0's system registers hold the USI mode of the touchscreen's USI2.
Like zuma's UFS sysreg, it takes no clock: HSI0 is firmware-owned.

Assisted-by: LLM
Signed-off-by: Brett-Michael Green <brett@bmgvisualtech.com>
zuma's (Tensor G3) SPI controllers are gs101-style, as on Tensor G4.
Document zuma's compatible with gs101's as the fallback.

Assisted-by: LLM
Signed-off-by: Brett-Michael Green <brett@bmgvisualtech.com>
zuma's (Tensor G3) SPI controllers match Tensor G4's: rate from the CMU,
64-byte FIFOs, 32-bit access. Stock drives the Pixel 8 Pro's touchscreen
with manual chip select (samsung,spi-chip-select-mode = <0>), as the
Pixel 9a's, so use Tensor G4's port configuration, which holds native
chip select for a whole message.

Assisted-by: LLM
Signed-off-by: Brett-Michael Green <brett@bmgvisualtech.com>
… controllers

Add the CUSTOM_ALIVE controller at 0x15060000 (gpn0-gpn9, one wake-up
interrupt each, SPI 0 to 9) and PERIC1 at 0x10c40000 (gpp19-gpp24, SPI
649), with the banks and interrupts of stock's live device tree, as
controllers 1 and 12 of the driver's zuma data. CUSTOM_ALIVE's bus clock
comes from CMU_APM; PERIC1 takes the bus-clock stand-in, as PERIC0 does.

The touchscreen's attention line is on gpn0 and its reset on gpp21.

Assisted-by: LLM
Signed-off-by: Brett-Michael Green <brett@bmgvisualtech.com>
Add HSI0's system registers and USI2 at 0x111d00c0 with its SPI
controller (SPI 408), clocked from CMU_HSI0, as stock's spi@111D0000
(usi-offset 0x101c). This is the touchscreen's bus.

Assisted-by: LLM
Signed-off-by: Brett-Michael Green <brett@bmgvisualtech.com>
The Pixel 8 Pro's FTM5 firmware first reports a forced calibration
(status 43 05 01) after the scan command, then echoes the command about
60 ms after it was sent, past the 50 ms window. Probe then failed with
"turning sensing on".

Wait up to 2.5 s, as stock's checkEcho does (TIEMOUT_ECHO), and stop
polling once the echo arrives, so the longer window costs nothing when
the firmware answers promptly.

Assisted-by: LLM
Signed-off-by: Brett-Michael Green <brett@bmgvisualtech.com>
The Pixel 8 Pro's touchscreen is an ST FTM5 (SALIXP, chip id 36 40) on
USI2's SPI, as in stock's fts node: 10 MHz, attention on gpn0-0, reset
on gpp21-2, 1344 x 2992. Its rails are the main PMIC's LDO25M (1.8 V
digital) and LDO4M (3.3 V analog), which the firmware leaves off and at
those voltages. Pin them there, as stock does.

Stock's node inverts both axes, but salixp already reports in the
panel's orientation: with stock's inversion, a tap at the top-left came
in at the bottom-right.

Assisted-by: LLM
Signed-off-by: Brett-Michael Green <brett@bmgvisualtech.com>
The gs201 (Tensor G2) PCIe Gen4 PHY is a two-lane Samsung PHY with PMA
and PCS register blocks, a debug block that selects its reference clock,
and three reset lines inside the sub-control space of the controller it
serves. Its isolation is a PMU register, so the PMU phandle carries the
offset of this instance's PHY_CTRL_PCIE_GEN4_x register.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Derek Ross <derekross@gmail.com>
The gs201 (Tensor G2) PCIe controllers are DesignWare cores in a Samsung
wrapper: an ELBI sub-control block for link training and interrupt
status, and an I/A sequencer that re-locks the PHY clock-data recovery
when the link leaves L1.2. INTx is demultiplexed from the controller
interrupt, so the node has a legacy-interrupt-controller child.

The I/A region is not one of the generic DesignWare register names, so
the binding refers to snps,dw-pcie-common.yaml rather than
snps,dw-pcie.yaml and lists its own reg-names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Derek Ross <derekross@gmail.com>
… pool

A PCIe Wi-Fi chip runs firmware that parses untrusted frames. Platforms
that confine the chip's DMA to one region (with an IOMMU-less firewall
such as the Google gs201 S2MPU) describe that region as a
restricted-dma-pool and point the device node at it, as is already done
for other PCIe Wi-Fi bindings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Derek Ross <derekross@gmail.com>
The System MMU in front of the gs201 PCIe GEN4A_1 controller (the Pixel
7 Wi-Fi link), described for use as a DMA window: a 1:1 mapping of one
reserved memory region, with the VID the controller's traffic uses.

The window is a plain phandle property, google,dma-window: memory-region
on this node would attach a restricted-dma-pool to the SysMMU device
itself, which would then bounce its page table into the window.
google,vid is the default VID to translate, which still has to be
confirmed by a negative test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Derek Ross <derekross@gmail.com>
Add a driver for the PCIe Gen4 PHY of the Google gs201 (Tensor G2) SoC,
which connects the Wi-Fi chip on Pixel 7 phones.

The bootloader leaves the PHY isolated in the PMU and does not train the
link, so the whole Samsung init sequence is needed. phy_init() is
Google's probe-time step: release the PMU isolation (a secure register,
written through the PMU regmap's SMC path) and power the PHY down.
phy_power_on() clears the power-down and runs "CAL ver 210802": PHY
resets, the common PMA block for a 100 MHz LCPLL with a 38.4 MHz input
clock, the per-lane tables, PCS settings for root complex mode, the
external XO selection and an AFC calibration restart, then polls the PLL,
CDR and offset calibration status. phy_calibrate() reports the offset
calibration after the controller's soft power reset.

The sequence follows the driver Google builds for gs201
(google-modules/soc/gs/drivers/pci/controller/dwc-whi:
pcie-exynos-gs201-rc-cal.c and pcie-exynos-rc.c, Copyright Samsung
Electronics). Most PMA registers have no public names, so the tables keep
the raw offsets. As on stock, the PHY is not isolated again after init:
controller register accesses hang the SoC while it is isolated.

For bring-up, trace=1 logs every hardware step before it happens (with a
short sleep so a remote log reader receives the line before a possible
bus hang), and check_tcxo=1 reads and fixes the PMU TCXO buffer bits that
Google's driver checks.

The controller sets the lane count with phy_set_bus_width(); the
default is one lane, as on Pixel 7.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Derek Ross <derekross@gmail.com>
Add a host driver for the PCIe controllers of the Google gs201 (Tensor
G2) SoC. Pixel 7 phones connect their BCM4389 Wi-Fi to the HSI2
controller (GEN4A_1), one lane at Gen2.

The sequence follows the driver Google builds for gs201
(google-modules/soc/gs/drivers/pci/controller/dwc-whi/pcie-exynos-rc.c:
resumed_phydown(), poweron() and establish_link()). Order matters: the
bootloader leaves the PHY isolated, and any access to the controller's
ELBI registers hangs the SoC until the PHY driver has released it. So:
PHY init (isolation off, power-down) before the first ELBI access, then
endpoint power through the pwrctrl core (WL_REG_ON, 200 ms), the PHY
configuration and the I/A sequencer, the soft power and non-sticky
resets with the device type set to root complex, PERST# release and
20 ms, the wrapper setup (exit-L1 request, manual link-down reset, no
Q-channel clock gating, NAK on pending AXI), Gen3 equalization off, DMA
cache coherency through the HSI2 sysreg, and finally the LTSSM, polled
for L0 in the ELBI. As on stock, a failed attempt redoes the PHY and
controller sequence; the last failure prints the LTSSM history buffer.

Only INTx is supported, which is what the stock Wi-Fi driver uses: the
ELBI interrupt status is demultiplexed into a four-line INTx domain, and
link-down and completion-timeout events are logged. The chained handler
is installed only once ELBI is reachable. A no-op msi_init keeps the
DesignWare core from claiming the shared interrupt for its iMSI-RX, so
devices fall back to INTx.

Bring-up aids: the sequence runs in numbered stages and stop_after=N
ends probe after stage N without binding (0 resources, 1 clocks, 2 PHY
isolation off and first register access, 3 PHY configuration, 4
controller setup, 5 link); trace=1 logs every hardware step before it
happens; use_ia=0 skips the I/A sequencer; cmu_acg_off=1 clears the
CMU_HSI2 global automatic clock gating, as Google's driver does, through
the optional samsung,cmu phandle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Derek Ross <derekross@gmail.com>
Google's driver programs the I/O coherency (AxCACHE in DBI 0x8e8 and the
HSI2 shareability in SYSREG_HSI2 0x730) after the root port setup in
exynos_pcie_rc_establish_link(), and once more at the end of
exynos_pcie_rc_probe(), after the endpoint is enumerated. We did it
once, before the link came up.

The Wi-Fi chip is dma-coherent through this bridge. If the coherency
were not in effect, the chip would read stale ring memory and the host
would not see what the chip writes, which is how the first BCM4389
runs fail. Program it again after link up and after enumeration, and
print the two registers, so the log shows what is in effect.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Derek Ross <derekross@gmail.com>
The Wi-Fi chip on the gs201 PCIe GEN4A_1 controller can DMA anywhere
in RAM: there is no IOMMU in use and the HSI2 S2MPU is left open
(CTRL0 = 0). Stock Android puts the controller's traffic through the
HSI2 PCIe System MMU (0x145c0000, version 8.1, VID 1).

Use that System MMU as a firewall rather than a translator: one
first-level table (36-bit IOVA, 1 MiB sections, 256 KiB aligned) that
maps a single reserved region 1:1, so the device driver keeps using
physical addresses and nothing outside the region is reachable. The
register map, table format and enable sequence follow Google's
exynos-pcie-iommu-whi driver; faults are reported from the System MMU
interrupt with the address and direction. A mode parameter stages the
bring-up: 0 only logs the registers (default), 1 enforces, 2 enforces
with an empty table as a negative test.

The window comes from "google,dma-window", not "memory-region": for a
restricted-dma-pool, memory-region would also make the pool the SysMMU
node's own swiotlb, so mapping the first-level table for the walker
would bounce it into the very window the PCIe device may write, and the
device could rewrite its own page table. A table that was bounced or
overlaps the window is refused.

An enforced empty table did not stop the Wi-Fi chip's DMA on VID 1. No
kernel code assigns the controller's VID (stock 1:1 maps every buffer, so
it never notices a bypass either), so the driver also:
- has "vids", a bitmask of VIDs to translate (default: google,vid);
- has mode 3, a 1:1 map of everything except the window, which only
  blocks DMA into the window and is therefore safe on every VID;
- reads the fault address and info from the faulting VID's registers
  (0x1000 + 0x10 * vid with VM support), not always VID 1's;
- restores each VID's CTRL on remove rather than writing 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Derek Ross <derekross@gmail.com>
Negative tests on cheetah showed that the PCIe controller's DMA (AxID
0x0) and the UFS host controller's (AxID 0x2) both arrive on VID 0. An
empty or window-only table on VID 0 blocked the UFS transfer request
list, storage stalled and the phone wedged.

Refuse any mode that would translate VID 0 unless the debug parameter
allow_vid0 is set, and document the measurement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Derek Ross <derekross@gmail.com>
brcmfmac decodes the SYSMEM core's coreinfo register with the SOCRAM
layout (bank count in bits 7:4) and sizes banks from index 0. On the
BCM4389 the SYSMEM coreinfo holds the RAM bank count in bits 4:0 and the
ROM bank count in bits 9:5 (bits 23:16 and 31:24 from core revision 12),
and the ROM banks come first in the bank index space. That is how
Broadcom's own driver sizes it (bcmdhd siutils.c si_sysmem_size(),
sbsysmem.h), and what Google's Pixel 7 Pro logs at boot:

  si_sysmem_size: coreinfo:0x115 num_rom_banks:8 num_ram_baks:21
  sysmem_banksize: bankidx:8 bankinfo:0xf00060f banksize:131072(0x20000)
  ...
  DHD: dongle ram size is set to 2752512(orig 2752512) at 0x200000

With the SOCRAM decoding, coreinfo 0x115 reads as one bank, and bank 0
is a ROM bank. The register dump of the failed load has the NVRAM length
token (0xe8b4174b, the same as stock's) and 0x23a2d0, which is
0x240000 minus the 23856-byte NVRAM: brcmfmac sized the RAM at 256 KiB
instead of 2688 KiB, and wrote the NVRAM and the random seed into the
1.7 MB firmware image it had just downloaded to 0x200000. The
firmware crashed on start, and the shared RAM address read back as
0xffffffff:

  brcmf_pcie_download_fw_nvram: Invalid shared RAM address 0xffffffff

Decode the BCM4389 the way Broadcom's driver does: count only the RAM
banks and skip the ROM banks in front of them. Other SYSMEM chips
(BCM4365/4366 family) keep the current decoding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Derek Ross <derekross@gmail.com>
brcmfmac reaches the chip's RAM through PCI BAR 2 (Broadcom's "BAR1")
and assumes it maps the backplane from address 0. The BCM4389 has
2688 KiB of RAM at 0x200000, up to 0x49ffff, behind a 4 MiB BAR. The
top of RAM, where the NVRAM, the random seed and the shared-area
handshake word go, is beyond the BAR, and brcmfmac's accesses there
land past the end of its ioremap().

The BAR maps the 4 MiB-aligned block of backplane space named by the
BAR1 window register (PCI config 0x84). Broadcom's own driver moves it
for every TCM access when RAM does not fit (bcmdhd dhd_pcie.c
dhdpcie_bar1_window_switch_enab(), dhdpcie_bus_chkandshift_bpoffset(),
pcicfg.h PCI_BAR1_WIN), and points it back at 0 before the download
(dhdpcie_bus_download_state()). On the Pixel 7 Pro it logs the random
seed TLV at 0x49a248.

Do the same: when RAM ends beyond the BAR, route every TCM access
through one helper that moves the window under a spinlock, split block
copies at window edges (and into 4 KiB pieces, so the 1.7 MB firmware
download does not hold the lock throughout), and reset the window
before the download and after a chip reset. Chips whose RAM fits the
BAR take the same path with the window left alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Derek Ross <derekross@gmail.com>
The BCM4389 splits its backplane into save/restore power domains: PCIe,
ARM/backplane, MAC aux and MAC main. Unless the host requests them, the
chip's PMU may keep the ARM/backplane and MAC domains off, and a chip
reset drops the host's requests. Backplane accesses to a domain that is
off fault and read back as 0xffffffff, which also hides behind a warm
chip that some earlier driver had left powered.

Google's driver (bcmdhd) treats the 4378/4387/4389 family as multi-
backplane chips (siutils.h MULTIBP_CAP()). It requests all four domains
through the powerctl register (bits 11:8, status in 19:16) of the PCIe
core, at BAR0 + 0x2000 + 0x1e8, before it resets the chip
(dhd_pcie.c dhd_bus_pcie_pwr_req_reload_war(), siutils.c
si_srpwr_request() and si_srpwr_domain_all_mask()), and on PCIe core
revision 68 and later also asserts the ARM/backplane domain in the DAR
copy of the register, because "ARM fails to boot" from cold without it
(dhd_pcie.c dhd_bus_pcie_pwr_req_wl_domain(), pcie_core.h
DAR_PCIE_PWR_CTRL()). The Pixel 7 Pro's BCM4389 has PCIe core revision
72. For the ARM CA7 it also sets the BAR coherent-access bits in PCI
config 0x88 (dhd_pcie.c "CA7 requires coherent bits on",
pcicfg.h PCIE_BARCOHERENTACCEN_MASK).

For the BCM4389, request all four domains (and the DAR one) once the
BARs are mapped, before brcmfmac first touches a core, and again before
and after the watchdog reset; and set the coherent-access bits. The
requests stay on while the driver is bound, which costs idle power but
keeps every backplane access safe; releasing them once the firmware
runs is left for later.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Derek Ross <derekross@gmail.com>
@derekross

Copy link
Copy Markdown
Owner

Answering the split question here and on the sibling PR together, since #156 (husky, zuma) and #168 (tegu, zumapro) both bring up a Tensor PCIe host: yes, please split the PCIe part into its own PR first, and the PHY into its own driver commit, as upstream expects. For the host itself I'd like one approach for the zuma family rather than two: reuse the gs201 host driver with per-SoC match data wherever the controller's registers are the same, and add a separate driver only for what really differs, with the reason in the commit message. Brett and W4HO, could you compare notes on where zuma and zumapro actually differ, and agree which PR carries the shared part? Both still wait on the BCM4389 series (#143, mine), which I'm fixing now.

@greenbrettmichael

Copy link
Copy Markdown
Contributor Author

Following #168: W4HO and I agreed to put the zuma-family PCIe host and PHY in one PR on #143, with zumapro as a fallback compatible. This PR's Wi-Fi parts will rebase onto that one. My Wi-Fi baseline before the host changes, from tag husky-test-20261101-e1, is in #168: 108-132 Mbit/s down and 58-73 up on 2.4 GHz, over a Gen3 x1 link.

@derekross

Copy link
Copy Markdown
Owner

Thanks Brett, and thanks to W4HO for the table comparison on #168. One zuma-family PCIe PR on top of #143, with zumapro as a fallback compatible and the two stock steps (the PMU "PHY configured" bit with the clock back to the oscillator, and the soft power reset), is the shape I hoped for. The Gen3 x1 baseline from e1 will make the before/after easy to read.

I also checked this PR's copy of the BCM4389 series against #143's new head (45bb8e1). All 33 shared commits are patch-for-patch identical, including the versioned join parameters with the flexible chanspec_list[], so nothing has drifted. When the shared PCIe PR is up, please rebase the Wi-Fi part onto it and #143 and drop your copies of #143's commits. The PR then carries only the zuma and BCM4398 work. I'll leave this as a draft until then.

@Somnius

Somnius commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

@greenbrettmichael for when you're back, a 5 GHz data point for the before/after on this PR (@derekross fyi). On husky-test-20261101-e1 plus my battery commits, my 8 Pro joined on 5180 MHz, link 1.7 to 2.4 Gbit/s, -49 to -43 dBm, and ran 40 min: 41 timed 15 s downloads at 221 to 502 Mbit/s (avg 367, bounded by the remote host and my router), no drops, hottest SoC zone 52 to 56 C, battery 34 to 36 C.

One thing to look at: on that first boot the journal had about 192,000 lines of brcmf_msgbuf_rxbuf_data_post: No PKTID available !!, roughly 4,550 a minute while the run was going, and zero dma_map_single failed. On the second boot of the same images there were 3. I read brcmf_msgbuf_alloc_pktid as returning -ENOMEM for both cases and the missing dma line as pointing at the pktid array rather than the mapping, but that's a reading, not a cause, and the second boot also carried far less traffic, so it may just be load. Throughput didn't visibly suffer. I kept the journal if you want the timing around the first flood.

Also for the record: the display start has to run before sddm. I once ran it inside a live session and Hyprland kept the dead simpledrm handle until I restarted sddm. The packaged unit ordering from #228 does it right, verified on the next boot.

@derekross

Copy link
Copy Markdown
Owner

Thanks Lef, the 5 GHz numbers are a useful baseline for the PCIe work: 221-502
Mbit/s over 40 minutes with no drops, and the thermals stayed comfortable.

On the No PKTID available flood, I read it the same way you do: with no
dma_map_single failed line, the packet-ID allocator ran out of free IDs in the
data range. One thing for Brett to look at when he's back: since "give control
buffers the lowest packet IDs", the data range has exactly as many IDs as the
cap on posted rx buffers, and the rx-complete path refills before it releases
the ID of the buffer it has just completed. So if the BCM4398 reports a large
max_rxbufpost, every refill could come up one ID short. Our config builds
brcmfmac with CONFIG_BRCMDBG, which turns off the message's rate limit, so each
of those would be logged. That doesn't explain why your second boot logged only
three, so treat it as a lead, not a cause. If you still have the first boot's
journal, the lines around the first flood would help, and so would the
firmware's max_rxbufpost if brcmfmac's PCIe debug output was on.

Thanks for the sddm note too. Brett, nothing more is needed here while you're
away. I'll sort out with W4HO on #178 how the shared PCIe part lands.

@Somnius

Somnius commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

@derekross @greenbrettmichael thanks for the lead, and I need to correct something I wrote earlier. I said the second boot logged only 3 No PKTID lines. I read that about 90 seconds into the boot, so it was too early to call. Counted over whole boots with journalctl -k -b <n> | grep -c "No PKTID" at 21:46 (persistent journal):

boot No PKTID lines
first (about 66 min) 193,533
second (about 97 min) 2,138
third (about 13 min) 721
fourth (about 38 min) 7,380
current (about 50 min at the time) 18,329

So it happens on every boot, only the amount differs. Same kernel image on all five, but the last three boots also had my Type-C and USB-role device tree overlays (nothing Wi-Fi related). All five have zero dma_map_single failed, and CONFIG_BRCMDBG=y is on, so as you said the message isn't rate limited.

The first two boots start the same way. The lines around the start of the first one (not every line, MACs removed):

17:25:03.123 brcmf_p2p_create_p2pdev: timeout occurred
17:25:06.282 brcmf_join_v1: join (v1, chanspec 0xd024, 78 bytes) failed: firmware error -14
17:25:06.383 brcmf_msgbuf_rxbuf_data_post: No PKTID available !!
17:25:06.385 brcmf_msgbuf_rxbuf_data_post: No PKTID available !!
17:25:06.385 brcmf_msgbuf_process_rx_complete: Received unexpected monitor pkt

The second boot has the same three steps a few seconds in (p2p timeout 18:30:03, failed join 18:30:06.277, first No PKTID 18:30:06.378). The other three boots each have one failed join and 9 "unexpected monitor pkt" lines, I didn't time them. I don't know max_rxbufpost, brcmfmac's PCIe debug output wasn't on, and turning it on needs another boot. I'd take the failed join as a pointer to where it starts, not as the cause. Brett, nothing needed while you're away.

@derekross

Copy link
Copy Markdown
Owner

Thanks Lef, the whole-boot counts are exactly what was missing, and they make
the lead fit better than I said yesterday. Walking the code again: since "give
control buffers the lowest packet IDs", the data range has exactly as many IDs as
the cap on posted rx buffers. A refill starts once 32 buffers have come back. At
that moment it needs 32 IDs, but the buffer being completed still holds its own,
so it finds 31. The first attempt posts 31 and logs, and the retry for the last
buffer logs again. After that the posted count sits one under the cap, so the
next refill, 31 packets later, is short the same way. If the BCM4398 reports a
max_rxbufpost at or above the cap, that gives about two lines for every 31
received buffers, from the first moments of traffic, with at most one buffer
missing. That fits a flood on every boot that follows the traffic, and
throughput that doesn't suffer.

If you'd like to test it without a reboot, note the Wi-Fi interface's
statistics/rx_packets and the No PKTID count, run one of your 15 s downloads,
and read both again. If the lead is right, the new lines come to roughly one per
15-16 received packets. If they come out much lower, look for Missed … kernel messages in that boot's journal first: at that rate journald can fall behind
the kernel log, and the count would be low.

The "unexpected monitor pkt" lines don't leak IDs: that path releases the ID
before it drops the frame. And as you say, the failed join is on the control
path, so it marks when data starts flowing rather than causing anything.

Brett, for when you're back: the fix I'd suggest is one ID of slack in the data
range (cap max_rxbufpost at NR_RX_PKTIDS - 2 - nr_ctrl), or releasing the
completed buffer's ID before the refill. Nothing is needed before then.

@W4HO-ham

W4HO-ham commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

@greenbrettmichael, for when you're back (and @derekross, in case it helps before then): I needed this rebased for linux-omarchy-mobile#178, so I've pushed the result as a branch you can take as is or compare against: W4HO-ham/linux-omarchy-mobile rb-156-onto-omamobile-20261101 (c89996c). It's #156's 57 commits not yet on omamobile, rebased onto 8b8235e, and it merges cleanly onto today's b39c04d too.

Two conflicts, both resolved by keeping both sides:

  • in zuma-husky.dts, omamobile's new panel0 node (the simpledrm size) and this PR's regulator-wlan, panel first;
  • in zumapro.dtsi, both includes (google,zumapro-acpm.h and gpio.h).

Every other commit applied unchanged, authorship and sign-offs as they were. I haven't booted husky with it; the 9a ran this base with #178 on top today (Gen2 x1, Wi-Fi, details there).

@Somnius

Somnius commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

@derekross I ran the no-reboot check you described, over Wi-Fi, with the download coming from the desktop.

Before: rx_packets 9,419 and 520 No PKTID lines. Then one download of 300 MB (ssh from the desktop, it took about 4 s, not 15 s, so it's a shorter run than you suggested). After: rx_packets 217,948 and 13,770 No PKTID lines. That is 208,529 received packets and 13,250 new lines, one line per 15.7 packets, which is in your 15-16 range. No Missed … kernel messages in that boot's journal, so journald wasn't dropping lines.

It's one run on one boot. I haven't read the driver code myself, so this fits your reading but doesn't prove the cause. I haven't tried the one-ID-of-slack change either, that's for @greenbrettmichael when he's back, as you said. If it helps I can build the 8 Pro with that change and repeat the same measurement before and after.

@derekross

Copy link
Copy Markdown
Owner

Thanks Lef, that's a clean measurement: 208,529 packets for 13,250 new lines is one line per 15.7 packets, and no "Missed … kernel messages" means the count is the real one. The refill reading predicts two lines for every 31 received buffers, one per 15.5, so the rate matches the mechanism and not only the fact that there is a flood. I'd now call this the cause rather than a lead. Throughput not suffering fits as well, since each short refill leaves at most one buffer unposted.

If you'd like to try the fix on your 8 Pro, yes please. Put it on a branch on your fork so the result points at a commit, and give the brcmfmac msgbuf.c blob you built from (git rev-parse HEAD:drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c). Then repeat the same 300 MB download. With one ID of slack, the prediction is zero new No PKTID lines, with rx_packets and the download time about the same as today. If lines still appear at a lower rate, that would tell us something else also holds IDs, and it would be worth knowing before Brett picks a version.

W4HO, thank you for the rebase. I've checked rb-156-onto-omamobile-20261101 (c89996c) against this PR's head:

  • It has the same 57 commits as the ones not yet on omamobile, in the same order, with authors and sign-offs unchanged. 55 are identical patches. The other two differ only in where a hunk lands: the HSI2/FAR_ALIVE pin controllers sit after hsi2c11_bus in zuma-pinctrl.dtsi, and regulator-wlan comes after the new panel0 node in zuma-husky.dts. The contents are the same.
  • It merges cleanly onto today's omamobile (b39c04d). Our kernel gate on that merge passes: sign-offs, subject prefixes, checkpatch with no errors, W=1 builds of the 14 touched C files, and the 8 device trees with no new warnings. dtbs_check couldn't run locally, so CI still has to run it.
  • One small correction to your note: none of the 57 commits touches zumapro.dtsi. I think that conflict came from Pixel 9a (zumapro): Wi-Fi PCIe on the shared gs201 host and zuma PHY drivers, stacked on #156 #178 or from a commit that's already on omamobile. The branch is right either way.

Brett, nothing is needed from you while you're away. When you're back, the quickest path is to take W4HO's branch as this PR's head, so CI can run here, and add the packet-ID slack as a commit on top. I'll coordinate with W4HO on how #178 lands in the meantime.

@derekross

Copy link
Copy Markdown
Owner

One more thing for @greenbrettmichael for when you're back, and for @W4HO-ham, since #178 carries the same commits. I went through which of the stack's brcmfmac commits also run on the Pixel 7 Pro's BCM4389. Most are gated on the BCM4398 or on what the firmware reports, but two aren't clearly:

  • "msgbuf: give control buffers the lowest packet IDs" (a6d6cda) has no chip check. On omamobile today the control buffers take their IDs from the same pool as the data buffers. With this commit every chip gets the split: IDs 1 to 32 for control buffers, data above them. The one-ID shortfall we found on the 8 Pro can't happen on the 7 Pro, because its firmware asks for 1535 rx buffers (the message of "keep rx packet IDs for the control buffers" records that), well under the 2015 cap. But the IDs the 7 Pro's firmware sees still change, so it's a 7 Pro change all the same.
  • "msgbuf: wait for D2H items the firmware has finished" (efb7c6b) turns on whenever the firmware sets PCIE_SHARED_D2H_SYNC_SEQNUM or _XORCSUM in its shared flags. I don't know yet whether the BCM4389's firmware sets either. If it does, the 7 Pro's receive path changes as well.

The event_msgs_ext fallback only acts when event_msgs fails, which it doesn't on the 7 Pro, and the third band only adds room in an array.

Our contributing guide asks that shared drivers leave the 7 Pro unchanged unless there's a reason that holds on the 7 Pro, and then I run it on my phone before merging. With the 7 Pro's first release being prepared, I'd prefer to leave it unchanged here: gate the packet-ID split on the chips that need it, the BCM4398 and, if W4HO's 9a needs it, the BCM4383. For the D2H sync, a line in the commit saying whether the BCM4389's firmware asks for it would settle it. If you'd rather keep the split for every chip, that's fine too, but then it's a 7 Pro change, and I'll run the stack on my 7 Pro before it lands. Nothing is needed until you're back.

@Somnius

Somnius commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

@derekross I tried it on the 8 Pro: branch husky-e1-pktid-slack on my fork (https://github.com/Somnius/linux-omarchy-mobile/tree/husky-e1-pktid-slack), commit fc654ef68, on top of the e1 tree I'm running. The change is the one line you described (NR_RX_PKTIDS - 2 in max_rxbufpost) plus a comment; the msgbuf.c blob went from 93eebe6cebbf837f681d5245ca2d3f22daf7a152 to ba1744a44c0fb486b530bbbfeed87f3f01435a6d. I built only brcmfmac.ko from that tree (same vermagic as the running kernel), stripped it with --strip-debug, and put it in place of the installed module after checking that the stripped build of the unpatched source has the same sha256 as the installed file. I kept the original, rebooted, and ran the same test as before.

The same kind of measurement as on the stock module, over Wi-Fi, 300 MB pushed from the desktop through ssh (head -c 300M /dev/zero | ssh phone 'cat > /dev/null'):

  • Stock module, the numbers I gave earlier: 208,529 received packets, 13,250 new No PKTID lines, about 4 s.
  • Patched module, first run: rx_packets 650 to 219,394 (218,744 packets), 0 No PKTID lines, 0 Missed … kernel messages. I didn't time that one.
  • Three more runs straight after, timed: 3.62 s, 5.69 s and 5.57 s, with 218,527, 218,691 and 218,677 packets, and 0 new lines in all three.

The stock figures are from my earlier run, not repeated with this exact script, so the time is only roughly comparable: about 4 s then, 3.6 to 5.7 s now.

Before any download, this boot had 0 No PKTID lines; the boot with the stock module a few minutes earlier already had 3 (in the smoke report I posted on #278). Two other brcmfmac lines in dmesg, add_iface p2p-dev ... err=-5 and brcmf_join_v1 ... firmware error -14, are in the journal of the two boots before as well, so they're not from this change.

So the lines are gone, as you predicted; the packet counts are the same, the time is in the same range. It's four runs on one boot, on one phone; I only changed that one line and haven't tested anything beyond this download. If @greenbrettmichael or @W4HO-ham want to try it on their phones, it's the one-line change on that branch: my .ko only loads on my e1 build, so they'd need a module built from their own tree.

@derekross

Copy link
Copy Markdown
Owner

Thank you, @Somnius, that's a clean result: four runs with no No PKTID lines against 13,250 before, the same
packet counts and about the same time, and you checked the stripped build of the unpatched source against the
installed module first. That settles the refill reading.

The commit on husky-e1-pktid-slack is the right shape: one line, a message that explains why, and your sign-off.
It belongs in this stack, after "keep rx packet IDs for the control buffers". @greenbrettmichael (and @W4HO-ham,
for #178), would you pick it up as Somnius's own commit, with authorship and sign-off kept, when you're back?

For the Pixel 7 Pro it changes nothing: its firmware asks for 1535 rx buffers, and the cap only moves from 2015 to
2014, so the min_t still picks 1535.

@Somnius

Somnius commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

@greenbrettmichael, I'm working on GNSS for the 8 Pro (a BCM4775x on spi21, with the clocks and the PMIC node as #210 and #211) and its pins are on the HSI2 and FAR_ALIVE pin controllers that your first commit here adds: host-req is gpa5-3 and nstandby and mcu-resp are gph3-3 and gph3-2. I wrote the same two controllers and the gpa5 and gph3 banks myself before I saw yours, and I'm not going to post that, because the labels would collide.

Would you be OK with that one commit becoming a small PR of its own, so GNSS and Wi-Fi can both sit on it? If you'd rather keep it here, I'll stack my node on #156 and wait. I only need the controllers and the banks, my part would be four pin groups and a disabled gnss@0.

@derekross

Copy link
Copy Markdown
Owner

@greenbrettmichael, an update for when you're back, since this PR's work is
about to land another way. W4HO's #187 carries your commits from this branch,
rebased onto today's omamobile, with your authorship and sign-off on each.
I checked them patch by patch. Of the 25 commits here that aren't on
omamobile yet, 22 are identical in #187. The other three differ only in
context: the versioned join is already on omamobile (from #143), and the PMU
isolation register and the 8 Pro's Wi-Fi node are the same lines, rebased.
I plan to rebase-merge #187 after my 7 Pro runs today. That lands your
commits as they are, and then I'll close this PR with a link. Nothing is lost,
and nothing is needed from you. If you'd rather it went differently, tell me
and I'll wait.

On my 11-02 request to gate the packet-ID split to the chips that need it:
W4HO pointed out on #187 that Broadcom's driver keeps a separate
control-buffer ID map on every chip, so the split stays as you wrote it and I'm
running it on my 7 Pro before the merge. Please treat that request as
withdrawn. Somnius's one-line packet-ID slack (husky-e1-pktid-slack), which
stops the "No PKTID available" flood on the 8 Pro, should land as its own
small PR right after #187.

@Somnius, on your question about the HSI2 and FAR_ALIVE pin controllers: no
need for a separate PR. That commit is in #187 unchanged (it's the first
commit after #56's three), with pinctrl_hsi2, pinctrl_far_alive and the
gpa5 and gph3 banks your GNSS pins need. Please base your GNSS node on
#187's branch once W4HO has rebased it (or on omamobile once it lands), and
drop your own copy of the banks, so the labels don't collide. Your PR will
need one more rebase after #187 merges, since the commit ids change.

@Somnius

Somnius commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

@derekross understood, thank you. I'll base the GNSS node on #187's branch once @W4HO-ham's rebase is in (or on omamobile after it lands), drop my own copy of the pin controller banks so the labels don't collide, and rebase once more after #187 merges. The packet-ID slack (husky-e1-pktid-slack) goes in as its own small PR right after #187, as you said.

@greenbrettmichael

Copy link
Copy Markdown
Contributor Author

Thanks Derek, and thank you @W4HO-ham for carrying these through #187 with the authorship and sign-offs intact. Closing this one with a link there is exactly right; nothing more from me here.

@Somnius, thank you for measuring the packet-ID shortfall and testing the one-line slack: four clean runs against 13,250 lines is a clear result, and it's good that it lands as your own PR. And yes, base your GNSS node on the pin controllers as they are in omamobile now.

Agreed that the open gaps (P2P and crash recovery) move to the 8 Pro's notes; Bluetooth is covered now by Somnius's #199.

@derekross

Copy link
Copy Markdown
Owner

Thanks, Brett. #187 is in, and I checked again: 71 of this branch's commits are on omamobile
unchanged, the pin controllers, the PCIe PHY isolation and the Wi-Fi node landed with your
authorship and the same lines, and the versioned join was already in. So I'm closing this one in
favour of #187. The P2P and crash-recovery gaps move to the 8 Pro's notes, and Bluetooth is
Somnius's #199, as you say. Thank you for all the groundwork here.

@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.

4 participants