Repository navigation
drm/apple: fix resume with an external display, hold DCP messages in s2idle, DP polish - #313
Merged
Merged
Conversation
Every resume with the external display at 1920x1080@180 logged [drm:drm_mode_config_helper_resume] *ERROR* Failed to resume (-22) The 180 Hz mode is admitted only while the DPTX link training that proves its bandwidth is current. System sleep releases the link, so when drm_atomic_helper_resume() commits the saved state, dcp_crtc_mode_fixup() rejects the mode and the whole commit fails with -EINVAL. Neither CRTC is restored; both outputs come back only when the compositor reacts to the hotplug that follows the relink. Before resuming, disable each CRTC of the saved state whose mode no longer passes the mode fixup, detaching its planes and connectors. The rest of the state is restored as before, and the DCP reports the external display again once its link is back, which is when userspace re-enables it, as after a replug. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
Resume restores a CRTC whose mode needs a link that system sleep released by bringing it back disabled. That edit of the suspend state detaches planes, connectors and the framebuffer by hand, outside the helpers, and nothing exercises it. Move it into its own file and have it ask the CRTC's own mode fixup, which for every apple-drm CRTC is dcp_crtc_mode_fixup(), so that KUnit can run it against a mock device. Add tests that take that device through drm_mode_config_helper_suspend() and _resume(): an inadmissible mode fails the resume when it is restored as is, and resumes disabled, with its planes, connector and framebuffer reference released, when it goes through the filter; an admissible or DPMS-off CRTC is handled the same way as before. No functional change. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
A CRTC restored disabled after system sleep has its connectors detached from it in the suspend state, but each keeps the encoder it was routed through. The commit that restores the state then finds a connector with an encoder and no CRTC, which the atomic helpers only expect from a broken duplicate, and every such resume logs WARNING: drivers/gpu/drm/drm_atomic_helper.c:238 at set_best_encoder The CRTC also keeps the encoder in its encoder mask. Release the encoder together with the CRTC, as the helpers do when they route a connector to no CRTC. The KUnit test now checks the edited suspend state. Fixes: 229d38c ("drm/apple: Resume a CRTC whose mode needs a new link disabled") Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
A CRTC whose mode needs a link that system sleep released is restored disabled, on the expectation that the hotplug following the relink makes userspace enable it again. Nothing guarantees that hotplug: the DCP reports a display that comes back on the same cable only for a new cable or the first attachment, and the 180 Hz mode is announced again only if its rate proof is renewed. Even when a hotplug arrives, the connector is still connected with the same modes, so a compositor that tracks its own state sees no change, believes the output is still lit, and has every flip rejected on the disabled CRTC. Use the link-status contract instead: mark the link of each connector detached from such a CRTC bad in the state being restored, and send a hotplug event once resume has committed it. Userspace then sets the mode again, with whatever modes the connector offers at that point, as it does after a failed link retraining. Fixes: 229d38c ("drm/apple: Resume a CRTC whose mode needs a new link disabled") Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
The receive interrupt of an ASC mailbox is requested IRQF_NO_SUSPEND so that RTKit co-processors stay serviceable during system sleep. A co-processor that keeps sending while the system sleeps then wakes a CPU for every message. Add apple_mbox_hold_rx() and apple_mbox_release_rx(), which mask and unmask the receive interrupt so that messages stay queued in the hardware FIFO, and the RTKit wrappers apple_rtkit_hold_rx() and apple_rtkit_resume_rx() for co-processor drivers. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
DPMS off on the internal H17P panel is a brightness present and leaves the pipe scanning out. While it scans out, the firmware publishes a property to the AP on every frame (D300 pr_publish, id 108, about 60 per second), and the DCP mailbox interrupt is IRQF_NO_SUSPEND, so each of them wakes a CPU out of suspend-to-idle: a 60 s RTC sleep took about 3650 interrupts from 412e08000.mailbox-recv, a 360 s one 21676. Hold the coprocessor's messages in the mailbox as the last step of the DCP suspend handler, after presentation is paused and the command queue has settled, and process them first thing on resume. A 360 s sleep now takes 97 interrupts, all of them in the transitions, and the panel and the firmware carry on normally after it. apple-drm is a device-link consumer of each DCP, so its suspend handler has blanked the panel before this runs and its resume handler restores the CRTC after the messages are processed. Powering the pipe off with A473 or idling the coprocessor through RTKit instead are not usable: the first left the firmware crashed after the power on, and the firmware does not acknowledge the second. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
The CD321x driver treats -EBUSY from typec_mux_set() as "the shared external display is driven by the other port": it sets up the port's USB path without the display and does not retry. -EBUSY has other sources on the same mux chain, though. The Apple Type-C PHY returns it while a mode or pipe transition is pending, and the DCP route returned it while the previous SAFE transition was still running and while the external DCP had not finished stopping. Those conditions clear on their own, but the port was left without its display until the next cable event. Have the DCP route report the lasting condition, every pipeline driving another port's display, as -ENOSPC, and the transient ones as -EAGAIN. The CD321x driver now skips the retry only for -ENOSPC, through a helper with a KUnit case; -EBUSY and -EAGAIN are retried like any other failure, -EAGAIN without counting against the port. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
Every hotplug, link training and resume of the external display logged a dozen info lines: each DPTX port call (SET_LINK_RATE, GET_SUPPORTS_HPD, DEACTIVATE, FORCE_HOTPLUG_DETECT, INACTIVE_SINK_DETECTED, the lane count calls and the validate_connection attributes), the AV service announcing its EDID channel, every connect attempt, every boot property and read_edt_data request, and "copy_edid failed: -ENODEV" whenever the EDID was probed while the link was down. None of them is a problem; they are the normal protocol flow. Log them with dev_dbg() instead, so dynamic debug still shows them. -ENODEV from the EDID copy now means no EDID source for any connector, not only the internal panel. A copy or publication failure with any other error is a real problem and is now a warning. No functional change. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
Comments, function names and a few messages in the H17P support still use the language of its bring-up: "measured" profiles, "qualified" loaders and sequences, an "unqualified" callback, the "USB4 PHY experiment". They tell a reader nothing beyond the code next to them, and "unqualified" in an error suggests a state the driver could get out of rather than an unsupported request. Say what is meant instead: the H17P profile, a known or unknown sequence, an unsupported callback or request, the J700 defaults. Rename dptxport_call_qualified_config() and dptxport_qualified_teardown() after what they do. No functional change. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
atcphy_enable_dp_aux() logged "Applied T8140 DisplayPort setup lists" once per boot. It comes from enabling the AUX channel, not from where the setup lists are applied, and it reports nothing a user needs. atc_tunnel_start_t602x() logged four raw register values at info level on every tunnel clock preflight. They only help when a preflight is refused, so log them with dev_dbg(). No functional change. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
atc_tunnel_restore(), atc_tunnel_start_t602x() and the T602X tunnel rate code write raw masks where the fields already have names: 0x54 and BIT(2), BIT(4), BIT(6) are the AUSPLL_CLKOUT_MASTER output drivers, the ACIOPHY_SLEEP_CTRL values are the TX_SMALL, TX_BIG and TX_CLAMP fields and their overrides, and 0xc00, 0xc0 and 0xc000 in ACIOPHY_CFG0 are RX_BIG, RX_SMALL and RX_CLAMP. The comments calling the last three "additional override bits" of unconfirmed meaning were wrong; the sequence is the same one atc_tunnel_wake_t8103() writes for the TX and RX lanes. Use the names. No functional change: every write is the same value. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
atc_tunnel_start_t8103() mapped the DP link rate code to the pixel clock selector with its own switch, a copy of atc_tunnel_rate_selector() used by the T602X code. Move the helper up and use it for both. No functional change. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
Align the readl_poll_timeout() continuations in the tunnel clock code with the open parenthesis and drop a doubled blank line after the J700 AUX register definitions, as checkpatch asks. No functional change. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
atcphy_configure() takes the USB3 PHY out of reset after the lane configuration, while the Asahi driver this is based on carries a note that the reference sequence releases the reset earlier, and that the order is the first thing to revisit if a mode does not come up. The note was lost when the J700 paths were added; put it back. No functional change. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Display (DCP) system-sleep fixes for the J700, plus a DisplayPort polish pass.
Resume with an external display (bug fix, MED). With a DP sink at a mode that needs link training (for example 1080p180), every resume failed with
drm_mode_config_helper_resume: -22, and the external output did not come back until a replug.Sleep wake storm (MED/HIGH). During s2idle the internal DCP kept publishing per-frame messages at about 62 interrupts/s, which drains the battery.
Polish (LOW/MED).
-ENOSPC, and transient states as-EAGAIN. The CD321x driver skips the retry only for-ENOSPC, so a port no longer loses its display on a transient-EBUSY(helper + KUnit).Regression tests
dcp-s2idle-regress.sh(display agent; unattended, RTC s2idle with eDP and DP at 1080p180). Before this series:-22on every resume with the external display, and about 62 DCP mailbox IRQ/s in sleep. After: 6/6 cycles per run on every qualification boot with 0-22, outputs back within 1 s, internal panel flipping (77–91 per 2 s), 0 DCP errors, and about 3 IRQ/s over a 30 s sleep (about 90 per cycle whatever the sleep length; 0.27/s on a 360 s sleep).-ENOSPCcase) passes.copy_edid failed: -ENODEVon resume (0 lines over a full qualification run).Risk
Not included
j700/dcp-s2idlestill contains them and is superseded by this PR.Needs Ryan (attended)
Hardware qualification (MacBook Neo J700, 2026-10-15)
This series was qualified on the Neo inside the 2026-10-15 release stack: aurora-wip ac89582 plus, in merge order, tipd polish, input polish, speaker KUnit, SEP (#303), DCP sleep fixes, platform polish, audio polish, radio polish, power polish and fixes, and storage polish. It used the published 5f config with LLVM=1 and clang 22, and modules installed with INSTALL_MOD_STRIP=1. Each test was a one-shot GRUB boot. The saved default stayed on the public 5f kernel. The DTB came from Stage 2 and was not changed.
Results on the release kernels (7.1.12-aurora-rel-g257ca7bed, then -g3faecd4f7 with audio and radio added), and on the earlier integration kernels that also carried the held USB wake line (-integ-ge78a80fd8, -g07a8a7ff4, -g32b5436bd):
runningwith no failed units.neo-public5f-20261015). No new kernel warning types appeared. These went away as expected: dockchannel "keyboard is not initialized", AOP "Unknown oslog message", and the PMGR "always-on domain ... not on at boot" ×8 (now info).dcp-s2idle-regress.sh 6 30 5, 6/6 cycles per run, 3 runs. The DCP mailbox rate in s2idle was about 3 IRQ/s, down from about 62/s.tools/aurora-wake/s2idle-rtc-regression.sh -c 5 -s 20passed 5/5 per run. W1 ran 10 RTC cycles with the lsusb count steady at 13, and no "HC died", Host System Error or DART fault.Evidence:
/Volumes/AuroraS500/aurora-ctl/artifacts/integ-20261015/(per-boot dmesg, journal and checks; scripts are inscripts/).🤖 Generated with Claude Code