Repository navigation
wifi: apple: centauri: t6050: let the system sleep after a failed N1 startup - #3356
Conversation
…startup On a s2idle path (no firmware sleep), centauri_t6050_suspend() returns -EBUSY unless the N1 reached CEN_BOOT_READY. That holds off a sleep while the boot worker is in the middle of the ROM, cycle or IPC stage, which is the point. But it also refuses every sleep for good once the startup has given up (CEN_BOOT_FAILED: missing firmware, say) or was stopped: the worker does not run again, nothing runs on the N1, and there is no state to keep. A MacBook Pro whose installed firmware lacks the N1's FTAB therefore could never suspend: every attempt ended with "pci_pm_suspend(): centauri_t6050_suspend returns -16". Return 0 for CEN_BOOT_FAILED and CEN_BOOT_STOPPED and keep -EBUSY for a startup in progress. The PCI core saves the config space as for any driver that does not. Signed-off-by: Ryan Murray <[email protected]>
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict at e89a04fc575f: no code blockers. It isn't ready to merge yet: the noirq half of the new path is untested, and CI hasn't run the build jobs (see below).
Checked
- The change only touches the s2idle path (
!apple_centauri_sleep_reboot()):CEN_BOOT_READYstill callspci_save_state(), as before.- Startups in progress (ROM, cycle, IPC) still return
-EBUSY. CEN_BOOT_FAILEDandCEN_BOOT_STOPPEDnow return 0.
- Those two phases are final:
centauri_t6050_boot_worker()setsFAILEDonly when it doesn't re-queue itself; an-EAGAINin cycle or IPC keeps the phase and retries.STOPPEDis set on removal and bycentauri_t6050_quiesce().- So nothing is left running on the N1 when the sleep starts.
- Firmware sleep and resume are untouched:
- The firmware-sleep path below is unchanged.
centauri_t6050_suspend_noirq()and both resume callbacks return early withoutfirmware_keptorfirmware_sleep, so a failed N1 resumes as a no-op in this driver.
- Commit:
checkpatch --strictgives 0/0/0. It is signed off by the author, with no attribution.
Before merge
- A noirq run with a failed N1:
- Returning 0 without
pci_save_state()means the PCI core'spci_pm_suspend_noirq()seesstate_saved == false. It then saves the config space and, throughpci_prepare_to_sleep(), puts F0 into D3hot. On resume it brings F0 back to D0 and restores it. - That D3hot round trip of a firmware-less N1 is new: until now, s2idle never got past this driver.
- The K114s row used
pm_test=devices, which stops before the late and noirq phases, so it doesn't cover it.pm_test=platform(orprocessors) withfreezeruns suspend_noirq and resume without needing a wake source, so it can run unattended. - Either show that run, or keep F0 in D0 the way READY does by calling
pci_save_state()for these two phases too. Either way, the comment ("The PCI core saves the config space") should say what happens to the device.
- Returning 0 without
- CI: only
host-testsandpr-textran at this head, andreadinessis pending. The Apple build and KUnit jobs need to run green. - J714s (working N1): a boot plus one s2idle, to show the READY path is unchanged (already under
Still to run).
|
Real s2idle row (supervised lid sleep), K114s, kernel 7.3.0-42, the N1 startup failed in phase 0 (no FTAB), with this patch's module loaded:
With the stock module the same machine refused every suspend ( |
|
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. |
|
Second real s2idle row, same K114s and kernel, with this patch: GNOME idle-suspended the machine at 18:51:59 (lid open), 'PM: suspend entry (s2idle)'. The owner woke it 17 minutes later from the built-in keyboard/trackpad (MTP input) at 19:09:20: 'resume from suspend-to-idle', resume of devices 330 ms, 'suspend exit'. After resume there were no kernel errors, the GPU render node was present and the network was back. With the stock module this idle suspend would have been refused (-16). |
There was a problem hiding this comment.
Verdict: MERGE at e89a04fc575f, once the J714s row below is in.
Blockers: none in the code.
Before merge:
- J714s (working N1): one boot plus one s2idle cycle with this module, as Dj asked. The READY path is unchanged in the source, so this is the second-Mac regression row, not a new test.
- The rows name
a851ca0eplus this patch, not the head SHA. One line restating them fore89a04fcwould clear the readiness bot; the driver source is the same (see Evidence).
Checked: read the whole diff and the boot worker; built at this head with W=1; confirmed the rows ran on the same driver source as this head; looked for a way the new return 0 could hide a startup still in progress; no gates, no tunables, no attribution.
Evidence
CEN_BOOT_FAILEDis final: only probe setsCEN_BOOT_ROM, and the worker sets FAILED only when it doesn't re-queue (-EAGAINin cycle/IPC keeps the phase and retries).CEN_BOOT_STOPPEDcomes only from removal and quiesce. So the newreturn 0can't race a startup: ROM/cycle/IPC still return-EBUSY.- Dj's open point (the noirq half:
pci_pm_suspend_noirq()now saves F0 and puts it into D3hot) is covered by data. His review was at 06:40Z, and the two real s2idle rows came after it: the 07:37Z lid sleep ("late + noirq suspend complete", then resume) and the 08:09Z 17-minute GNOME idle sleep with a keyboard wake. Both are full suspend/resume cycles with a failed N1, so they include the D3hot round trip. - Row source vs head:
git diff a851ca0e e89a04fc -- drivers/net/wireless/apple/centauri/is exactly this patch, and main hasn't changed that directory sincea851ca0e. The rows therefore ran this head's driver. - Build:
make W=1 drivers/net/wireless/apple/centauri/t6050/(arm64, aurora_defconfig) ate89a04fc: 0 warnings. checkpatch --strict: clean. No CI job buildsdrivers/net/wireless(it isn't in apple-build-kunit's paths), so this build stands in for it. - Conflicts: none with main
2d96d922or with the other open K-board PRs (#3372, #3376, #3383, #3363).
|
@DjDeveloperr code-owner ping (6-point rule, point 6) at |
erikwb
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at e89a04fc575f
Blockers:
drivers/net/wireless/apple/centauri/t6050/centauri_pci.c:1145:CEN_BOOT_FAILEDonly means that startup stopped retrying. If the ROM image response times out,centauri_t6050_rom_boot()has already enabled PCI bus mastering and published a DMA descriptor (lines 326–356). It returns without stopping DMA, and the worker marks the phase failed at line 492. The new success path lets PCI noirq put the function in D3hot without the driver checking whether transactions have drained.CEN_BOOT_STOPPEDalso precedes the DMA fence incentauri_t6050_quiesce()(lines 806–825), which can fail. Allow sleep after a failure before DMA starts, or require a successful quiesce and DMA fence for the other cases.
Checked: The K114s tests included full lid and keyboard wake cycles for the missing-file case. READY still saves PCI state and in-progress phases still return busy. Host tests, PR text and readiness passed, and the branch has no conflicts. The patch adds no model gate, tunable or timing constant.
Evidence
The K114s module was built from a851ca0e plus this patch. The missing file returns at line 298, before any boot DMA is submitted. The two real s2idle runs answer the earlier noirq coverage question for that path. A working-N1 s2idle cycle would cover the READY path after the fix.
…ailed start A failed or stopped N1 startup no longer holds off system sleep, but a failure is not always DMA-free. When the ROM image response times out, the ROM boot has already enabled bus mastering and published the boot descriptor, and it returns without stopping DMA. A stopped startup sets CEN_BOOT_STOPPED before quiesce fences its DMA, and that fence can fail. Either way, PCI noirq could put the function in D3hot with transactions outstanding. Before allowing the sleep, release the boot DMA the same verified way teardown does (free_boot only frees buffers after a confirmed bus-master stop), then check that nothing is left: no IPC, firmware or descriptor buffers and bus mastering off. A function that already reads all ones is off the bus and cannot master. If the DMA cannot be confirmed stopped, refuse the sleep with -EBUSY, as before this series. A startup that failed before any DMA (missing firmware) passes the check at once, so the K114s case that motivated the change still sleeps. Signed-off-by: Ryan Murray <[email protected]>
There was a problem hiding this comment.
Verdict: FINISH, then merge at a4eb6e8a
Blockers:
centauri_t6050_boot_dma_idle()(drivers/net/wireless/apple/centauri/t6050/centauri_pci.c:285) does not checkc->recovery->arena(Beta/Bluetooth DMA backing) before admittingCEN_BOOT_STOPPEDtos2idle:- In
centauri_t6050_quiesce()(lines 820–846),c->boot_phase = CEN_BOOT_STOPPEDis set at line 826 even ifcentauri_t6050_beta_call(c->recovery, false),centauri_t6050_domain_fence(c->recovery), orcentauri_t6050_beta_call(c->recovery, true)fails — leavingc->recovery->arenaallocated and potentially unfenced. centauri_t6050_quiesce()explicitly treatsc->ipc || c->firmware || c->descriptor || c->recovery->arenaas live DMA backing (line 833), whereascentauri_t6050_boot_dma_idle()checks onlyc->ipc || c->firmware || c->descriptorand F0'sPCI_COMMAND_MASTER(lines 290–297).- If a failed quiesce leaves
c->recovery->arena != NULL(withc->ipc/c->firmware/c->descriptoralready released or cleared bycentauri_t6050_free_boot()),centauri_t6050_suspend()seesCEN_BOOT_STOPPED, concludesidle == true, and returns0— putting F0 into D3hot while Beta's DMA arena is still retained/unfenced. - Fix: Check
c->recovery && c->recovery->arena(takingcen_recovery_lockbeforec->boot_lockto preserve existing lock ordering, or refusingCEN_BOOT_STOPPEDwheneverarenais non-NULL) sos2idleis refused (-EBUSY) whenever Beta's DMA arena has not been fenced and released.
- In
- Open
CHANGES_REQUESTEDreview, queued CI, and exact-head hardware row:- Hosted CI at
a4eb6e8a(apple-build,host-tests,pr-text,readiness,KUnit) is still queued. - Needs
@erikwbsign-off on the updated DMA-fence handling once blocker 1 is closed. - Needs an exact-head hardware row covering the updated commit (plus the working-N1
READYs2idle regression row if not waived).
- Hosted CI at
Checked:
- Audited commit
a4eb6e8a(+49/-1indrivers/net/wireless/apple/centauri/t6050/centauri_pci.c, DCOSigned-off-bypresent on both commits,MERGEABLEonmain):- For
CEN_BOOT_FAILEDafter a ROM-boot timeout (withc->firmware/c->descriptorallocated andPCI_COMMAND_MASTERset),centauri_t6050_free_boot()invokescentauri_t6050_free_irqs()andcentauri_t6050_stop_dma(c->pdev)(pci_clear_master()+pci_wait_for_pending_transaction()) before freeingfirmware/descriptor; ifstop_dma()fails or!c->link_ready && c->boot_attempted, the buffers remain non-NULL andcentauri_t6050_boot_dma_idle()returnsfalse->-EBUSY. - For
c->ipc != NULL,centauri_t6050_free_ipc()runscentauri_t6050_ipc_fenced()across all owned functions before releasingc->ipc; if fencing fails,c->ipcstays non-NULL ->-EBUSY. - For a missing-firmware failure (before
dma_alloc_coherent/pci_set_master),centauri_t6050_boot_dma_idle()returnstrueimmediately without touching hardware.
- For
Evidence
drivers/net/wireless/apple/centauri/t6050/centauri_pci.cL820–L846 (centauri_t6050_quiesce) vs L285–L298 (centauri_t6050_boot_dma_idle) and L1165–L1186 (centauri_t6050_suspend).- Non-blocking nit: reading
c->boot_phaseunderc->boot_lock(or pairingWRITE_ONCEincentauri_t6050_boot_worker()/centauri_t6050_quiesce()withREAD_ONCEincentauri_t6050_suspend()) avoids a plain-write/READ_ONCE data race annotation under KCSAN.
|
Pushed What changed. A failed or stopped startup now only lets the system sleep once no boot DMA can be in flight. Before returning 0, suspend runs the same verified release that teardown uses ( The missing-firmware case (no DMA ever submitted) passes the check at once, so the K114s case this PR is about still sleeps. Row at
Not covered: a real s2idle with a key wake (needs hands at the Mac), and the ROM-timeout branch, which I can't trigger on demand. Build: W=1 clean, checkpatch clean. |
There was a problem hiding this comment.
The new check correctly refuses suspend when a failed ROM transition retains its descriptor. There is still a verification gap when boot_dma_idle first sees PCI_COMMAND_MASTER set but the three checked pointers are NULL. free_boot calls stop_dma, which can clear MASTER and then time out waiting for pending transactions. It returns void, so the second idle check can accept the cleared bit and allow suspend after the drain timed out. Please propagate a failed fence through to -EBUSY when cleanup was needed, or establish a stronger invariant that excludes this path. Add a focused regression for the drain failure. The posted K114s devices-only row exercised READY, so it does not cover this branch. The J714s row or explicit waiver remains a separate merge gate.
…d-start sleep The previous change ran free_boot() and then re-checked the DMA state, but free_boot() returns void. When the boot DMA state was "no buffers left but MASTER still set", free_boot() could clear MASTER and then time out draining transactions; the second check only saw the cleared bit and let the system sleep with transactions possibly outstanding. When cleanup is needed, release the buffers as before and then run an explicit bus-master fence with centauri_t6050_stop_dma(), whose result says whether MASTER is clear and the pending transactions drained. Allow the sleep only if every buffer is gone and that fence succeeded. The decision is a small helper with KUnit coverage (no N1 hardware needed), including the drain-timeout case: ./tools/testing/kunit/kunit.py run --arch=arm64 --make_options LLVM=1 \ --kunitconfig drivers/net/wireless/apple/centauri/t6050 Signed-off-by: Ryan Murray <[email protected]>
|
Pushed
|
There was a problem hiding this comment.
The explicit fence fixes the first suspend attempt. Please carry the failure across retries. When both fence attempts time out with no tracked buffers, stop_dma has already cleared MASTER. A second suspend can then enter the initial boot_dma_idle fast path, see null pointers and MASTER clear, and skip transaction draining. Require a fresh verified drain on a reachable function or retain the unverified-fence state until a retry verifies it. Please cover two consecutive suspend attempts in the test, with the first drain timed out and the pending transaction still present on the second. The current KUnit cases cover the single-attempt decision.
After cleanup, the previous version accepted a sleep only if stop_dma() verified the drain, but it kept a fast path: a state with no buffers and MASTER clear was taken as idle without draining. A timed-out fence leaves exactly that state, since stop_dma() clears MASTER before it waits, so a second suspend attempt could skip the drain and sleep with a transaction still outstanding. Drop the fast path. A failed or stopped startup now releases any boot buffers and then runs a fresh fence on every suspend attempt; the sleep is allowed only if all buffers are gone and that fence drained. A function that reads all ones is off the bus and cannot master. A start that failed before any DMA (missing firmware) drains at once and still sleeps. The KUnit cases use a fake function with the same contract as stop_dma(), covering two consecutive timed-out attempts with the transaction still pending and a later attempt that drains. Signed-off-by: Ryan Murray <[email protected]>
|
Pushed
|
There was a problem hiding this comment.
The retry blocker is resolved. With boot buffers released, each suspend attempt fences a reachable function again under boot_lock, including after a previous attempt cleared MASTER. The posted arm64 QEMU KUnit run covers two attempts that refuse while a transaction is pending and a third that succeeds after it drains. The K114s devices-only receipt covers READY. Keep exact-head hosted checks and the J714s regression row or explicit waiver as merge gates.
|
K114s row at head
|
|
@erikwb your 11-29 blocker (a ROM-timeout or stopped start reaching D3 with boot DMA live) is addressed in |
Thanks erikwb. The failure you showed (a failed or stopped N1 start reaching D3 with boot DMA live) is fixed at head 357bf2b by a4eb6e8, 8b304a4 and 357bf2b: every suspend attempt after a failed start releases the boot buffers and runs a fresh verified fence, and only sleeps once it drains. KUnit covers two consecutive drain timeouts; K114s row at 357bf2b passes. Dismissing this stale review so it can merge; if you still see a gap, please reopen with the case and we'll follow up.
Problem
On a T6050 Mac whose N1 (Wi-Fi/BT) startup has failed, the system can never suspend. The K114s with #3337 enumerates the N1, but its installed firmware has no FTAB, so the startup stops in phase 0 (
required firmware apple/centauri/k114s-ftab.bin unavailable: -2). From then on every s2idle attempt aborts withpci_pm_suspend(): centauri_t6050_suspend [apple_centauri_t6050] returns -16, and closing the lid does nothing.Change
On the s2idle path (no firmware sleep),
centauri_t6050_suspend()refused anything butCEN_BOOT_READY. It now:CEN_BOOT_FAILEDandCEN_BOOT_STOPPED: the boot worker has finished, nothing runs on the N1, and the PCI core saves the config space;Tested: K114s, kernel 7.3.0-42 (linux a851ca0) with the module rebuilt from that source plus this patch, N1 startup failed in phase 0,
pm_test=devices+freeze:centauri_t6050_suspend returns -16, suspend aborted (rc 1);Risk: two-way · T6050 machines with an N1 (J714c/J714s/J716c/J716s/K boards) where the N1 startup failed or was stopped; READY and in-progress behaviour is unchanged.
Still to run