From 9e707546362e402687c50246402638eea4b0564b Mon Sep 17 00:00:00 2001 From: Kyle Arrington Date: Sun, 15 Nov 2026 13:21:56 -0600 Subject: [PATCH] drm/apple: stop the DCP firmware for a suspend-to-idle too With hw.s2r a DPMS off stops the internal display's firmware and powers its domains off, and a firmware-driven sleep stops it from the DCP's own suspend. A suspend-to-idle does neither. The DRM device's suspend turns the CRTC off, which arrives as a DPMS off, but dcp_dpms_power_cycles() refuses during any system sleep, so only the backlight goes down and the firmware runs for the whole sleep. It is only stopped if the compositor blanked the display before suspending. Let the DPMS power cycle run during a sleep that is not firmware-driven. The resume side needs nothing new: the DRM device's resume turns the CRTC on, and dcp_dpms_power_on() starts the firmware again as after any DPMS off. In the DCP's own suspend a suspend-to-idle takes the generic path, which already copes with firmware that DPMS stopped: it is the state a compositor that blanks before suspending leaves. Crashed firmware is still refused there, as for any DPMS off. dcp_s2r_stops_crashed() asked only for a system sleep, which was the same thing while DPMS off never ran in one; it now asks for a firmware-driven sleep, so its two callers behave as before. On this tree only T8140 has hw.s2r, so that is the SoC this changes today, and it has not run there. It has run on a J813 (T8142, firmware 27.0) with the T8142 firmware stop from the pull request below applied (appledrm.s2r_untested=1). Test suspends with pm_test=platform and pm_test_delay 60 and 120 (devices suspended, the SoC held short of the idle loop), on battery, display on before each: before: 1.53 W, 1.53 W, 1.55 W; the firmware runs through the sleep after: 0.53 W, 0.58 W, 0.57 W; "IOMFB: power on -> off" inside the suspend, "RTKit: Initializing" and "power off -> on" inside the resume, panel and backlight back The stop adds 146 ms to the suspend and the start 57 ms to the resume. With the display already off by DPMS nothing changes (0.51 W, restart at the next DPMS on). A real suspend-to-idle and a crashed firmware were not run. Link: https://github.com/aurora-silicon/linux/pull/1941 Assisted-by: Claude Fable 5.2 Signed-off-by: Kyle Arrington --- drivers/gpu/drm/apple/dcp.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index 21a0c8a822294..6de8f544ab345 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -7790,12 +7790,13 @@ static void dcp_s2r_restart_failed_stop(struct apple_dcp *dcp); /* * Crashed firmware takes no stop sequence, and refusing would hold every later sleep off until * reboot. Its CPU stops cold, as for a failed start, and the wake starts it again, as macOS - * recovers a crashed DCP. A system sleep only: DPMS off still refuses it. + * recovers a crashed DCP. A firmware-driven sleep only: DPMS off still refuses it, the DPMS + * off of a suspend-to-idle included. */ static bool dcp_s2r_stops_crashed(struct apple_dcp *dcp) { return READ_ONCE(dcp->crashed) && !IS_ERR_OR_NULL(dcp->rtk) && - pm_suspend_target_state != PM_SUSPEND_ON; + pm_suspend_target_state != PM_SUSPEND_ON && pm_suspend_via_firmware(); } static int dcp_s2r_stop_crashed(struct apple_dcp *dcp) @@ -8558,11 +8559,17 @@ static void dcp_s2r_restart_failed_stop(struct apple_dcp *dcp) /* * DPMS on an internal panel with hw.s2r as macOS does a display sleep: the backlight to 0, * then the firmware stopped and the display domains off, and the reverse on wake. Not - * during a system sleep: that path stops the firmware itself. + * during a firmware-driven system sleep: that path stops the firmware itself. + * + * A suspend-to-idle has no such path. Its CRTC goes off from the DRM device's suspend, which + * comes here as a DPMS off: without the power-off the firmware would run through the whole + * sleep unless the compositor had blanked the display first. The flag is only current while + * a sleep is under way. */ static bool dcp_dpms_power_cycles(struct apple_dcp *dcp) { - return dcp_s2r_capable(dcp) && pm_suspend_target_state == PM_SUSPEND_ON; + return dcp_s2r_capable(dcp) && + (pm_suspend_target_state == PM_SUSPEND_ON || !pm_suspend_via_firmware()); } static void __dcp_dpms_power_off(struct apple_dcp *dcp)