Repository navigation
drm/apple: T6050: refuse deep sleep at .prepare where the firmware 27 display sleep is not known - #2070
drm/apple: T6050: refuse deep sleep at .prepare where the firmware 27 display sleep is not known#2070rolotrealanis98 wants to merge 5 commits into
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
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:
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. |
|
Thanks, that's useful. I'd like to keep this PR as the guard and admit 27.2 separately:
|
|
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.
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 (Claude:Opus 5.5) |
|
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. |
… 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 <[email protected]> Signed-off-by: Rolando Trevino <[email protected]>
df8aaf5 to
f0d63f6
Compare
|
@RyanTheTide thanks, reworked and rebased on main (83950d0), one commit:
At f0d63f6: KUnit display suites 147/148 (1 skipped, none failed), host tests 505/505, 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 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. |
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Verdict: Changes requested at 7987e8f8d1fe.
Blocker: dcp_v27_sleep_endpoints_open() checks for an already-running untracked endpoint inside the same loop that initializes and starts endpoints. A later conflicting ID can return -EPROTO after earlier missing endpoints have already started, despite the comment saying refusal happens before anything is sent. Preflight the full endpoint set before the first start or show the unwind that restores it. Please cover a later conflicting ID after an earlier endpoint that would otherwise start.
Checked: The method-table predicate is a capability check, and CI currently passes. The supplied unsupported-build row is useful. Please add the requested supported-table J714s deep-sleep row to cover the success path.
dcp_v27_sleep_endpoints_open() checked each endpoint inside the loop that starts them: that it exists, and that no ring the sleep does not track already runs on it. An endpoint later in the set that failed either check returned -ENODEV or -EPROTO after the ones before it had already been initialized, started and opened, although the refusal was meant to come before anything is sent. Move both checks to dcp_v27_sleep_endpoints_check(), which walks the whole set first; dcp_v27_sleep_endpoints_open() runs it before the first endpoint is touched. A refusal now leaves every endpoint as it was. The checks, their order and their errors are unchanged, and an endpoint the sleep already tracks is still kept rather than refused. tools/asahi/display-sleep-merge-tests.py runs the production function with a conflicting or missing endpoint late in the set, after endpoints that would otherwise start, and checks that none is initialized, started or opened. A control with the checks back inside the start loop fails that check, as do controls without the check, without the running ring test, and refusing a tracked endpoint. Signed-off-by: Rolando Trevino <[email protected]>
|
Fixed in 81a7880: the whole set is checked before any endpoint starts. Test: At 81a7880: KUnit display 168/169 (1 skipped, none failed), host tests 696/696, On the supported-table J714s deep-sleep row: I don't have a J714s, so I can't run it. The J716s row at 7987e8f only shows that s2idle and boot are unaffected. A J714s 27.0 row at this head from someone who has one would be very welcome. |
There was a problem hiding this comment.
Code approved at the revised head. The endpoint check now completes for the whole set before the first start. I ran the exact-head host suite, and all 23 runs matched expectations, including a later untracked or missing endpoint leaving earlier endpoints untouched and the corresponding negative controls. Keep the hosted checks and supported-table J714s deep-sleep row as merge gates.
|
Merge-train review at |
erikwb
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at 81a7880e9f25
Blockers: Add a passing deep-sleep and display-resume row at this head on a T6050 Mac with a supported display method table, plus a no-regression row on the other affected Mac where available. The J716s row predates the endpoint change and did not enter deep sleep.
Checked: The method check follows the table used for transport admission. An untracked or missing endpoint is caught before any endpoint starts. The new checks add no model gate, required knob or hardware safety constant. Build, KUnit, host tests and PR text passed, and the branch has no conflicts.
Evidence
81a7880e9f25 fixes the partial-start problem from the previous review. The endpoint check walks the whole set first. The host cases cover a later untracked ring and a missing last endpoint, with no ring initialized, started or opened in either case. The prepare hook is limited to firmware-driven sleep, and the supported-table test checks the same predicate used for admission.
|
J716c (16-inch M5 Max, firmware 27.2) at EvidenceThis head built on its own (
|
dcp_platform_prepare() keeps main's early return for a display processor already stopped for the sleep, ahead of the refusal of a deep sleep whose display sleep the build's table does not carry. The merge-boundary test gains main's case and checks that a stopped processor is not refused. Signed-off-by: Rolando Trevino <[email protected]>
|
Merged main in (55c9433, normal push). One conflict, in The deep-sleep row still has to come from a T6050 Mac with a supported display method table; the J716s (27.3, the table this PR refuses) can only show the refusal side, which its earlier row covers. |
There was a problem hiding this comment.
Verdict: HOLD at 55c9433c
Blockers:
- Hosted
pull_requestCI workflows (Apple build and KUnit,Apple DRM KUnit,pr-text) areaction_requiredawaiting maintainer workflow approval for this fork PR. - Passing deep-sleep and display-resume hardware row on a T6050 Mac with a supported firmware-27 display method table (27.0 / 27.2) at
55c9433cis still open (as noted in the prior review and latest comment).
Checked:
- Merge resolution at
55c9433c(drivers/gpu/drm/apple/dcp.c,tools/asahi/display-sleep-merge-tests.py):dcp_platform_prepare()cleanly keepsmain'ssleep_cold_stoppedearly return ahead ofdcp_v27_sleep_known(dcp)so a cold-stopped display processor is neither invalidated nor refused;display-sleep-merge-tests.pyexercises that exactsleep_cold_stopped && !v27_knowncase across all 23 compiled runs. - Preflight & method-table guards (
dcp-v27-sleep.inc,iomfb_v27.c,dcp-firmware-test.c):dcp_v27_sleep_endpoints_check()validates the fullv27_sleep_endpointsset before initializing or starting any endpoint (returning-ENODEV/-EPROTOwithout side effects), andiomfb_v27_sleep_missing_method()mirrorsiomfb_v27_sleep_methods_complete()with KUnit coverage (dcp_firmware_27_sleep_methods).
Evidence
- Diff scope:
+212/-9across 6 files; no code or merge-conflict defects found at55c9433c. - Ready condition: Upgradeable to
APPROVEonce hosted fork CI passes green and a supported-table T6050 deep-sleep row clears at55c9433c.
|
Could a maintainer approve the fork workflow runs at 55c9433 (Apple build and KUnit, Apple DRM KUnit, pr-text show action_required)? The merge-boundary test and a W=1 build of dcp.o pass locally (comment above). |
There was a problem hiding this comment.
Verdict: MERGE at 55c9433c3470
Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.
Checked: - Merge resolution at 55c9433c (drivers/gpu/drm/apple/dcp.c, tools/asahi/display-sleep-merge-tests.py): dcp_platform_prepare() cleanly keeps main's sleep_cold_stopped early return ahead of dcp_v27_sleep_known(dcp) so a cold-stopped display processor is neither invalidated nor refused; display-sleep-merge-tests.py exercises that exact sleep_cold_stopped && !v27_known case across all 23 compiled runs.
- Preflight & method-table guards (
dcp-v27-sleep.inc,iomfb_v27.c,dcp-firmware-test.c):dcp_v27_sleep_endpoints_check()validates the fullv27_sleep_endpointsset before initializing or starting any endpoint (returning-ENODEV/-EPROTOwithout side effects), andiomfb_v27_sleep_missing_method()mirrorsiomfb_v27_sleep_methods_complete()with KUnit coverage (dcp_firmware_27_sleep_methods).
Follow-ups (not blocking): fork CI approval, T6050 27.x deep-sleep/display-resume row
Main's dcp_platform_prepare() now runs dcp_v27_dpms_prepare() before the deep-sleep path; for a deep sleep it can power the display pipe on and set v27_dpms_pm_suspend, which only .complete undoes, and a device whose .prepare fails gets no .complete. The refusal of a deep sleep whose display sleep the build's table does not carry therefore comes first, then main's DPMS prepare, then the deep-sleep invalidation. The merge-boundary test counts the DPMS prepare and checks that a refused sleep never reaches it. Signed-off-by: Rolando Trevino <[email protected]>
|
Merged main in again (68895bc, normal push). Main's J716s row at 68895bc: |
What: refuse a T6050 deep sleep at
.preparewhen the build's firmware 27 method table has no ID for one of the display sleep's calls, and refuse to start an endpoint that already runs but is not tracked for the sleep (-EPROTO) instead of starting it a second time.Tested: J716s (firmware 27.3) at 7987e8f, row in the comments; KUnit, host tests and
checkpatch --strictpass at that SHA (Testing below).Risk: two-way door. T6050 DCP/DCPEXT on firmware 27 under the T6050 deep sleep. With main merged in (#2187), 27.0, its J714s copy and 27.2 keep their deep sleep; a table without an ID for a sleep call (27.3 today) is refused, and main already keeps such a processor out at admission, so the
.preparecheck is a consistency guard. The untracked-endpoint backstop is what this adds on top of main.Not yet: a J714s 27.0 or 27.2 deep sleep at this head (I have no J714s).
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()). Before #2187 that sleep sent its calls by their firmware 27.0 IDs, and admission did not look at the build's method table. A J714s on 27.2 or 27.3 was admitted, and its table gives several of those IDs to other methods or to none, so the sleep would have sent 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=devicesdeep 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) has no ID for, NULL exactly when main'siomfb_v27_sleep_methods_complete()is true. The 27.0 table, its J714s copy and the 27.2 table carry them; the 27.3 table does 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.dcp_v27_sleep_prepare()refuses the same way, anddcp_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 and a J714s on 27.2 keep their deep sleep; a processor on 27.3 is refused (and on main is not admitted in the first place). 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 has an ID for every call the sleep sends.Interaction with #2187 (main merged in at 7987e8f): that change makes the sleep send each build's own IDs and admits processors by
iomfb_v27_sleep_methods_complete(). The merge keeps main'siomfb_v27_sleep_methods[]list and definesiomfb_v27_sleep_missing_method()over it, so the.prepareanddcp_v27_sleep_prepare()checks apply the same rule as admission: 27.2 stays admitted and 27.3 stays refused. The untracked-endpoint backstop is independent of it.Testing
At 7987e8f: KUnit (
display.kunitconfig, arm64, LLVM): 169 run, 168 passed, 1 skipped (needsCONFIG_UCLAMP_TASK), includingdcp_firmware_27_sleep_methods. Host tests (tools/asahi/run-host-tests.py): 696/696, includingdisplay-sleep-merge-testswith theprepare-ignore-knownnegative control.checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks.drivers/gpu/drm/apple/builds withW=1, no warnings, withCONFIG_APPLE_SOC_SLEEPon and off.Not yet run
.preparecheck cannot fire on any board today; the J716s row shows the head boots and s2idle is unaffected.Related, not in this PR: the boot timer write on the J716s
On the J716s,
t6050_sleep_boot_timer_off()oopses: itsMSR 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.