Skip to content

PCI: apple: keep adopted links across s2idle on every adopted host - #2488

Open
satchlj wants to merge 2 commits into
integration/aurorafrom
satchlj/pcie-s2idle-dt-property-20261119
Open

satchlj wants to merge 2 commits into
integration/aurorafrom
satchlj/pcie-s2idle-dt-property-20261119

Conversation

@satchlj

@satchlj satchlj commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Claude Opus 5.5 on @satchlj's behalf.

pcie-apple admitted suspend-to-idle with boot-loader-trained ("adopted") links left running only on a list of board compatibles: J716c, K114c, K116s, J714s. That list records where s2idle was tried, not anything about the hardware. This PR removes it.

apple_pcie_check_adopted_s2idle() is only reached for hosts whose links the boot loader trains (hw->adopt_link, today t6050_hw). On those hosts it now admits s2idle on every board. The existing hardware checks stay as the guard, before the sleep and again after it:

  • the root complex is running and ready;
  • every port's link is up and not busy, with no link-down interrupt pending;
  • every device below a boot-trained port answers in D0.

A host that cannot keep its link still refuses at these checks, or reports the lost link on resume.

Commits:

  1. The first version moved the list into a DT property, apple,s2idle-retain-adopted-links.
  2. On review, the property, its binding and its four board lines are gone again. Against integration/aurora, the PR now changes only pcie-apple.c.

Behaviour change: every other board on a T6050 PCIe host (t6050_hw), J775c among them, now attempts s2idle with its adopted links kept, instead of getting -EBUSY.

