From 4becf74298599d4e210b91bc19074f5333f362c0 Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Wed, 25 Nov 2026 09:37:29 +0100 Subject: [PATCH] drm/apple: T6041 S2R: no second power-off for a display DPMS already turned off A lid close blanks the internal panel before the sleep: the desktop's DPMS off runs set_power_state(0) on the internal DCP, and its D572(0) comes then, while s2r_active is clear. The S2R display stop then sent a second set_power_state(0), which gets no D572, and failed the suspend: apple-dcp 402e00000.dcp: no D572 after the power-off apple-drm display-subsystem: PM: failed to suspend: error -110 so on the J614c every lid sleep was refused, and systemd retried every 30 s while the lid stayed closed. rtcwake with the panel lit was not affected. Remember that the firmware confirmed the scanout stop of a power-off (pipe_off), until the next power-on starts. When the S2R stop finds the pipe already off, skip the second power-off and its D572 wait, and turn the display DART's streams off as that D572(0) would have. If the stop fails later, the unwind turns them on again. Fixes: 4af660c74e44 ("drm/apple: T6041 S2R display stop and warm restart") Signed-off-by: Jos Dehaes --- drivers/gpu/drm/apple/dcp-internal.h | 5 ++++ drivers/gpu/drm/apple/dcp.c | 41 +++++++++++++++++++------- drivers/gpu/drm/apple/iomfb_template.c | 7 +++-- 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp-internal.h b/drivers/gpu/drm/apple/dcp-internal.h index cb77aa8eabd5a..c141dea63e21e 100644 --- a/drivers/gpu/drm/apple/dcp-internal.h +++ b/drivers/gpu/drm/apple/dcp-internal.h @@ -928,6 +928,11 @@ struct apple_dcp { bool s2r_stopped; /* DPMS off stopped the firmware and lowered the domains; DPMS on brings them back. */ bool dpms_powered_off; + /* + * The firmware confirmed the scanout stop of a set_power_state(0) and no power-on has + * started since: its D572(0) has come and gone, and a second set_power_state(0) gets none. + */ + bool pipe_off; /* Refused its idle with the display off: the firmware still runs, the display is dark. */ bool s2r_refused_off; /* The firmware's secure mailbox, where it has one. */ diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index 4e48c4574624f..df54c7d124607 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -11041,6 +11041,8 @@ static int dcp_t6041_stop_one(struct device *dev, void *data) struct task_struct *poller; bool keep_set = false; bool powered_off = false; + /* The display DART's streams turned off here, not by a D572(0). */ + bool streams_off = false; bool idle_attempted = false; bool idle; u32 ctrl, status; @@ -11094,18 +11096,35 @@ static int dcp_t6041_stop_one(struct device *dev, void *data) * (axi_rd_err, 11 Nov). Without D572(0) abort sleep instead of tearing down domains * while scanning out. */ - reinit_completion(&dcp->s2r_dart_done); - WRITE_ONCE(dcp->s2r_active, true); - _dcp_poweroff(dcp); - powered_off = true; - if (!wait_for_completion_timeout(&dcp->s2r_dart_done, - msecs_to_jiffies(DCP_S2R_D572_TIMEOUT_MS))) { + /* + * A DPMS off before the sleep (the desktop blanking on a lid close) already ran + * set_power_state(0), and its scanout stop was confirmed: its D572(0) came then, + * while s2r_active was clear, and a second set_power_state(0) gets none. Turn the + * display DART's streams off as that D572(0) would have; the pipe no longer scans + * out. + */ + if (READ_ONCE(dcp->pipe_off)) { + dev_info(dev, "display already off: no second power-off\n"); + if (dcp->s2r_disp_dart) { + apple_dart_display_streams(dcp->s2r_disp_dart, + DCP_S2R_DISP_STREAMS, false, false); + streams_off = true; + } + } else { + unsigned long d572 = msecs_to_jiffies(DCP_S2R_D572_TIMEOUT_MS); + + reinit_completion(&dcp->s2r_dart_done); + WRITE_ONCE(dcp->s2r_active, true); + _dcp_poweroff(dcp); + powered_off = true; + if (!wait_for_completion_timeout(&dcp->s2r_dart_done, d572)) { + WRITE_ONCE(dcp->s2r_active, false); + dev_err(dev, "no D572 after the power-off\n"); + ret = -ETIMEDOUT; + goto err_unwind; + } WRITE_ONCE(dcp->s2r_active, false); - dev_err(dev, "no D572 after the power-off\n"); - ret = -ETIMEDOUT; - goto err_unwind; } - WRITE_ONCE(dcp->s2r_active, false); if (read_poll_timeout(iomfb_channels_idle, idle, idle, 1000, 200000, false, dcp)) { dev_err(dev, "display calls still in flight after the power-off\n"); ret = -ETIMEDOUT; @@ -11205,7 +11224,7 @@ static int dcp_t6041_stop_one(struct device *dev, void *data) apple_dart_display_keep(dcp->s2r_dcp_dart, DCP_S2R_DCP_STREAMS, false); } - if (powered_off && dcp->s2r_disp_dart) + if ((powered_off || streams_off) && dcp->s2r_disp_dart) apple_dart_display_streams(dcp->s2r_disp_dart, DCP_S2R_DISP_STREAMS, true, false); } diff --git a/drivers/gpu/drm/apple/iomfb_template.c b/drivers/gpu/drm/apple/iomfb_template.c index 88c303630aae0..7fa70dc175ff6 100644 --- a/drivers/gpu/drm/apple/iomfb_template.c +++ b/drivers/gpu/drm/apple/iomfb_template.c @@ -2573,6 +2573,7 @@ void DCP_FW_NAME(iomfb_poweron)(struct apple_dcp *dcp) u32 handle; #endif dev_info(dcp->dev, "dcp_poweron() starting\n"); + WRITE_ONCE(dcp->pipe_off, false); #if DCP_FW_H17(DCP_FW_VER) if (dcp_is_ext26(dcp)) return; /* Native26 publishes A473 only after a successful A413. */ @@ -3004,10 +3005,12 @@ void DCP_FW_NAME(iomfb_poweroff)(struct apple_dcp *dcp) dev_dbg(dcp->dev, "setPowerState(0) finished with %d ms to spare", jiffies_to_msecs(ret)); - if (dcp_power_stop_confirmed(poff_cookie)) + if (dcp_power_stop_confirmed(poff_cookie)) { dcp_release_all_retained_framebuffers(dcp); - else + WRITE_ONCE(dcp->pipe_off, true); + } else { dev_warn(dcp->dev, "scanout stop was not confirmed\n"); + } } kref_put(&poff_cookie->refcount, release_wait_cookie);