Skip to content

soc: apple: sleep: clock back the PCIe ports no host restores after a wake - #1966

Merged
RyanTheTide merged 1 commit into
aurora-silicon:integration/aurorafrom
IronsideXXVI:j604-sleep-port-clocks
Nov 21, 2026
Merged

RyanTheTide merged 1 commit into
aurora-silicon:integration/aurorafrom
IronsideXXVI:j604-sleep-port-clocks

Conversation

@IronsideXXVI

@IronsideXXVI IronsideXXVI commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

A real sleep takes the APCIe block's power, and the commit path stops port 0 first: its application clock and its PHY glue clocks go off. On the wake apple_sleep_raise_apcie() brings the shared block back as the loader set it up at boot, but not the ports. Where the managed radio contract is in force the radio's host restores its port before the DART, and where a host calls apple_dart_set_host_resumes() the DART waits for it. A host with neither leaves the ports unclocked, and the DART in each port's unit, clocked by the port, aborts the first register read its resume makes even though its power state reads on.

When the PCIe node has no apple,managed-sids, this gives each port it names (port0/phy0, port2/phy2) its application clock and PHY glue clocks back in the loader's order, right after the shared block. PERST# and the link stay as the wake left them; the host still owns retraining. If a PHY glue clock doesn't ack, the sequence stops before the reset release and the PHY enables, and the wake's report names the port. There is no parameter.