Testing

  • Compiled (commit 1): drivers/pci/controller/pcie-apple.o built without warnings on 26294e82 (gcc 16.1.1, arm64). Commit 2 is not yet compiled on its own; lobata's next candidate builds it.
  • J775c, commit 1 with the property (cand-2d, 2026-11-20): past the gate, s2idle was refused 3 of 3 at the D0 check, because the boot-trained SD reader (GL9755) had no driver on that boot (see arm64: dts: apple: t6050-j775c: RTC alarm wake, MTP disabled (stacked on #2102, needs #1743) #2495). The next lobata candidate runs this head with the SD reader driven.
  • Untested on the four previously listed boards with this head.

Assisted-by: LLM (Anthropic:Claude Opus 5.5)

Suspend-to-idle with links the boot loader trained ("adopted") left
running was admitted by a list of board compatibles. Admit it instead on
the host's apple,s2idle-retain-adopted-links property, and set that
property in the device trees of the four boards on the list (J716c,
K114c, K116s, J714s). A board whose s2idle is qualified later then needs
only its own device tree, not a driver change.

Behaviour on those four boards is unchanged; every other board still gets
-EBUSY, as before.

Signed-off-by: Satya Benson <satya@benson.earth>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for moving this out of the compatible list; that is the right direction.

One thing we would still change: we select behaviour by a hardware property, not by the list of machines it was tested on, and apple,s2idle-retain-adopted-links is that list moved into the device tree. The binding text says so ("This board's suspend-to-idle has been qualified..."), and the driver keys on it at pcie-apple.c:6779, with the same four boards in t6050-j714s.dts:87, t6050-j716c.dts:64, t6050-k114c.dts:43, t6050-k116s.dts:73.

The hardware fact here is "this port's link was trained by the boot loader", which the driver already knows per port. Could apple_pcie_check_adopted_s2idle() admit s2idle on every host with adopted links by default, keeping the existing D0/RUN checks as the guard? If a host genuinely cannot keep its adopted link across s2idle, a property describing that hardware reason (and citing it) is fine.

We can run s2idle rows on our M1 Pro, M2, M4 Pro and A18 Pro if you make it the default.

apple,s2idle-retain-adopted-links named the boards where s2idle had been
tried; it did not describe the hardware. What the driver has to know is
whether the boot loader trained the host's links, and hw->adopt_link
already says that: apple_pcie_check_adopted_s2idle() is called only for
such hosts.

Drop the property, its binding and its four board lines, and admit
s2idle on every adopted host. The existing checks remain the guard: the
root complex must run, every port's link must be up and not busy, and
each device below a boot-trained port must answer in D0, before the
sleep and again after it. A host that cannot keep its link still
refuses s2idle there, or reports the lost link on resume.

Signed-off-by: Satya Benson <satya@benson.earth>
@satchlj satchlj changed the title PCI: apple: select adopted-link s2idle by a device-tree property PCI: apple: keep adopted links across s2idle on every adopted host Nov 20, 2026
@satchlj

satchlj commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf: thanks, done in 11fa3dfc1 (a new commit, no force-push).

  • The apple,s2idle-retain-adopted-links property, its binding and the four board lines are removed. Against integration/aurora, the PR now changes only pcie-apple.c.
  • apple_pcie_check_adopted_s2idle() is only reached for hosts with hw->adopt_link, which the driver already knows, so it now admits s2idle on all of them. The RUN/READY, per-port link and D0 checks stay as the guard, before and after the sleep.

I've retitled the PR and updated the description, including the behaviour change: the other T6050 boards now attempt s2idle instead of getting -EBUSY. Your M1 Pro, M2, M4 Pro and A18 Pro rows would be welcome, though none of them has adopt_link in this tree, so they should behave as before. The J775c row on this head comes with lobata's next candidate.

🤖 Generated with Claude Code

satchlj added a commit that referenced this pull request Nov 20, 2026
#2488 no longer adds this property: pcie-apple keeps adopted links
across s2idle on every host whose links the boot loader trains
(hw->adopt_link), so J775c needs no line for it. Without the binding,
the property would also fail dt-validate.

Signed-off-by: Satya Benson <satya@benson.earth>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for 11fa3df. Admitting s2idle on every host with adopted links, with the existing RUN/READY, link and D0 checks as the guard, is the selection we hoped for, and the PR is much smaller for it. As you note, our machines have no adopted links, so the J775c row on this head is the one that matters.

@satchlj

satchlj commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf: J775c (Mac Studio, M5 Max) row on this PR's head, 11fa3dfc12. It gets past this PR's change, then the refusal comes from the existing D0 guard, 6 of 6. That refusal is a J775c problem still under investigation, not this PR's.

Kernel: lobata's cand-4, 7400d465c320 = integration/aurora e0ee46a1 + 80 commits (0 behind at 06:27Z), booted 2026-11-20 05:57Z. It includes this head, #1743 and #2495. The J775c DT has no apple,s2idle-retain-adopted-links. The SD reader (GL9755, below the boot-trained port 00:01.0) is bound to sdhci-pci.

Method: rtcwake -d rtc0 -m freeze -s 20 (RTC alarm wake, no hands). Thunderbolt was settled, with 60 s between cycles. Before each cycle, every PCI device's power state and runtime status was recorded.

Cycles Setup Before the cycle Result
1-3 as booted every PCI device in D0, runtime active (root ports bound to pcieport, control=auto) refused 3/3
4-6 runtime PM forbidden on every PCI device (power/control=on) every device D0 / active refused 3/3

The kernel log, the same in every cycle:

pcieport 0000:00:01.0: adopted link requires accessible D0 devices for s2idle
pcie-apple 1cb0000000.pcie: PM: dpm_run_callback(): apple_pcie_suspend_noirq returns -16

What this shows:

  • The board list is gone, and J775c reaches the hw->adopt_link path with no DT line, as intended. With the old list it was refused earlier, with -EBUSY before the D0 walk.
  • The D0 walk refuses J775c. It is not runtime PM: everything is in D0 beforehand, and forbidding runtime PM changes nothing.
  • An untested possibility: the system-suspend noirq step of the bound root ports and the SD controller puts them in D3hot before the host's noirq check. On lobata's default kernel the root ports have no driver (PCIEPORTBUS=n). I'll trace it, with per-device power_state inside the check, before proposing anything. Any change would go in the D0 rule, not in a board property.

The RTC alarm wake (#1743 + #2495) could not be tested by a real freeze, because none happened.

🤖 Generated with Claude Code

@satchlj

satchlj commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf: cause of the J775c refusal, from a diagnostic print in the D0 check (local, not part of this PR).

Kernel: lobata's cand-5, d2f8af83bf98 = integration/aurora 09c7ad0eb4d6 + 82 commits, including this PR's head. Booted 2026-11-20 09:05Z.

Six rtcwake -m freeze cycles: 3 as booted, then 3 with runtime PM forbidden on every PCI device. Each refused with the same line, verbatim:

pcieport 0000:00:01.0: adopted link requires accessible D0 devices for s2idle (DIAG: vendor 0x106b, PMCSR 0x000b, current_state D3, below a boot-trained port)

What it shows:

  • The device the check refuses is the boot-trained root port 00:01.0 itself.
  • It's in D3hot at the host's noirq check: PMCSR power-state bits 0b11, plus No_Soft_Reset; current_state D3.
  • Runtime PM was off in cycles 4–6, so it's the PCI core's system-suspend path that puts the port in D3hot.
    • A pm_print_times trace on the previous candidate shows the order: sdhci-pci 0000:02:00.0 (below the port) and pcieport 0000:00:01.0 take ~12 ms each in pci_pm_suspend_noirq, then apple_pcie_suspend_noirq runs and refuses.
    • The walk stops at the first refusal, so the SD controller's own state wasn't printed.
  • On lobata's default kernel, PCIEPORTBUS=n, so the root ports have no driver and stay in D0. There, s2idle passes.

Fix to test next (a new commit here, selected the way this PR already is): keep the devices on an adopted link, from the root port down, out of D3, so that the existing D0 check holds what it requires (for example PCI_DEV_FLAGS_NO_D3 on the adopted ports' subtrees). It is keyed on the link being adopted, not on a board. It also costs the runtime D3 of those devices, which is the same as on the default today. I'll post a J775c row with idle power before proposing it.

🤖 Generated with Claude Code

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for the two J775c runs and the diagnostic print. They show the PR's own change working: J775c reaches the hw->adopt_link path with no DT line, and the refusal comes from the existing D0 guard, because the boot-trained root port 00:01.0 is already in D3hot at the host's noirq check. We agree the fix belongs in that D0 rule, keyed on the port's state rather than on the board, and is better as its own change. We'll count a completed RTC-woken freeze on J775c as the remaining row for this PR.

@satchlj

satchlj commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf: agreed. This PR's code stays as it is.

The D0-rule fix will be a separate PR against integration/aurora. It will keep a boot-trained root port on an adopted link, and the devices below it, in D0 through system suspend. It is selected by the port's adopted-link state, not by a board or a command-line option.

The remaining J775c row will run on this PR's head plus that PR: a completed rtcwake -m freeze cycle woken by the RTC. I'll name the kernel (hash, base and distance behind the tip) and record idle power in the row, and link the new PR here when it opens.

🤖 Generated with Claude Code

@satchlj

satchlj commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf: the D0 fix is now its own draft PR, #2557. It's based on integration/aurora f44bf7af65ea, and this PR's code is unchanged.

The first run on this head plus #2557 doesn't count as the row yet. That was cand-7, 324280cadc47 = d91db387c720 + 85. The RTC wake path was in place: rtc0 had wakeup enabled, and its alarm IRQ is routed through apple_spmi. The freeze then didn't resume, and the console stopped at Filesystems sync, so where it stopped isn't known. I'll post the next run here, with the console kept awake and the wake IRQ logged.

🤖 Generated with Claude Code

@satchlj

satchlj commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf: progress on this PR's last row. On cand-8 (7b5df9391f5f = c92ed8517b79 + 84: this head plus #2557), pm_test=platform gets past the host's noirq check: apple_pcie_suspend_noirq returned 0. Resume then hangs in the noirq phase, with an RCU stall on CPU 7. Details and next steps are on #2557: #2557 (comment)

A completed RTC-woken freeze on J775c still waits on that resume hang, so this PR's row stays open.

🤖 Generated with Claude Code

@satchlj

satchlj commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf: J775c row: completed RTC-woken freezes on this PR's head, 3/3. This is the row you said this PR still needed.

Kernel: lobata's cand-10, 6ebd4f505fd5 = integration/aurora df62a8c4d38d + 84. Besides this head it includes two more changes, both needed on J775c:

The J775c DT is #2102's board file plus #2592's change. Entered by an ordinary reboot as a one-shot, 2026-11-20 17:45Z.

Method: rtcwake -d rtc0 -m freeze -s 30 ×3, with 60 s between cycles and async resume. /sys/power/pm_wakeup_irq was logged after each cycle.

Cycle Asleep rc pm_wakeup_irq RTC IRQ count
1 17:46:17–17:46:49Z 0 151 (macsmc-rtc) 0 → 1
2 17:49:22–17:49:54Z 0 151 1 → 2
3 17:50:54–17:51:26Z 0 151 2 → 3
  • No adopted link requires accessible D0 devices line all boot, and apple_pcie_suspend_noirq returns 0.
  • Each wake is the RTC alarm itself (pm_wakeup_irq = 151), not another source.
  • Wake-on-LAN was armed as a fallback and wasn't needed.

Not covered: idle power during sleep, and a USB-C/Thunderbolt device in use across the cycle.

🤖 Generated with Claude Code

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks, 3/3 completed RTC-woken freezes on J775c with the wake IRQ logged is the row this PR needed. The other two changes in that kernel are tracked in their own PRs: #2557 for the D0 rule, keyed on the port's state, and #2592 for the ATC USB domains, documented in the SoC tree.

From our side this PR is done. It should land together with #2557 and #2592, since J775c s2idle needs all three.

@satchlj

satchlj commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf: trailer-only rewrite, removed Co-Authored-By from 2 commit(s); same trees, Signed-off-by kept (11fa3df -> 7012343, --force-with-lease).

@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.

Pre-PR checklist review of 70123439e95fe207beb96dac2ea59eb1990990d9 (§1–§6): 0 code/policy/attribution/naming/CI blockers; holding on §5 hardware evidence recorded on this PR.

Checklist Summary

  • §1 No model gating — PASS: Removes the 4-board compatible allowlist (apple,j716c, apple,k114c, apple,k116s, apple,j714s) from apple_pcie_check_adopted_s2idle() (drivers/pci/controller/pcie-apple.c:6765-6795). Selection is now strictly on hw->adopt_link (currently t6050_hw) plus live hardware checks.
  • §2 Production-ready, no hacks — PASS: No new cmdline/module parameters, delays, or lab-only paths.
  • §3 Safety — PASS: Keeps all pre-sleep (apple_pcie_suspend_noirq(), :6840-6858) and post-sleep (apple_pcie_resume_noirq(), :7354-7387) hardware guards: root-complex CORE_RC_CTL_RUN/CORE_RC_STAT_READY, per-port PORT_STATUS_READY / PORT_LINKSTS_UP / !PORT_LINKSTS_BUSY / !PORT_INT_LINK_DOWN, and apple_pcie_check_d0() vendor-ID + PMCSR D0 verification, with port->link_failed = true if a retained link drops during s2idle.
  • §4 Clean-room & attribution — PASS: Both commits (845424c7fb10, 70123439e95f) have human author/committer (Satya Benson <satya@benson.earth>) and a single human Signed-off-by: with no Co-Authored-By: or AI trailers. PR body carries Assisted-by:.
  • §5 Evidence — HOLD (incomplete on this PR):
    1. The last row recorded on #2488 (cand-10 on 11fa3dfc12, tree-identical pre-rewrite) was combined with the now-closed #2592 and omitted the §5 regression counts (SELinux denials, failed units, new kernel errors).
    2. The newer default-cmdline J775c row (5a2b7d50 on cacf35543b4d + #2488 + #2557 + #2664, 3/3 rtcwake -m freeze -s 10, 0 SELinux denials, 0 failed units) was posted on #2664 rather than recorded here and does not explicitly confirm 0 new kernel errors. Please copy/link that row here with the full regression triple.
    3. None of the four previously allowlisted adopt_link MacBook Pro boards (J714s, J716c, K114c, K116s) have a regression row on this head (as noted in the PR body). Asking for at least one MacBook Pro T6050 row before approval/merge.
  • §6 Naming — PASS.
  • CI — PASS: host-tests and kunit both green on 70123439e95f.

Non-blocking notes

  • Landing order: Keep coordinated with #2557 and #2664, since J775c s2idle hangs on real freeze without #2664 once it gets past apple_pcie_check_adopted_s2idle().
  • History / PR body hygiene: Commit 1 (845424c7fb10) introduces apple,s2idle-retain-adopted-links and four DTS edits that commit 2 (70123439e95f) completely removes; squashing into a single commit keeps bisect history clean. The PR body's ## Testing section is also stale (still says commit 2 is uncompiled and J775c refused 3/3 on cand-2d).

Assisted-by: LLM (Gemini 4 Neon)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants