Skip to content

soc: apple: t6050-aop: stop AOP2 before AOP, well before the commit, as macOS - #2606

Merged
DjDeveloperr merged 1 commit into
integration/aurorafrom
djdev/m5-t6050-aop2-before-aop
Nov 21, 2026
Merged

DjDeveloperr merged 1 commit into
integration/aurorafrom
djdev/m5-t6050-aop2-before-aop

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

A J714s (M5 Pro) deep-sleep change, copied from macOS 27 traced under the hypervisor on the same machine. On integration/aurora df62a8c. It is separate from #2602.

What macOS does. In every sleep traced (cp9d, cp10c, k6, k7, k8), macOS stops the two always-on processors in one order:

  • AOP2's ring elements and AP IDLE come first, ~185-215 ms before the commit;
  • AOP's endpoint stops follow 1-11 ms later;
  • AOP's AP IDLE comes 18-25 ms after AOP2's.

What Linux did.

  • AOP is stopped at its late suspend (aop.rs). Its endpoint order, from the device tree's lists, already matches macOS's.
  • AOP2 was stopped last, in the commit's first coprocessor pass (apple_sleep_coproc_register_first), with interrupts off.
  • So the order was reversed.

Why. On the J714s the AOP firmware crashed in deep sleep twice, on 11-18 and 11-20, each time:

  • 0.2-0.5 s after the commit, with the same crash frame; its crash report woke the machine;
  • on the first sleep after a boot, about 1 in 35 such sleeps.

Both crashes followed that commit-time AOP2 stop. The AOP2/AOP order is the one difference the traces show. This is a literal copy, not a proven cause. A crash with this order in place means it's wrong.

The change (drivers/soc/apple/t6050-aop.c).

  • At probe, AOP2 becomes a consumer of the AOP device for the PM core through a stateless device link, so its late suspend runs before AOP's.
  • That late suspend does the stop the commit pass did: the same elements and AP IDLE, polled.
  • AOP2 stays registered and ready for the commit, whose pass now sends it nothing.
  • Nothing waits a fixed time between the two stops. AOP's endpoint stops start once the PM core reaches AOP's late suspend, right after AOP2's (macOS: 1-11 ms after). An earlier head had a fixed 15 ms pause to copy macOS's 18-25 ms gap. It was removed under the project rule against runtime switches and magic constants in merged code.
  • A suspend undone after it restarts AOP2 in its resume, as before.
  • Without an AOP device, nothing changes.
  • Known differences:
    • The resume now restarts AOP, then AOP2. macOS sends AOP2's AP ON 1 ms before AOP's. The resume is left as it was.
    • With interrupts on, AOP2's mailbox interrupt can now take the polled exchange's messages, under the mailbox's receive lock.
  • The independent review's blocker on the first head is fixed: an unready registered coprocessor refused every sleep at the commit.

Testing.

🤖 Generated with Claude Code

@DjDeveloperr
DjDeveloperr force-pushed the djdev/m5-t6050-aop2-before-aop branch from 74b149f to 9f353d7 Compare November 20, 2026 20:41
…as macOS

On the J714s, macOS stops the two always-on processors in one order, in
every sleep traced under the hypervisor (cp9d, cp10c, k6, k7, k8):
- AOP2's ring elements and AP IDLE come first, ~185-215 ms before the
  commit;
- AOP's endpoint stops follow 1-11 ms later, and AOP's AP IDLE 18-25 ms
  after AOP2's.

Linux had the order the other way round. AOP is stopped at its late
suspend. AOP2 was stopped last, in the commit's first coprocessor pass,
with interrupts off.

On the J714s the AOP firmware crashed in deep sleep twice (11-18, 11-20),
each time 0.2-0.5 s after the commit and on the first sleep after a
boot, about 1 in 35 such sleeps. Both crashes followed that commit-time
AOP2 stop. AOP's own endpoint order already matches macOS's (the device
tree's lists), so the AOP2/AOP order is the difference the traces show.

AOP2 now becomes a consumer of AOP for the PM core through a stateless
device link, so its late suspend runs before AOP's. That late suspend
does the stop the commit pass did: the same elements and AP IDLE, polled.
AOP2 stays registered and ready for the commit, whose pass then sends it
nothing.

Nothing waits a fixed time between the two stops. AOP's endpoint stops
start once the PM core reaches AOP's late suspend, right after AOP2's
(macOS: 1-11 ms after). AOP2's stop line is logged at its late suspend.

A suspend that is undone after it restarts AOP2 in its resume, as
before. Without an AOP device the link isn't made, and AOP2 is stopped
at the commit, as before. With interrupts on, AOP2's mailbox interrupt
can now take the polled exchange's messages; both paths hand them over
under the mailbox's receive lock.

The resume order follows the link: AOP restarts, then AOP2, where macOS
sends AOP2's AP ON 1 ms before AOP's. The resume is left as it was: the
crashes come in the sleep, before any wake, and AOP2's restart in its
.resume is the tested path.

Signed-off-by: Diljit Singh <hey@djdev.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DjDeveloperr
DjDeveloperr force-pushed the djdev/m5-t6050-aop2-before-aop branch from 9f353d7 to 4afff64 Compare November 20, 2026 23:44
@RyanTheTide

Copy link
Copy Markdown
Contributor

The ordering through a device link is a tidy way to get AOP2's stop ahead of AOP's. I checked the interrupts-on concern: apple_rtkit_polled_begin() switches the mailbox's receive callback under its lock, so a reply delivered by interrupt still satisfies the polled exchange. Small points:

  • t6050_aop_order_before_aop(): the DL_FLAG_STATELESS link is never deleted. The driver has no remove callback today, but if it ever gets one, or is built as a module, the link should be dropped there.
  • The supplier is the first available apple,t6050-aop node in the tree. A phandle from the AOP2 node to AOP would make the dependency explicit and would also show up in the DT.
  • Between AOP2's late suspend and the commit, AOP2 is now in AP IDLE while the noirq phase runs. If no driver uses AOP2 endpoints in that window, a line in the header comment saying so would help the next reader.
  • For the tally: at the observed rate of about 1 in 35 first sleeps, around 100 first sleeps without an AOP crash are needed before the result says more than chance would. Please include the AP IDLE times of both processors from the kit logs, so the 15 ms gap can be compared against macOS's 18-25 ms.

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Hardware gate (J714s, M5 Pro), pe1, 20:06-20:27: 6 of 6 clean, in the same slot as #2602.

  • Kernel: 7.3.0-m5-kits6 = merged integration/aurora d1d26ab + drm: apple: dcp: V27 sleep: take messages that come during the settle (J714s -16 refusal) #2602 + this commit (byte-identical) + a log-only AOP line, built natively on the M5.
  • At boot: AOP2 logged that it is ordered before 290c00000.aop.
  • Every sleep:
    • AOP2's stop (elements and AP IDLE) ran at its late suspend, 133-254 ms before the commit. On macOS it is 185-215 ms; before this change it was inside the commit.
    • AOP's endpoint stop (all 13, 0x20-0x2c) completed 4.3-4.9 ms after AOP2's.
  • Results:
    • 6 replug-then-30 s sleeps, all clean: no refusal, no GPU fault, every device back;
    • the default was restored and verified at the end;
    • AOP first-sleep tally with the new order: 1 first sleep after a boot, 0 AOP crashes. The baseline is 2 in ~70, so this is a running tally, kept as the gates it rides add first sleeps.

🤖 Generated with Claude Code

@DjDeveloperr
DjDeveloperr merged commit 9ad7f89 into integration/aurora Nov 21, 2026
7 checks passed
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.

2 participants