Skip to content

drm/apple: T6050: refuse deep sleep at .prepare where the firmware 27 display sleep is not known - #2070

Open
rolotrealanis98 wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
rolotrealanis98:pr/t6050-deep-sleep-guards
Open

rolotrealanis98 wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
rolotrealanis98:pr/t6050-deep-sleep-guards

Conversation

@rolotrealanis98

Copy link
Copy Markdown
Contributor

On a T6050 whose internal DCP runs firmware 27 other than the J714s's 27.0 table, a deep sleep (mem_sleep=deep) now stops at the DCP's .prepare with one line, instead of running the firmware 27 display sleep and crashing the DCP.

What happened

On the J716s (16-inch M5 Pro, firmware 27.3) a pm_test=devices deep sleep crashed the DCP in the device suspend:

  • dcp_v27_sleep_selected() asks only for a T6050 DCP on firmware 27 under the T6050 sleep, so dcp_platform_suspend() took dcp_v27_sleep_suspend().
  • Its "open" step found no endpoint in sleep_v27_ep (filled only for dcp->v27_j714s). It ran afk_init()/afk_start() on the system endpoint 0x20, which was already running since boot: START_EP, then RBEP_INIT on the running ring.
  • The firmware asserted at afk_messenger_common.c:246, afk_start() timed out after 1 s, and the suspend returned -110. The display was dead until reboot.

Past that step, the sleep sends 27.0's method tags. 27.2 and 27.3 renumbered them (set_power_state is A534/A535 there, A500 is set_parameter_dcp), and the 27.3 tags for the sleep's own calls are not known. This also applies to a J714s running 27.2 or 27.3 firmware.

The change (one commit)

  • dcp->v27_sleep_known is set only where the sleep's calls are known: the J714s with its 27.0 table copy.
  • dcp_platform_prepare() refuses a firmware-driven sleep on any other T6050 firmware 27 DCP with -EOPNOTSUPP, before any device suspends. s2idle never reaches this check.
  • Two backstops: dcp_v27_sleep_prepare() refuses the same way, and dcp_v27_sleep_endpoints_open() returns -EPROTO rather than restart an AFK endpoint that is already running but untracked. On the J714s every endpoint is tracked, so the backstop does not trigger there.

Tested

  • J716s, 27.3, aura stage 2 with the S2R mailbox (the board admitted to the T6050 sleep on my branch):
    • deep pm_test=devices now ends at prepare with -95 and deep sleep refused: no display sleep known for firmware 27.3.0 on this machine (only the J714s on 27.0); s2idle is not affected;
    • no device suspended, and the display stayed up;
    • an s2idle pm_test=devices run afterwards succeeded.
  • Build: drivers/gpu/drm/apple with W=1 on this base (d5a8a25), no warnings in the touched files.
  • Not run on a J714s.

Related, not in this PR

On the J716s, t6050_sleep_boot_timer_off() oopses: its MSR S3_4_C15_C2_7 (SYS_APL_AGT_CTL_EL02) is an undefined instruction there (ESR 0x02000000, in the bound worker). The oops kills CPU0's high-priority kworker, so block I/O completions stop and the root file system hangs a couple of minutes later.

Upstream only admits the J714s to this driver, so nothing here reaches that code on another board today. I'm noting it for whichever board is admitted next. My branch puts the write behind a module parameter (rolotrealanis98/linux@77f43d0e2a53). If the J714s's loader makes these registers accessible and it works there, that would explain the difference.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TYoPBXdNYTj12jEVptd1y7

… display sleep is not known

A pm_test=devices deep sleep on the J716s (firmware 27.3) crashed its DCP
in the device suspend. dcp_platform_suspend() took dcp_v27_sleep_suspend():
dcp_v27_sleep_selected() asks only for a T6050 DCP on firmware 27 under the
T6050 sleep. Its "open" step found no endpoint in sleep_v27_ep, which
afk_init() fills only for dcp->v27_j714s, so it ran afk_init() and
afk_start() on the system endpoint 0x20 that systemep_init() had started at
boot: START_EP (mgmt 0x0050002000000002), then RBEP_INIT
(0x0080000000000000) on its running ring. The firmware asserted at
afk_messenger_common.c:246 with that message, afk_start() timed out after
1 s and the suspend returned -110. The display stayed dead until reboot.

Past that step the sleep would send 27.0's tags (A484, A500, A414, A489,
A487, A412, A115). 27.2 and 27.3 renumbered those methods: set_power_state
is A534/A535 there and A500 is set_parameter_dcp. The 27.3 tags of the
sleep's own calls are not known, so there is no 27.3 path to enable yet.

- dcp->v27_sleep_known is set only where the sleep's calls are known: the
  J714s with its 27.0 table copy (iomfb_v27_methods_j714s()).
- dcp_platform_prepare() refuses a firmware-driven (deep) sleep on any
  other T6050 firmware 27 processor with -EOPNOTSUPP, before any device
  suspends, and logs one line. s2idle does not come here (no
  pm_suspend_via_firmware()).
- dcp_v27_sleep_prepare() refuses the same way if it is ever reached.
- dcp_v27_sleep_endpoints_open() refuses with -EPROTO when an AFK ring
  already runs on an endpoint it does not track, instead of starting it
  again. On the J714s every AFK endpoint is tracked, so it never triggers
  there.

Tested on the J716s (27.3, aura stage 2 with the S2R mailbox):
pm_test=devices with mem_sleep=deep now ends at prepare with -95 and the
line "deep sleep refused: no display sleep known for firmware 27.3.0 on this
machine (only the J714s on 27.0); s2idle is not affected"; no device
suspended, the display stayed up. A pm_test=devices s2idle afterwards
succeeded. Not run on a J714s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TYoPBXdNYTj12jEVptd1y7
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T09:57:49.209727Z df8aaf5 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@axboe

axboe commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

A data point for the 27.2 side of this, from the K116s (16" M5 Pro, 27.2): the firmware 27 display sleep does run to completion there, so 27.2 need not stay in the "not known" set. What it took, on top of the J714s 27.0 path:

  • Tags: A401 and up move by +50 on 27.2 (A484 → A534, A500 → A550, A442 → A492); A115 is unchanged. A492 rejects the 0xaa filler as index count and block size; zeros are accepted.
  • Secure mailbox: the internal DCP only acknowledges the IOP power state after /arm-io/dcp-exclave-mailbox is handshaken at bind and AP-idled between the main mailbox's AP and IOP idle. Without it the suspend times out as described here.
  • External engines: the four DCPEXT hand off and sleep with the same tags once the loader hands them over.

Details and logs are in #2075, the experiment branch is linked there. I have no 27.3 machine, so I can't say whether its tags follow the same shift.

@rolotrealanis98

Copy link
Copy Markdown
Contributor Author

Thanks, that's useful. I'd like to keep this PR as the guard and admit 27.2 separately:

  • This PR stops the crash for any T6050 firmware 27 DCP whose sleep calls aren't known. It stays needed for 27.3 and for anything newer.
  • 27.2 can leave the "not known" set when the work in T6050 K116s (27.2): deep sleep entry completes, the SoC does not sleep; DCP secure mailbox and DCPEXT handoff needed #2075 lands: the +50 tag shift, the zeroed A492 fields, and the dcp-exclave-mailbox handshake and AP idle. That should be one change. Admitting 27.2 without the secure mailbox would just move the failure to the IOP-idle timeout you describe. When you open it, I'll narrow v27_sleep_known to match, or rebase onto it, whichever you prefer.
  • 27.3: this J716s is on 27.3, so I can check whether the tags follow the same +50 shift there. That will be after Saturday (2026-11-21), when I'm back at the hardware. I'm also moving the J716s to the 27.2 stub for aura#274, so I can try your branch on a second 27.2 board if you push it.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Blockers: 2.

The fail-closed direction is right: refusing at .prepare (drivers/gpu/drm/apple/dcp.c:7528) stops the deep sleep before any device suspends, and the untracked-endpoint backstop at drivers/gpu/drm/apple/dcp-v27-sleep.inc:968 is a good generic check.

  1. The commit has no Signed-off-by, only agent trailers (a Co-Authored-By and a session link). Re-sign it with your own Signed-off-by and drop both trailers.
  2. dcp-v27-sleep.inc:408-419 (the comment above dcp_v27_sleep_known()) and the commit message quote the firmware's own assertion source file and line and its internal method names. Those are strings from the firmware. Describe the failure in our terms instead ("the firmware asserted on a second endpoint start and the call timed out").
  3. Not a blocker, but it shapes the next step. v27_sleep_known is set only inside the v27_j714s branch (dcp.c:6682), so whether the sleep is "known" is decided by board plus firmware version. The driver already keeps one method table per build (iomfb_v27_methods()) and checks a table for missing IDs (iomfb_v27_missing_method()). Set v27_sleep_known when the selected table has an ID for every method the sleep sends. Then 27.2, and 27.3 once its IDs are in its table, are admitted by data, not by a board check.
  4. This conflicts with drm/apple: J716c external displays and display sleep on firmware 27.2 #2187, which admits the J716c on 27.2 to the firmware 27 sleep transport (dcp_v27_sleep_transport_supported()) and reports a working 27.2 deep sleep there. With this PR that same sleep is refused at .prepare, because the J716c never sets v27_sleep_known. Point 3 fixes this if the 27.2 table carries the sleep's IDs; otherwise rebase onto drm/apple: J716c external displays and display sleep on firmware 27.2 #2187 and say which one wins.
  5. The branch no longer merges cleanly with integration/aurora; it needs a rebase.

HW row: J714s on 27.0 with this branch, default cmdline: a deep sleep still enters and resumes with the panel back (no refusal line); J716s on 27.3: the refusal line, no device suspended, s2idle unaffected; 0 AVC / 0 failed units / 0 new kernel errors on both.

Nit: the PR body ends with "Generated with Claude Code" and a session link; the last line should be Assisted-by: LLM (<Vendor>:<Model>).

Assisted-by: LLM (Claude:Opus 5.5)

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