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:mainfrom
rolotrealanis98:pr/t6050-deep-sleep-guards
Open

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

Conversation

@rolotrealanis98

@rolotrealanis98 rolotrealanis98 commented Nov 16, 2026 •

Copy link
Copy Markdown

What: refuse a T6050 deep sleep at .prepare when the build's firmware 27 method table does not carry the display sleep's calls under the IDs the sleep sends, instead of sending them anyway.
Tested: no hardware row at f0d63f6 yet; KUnit, host tests and checkpatch --strict pass at that SHA (Testing below).
Risk: two-way door. T6050 DCP/DCPEXT on firmware 27 under the T6050 deep sleep; a J714s on 27.2 or 27.3 now refuses deep sleep (its table gives the sleep's IDs to other methods); the J714s and J716c on 27.0 are unchanged.
Not yet: a J714s 27.0 deep sleep at this head, and the refusal itself on a J714s 27.2 or 27.3 (see the end).

Problem

A T6050 deep sleep (mem_sleep=deep) runs the firmware 27 display sleep on every DCP and DCPEXT admitted to the firmware 27 sleep transport (dcp_v27_sleep_selected()). That sleep sends its calls by their firmware 27.0 IDs, and admission does not look at the build's method table. A J714s on 27.2 or 27.3 is admitted, and its table gives several of those IDs to other methods or to none, so the sleep would send them anyway.

How it shows up, from the J716s (16-inch M5 Pro, firmware 27.3) on the base this was first written for, before #2124 decided admission per processor: a pm_test=devices deep sleep crashed the DCP in the device suspend. None of the J716s's endpoints were tracked for the sleep (sleep_v27_ep), so the sleep started the already running system endpoint 0x20 a second time. The firmware asserted, the call timed out after 1 s, the suspend returned -110, and the display stayed dark until a reboot.

Change

One commit, decided by the method table rather than by the board:

  • iomfb_v27_sleep_missing_method() names the first call of the display sleep that the selected table (dcp->v27_methods) does not carry under the ID the sleep sends, NULL if it carries them all. The 27.0 table and its J714s copy carry them; the 27.2 and 27.3 tables do not.
  • dcp_platform_prepare() refuses a firmware-driven sleep with -EOPNOTSUPP on a processor the display sleep would run on whose table does not carry it, before any device suspends, and logs the build and the first missing call. 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 start an endpoint that already runs but is not tracked for the sleep. On an admitted processor every endpoint is tracked, so it does not trigger there.

Affected: T6050 DCP/DCPEXT on firmware 27 under the T6050 sleep. The J714s and the J716c on 27.0 keep their deep sleep; a J714s on 27.2 or 27.3 is refused at .prepare. No other SoC reaches this code.

No board or firmware-version check is added: the decision comes from the method table the driver already selects for the build, the same data iomfb_v27_missing_method() uses to decide whether a build may start at all. A build is admitted as soon as its table carries the sleep's calls under the IDs the sleep sends.

Interaction with #2187: that change makes the sleep send each build's own IDs and admits processors by iomfb_v27_sleep_methods_complete(). With both applied, the .prepare and dcp_v27_sleep_prepare() checks use that helper, so 27.2 stays admitted and 27.3 stays refused; the untracked-endpoint backstop is independent of it.

Testing

KUnit (display.kunitconfig, arm64, LLVM): 148 run, 147 passed, 1 skipped, including the new dcp_firmware_27_sleep_methods. Host tests (tools/asahi/run-host-tests.py): 505/505, including display-sleep-merge-tests with the added prepare-ignore-known negative control. checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks. drivers/gpu/drm/apple/ builds with W=1, no warnings, with CONFIG_APPLE_SOC_SLEEP on and off.

Not yet run

  • J714s on 27.0, default command line: a deep sleep still enters and resumes with the panel back, no refusal line; 0 AVC / 0 failed units / 0 new kernel errors.
  • The refusal on hardware in this form: on main the J716s no longer takes this sleep (drm/apple: J716c display coprocessors over a deep sleep #2124), so it needs a J714s on 27.2 or 27.3. On the J716s, a deep sleep on this head to show it is unaffected.
Related, not in this PR: the boot timer write on the J716s

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. Only the J714s and the J716c are admitted to the T6050 sleep today, so nothing here reaches that code on another board. Noting it for whichever board is admitted next.

@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

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

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)

@RyanTheTide

Copy link
Copy Markdown

This no longer applies to the current integration/aurora tip 110861f. Since it was opened, #2124 (fd5cc59) admitted the J716c on 27.0.0 to the firmware 27 sleep through a new v27_sleep_transport flag, and dcp_v27_sleep_selected() now requires that flag. A J716s on 27.3 therefore no longer takes the v27 sleep at all, but a J714s on 27.2 or 27.3 still does. Rebased as is, the J716c's merged deep sleep would be refused at .prepare, because v27_sleep_known is only set for the J714s 27.0 table. @rolotrealanis98 could you rebase and derive v27_sleep_known from the selected method table carrying every ID the sleep sends, as suggested in the 11-21 review? The comment and commit message should also describe the firmware assertion in our own words rather than quoting its source file, line and method names.

@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) merge-conflict Conflicts with the base branch (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026
… display sleep is not known

A T6050 deep sleep runs the firmware 27 display sleep on every DCP and
DCPEXT admitted to its transport (dcp_v27_sleep_selected()). That sleep
sends its calls by their firmware 27.0 IDs, and admission does not look
at the build's method table: a J714s on 27.2, whose table gives several
of those IDs to other methods or to none, takes the sleep and sends them
anyway.

On a J716s (27.3), before admission to the transport was decided per
processor, this sleep left the display dark until a reboot. None of its
endpoints were tracked for the sleep, so the sleep started the running
system endpoint a second time; the firmware asserted, the call timed out
after 1 s and the suspend failed with -ETIMEDOUT.

Refuse such a deep sleep where it starts, decided by the method table
rather than by the board:

- iomfb_v27_sleep_missing_method() names the first call of the display
  sleep that a build's table does not carry under the ID the sleep sends,
  NULL if it carries them all. The 27.0 table and its J714s copy carry
  them; the 27.2 and 27.3 tables do not.
- dcp_platform_prepare() refuses a firmware-driven (deep) sleep with
  -EOPNOTSUPP, before any device suspends, on a processor the display
  sleep would run on whose table does not carry it, and logs one line
  with the build and the first call it lacks. 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 a ring already
  runs on an endpoint that is not tracked for the sleep, instead of
  starting that endpoint again. Every endpoint of an admitted processor
  is tracked, so it does not trigger there.

The J714s and the J716c on 27.0 keep their deep sleep. Another build is
admitted as soon as its table carries the sleep's calls under the IDs
the sleep sends; once the sleep sends each call by the build's own ID,
the check becomes whether the table has an ID for each call.

The apple-dcp-firmware KUnit suite checks the tables against the sleep's
calls, and display-sleep-merge-tests checks the refusal at .prepare.

Signed-off-by: rolotrealanis98 <122947376+rolotrealanis98@users.noreply.github.com>

Signed-off-by: Rolando Trevino <122947376+rolotrealanis98@users.noreply.github.com>
@rolotrealanis98
rolotrealanis98 force-pushed the pr/t6050-deep-sleep-guards branch from df8aaf5 to f0d63f6 Compare November 24, 2026 15:14
@rolotrealanis98
rolotrealanis98 requested review from a team and DjDeveloperr as code owners November 24, 2026 15:14
@rolotrealanis98

Copy link
Copy Markdown
Author

@RyanTheTide thanks, reworked and rebased on main (83950d0), one commit:

  1. Re-signed with my own Signed-off-by; the Co-Authored-By and session-link trailers are gone.
  2. The code comment and commit message describe the failure in our terms (the sleep started an already running endpoint again, the firmware asserted, the call timed out), with no firmware file, line or method names.
  3. The PR body follows the template (What / Tested / Risk / Not yet) and carries no attribution line, per the rulebook.
  4. v27_sleep_known is gone. dcp_v27_sleep_known() asks the selected method table, with no board check: iomfb_v27_sleep_missing_method() checks that the table carries every call the sleep sends under the ID it sends. The J714s and the J716c on 27.0 keep their deep sleep; a J714s on 27.2 or 27.3 is refused at .prepare. No board or firmware-version check is added.

At f0d63f6: KUnit display suites 147/148 (1 skipped, none failed), host tests 505/505, checkpatch --strict clean, drivers/gpu/drm/apple/ builds with W=1 and no warnings with CONFIG_APPLE_SOC_SLEEP on and off.

On #2187: today the sleep sends 27.0 IDs, so a 27.2 table is refused here. Whichever lands second rebases. If #2187 lands first, I'll switch the .prepare and dcp_v27_sleep_prepare() checks to its iomfb_v27_sleep_methods_complete(), so 27.2 stays admitted and 27.3 stays refused; the untracked-endpoint backstop stays.

No hardware row yet at this head. On main the J716s no longer takes this sleep, so it can only show its deep sleep is unaffected; the refusal itself needs a J714s on 27.2 or 27.3. I don't have a J714s, so a run of the J714s 27.0 row would be very welcome.

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) and removed merge-conflict Conflicts with the base branch (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Merge readiness at f0d63f6f: not ready yet

Check Detail
CI at head ok 3 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head no no line with the head SHA f0d63f6f, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · . T6050 DCP/DCPEXT on firmware 27 under the T6050 deep sleep; a J714s on 27.2 or 27.3 now refuses deep sleep (its table gives the sleep's IDs to other methods); the J714s and J716c on 27.0 are unchanged.

Areas: area:display, area:gpu

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: FINISH at f0d63f6f7c44

Blockers:

  • §5 (Evidence) — no hardware row at exact head f0d63f6f7c44 yet. Add a default-cmdline row at f0d63f6f7c44 on T6050 hardware (J714s or J716c on 27.0 confirming deep sleep enters and resumes with the panel back, no refusal line, and 0 AVC / 0 failed units / 0 new kernel errors; plus a J714s on 27.2 refusal row if available, or state what the closest T6050 row stands in for per merge policy §3).

Checked: §1–§4 and §6 pass across the 7-file diff and commit f0d63f6f7c44 (data-driven method-table check, PM .prepare/.complete/s2idle/backstop audit, clean attribution and IP hygiene); CI is green (kunit, host-tests, pr-text) and mergeable == MERGEABLE; waiting only on the §5 exact-head hardware row.

Evidence
  • §1 (No model gating): iomfb_v27_sleep_missing_method() in drivers/gpu/drm/apple/iomfb_v27.c:344-356 gates solely on whether the build's selected dcp->v27_methods table carries the 6 table-mapped sleep RPCs (dcpep_set_power_state, dcpep_unnamed_500, dcpep_pipe_cfg_414, dcpep_pipe_query_478, dcpep_pipe_set_476, dcpep_is_main_display) under the 27.0 wire tags currently sent by dcp-v27-sleep.inc and iomfb.c (A484, A500, A414, A489, A487, A412; A115 and A442 have no table entry and only ride with checked calls). No board, SoC, or firmware-version check is added. J714s (iomfb_v27_methods_j714s() copy differing only in dcpep_swap_submit) and J716c on 27.0 remain admitted; J714s on 27.2 (currently admitted to v27_sleep_transport via dcp->v27_j714s) or 27.3 is refused cleanly. Non-T6050 SoCs never satisfy dcp_v27_sleep_selected(), so there is no interaction with #2710 or #2721. Interaction with #2187 is clean and documented (once #2187 switches sleep RPCs to dynamic table lookup, the check narrows to non-empty tags).
  • §2–§3 (PM lifecycle & safety):
    • drivers/gpu/drm/apple/dcp.c:8499-8502: gated on pm_suspend_via_firmware() && dcp_v27_sleep_selected(dcp), so s2idle (pm_suspend_via_firmware() == false) and hibernation are unaffected.
    • Returning -EOPNOTSUPP from dcp_platform_prepare() aborts before any device .suspend() runs, with no firmware RPCs or endpoint mutations; dcp_v27_sleep_invalidate() is idempotent, PM core skips .complete() on the failing device, and any sibling DCP that already passed .prepare() completes cleanly in dcp_platform_complete().
    • drivers/gpu/drm/apple/dcp-v27-sleep.inc:424-435: dcp_read_fw_version() initializes compat safely (writing "UNKNOWN" on failure); #else stub at line 1777 matches forward declaration for CONFIG_APPLE_SOC_SLEEP=n.
    • Backstops: dcp_v27_sleep_prepare() (dcp-v27-sleep.inc:1464-1465) re-checks iomfb_v27_sleep_missing_method() before any teardown or RPCs; dcp_v27_sleep_endpoints_open() (dcp-v27-sleep.inc:1043-1044) returns -EPROTO if dcp_afkep(dcp, id) already has a live untracked ring (safe on admitted processors because v27_sleep_transport is set at dcp.c:7624 before any afk_init() runs).
    • Unit & host tests: KUnit dcp_firmware_27_sleep_methods (dcp-firmware-test.c:75-104) covers 27.0, 27.2, 27.3, NULL, J714s A407 copy, mismatched tag, and cleared tag; tools/asahi/display-sleep-merge-tests.py covers .prepare refusal plus prepare-ignore-known negative control; tools/testing/selftests/drivers/gpu/apple-dcp/boot.py adds ARRAY_SIZE for the extracted table slice.
  • §4 (IP & attribution hygiene): Commit f0d63f6f7c44, PR title, PR body, and code comments carry no firmware assertion filenames/lines/internal symbols and no AI attribution. Human Signed-off-by: is present.
  • §5 (Evidence & CI): PR body includes What:, Tested:, Risk: (two-way door), and Not yet:. CI at f0d63f6f7c44: kunit PASS, host-tests PASS, pr-text / pr-text PASS (readiness run cancelled by newer trigger). Missing only the exact-head hardware row at f0d63f6f7c44.
  • §6 (Naming): Clean.
  • Non-blocking nit: Commit f0d63f6f7c44 has two Signed-off-by: lines for the same author separated by a blank line (rolotrealanis98 and Rolando Trevino); fine to tidy if you amend for any reason, not blocking.

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

Labels

area:display Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (bot) blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants