Repository navigation
wifi: apple: centauri: attach the Beta function outside the rescan lock and boot_lock - #2206
Conversation
|
No blockers. Checked drivers/net/wireless/apple/centauri/t6050/centauri_ipc.c at the head: the Beta function is pinned with HW row: K116s on this branch with CONFIG_PROVE_LOCKING, 10 back-to-back Assisted-by: LLM (Claude:Opus 5.5) |
|
Moving attachment out of the rescan lock is still needed. This head replays cleanly onto integration/aurora |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Formal pre-PR §1–§6 review at caa54bfba018 against integration/aurora tip 70a00e583b03: REQUEST_CHANGES.
Code, Concurrency & Supersession Audit
- Not superseded: Even after commit
b8fce260d6be(N1 keep-alive deep sleep), livedrivers/net/wireless/apple/centauri/t6050/centauri_ipc.c:453still callsdevice_attach(&ipc->function[2]->dev)while holdingpci_lock_rescan_remove(). The lock-order inversion withapple_pcie_t6050_pm_notify()->flush_work(&pcie->t6050_unpark_work)->apple_pcie_t6050_cold_rescan()->pci_lock_rescan_remove()still exists on boot and on any fallback warm-reset sleep/recovery path. - §1–§3 (Concurrency / lifetimes / error paths): Clean.
centauri_t6050_start_ipc_locked()pinsipc->function[2]withpci_dev_get()beforepci_unlock_rescan_remove(), andcentauri_t6050_start_ipc()callsdevice_attach(&beta->dev)outside the rescan lock followed bypci_dev_put(beta).- Error paths preserve exact return values when
beta == NULL(-ECANCELED,-EBUSY,-ENOMEM, etc.) and return0with the existing warning whendevice_attach()fails. - Teardown/removal races are safe:
centauri_t6050_quiesce()clearsc->ready(smp_store_release) and drainscancel_delayed_work_sync(&c->boot_work);cen_probe()(drivers/bluetooth/btcentauri_t6050.c:956) returns-EPROBE_DEFERwhenapple_centauri_control_ready()is false and takes neither the rescan lock nor F0'sdevice_lock;centauri_t6050_prepare()serializes suspend behindc->boot_lock; anddevice_attach()safely skips adevice_del()'dbeta.
- §4 (Attribution): Clean — human author/committer and human
Signed-off-by: Jens Axboe <axboe@kernel.dk>only, zero AI commit trailers. - §6 (CI & naming): Live CI is green (
host-testsrun44377640166).
Blockers
- §5 (Exact-head regression & lockdep evidence on current tip): The K116s suspend/resume test results were run on
0abc2f385e54(prior tob8fce260d6be, which substantially changedcentauri_pci.c/centauri_ipc.c/btcentauri_t6050.cdeep sleep) and omit the required §5 regression summary. Please post an exact-head K116s test run (withCONFIG_PROVE_LOCKINGexercising back-to-back suspend/resume including fallback/boot attach) plus the full regression pass (0 SELinux denials, 0 failed units, 0 new kernel errors).
Assisted-by: LLM (Gemini 4 Neon)
|
K116s row with lock checking, as far as it goes. Kernel:
Neither report is this PR's. Until those two are sorted, a |
…ck and boot_lock centauri_t6050_start_ipc() holds the PCI rescan lock while it attaches the Bluetooth function's driver, whose probe registers a PM notifier. A suspend that starts while the N1 is still coming up after a wake then never finishes: - the suspend runs the PM notifiers; the PCIe host's flushes its unpark work, - that work waits for the rescan lock in its cold rescan, - the boot worker holds the lock and waits, in hci_register_dev(), to write the notifier chain the suspend is reading. Nothing has armed the sleep's watchdog yet, so the machine stays up with the suspend stuck. On a K116s, two RTC deep sleeps back to back do it every time; a lid closed again a few seconds after a wake does too. Take a reference under the lock and attach after dropping it. The boot worker's boot_lock has the same problem one step removed. The attach ran under it, the PCIe host's PM notifier takes the rescan lock, and the rewake worker takes boot_lock in centauri_t6050_quiesce() with the rescan lock held. Lockdep reports it at the first deep sleep: &c->boot_lock --> (pm_chain_head).rwsem --> pci_rescan_remove_lock So the boot worker attaches after it has dropped boot_lock as well. Fixes: 0a2d99d ("PCI: apple: T6050: look for a parked port's functions from a work") Signed-off-by: Jens Axboe <axboe@kernel.dk>
caa54bf to
cbc00ab
Compare
|
v2 pushed (cbc00ab), rebased onto The lockdep row above stopped at the first sleep because of two reports in the sleep code. With those fixed (#3065) lockdep kept running and reported one more cycle, this one in this PR's area: the attach was still under the boot worker's With v2 and #3065, |
|
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. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: MERGE at cbc00abf1689
Blockers: none
Checked: Full v2 diff (+28/-9, 3 files) against main (0a7dcb396537), rescan/boot_lock/refcount/teardown/suspend concurrency, and §1–§6 pre-PR checklist. Prior §5 blocker is resolved by the updated K116s CONFIG_PROVE_LOCKING=y and regression runs at cbc00abf1689, and moving device_attach() outside boot_lock fixes the lockdep cycle surfaced by lock checking.
Evidence
- Locking & lifetimes (
centauri_ipc.c:454,471-495,centauri_pci.c:458,477,500-501):centauri_t6050_start_ipc_locked()pinsipc->function[2]withpci_dev_get()underpci_lock_rescan_remove()aftersmp_store_release(&c->ready, true).centauri_t6050_boot_worker()initializesbeta = NULL, transitions toCEN_BOOT_READYon success, drops bothpci_rescan_remove_lockandc->boot_lock, and then callscentauri_t6050_attach_beta(c, beta)which always pairspci_dev_put(beta). Teardown/removal races stay safe:centauri_t6050_quiesce()clearsc->readyand drainscancel_delayed_work_sync(&c->boot_work),cen_probe()defers onceapple_centauri_control_ready()is false, anddpm_prepare()'sdevice_block_probing()defers overlapping probes cleanly todpm_complete(). (Minor non-blocking note:centauri_t6050_start_ipc()relies on caller-initialized*beta = NULL, which holds for its sole callercentauri_t6050_boot_worker().) - §1–§3 (No model gating / production-ready / safety): No chip/board/firmware gates, no cmdline/module params or hacks, DMA fencing and refcount pairing preserved.
- §4 (Attribution & clean-room): Single commit
cbc00abf1689, human author/committer andSigned-off-by: Jens Axboe <axboe@kernel.dk>, verifiedFixes: 0a2d99d4ae30, clean PR title/body. - §5 (CI & HW evidence at head):
host-tests(run45399655802) andpr-text(run45399657197) both green atcbc00abf1689. K116s (T6050, fw 27.2) tested atcbc00abf1689both withCONFIG_PROVE_LOCKING=y(+ #3065: boot with Beta bound tobtcentauri_t6050+ 4 deep sleeps, 0 lockdep reports,debug_locks: 1, Wi-Fi back each time) and without lockdep (3 deep sleeps across associated/logind/disconnected states, 0 SELinux denials, 0 failed units, 0 boot/wake kernel errors). - §6 (Naming): Clean across diff, commit, PR title, and PR body.
Problem
A suspend that starts while the N1 is still coming up after a wake never finishes. The machine stays up with the suspend stuck, and no watchdog fires, because the sleep's WD2 is not armed yet. Seen on a K116s (T6050, M5 Pro), firmware 27.2: two RTC deep sleeps back to back do it every time, and a lid closed again a few seconds after a wake does too.
apple_pcie_t6050_pm_notify()callsflush_work()on the host's unpark work.apple_pcie_t6050_cold_rescan(), waiting inpci_lock_rescan_remove().centauri_t6050_start_ipc()holds the rescan lock while it attaches the Bluetooth function's driver.cen_probe()→hci_register_dev()→register_pm_notifier()waits to write the notifier chain the suspend is reading.The boot worker's
boot_lockhas the same problem one step removed, and lockdep reports it at the first deep sleep: the attach ran underboot_lock, the PCIe host's PM notifier takes the rescan lock, and the rewake worker takesboot_lockincentauri_t6050_quiesce()with the rescan lock held.Fixes: 0a2d99d ("PCI: apple: T6050: look for a parked port's functions from a work")
Change
centauri_t6050_start_ipc()takes a reference to the Beta function under the rescan lock and hands it back; the boot worker callsdevice_attach()after it has dropped both the rescan lock andboot_lock. One commit, three files, 28 lines added, 9 removed. Affects every machine with the N1 (T6050).Testing
Tested: K116s (T6050, M5 Pro), firmware 27.2, with and without lock checking; rows below. Host tests 503/503 and
centauri-t6050-probe.pyat the head.Risk: two-way · T6050 machines with the N1 (J714s, J716c, K116s).
cbc00abf1689T6050 / K116s (M5 Pro), firmware 27.2: booted on a stack that contains this change, there as the first version of the commit plus theboot_lockpart on top (the surrounding code differs with wifi: apple: centauri: t6050: harden keep-alive sleep fallback, PME gating, and 27.2 TLV 280 #2877, so the commit is not byte-identical) (main974efa5 + drm/apple: J716c external displays and display sleep on firmware 27.2 #2187 + T6050: firmware-driven deep sleep on the K116s (16-inch M5 Pro, firmware 27.2) #2201 v10 + spmi: apple: recover every generation 4 controller from a failed exchange #2309 + wifi: apple: centauri: t6050: harden keep-alive sleep fallback, PME gating, and 27.2 TLV 280 #2877 + the lock fixes + my other K116s commits,7.3.0-m5pro-ge3fa7f0044df); 3 deep sleeps resumed on the same boot (rawrtcwake -m memwith Wi-Fi associated, logind suspend with an RTC alarm, rawrtcwake -m memwith Wi-Fi disconnected), panel and Wi-Fi back each time; 0 SELinux denials (not installed on this Debian), 0 failed units, 0 error-level kernel lines at boot, 0 new kernel errors at the wakes.The K116s does not sleep on
mainalone, so the rows are on a stack that contains this commit unchanged:main+ #2187 + #2201 + #2309 + #2877 + #3065 + my other K116s commits. The command line is not the default (idle=nopamong others).boot_lockreport above at the first deep sleepbtcentauri_t6050) and 4 deep sleeps on one boot, 0 lockdep reports,debug_locks: 1at the end, Wi-Fi back after eachRows for the first version (rescan lock only), integration/aurora 0abc2f3 plus my K116s series
rtcwakehangs every time.Beta driver attachment failed: -517; the deferred probe binds the function after the wake.Still to run
J714s and J716c: not run here; the three code paths are the same there.
Lock checking only survives a T6050 deep sleep with T6050 sleep: two lock checking reports at the first deep sleep #3065.
Clean-room: no Apple code, strings, firmware, RE output or tuning values
No chip/board/firmware-version gate where a hardware property can decide
Works on the default kernel command line; no hacks, delays or lab-only paths
Safety limits come from the machine, not from constants in code
Hardware safety rules followed for every test boot
Third-party commits unchanged; reporters and testers credited
Commits: human Signed-off-by only; no AI attribution in commits or PR text
Tested on the affected hardware; no regression