Measured on the J604 (MacBook Pro 14" M4, T8132): on our 1.922 this commit and the first commit of #1962 together took the J604 from dying in resume to its first full deep sleep and wake (back alive on the same boot, Wi-Fi, Bluetooth, audio, NVMe and display back; the panel lighting again at a key press on the lock screen after a sleep that began with it blanked is not proven yet). In that kernel the host relink did not yet clear the reference-buffer bit, so this commit is what cleared it before the ports got their reference clock. On our 1.923, with both of #1962's commits, the J604 slept three times in a row on one boot, the last for 10 minutes, with no reset (2026-11-15).

Open item (updated 2026-11-15): on our 1.922, about 7 minutes after the first full wake, the resumed system cold-reset while our tooling reloaded a module; the same steps on a boot that had not slept did not. The earlier guess that the wake leaves kernel text write-protected is ruled out (kernel text writes after a wake returned on 1.922 and on 1.923). On our 1.923 the same steps, replayed one at a time on a resumed boot, did not reset it; one clean replay does not prove it gone, so we will call it gone after three (details on #1961).

Where this goes: as asked, the port handling moves into the host on #1962, and this PR stays open until #1962 has it. It acts only on a T8132 host without apple,managed-sids; every T8132 board in Aurora's tree inherits that property from t8132-jxxx.dtsi, so on that tree it is inert and follows what is decided on #1962. Every wake we measured ran with both this and the host relink in, so we have no measured wake showing the DARTs need their port clocks before the host's noirq resume, and this does not claim it.

Checked on top of integration/aurora 5b596e6: checkpatch --strict 0 errors, 0 warnings, 0 checks; drivers/soc/apple/sleep.o builds with W=1, no warnings.

Tested on the J604 only: our linux-aurora-next 1.922 and linux-aurora 1.923 carry it with the parameter (on by default). This version drops the parameter and checks the clock acks. It has not run on the J604, and on the current tree it can't: every T8132 board inherits apple,managed-sids, so the new code isn't reached.

Assisted-by: LLM (Claude:Opus 5.5, Claude:Fable 5.2)

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

Thanks. Two things.

  1. apcie_port_clocks is a module parameter that picks between the old and the new wake behaviour, and we don't merge those any more. Where the behaviour applies, it should simply be on.
  2. To your question: keep the port handling in the host (#1962's second commit) and drop this one. The exception is a measured wake showing that the DARTs need their port clocks before the host's noirq resume runs; in that case, say so in the commit message and keep only that part. Two places re-clocking the same ports after a wake, in different orders, are harder to reason about than one.

It's also worth saying in the description that this is inert on our tree today. It acts only on a T8132 host without apple,managed-sids, and every T8132 board inherits that property from t8132-jxxx.dtsi. So it follows whatever is decided on #1962.

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Pushed 20b8779: apcie_port_clocks is gone, and the commit message and description say this is inert on Aurora's tree. Agreed on one place for it: the port handling moves into the host on #1962, and this stays open until #1962 has it. Every wake we measured had both in, so nothing we have shows the DARTs need their port clocks before the host's noirq resume.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Blockers: 2.

  1. drivers/soc/apple/sleep.c:3862 and :3864: the CLK0ACK/CLK1ACK polls in sleep_apcie_port_clock() ignore their result, and the function goes on to clear APCIE_PHY_CTRL_RESET and set PHY_EN0/EN1 on a PHY whose clocks never acked. The shared block's raise path checks the same polls and returns (sleep.c:4128-4135). Return an error here too, stop before the reset release, and log which port failed. Otherwise the DART resume this is meant to protect still faults, with no trace of why.
  2. The commit carries an Assisted-by: LLM trailer. Commits should carry only the human Signed-off-by; put Assisted-by: LLM (<Vendor>:<Model>) as the last line of the PR body instead (it is missing there).

The description says this "clears the PHY glue's reference-buffer-off bit that the commit set", but sleep_apcie_port_clock() (sleep.c:3853-3868) never touches a reference-buffer bit. Either add the write or drop the claim. The commit message already doesn't make it.

HW row: none can prove this on the current tree. Every T8132 board inherits apple,managed-sids (t8132-jxxx.dtsi:444, :450), so apcie_ports_unowned is false and the new code never runs.

Assisted-by: LLM (Claude:Opus 5.5)

… wake

A real sleep takes the APCIe block's power, and the commit path stops
port 0 first: its application clock and its PHY glue clocks go off.
On the wake apple_sleep_raise_apcie() brings the shared block back as
the loader set it up at boot, but not the ports. Where the managed
radio contract is in force the radio's host restores its port before
the DART, and where a host calls apple_dart_set_host_resumes() the DART
waits for it. A host with neither, as on the J604 with its radio port
and SD card port, leaves the ports unclocked, and the DART in each
port's unit, clocked by the port, aborts the first register read its
resume makes even though its power state reads on.

When PCIe's node has no apple,managed-sids, give each port it names
(port0/phy0, port2/phy2) its application clock and PHY glue clocks back
in the loader's order, right after the shared block. PERST# and the
link stay as the wake left them; the host still owns retraining.

If a PHY glue clock doesn't ack, stop there, before the reset release
and the PHY enables, as the shared block's raise path does for its own
clocks. The wake's report names the port.

This acts only on a T8132 host without apple,managed-sids. Every T8132
board in the tree inherits that property from t8132-jxxx.dtsi, so it is
inert there.

Signed-off-by: Dylan Ironside <[email protected]>
@IronsideXXVI
IronsideXXVI force-pushed the j604-sleep-port-clocks branch from 20b8779 to f8a3c10 Compare November 21, 2026 12:01
@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Both fixed at f8a3c10.

  1. sleep_apcie_port_clock() now returns the poll result. A CLK0ACK or CLK1ACK timeout stops it before the reset release and the PHY enables, and the wake's report prints which port it was ("PCIe port 0's PHY clocks did not ack after the wake" / port 2), next to the shared block's line. The result is stored at the wake and printed in the report, the same way pcie_ans_on_ret is.
  2. The trailer is gone from the commit, and the description now ends with the Assisted-by line. I've left the vendor/model part off for now and will come back on that separately.

I dropped the reference-buffer sentence from the description: this code doesn't write that bit.

Agreed on the HW row: nothing on the current tree reaches this code, so I have no row to offer. Rechecked on 5b596e6: checkpatch --strict 0 errors, 0 warnings, 0 checks; sleep.o builds with W=1 (clang 18) with no warnings.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-review of f8a3c10: No blockers.

Points from the last review:

  1. Resolved. sleep_apcie_port_clock() returns the CLK0ACK/CLK1ACK poll result and stops before the reset release and the PHY enables (drivers/soc/apple/sleep.c:3855-3876). t8132_wake() clears and stores the result for each port every wake (sleep.c:5832-5839), and apple_sleep_report() names the failing port (sleep.c:6874-6879).
  2. Resolved for the commit: it now carries only the human Signed-off-by. The PR body ends with Assisted-by: LLM but has no (<Vendor>:<Model>) part yet.
  3. Resolved. The reference-buffer claim is gone from the description.

Nothing else changed since the last review. The code is still unreachable on the current tree (every T8132 board inherits apple,managed-sids, sleep.c:7244), so the HW row from the last review still applies: none is possible here.

Assisted-by: LLM (Claude:Opus 5.5)

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

The description now ends with the full line, vendor and model included. Agreed on the HW row: none is possible while every T8132 board inherits apple,managed-sids.

@RyanTheTide
RyanTheTide merged commit 4c9f147 into aurora-silicon:integration/aurora Nov 21, 2026
7 checks passed
IronsideXXVI added a commit to IronsideXXVI/linux that referenced this pull request Nov 22, 2026
integration/aurora now carries aurora-silicon#1966, which maps port 2 and its PHY on
every host and gives their clocks back after a wake on hosts without the
managed radio contract (apcie_ports_unowned). This branch maps port 2 only
when the host has an available pci@2,0, so that the stop at the commit
never touches port 2 on a host that doesn't use it.

Conflict in drivers/soc/apple/sleep.c, in the struct and in
apple_sleep_map_apcie(). Keep both: port 2 is mapped on every host as
integration/aurora does, so the clock restore from aurora-silicon#1966 is unchanged, and
the "available pci@2,0" test moves into a new apcie_port2_enabled flag
that sleep_apcie_port2_stop_once() checks. The stop still runs only on a
host that describes and enables port 2. Nothing else conflicts.

Signed-off-by: Dylan Ironside <[email protected]>
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