Repository navigation
wifi: apple: centauri: enable function memory space before polling Beta BAR0 - #3373
Conversation
…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
left a comment
There was a problem hiding this comment.
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 withpci_enable_device_mem()on functions 2 and 1, in that loop order, beforepci_iomap(). Each enable runs under that function'sdevice_lock(), as in the t6050 backend.enabled[i]is set only after a successful enable, andcentauri_free_ipc()undoes exactly those. So the failure path out ofcentauri_start_ipc()stays balanced.
- Refcounting:
pci_enable_device*()andpci_disable_device()are refcounted throughenable_cnt. The extra enable on function 1 (its own probe already enabled it) and on function 2 doesn't conflict with btcentauri'spcim_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 therom_bootdebugfs write and the recovery worker, both underboot_lockand never inside a probe, so the newdevice_lock()can't deadlock on itself.- btcentauri's probe only does
pcim_enable_device()and never takesboot_lock, so theboot_lock→device_lock(fn2)order has no inverse. centauri_attach_beta()callsdevice_attach()outsideboot_lock.
centauri_beta_running():bar[2]is only set after the enable, so the newenabled[2]guard is a harmless extra check.- Checks:
checkpatch.pl --strictreports 0 errors, 0 warnings, 0 checks. The commit carries a humanSigned-off-byand no attribution, and it merges cleanly ontomain. - 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.cis shared with T8152, so the J815 or J873 peer row from the PR's Not yet is the remaining second-machine check.
|
Merge readiness at
Areas: none matched in CODEOWNERS Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
The |
|
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. |
What: Call
pci_enable_device_mem()(serialized withdevice_lock()) for Centauri functions 1 and 2 beforepci_iomap()inenumerate_functions(), guardcentauri_beta_running()onipc->enabled[2], and balance withpci_disable_device()incentauri_free_ipc(). Fixes an immediate Asynchronous SError kernel panic introduced by227c89b69b65(#3123) whenevercentauri_beta_running()pollsipc->bar[2] + 0x18beforebtcentaurihas probed function 2 (0000:01:00.2).Tested: J813 M5 MacBook Air (T8142,
7.3.0-aurora-j813-fn2fix+, default J813 cmdline,btcentauriblacklisted in/etc/modprobe.d/and loaded byn1-upafterecho 3 > rom_boot) atd77eb3148dd1: PASS (pci 0000:01:00.2: enabling device (0000 -> 0002), zero SError,wlp1s0f0associated,hci0UP RUNNING with ACL enabled, 1xdeepS2R + 8 s PMU wake cyclerc=0with full Wi-Fi/BT/panel recovery,0failed units,0DART faults,0new kernel errors). Negative control without this patch on the same J813 setup (4bbd481a549ecarrying227c89b69b65): instant Asynchronous SError panic (code 0x00000000be000000,x0=0x0000000bc2020018) duringecho 3 > rom_boot.Risk: two-way door · Apple N1 Centauri Macs (
J813,J815,J873/ T8142 and T8152 usingdrivers/net/wireless/apple/centauri/centauri_ipc.c). Does not touch thet6050backend (which already callspci_enable_device_mem()underdevice_lock()).Not yet: J815 or J873 peer row (same
centauri_ipc.cpath; J813 verified with both blacklisted-module cold boot and deep sleep).Details
enumerate_functions()indrivers/net/wireless/apple/centauri/centauri_ipc.crescans the N1 PCI bus to expose functions 1 (Alpha Wi-Fi,0x1902) and 2 (Beta Bluetooth,0x1903), then callspci_iomap(ipc->function[i], 0, 0)on all three functions without callingpci_enable_device_mem()on functions 1 or 2. Function 1 happened to be enabled becauseapple_centauriitself binds0x1902, whereas function 2 belongs tobtcentauri.Commit
227c89b69b65("wifi: apple: centauri: attach Bluetooth once Beta's firmware runs", #3123) addedcentauri_attach_beta()->centauri_beta_running()at the end ofcentauri_boot_write()(echo 3 > rom_boot), which readsipc->bar[2] + 0x18andipc->bar[2]. Wheneverbtcentaurihas not already probed function 2 (for instance whenbtcentauriis blacklisted until a boot script loads it afterrom_boot, or is built as a module and udev has not finished loading it yet),0000:01:00.2still hasPCI_COMMAND_MEMORYcleared (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):bool enabled[3]tostruct centauri_ipc.enumerate_functions(), callpci_enable_device_mem(ipc->function[i])underdevice_lock(&ipc->function[i]->dev)fori > 0beforepci_iomap(), recordingipc->enabled[i] = true.centauri_beta_running()onipc->enabled[2]before readingipc->bar[2].centauri_free_ipc(), balance withpci_disable_device(ipc->function[i])underdevice_lock()afterpci_iounmap().centauri_idsincentauri_pci.c.Evidence
Head
d77eb3148dd16969ba4e6e42b60b6723d1e18366onmaindeb2df2a9e2b.Build & static checks:
scripts/checkpatch.pl -g HEAD:0 errors, 0 warnings, 0 checks, 66 lines checkedARCH=arm64 LLVM=-22(7.3.0-aurora-j813-fn2fix+) +W=1 M=drivers/net/wireless/apple/centauri:0warningsNegative control (without this fix, J813 with
btcentauriblacklisted,4bbd481a549ecarrying227c89b69b65):pci 0000:01:00.2: BAR 0 [mem 0xbc2020000-0xbc202ffff 64bit pref]: assigned(never enabled)cfg80211 interface wlp1s0f0 ready:SError Interrupt on CPU8, code 0x00000000be000000 -- SError,Comm: n1-up,x0 = x21 = 0x0000000bc2020018(0000:01:00.2BAR0 +0x18),Kernel panic - not syncing: Asynchronous SError Interrupt.J813 M5 Air hardware row (
d77eb3148dd1,7.3.0-aurora-j813-fn2fix+, one-shotaura-try, default J813 cmdline,btcentauriblacklisted untiln1-up):[ 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 usewlp1s0f0scanned 38/38 channels and associated (UP);hci0UP RUNNING(ACL enabled=1,0errors).mem,8 sPMU wake):rc=0,suspend_stats/success 0->1,fail=0, elapsed8.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-wakecard1-eDP-12560x1600,wlp1s0f0re-scanned 38/38 channels and re-associated,hci0UP RUNNING(69commands /69events,0errors).0failed systemd units,0AVC (SELinux disabled),0DART faults,0new kernel errors.boot-fn2fixremoved from ESP.