Skip to content

wifi: apple: centauri: enable function memory space before polling Beta BAR0 - #3373

Merged
RyanTheTide merged 2 commits into
aurora-silicon:mainfrom
sithglan:fix/centauri-enable-fn2-mem
Nov 27, 2026
Merged

RyanTheTide merged 2 commits into
aurora-silicon:mainfrom
sithglan:fix/centauri-enable-fn2-mem

Conversation

@sithglan

Copy link
Copy Markdown
Contributor

What: Call pci_enable_device_mem() (serialized with device_lock()) for Centauri functions 1 and 2 before pci_iomap() in enumerate_functions(), guard centauri_beta_running() on ipc->enabled[2], and balance with pci_disable_device() in centauri_free_ipc(). Fixes an immediate Asynchronous SError kernel panic introduced by 227c89b69b65 (#3123) whenever centauri_beta_running() polls ipc->bar[2] + 0x18 before btcentauri has probed function 2 (0000:01:00.2).
Tested: J813 M5 MacBook Air (T8142, 7.3.0-aurora-j813-fn2fix+, default J813 cmdline, btcentauri blacklisted in /etc/modprobe.d/ and loaded by n1-up after echo 3 > rom_boot) at d77eb3148dd1: PASS (pci 0000:01:00.2: enabling device (0000 -> 0002), zero SError, wlp1s0f0 associated, hci0 UP RUNNING with ACL enabled, 1x deep S2R + 8 s PMU wake cycle rc=0 with full Wi-Fi/BT/panel recovery, 0 failed units, 0 DART faults, 0 new kernel errors). Negative control without this patch on the same J813 setup (4bbd481a549e carrying 227c89b69b65): instant Asynchronous SError panic (code 0x00000000be000000, x0=0x0000000bc2020018) during echo 3 > rom_boot.
Risk: two-way door · Apple N1 Centauri Macs (J813, J815, J873 / T8142 and T8152 using drivers/net/wireless/apple/centauri/centauri_ipc.c). Does not touch the t6050 backend (which already calls pci_enable_device_mem() under device_lock()).
Not yet: J815 or J873 peer row (same centauri_ipc.c path; J813 verified with both blacklisted-module cold boot and deep sleep).

Details

enumerate_functions() in drivers/net/wireless/apple/centauri/centauri_ipc.c rescans the N1 PCI bus to expose functions 1 (Alpha Wi-Fi, 0x1902) and 2 (Beta Bluetooth, 0x1903), then calls pci_iomap(ipc->function[i], 0, 0) on all three functions without calling pci_enable_device_mem() on functions 1 or 2. Function 1 happened to be enabled because apple_centauri itself binds 0x1902, whereas function 2 belongs to btcentauri.

Commit 227c89b69b65 ("wifi: apple: centauri: attach Bluetooth once Beta's firmware runs", #3123) added centauri_attach_beta() -> centauri_beta_running() at the end of centauri_boot_write() (echo 3 > rom_boot), which reads ipc->bar[2] + 0x18 and ipc->bar[2]. Whenever btcentauri has not already probed function 2 (for instance when btcentauri is blacklisted until a boot script loads it after rom_boot, or is built as a module and udev has not finished loading it yet), 0000:01:00.2 still has PCI_COMMAND_MEMORY cleared (0x0000), and the BAR0 read triggers a PCIe Unsupported Request and an immediate Asynchronous SError panic (0x0000000bc2020018).

Fix (matching drivers/net/wireless/apple/centauri/t6050/centauri_ipc.c):

  • Add bool enabled[3] to struct centauri_ipc.
  • In enumerate_functions(), call pci_enable_device_mem(ipc->function[i]) under device_lock(&ipc->function[i]->dev) for i > 0 before pci_iomap(), recording ipc->enabled[i] = true.
  • Guard centauri_beta_running() on ipc->enabled[2] before reading ipc->bar[2].
  • In centauri_free_ipc(), balance with pci_disable_device(ipc->function[i]) under device_lock() after pci_iounmap().
  • Update the stale comment above centauri_ids in centauri_pci.c.
Evidence

Head d77eb3148dd16969ba4e6e42b60b6723d1e18366 on main deb2df2a9e2b.

Build & static checks:

  • scripts/checkpatch.pl -g HEAD: 0 errors, 0 warnings, 0 checks, 66 lines checked
  • Cross-build ARCH=arm64 LLVM=-22 (7.3.0-aurora-j813-fn2fix+) + W=1 M=drivers/net/wireless/apple/centauri: 0 warnings

Negative control (without this fix, J813 with btcentauri blacklisted, 4bbd481a549e carrying 227c89b69b65):

  • pci 0000:01:00.2: BAR 0 [mem 0xbc2020000-0xbc202ffff 64bit pref]: assigned (never enabled)
  • Immediately after cfg80211 interface wlp1s0f0 ready: SError Interrupt on CPU8, code 0x00000000be000000 -- SError, Comm: n1-up, x0 = x21 = 0x0000000bc2020018 (0000:01:00.2 BAR0 + 0x18), Kernel panic - not syncing: Asynchronous SError Interrupt.

J813 M5 Air hardware row (d77eb3148dd1, 7.3.0-aurora-j813-fn2fix+, one-shot aura-try, default J813 cmdline, btcentauri blacklisted until n1-up):

  • Boot log:
    • [ 4.763503] pci 0000:01:00.2: BAR 0 [mem 0xbc2020000-0xbc202ffff 64bit pref]: assigned
    • [ 4.765240] pci 0000:01:00.2: enabling device (0000 -> 0002)
    • [ 7.718922] apple_centauri 0000:01:00.0: Bluetooth function not attached: 0 (no SError)
    • [ 7.734742] btcentauri 0000:01:00.2: Beta HCI transport registered; ACL enabled=1, SCO/ISO unsupported
    • [ 8.182121] Bluetooth: hci0: Native startup accepted; factory address in use
  • Wi-Fi & BT: wlp1s0f0 scanned 38/38 channels and associated (UP); hci0 UP RUNNING (ACL enabled=1, 0 errors).
  • Deep sleep (mem, 8 s PMU wake): rc=0, suspend_stats/success 0->1, fail=0, elapsed 8.35 s, back from sleep, boot object resumes 0 -> 1 (wake source: NUB.SPMI0.SW3), Alpha ACIPC host wake: ret=0, apple_sep: the enclave is back from its sleep request; post-wake card1-eDP-1 2560x1600, wlp1s0f0 re-scanned 38/38 channels and re-associated, hci0 UP RUNNING (69 commands / 69 events, 0 errors).
  • Regression counts: 0 failed systemd units, 0 AVC (SELinux disabled), 0 DART faults, 0 new kernel errors. boot-fn2fix removed from ESP.

…ta BAR0

enumerate_functions() maps BAR 0 of functions 1 (Alpha Wi-Fi) and 2
(Beta Bluetooth) via pci_iomap(), but never called pci_enable_device_mem()
on them. Function 1 happened to be enabled because apple_centauri itself
probes 0x1902, while function 2 (0x1903) belongs to btcentauri.

Since commit 227c89b ("wifi: apple: centauri: attach Bluetooth once
Beta's firmware runs"), centauri_boot_write() calls centauri_attach_beta()
-> centauri_beta_running() at the end of IPC bootstrap, which reads
ipc->bar[2] + 0x18 and ipc->bar[2]. When btcentauri has not already probed
function 2 (for example when btcentauri is blacklisted until a boot script
loads it after rom_boot, or is built as a module before udev probes it),
0000:01:00.2 still has PCI_COMMAND_MEMORY cleared and the BAR0 read causes
an immediate Asynchronous SError kernel panic on Apple Silicon PCIe.

Call pci_enable_device_mem() (serialized with device_lock(), matching the
t6050 backend) for functions 1 and 2 before pci_iomap() in
enumerate_functions(), guard centauri_beta_running() on ipc->enabled[2],
and balance with pci_disable_device() after pci_iounmap() in
centauri_free_ipc().

Fixes: 227c89b ("wifi: apple: centauri: attach Bluetooth once Beta's firmware runs")
Signed-off-by: Thomas Glanzmann <[email protected]>

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review at d77eb3148dd1: approve, 0 blockers. This fixes the SError panic centauri_beta_running() hits on main when it reads function 2's BAR0 before that function's memory decoding is enabled.

  • The fix:
    • enumerate_functions() now enables memory space with pci_enable_device_mem() on functions 2 and 1, in that loop order, before pci_iomap(). Each enable runs under that function's device_lock(), as in the t6050 backend.
    • enabled[i] is set only after a successful enable, and centauri_free_ipc() undoes exactly those. So the failure path out of centauri_start_ipc() stays balanced.
  • Refcounting: pci_enable_device*() and pci_disable_device() are refcounted through enable_cnt. The extra enable on function 1 (its own probe already enabled it) and on function 2 doesn't conflict with btcentauri's pcim_enable_device(). A later probe finds the device already enabled, and this driver's disable never drops btcentauri's count.
  • Locking:
    • centauri_start_ipc() runs only from the rom_boot debugfs write and the recovery worker, both under boot_lock and never inside a probe, so the new device_lock() can't deadlock on itself.
    • btcentauri's probe only does pcim_enable_device() and never takes boot_lock, so the boot_lock → device_lock(fn2) order has no inverse.
    • centauri_attach_beta() calls device_attach() outside boot_lock.
  • centauri_beta_running(): bar[2] is only set after the enable, so the new enabled[2] guard is a harmless extra check.
  • Checks: checkpatch.pl --strict reports 0 errors, 0 warnings, 0 checks. The commit carries a human Signed-off-by and no attribution, and it merges cleanly onto main.
  • Hardware: the exact-head J813 row, together with the negative control on the same setup, covers both the panic and resume from deep sleep.
  • CI at this head: 1/3 checks pass, 2 still pending at posting, 0 failing.
  • Rows: the t6050 backend (M5 Pro/Max, J714s) is untouched, so no J714s row is needed. centauri_ipc.c is shared with T8152, so the J815 or J873 peer row from the PR's Not yet is the remaining second-machine check.

@github-actions github-actions Bot added the blast:m5 Macs affected, from Merge risk (bot) label Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Merge readiness at eb46f1f3: not ready yet

Check Detail
CI at head running running: host-tests, pr-text / pr-text
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head no no line with the head SHA eb46f1f3, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · Apple N1 Centauri Macs (J813, J815, J873 / T8142 and T8152 using drivers/net/wireless/apple/centauri/centauriipc.c). Does not touch the t6050 backend (which already calls pcienabledevicemem() under devicelock()).

Areas: none matched in CODEOWNERS

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@github-actions github-actions Bot added door:two-way Revertible or not, from Merge risk (bot) ci-failing A check failed at the PR head (bot) labels Nov 27, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

The host-tests failure here isn't from this change: it touches only centauri_ipc.c/centauri_pci.c, and the failing suites are DCP ones (apple-dcp, dcpext26-startup, hardware-defaults, backlight-coldboot). The run is on the merge ref from 10:18 UTC, over a main that has since been fixed (main's own host-tests pass). A re-run reuses that old ref and fails the same way. Could you merge current main into the branch with one normal push? This PR merges once CI is green: Dj's approval and your J813 row are already at d77eb314, and a main-only merge keeps the row valid as long as your two files stay byte-identical.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merge-train: I updated this branch from main using GitHub's update-branch (a merge commit, no force push). The host-tests failure was inherited from a main breakage (#3302) that has since been reverted (#3374). Not from your change. I'll merge once CI is green at the new head, since Dj approved and your J813 row with the negative control is in.

@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 27, 2026
@RyanTheTide
RyanTheTide merged commit ae01199 into aurora-silicon:main Nov 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants