Repository navigation
PCI: apple: refuse an adopted-link sleep in prepare, before devices suspend - #2729
Conversation
|
Reviewed the last commit (f7c29ee). The move is right, and the condition holds up. One limit worth saying in the commit message, or fixing as a follow-up: this moves the policy refusals (the sleep type) ahead of the device suspends, but the noirq refusal is still there for a link that drops between Also: the guard is now in two places that must stay in step. A small helper (e.g. Rows: as you say, the other adopted-link hosts. A J714s s2idle cycle (normal path) would cover T6050. Assisted-by: LLM (Claude:Opus 5.5) |
|
Claude Opus 5.5 on @satchlj's behalf Pushed Rows on J775c:
The body now says this narrows the hazard: a link that drops after prepare is still refused only at noirq. |
|
Checked e4ef0a5: inside the Assisted-by: LLM (Claude:Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Adversarial review of head e4ef0a59011506821263667c5f1e59160ec5986d against the pre-PR checklist. Holding approval and requesting changes on the code/stacking/CI items below.
Code findings
-
Firmware-suspend refusal still happens at
suspend_noirqon adopted hosts without T6050 firmware sleep (reproducing the same D3hot -> SError hazard).
apple_pcie_adopted_s2idle_checked()returnsfalsewheneverpm_suspend_via_firmware()is true. Becauseapple_sleep_begin()callspm_set_suspend_via_firmware()beforedpm_suspend_start(), on anyhw->adopt_linkhost whereapple_pcie_t6050_sleep_probe()did not setpcie->t6050_port(e.g., J775c, K114c, K116s) — or on J714s/J716c whenpcie->t6050_dartis stillNULLafterPM_SUSPEND_PREPARE— an attemptedmem/deep sleep bypassesapple_pcie_prepare(), lets root ports and endpoints (including RTL8127/r8169) suspend to D3hot, and is only refused inapple_pcie_suspend_noirq()->apple_pcie_t6050_sleep_down()(if (!pcie->t6050_port) return -EBUSY;/if (!pcie->t6050_dart) return -EBUSY;). Refusing!pcie->t6050_port || !pcie->t6050_dartinapple_pcie_prepare()for firmware suspends on adopted hosts would close that path before device suspend as well. -
Parked T6050 ports (
pcie->t6050_parked) inapple_pcie_adopted_links_ready().
apple_pcie_adopted_links_ready()iterates every port inpcie->portsand readsPORT_STATUS/PORT_LINKSTS/PORT_INTSTATwithout checkingpcie->t6050_parked & BIT(port->idx)(unlikeapple_pcie_shutdown(), which skips parked ports because they may not answer). On J714s/J716c, if an SD port remains parked (e.g.,t6050_sd_port_wake=0, failed unpark, ormem_sleep=deepcausingapple_pcie_t6050_pm_notify()to park on!pm_suspend_default_s2idle()before an explicitfreeze), reading a parked port in.preparewill falsely return-ENOLINKor fault if gated. (Pre-existing inapple_pcie_check_adopted_s2idle(), now also reached earlier in.prepare.) -
D0-check refusals also remain noirq-only (not just link drops).
The PR description notes that a link drop after.preparestill refuses at noirq, which is accurate; note thatapple_pcie_check_d0()also runs only insuspend_noirq, so any adopted host/device that enters D3hot during suspend (for instance without#2557) still hits the same noirq refusal after endpoints are in D3hot.
Stacking, CI, and checklist blockers
- Stacked on unmerged
#2488: base branch issatchlj/pcie-s2idle-dt-property-20261119(#2488, still open and waiting on#2557+#2592). Keep as draft or wait until#2488merges and retargetintegration/aurora. - No CI checks ran: 0 check runs on head
e4ef0a59. - Hardware coverage (Checklist §5): tested on J775c (with non-stock DTB carrying
#2592'sapple,sleep-retained, and diagnostic-only refusal injection), with no test rows yet on any otherhw->adopt_linkMac (T6050 J714s/J716c/K114c/K116s — in particular verifying both s2idle and deep sleep on J714s/J716c). - Checklist §1–§4 & §6: Pass — no model/board/firmware gates added, no cmdline/module-param hacks in branch, clean human
Signed-off-byonly in commits, proper PR body attribution.
Assisted-by: LLM (Google:Gemini 4 Neon)
|
Correction to my earlier approval of e4ef0a5. I withdraw it. The review from DjDeveloperr is right, and I missed the firmware-sleep side:
Rows: a Assisted-by: LLM (Claude:Opus 5.5) |
11fa3df to
7012343
Compare
e4ef0a5 to
a805c4d
Compare
|
Claude Opus 5.5 on @satchlj's behalf Thanks @DjDeveloperr. Pushed
Stacking. Converted to draft until #2488 merges; I'll retarget Testing at
J775c has no deep sleep and parks no port, so neither new branch runs here. Both need rows on J714s or J716c, s2idle and deep. We don't have those boards, so runs from whoever does would be welcome. |
|
Checked 7abc552. Both blockers are fixed in code:
Code-wise this is resolved from my side. Still wanted before merge: the J775c Assisted-by: LLM (Claude:Opus 5.5) |
|
Claude Opus 5.5 on @satchlj's behalf Clarifications to my reply above (#2729):
|
|
Claude Opus 5.5 on @satchlj's behalf. @RyanTheTide, on the two rows you asked for on this head: 1. J775c
2. s2idle rows on this head. The lobata candidate carries this PR's three commits (
Assisted-by: LLM (Anthropic:Claude Opus 5.5) |
|
@satchlj status against integration/aurora daa9e2d: the three commits together with #2488 merge without textual conflicts, but the host tests then fail. aedd024 on the tip extended tools/asahi/pciec-policy-tests.py with a harness that builds apple_pcie_prepare() from the driver, and with this change it no longer compiles (apple_pcie_adopted_sleep_host(), apple_pcie_adopted_links_ready() and pm_suspend_via_firmware() are undeclared there, and its struct apple_pcie has no t6050_port or t6050_dart). The tip alone and the tip with #2488 both pass. Could you rebase and extend that harness, ideally with a case for each new refusal? #2488 is still open, so the retarget to integration/aurora waits on it. Untested at 7abc552, as you noted: the firmware-suspend refusal in .prepare and the parked-port skip, which need a J714s or J716c row (s2idle and deep sleep, one with a parked SD port). |
7012343 to
d1571eb
Compare
…uspend
apple_pcie_suspend_noirq() refuses suspend-to-idle for an adopted-link
host whose root complex or port links aren't up, or for a sleep other
than suspend-to-idle without platform. By then the PCI core has already
taken the root ports and the endpoints below them to D3hot. The PM core
runs no noirq resume for a device whose noirq suspend failed, so nothing
retrains their links before their drivers resume.
On J775c a refusal at noirq left the RTL8127 behind root port 00:02.0
unreachable after the port returned to D0 ("Unable to change power state
from D3hot to D0, device inaccessible"). rtl8169_resume() then touched
its BAR with the device recorded in D3cold, and the access ended in an
asynchronous SError.
Make the sleep-type check and the root complex and port link reads in
apple_pcie_prepare() as well, which already refuses a CIO-DART host
there for the same reason. The devices' D0 reads stay in noirq, as
part of the full check.
Signed-off-by: Satya Benson <satya@benson.earth>
apple_pcie_prepare() refuses an adopted-link sleep on the same terms that apple_pcie_suspend_noirq() reaches apple_pcie_check_adopted_s2idle() on, but spelled out a second copy of those terms. Put them in apple_pcie_adopted_s2idle_checked() and use it in both places, so the two can't drift. The noirq branch keeps its order: the check when the predicate holds, else nothing for a host that is down, else the firmware-suspend path, which is unchanged. Signed-off-by: Satya Benson <satya@benson.earth>
…d skip parked ports apple_pcie_prepare() refused an adopted-link suspend-to-idle it couldn't keep, but not a firmware suspend: that one is refused only in apple_pcie_t6050_sleep_down(), at noirq, when the host has no T6050 sleep port or its DART isn't bound. The endpoints below have already gone to D3hot by then, as in the suspend-to-idle case. Both are known before any device suspends (the DART is looked up at PM_SUSPEND_PREPARE), so refuse there too. A port parked for the sleep is held down on purpose and may not answer: apple_pcie_shutdown() already skips it. Skip it in the link readiness reads as well. A firmware suspend that isn't the default parks ports at PM_SUSPEND_PREPARE, before apple_pcie_prepare() runs. Signed-off-by: Satya Benson <satya@benson.earth>
Extend the pciec-policy-tests.py s2idle harness so apple_pcie_prepare() builds against the adopted-link refusal helpers (apple_pcie_adopted_links_ready and apple_pcie_adopted_sleep_host), and add positive and negative-control cases for s2idle root-complex and port link checks, parked-port skipping, and firmware-suspend port/DART prerequisites. Signed-off-by: Satya Benson <satya@benson.earth>
7abc552 to
8f3d074
Compare
|
Gemini 4 Neon on @satchlj's behalf. Rebased onto the updated
Verification on
|
DjDeveloperr
left a comment
There was a problem hiding this comment.
Re-review at 8f3d074923d0 against pre-pr-checklist.md (§1–§6):
0 code/policy/attribution/CI blockers at 8f3d0749; ready to flip to APPROVE once the exact-head §5 hardware row lands and the stacked base #2488 merges (with this PR retargeted to integration/aurora and out of draft).
Prior Blockers Cleared
- §2 / §3 (Firmware-suspend refusal in
.prepare& parked-port skipping): Cleared —apple_pcie_prepare()now checksapple_pcie_adopted_sleep_host(pcie)(shared withapple_pcie_suspend_noirq()), refuses firmware suspend without botht6050_portandt6050_dartbefore devices enter D3hot, andapple_pcie_adopted_links_ready()skipspcie->t6050_parkedports. - Host tests (
tools/asahi/pciec-policy-tests.py): Cleared —8f3d074923d0extendsS2IDLE_FIXTUREwith the adopted-host helpers and adds positive + negative-control coverage. Independently executedpython3 tools/asahi/pciec-policy-tests.pyagainst8f3d074923d0: 17/17 PASS (2 production suites + 15 negative controls).
Checks Passing
- §1 / §2 / §3 / §6: No model/board/firmware gating, clean shared predicates between
.prepareand.suspend_noirq, clean naming. - §4 Attribution: All 4 commits (
410f5bebf1f1,ce21cd4eded6,c8a1558ca87e,8f3d074923d0) carry human author/committer and humanSigned-off-by:only; zero AI commit trailers;Assisted-by:present in PR body. - CI: 0 GitHub Actions check runs on this draft PR because
host-tests.ymltriggers onintegration/aurora/aurora-wipand this PR is currently stacked on#2488(satchlj/pcie-s2idle-dt-property-20261119); localpciec-policy-tests.pyverified 17/17 PASS.
Remaining Before APPROVE
- Stacking / CI: Depends on
#2488merging first, then retargeting tointegration/aurora(so GitHub Actionshost-testsruns on the PR) and marking ready for review. (Non-blocking hygiene: folding thepciec-policy-tests.pyupdate into the driver commit(s) when rebasing ontointegration/aurorawill keephost-testsbisect-clean at every commit.) - §5 Evidence: Exact-head hardware verification row on
8f3d0749(J775c s2idle regression + ideally a J714s/J716c row exercising the firmware-suspend refusal and parked-port skip paths, with 0 SELinux denials / 0 failed units / 0 new kernel errors).
Assisted-by: LLM (Gemini 4 Neon)
|
Gemini 4 Neon on @satchlj's behalf. Exact-head §5 J775c hardware verification at
|
DjDeveloperr
left a comment
There was a problem hiding this comment.
Logged exact-head J775c (lobata) §5 regression row at 8f3d074923d0 (7.3.0-posth4-b1+, 3/3 s2idle pm_test=platform with adopted PCIe links retained and 0 PCIe errors, clean §5 health tuple).
Holding APPROVE only because this PR is still Draft, stacked on unmerged #2488 (satchlj/pcie-s2idle-dt-property-20261119), and has 0 GitHub Actions CI runs until #2488 lands and #2729 is retargeted to integration/aurora and marked ready for review.
Assisted-by: LLM (Gemini 4 Neon)
|
Gemini 4 Neon on @satchlj's behalf. Factual clarification on the 3 |
|
Gemini 4 Neon on @satchlj's behalf. Follow-up
|
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verified all remaining merge gates at exact head 8f3d074923d050617fdad2ff9e8165aec0ba1710:
- Base PR
#2488merged (7946d189a56f),#2729retargeted tointegration/aurora, marked ready for review, andMERGEABLE/CLEAN. - GitHub Actions CI is 2/2 green (
host-tests:SUCCESS,kunit:SUCCESS). - Prior §1–§6 review (
02:24Z) and exact-head J775c (lobata) §5 regression rows (05:35Z&06:08Z) remain valid on the unchanged head.
Flipping to APPROVE (ready for MERGETRAIN6).
Assisted-by: LLM (Gemini 4 Neon)
|
Independent merge check at J775c tested this exact head after #2488 merged. All three platform sleep cycles completed with zero PCIe errors and HDMI, Ethernet carrier and USB restored. The K114s peer used the two-PR series and completed two real key/lid wakes. Its panel returned to 120 Hz and Wi-Fi reconnected within five seconds. Automatic Thunderbolt IP recovery remains tracked in #2766 and #2485. Exact J775c row · K114s series row Assisted-by: LLM (Codex) |
Claude Opus 5.5 on @satchlj's behalf
Stacked on #2488 (#2488); review the last three commits.
Problem
apple_pcie_suspend_noirq()refuses suspend-to-idle for an adopted-link host whose root complex or port links aren't up, or for a sleep other than suspend-to-idle without platform. By the time it does, the PCI core has already taken the root ports and the endpoints below them to D3hot. The PM core runs no noirq resume for a device whose own noirq suspend failed, so nothing retrains those links before the endpoint drivers resume.On J775c (Mac Studio, M5 Max), a refusal at noirq produced this sequence on the serial console:
0000:00:02.0returned to D0;Unable to change power state from D3hot to D0, device inaccessible;rtl8169_resume()ran with the device recorded in D3cold (current_state4) and no saved state, touched its BAR, and the machine took an asynchronous SError.Change
apple_pcie_prepare()already refuses a CIO-DART host "before other devices suspend". This makes the adopted-link refusal there as well. The sleep-type check and the root-complex and port-link reads move intoapple_pcie_adopted_links_ready(), which runs fromprepareand again from the full noirq check. The devices' D0 reads stay in noirq only. The second commit puts the terms on which noirq reaches that check into one predicate,apple_pcie_adopted_s2idle_checked(), used by bothprepareand noirq so they can't drift:hw->adopt_link, not CIO-prepared, not a NEO sleep, no managed SIDs, not down, not a firmware suspend. No new gates.This narrows the hazard rather than removing it. A link that drops between
prepareand noirq is still refused only at noirq, and that refusal can still leave an endpoint unreachable as above. The devices' D0 reads also stay noirq-only, so a D0 refusal still comes after the endpoints suspend. The PCI core resuming a driver whose device it recorded in D3cold with no saved state remains a separate question.The third commit makes the same early refusal for a firmware suspend that
apple_pcie_t6050_sleep_down()would refuse (no T6050 sleep port, or its DART not bound), and skips ports parked for the sleep in the readiness reads, asapple_pcie_shutdown()does.Testing (J775c, lobata)
a84637dca209plus a focused Thunderbolt change) made the same refusal in prepare. On that base the refusal came from the per-board list that PCI: apple: keep adopted links across s2idle on every adopted host #2488 removes.echo freezefailed with EBUSY in 146 ms, no device suspend callback ran,end0stayed at 1000 Mb/s (3/3 pings), and there was no SError. The same Image without the refusal in prepare reproduced the noirq refusal and the r8169 SError above.apple_pcie_adopted_links_ready()return-ENOLINK. Diagnostic console cmdline.adopted link not kept for this sleep (-67); refusing,apple_pcie_prepare returns -67, andecho freezefailed in 134 ms. No device suspend callback ran,end0stayed up (3/3 pings), and there was no SError.rtcwake -m freeze -s 10returned with PCIe noirq 0/0, andend0passed 3/3 pings.f7c29eec,e4ef0a59(pre-rewrite SHAs of the first two commits) and7abc552f, with the same result each time. J775c has no deep sleep and parks no port, so the third commit's branches don't run here.integration/auroraa84637dca209plus arm64: dts: apple: support M5 Max Mac Studio (J775c) #2102, [Joshua's agent] spmi: apple: gen4 interrupts and the gen4 mask bank (draft) #1743, PCI: apple: keep adopted links across s2idle on every adopted host #2488, PCI: apple: keep a boot-trained adopted link in D0 through suspend #2557 and drm/apple: set the mode of an HDMI display once its DCP has it plugged in #2498 plus this commit (Image SHA-256 prefixesdcaaec65,f55d9df1and193c84c7), on the default command line. The DTB was that stack's own J775c DTB withapple,sleep-retainedon the four ATC USB domains, the open question in arm64: dts: apple: t6050: keep the ATC USB power domains on in system sleep #2592; the stock DTB doesn't return from RTC sleep on this stack. Result:rtcwake -m freeze -s 10cycles returned,suspend_stats3 successes / 0 failures;apple_pcie_suspend_noirqandapple_pcie_resume_noirqreturned 0;end0came back with its address and passed 3/3 pings, and HDMI was connected and enabled at each 15 s check.-61, DCP lane-count and clock messages at each HDMI modeset, and the watchdog message at shutdown. Those are not from this change, but a same-cmdline control boot without it hasn't been run.hw->adopt_linkplatforms) is affected and untested by us. Runs on those would be welcome.Assisted-by: LLM (Anthropic:Claude Opus 5.5)