From fd5cc59f4794996418384f7c784235e4615ed951 Mon Sep 17 00:00:00 2001 From: Erik Bourget Date: Sun, 15 Nov 2026 22:59:54 -0500 Subject: [PATCH 1/7] drm/apple: v27: the T6050 sleep transport on the J716c Let the J716c's display coprocessors use the sleep endpoint transport of DCP firmware 27.0.0 that the J714s uses: the sleep endpoints' inventory, their open and close controls and the replies to them. A new per-processor flag, v27_sleep_transport, gates that path; it is set on the J714s as before, and on the J716c for a T6050 display coprocessor that adopts a live session, uses the default method table and runs firmware 27.0.0. The J714s's normal method table and panel profile stay J714s only. The transport also gets stricter about the endpoints it hands out: a superseded endpoint's release no longer clears its replacement, a control is refused while a reply has failed or is pending, and the auxiliary sleep endpoints are quiesced at unbind. A cancelled suspend without a firmware resume no longer restarts the display coprocessors: they keep their running firmware session. Developed with Claude Code. Signed-off-by: Erik Bourget --- drivers/gpu/drm/apple/afk.c | 29 ++++++++++----- drivers/gpu/drm/apple/dcp-internal.h | 8 ++--- drivers/gpu/drm/apple/dcp-v27-sleep.inc | 17 +++++---- drivers/gpu/drm/apple/dcp.c | 48 +++++++++++++++++++++---- 4 files changed, 75 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/apple/afk.c b/drivers/gpu/drm/apple/afk.c index c08084877a151..36f82f6ba9315 100644 --- a/drivers/gpu/drm/apple/afk.c +++ b/drivers/gpu/drm/apple/afk.c @@ -92,6 +92,10 @@ static void afk_release_context(void *data) struct apple_dcp_afkep *afkep = data; afk_quiesce(afkep); + /* A superseded endpoint's devres must not erase its replacement route. */ + if (afkep->dcp->v27_sleep_transport && + afkep->endpoint >= 0x20 && afkep->endpoint < 0x40) + cmpxchg(&afkep->dcp->sleep_v27_ep[afkep->endpoint - 0x20], afkep, NULL); if (!afkep->dcp->retain_dma) { kvfree(afkep->command_tags); kfree(afkep); @@ -135,8 +139,7 @@ struct apple_dcp_afkep *afk_init(struct apple_dcp *dcp, u32 endpoint, if (ret) return ERR_PTR(ret); - if (IS_ENABLED(CONFIG_APPLE_SOC_SLEEP) && - dcp->v27_j714s && endpoint >= 0x20 && endpoint < 0x40) + if (dcp->v27_sleep_transport && endpoint >= 0x20 && endpoint < 0x40) WRITE_ONCE(dcp->sleep_v27_ep[endpoint - 0x20], afkep); return afkep; @@ -1113,7 +1116,7 @@ static void afk_compact_reply_worker(struct work_struct *work) dev_err(r->ep->dcp->dev, "AFK[ep:%02x]: failed to reply to compact service call: %d\n", r->ep->endpoint, ret); - if (ret && r->ep->dcp->v27_j714s) { + if (ret && r->ep->dcp->v27_sleep_transport) { guard(spinlock_irqsave)(&r->ep->lock); r->ep->sleep_poisoned = true; } @@ -1510,12 +1513,18 @@ int afk_v27_sleep_control(struct apple_dcp_afkep *ep, bool open) int ret; if (!IS_ENABLED(CONFIG_APPLE_SOC_SLEEP) || - !ep || ep->dcp->fw_compat != DCP_FIRMWARE_V_27_0) + !ep || !ep->dcp->v27_sleep_transport || + ep->dcp->fw_compat != DCP_FIRMWARE_V_27_0) return -EOPNOTSUPP; ret = afk_v27_sleep_check(ep); if (ret) return ret; spin_lock_irqsave(&ep->lock, flags); + /* A callback reply may have failed since the inventory check. */ + if (ep->stopping || ep->sleep_poisoned || ep->sleep_waiting) { + ret = -EBUSY; + goto out; + } if (ep->sleep_closed == !open) { ret = -EALREADY; goto out; @@ -1713,14 +1722,15 @@ static void afk_recv_handle_init(struct apple_dcp_afkep *ep, u32 channel, ep->dcp->fw_compat == DCP_FIRMWARE_V_27_0); if (ret == -ENOENT && (ep->dcp->hw.iomfb_method_profile == DCP_IOMFB_METHODS_H17G || - ep->dcp->v27_j714s)) { + ep->dcp->v27_j714s || + (ep->dcp->v27_sleep_transport && !strcmp(name, "md-manager")))) { /* * M5 (H17G) announces powerlog-service with only * ep-has-desc-mgr and interface-id, and firmware 27 * its descriptor manager (md-manager) without EPIC * keys; match them by the announced name, as for - * props-less announces. The second on the J714s only, - * where its endpoints are started. + * props-less announces. J716c admits only md-manager + * here; its normal service matching stays unchanged. */ epic_name = NULL; epic_class = NULL; @@ -2415,7 +2425,7 @@ static bool afk_v27_sleep_reply(struct apple_dcp_afkep *ep, u32 channel, u8 code; if (!IS_ENABLED(CONFIG_APPLE_SOC_SLEEP) || - !ep->dcp->v27_j714s || channel || type || + !ep->dcp->v27_sleep_transport || channel || type || size != 12 || get_unaligned_le32(data + 4) != 4 || get_unaligned_le16(data + 2)) return false; @@ -2423,7 +2433,8 @@ static bool afk_v27_sleep_reply(struct apple_dcp_afkep *ep, u32 channel, if (code != 3 && code != 5) return false; spin_lock_irqsave(&ep->lock, flags); - if (ep->sleep_waiting && code == ep->sleep_expected) { + if (!ep->stopping && !ep->sleep_poisoned && + ep->sleep_waiting && code == ep->sleep_expected) { ep->sleep_waiting = false; ep->sleep_closed = code == 3; complete(&ep->sleep_done); diff --git a/drivers/gpu/drm/apple/dcp-internal.h b/drivers/gpu/drm/apple/dcp-internal.h index 97b0db066bb93..22c66670c662d 100644 --- a/drivers/gpu/drm/apple/dcp-internal.h +++ b/drivers/gpu/drm/apple/dcp-internal.h @@ -722,12 +722,10 @@ struct apple_dcp { /* A firmware-driven suspend stops the firmware, see dcp_s2r_suspend(). */ struct apple_dcp_afkep *sleep_v27_ep[0x20]; - /* - * Firmware 27.0 on the J714s, the board the firmware 27 sleep and what it needs of the - * shared paths have run on. Every other machine on firmware 27, other T6050 boards and - * T8142 included, takes the paths it took before. - */ + /* The J714s normal method table, panel services and swap profile. */ bool v27_j714s; + /* Sleep endpoint inventory and control replies; not a normal RPC profile. */ + bool v27_sleep_transport; struct dcp_v27_sleep *sleep_v27; bool sleep_v27_closed; /* diff --git a/drivers/gpu/drm/apple/dcp-v27-sleep.inc b/drivers/gpu/drm/apple/dcp-v27-sleep.inc index 432ada48de987..c0ccea648573f 100644 --- a/drivers/gpu/drm/apple/dcp-v27-sleep.inc +++ b/drivers/gpu/drm/apple/dcp-v27-sleep.inc @@ -261,6 +261,9 @@ static int dcp_v27_rtkit_cycle(struct apple_dcp *dcp, unsigned int pause_ms) u32 status, run_status = 0; int ret; + /* A cancelled suspend must keep the inherited firmware session running. */ + if (!pm_resume_via_firmware()) + return -EPERM; if (s && s->cycle_failed) return -ECANCELED; dcp_v27_sessions(dcp, false); @@ -388,7 +391,7 @@ static int dcp_v27_rtkit_cycle(struct apple_dcp *dcp, unsigned int pause_ms) static bool dcp_v27_sleep_selected(struct apple_dcp *dcp) { - return apple_sleep_v27_late() && + return apple_sleep_v27_late() && dcp->v27_sleep_transport && (of_device_is_compatible(dcp->dev->of_node, "apple,t6050-dcp") || of_device_is_compatible(dcp->dev->of_node, "apple,t6050-dcpext")) && dcp->hw.adopt_live_session && dcp->fw_compat == DCP_FIRMWARE_V_27_0 && @@ -579,7 +582,7 @@ static unsigned long dcp_v27_ext_round(struct apple_dcp *dcp) * sessions opened. Here with its DART, PMC bits and power words as there * (dcp_v27_rtkit_cycle()), and without the pause. */ - if (v27_ext_cycles) { + if (pm_resume_via_firmware() && v27_ext_cycles) { int ret = dcp_v27_ext_cycle_ready(dcp); if (!ret) { @@ -1058,10 +1061,12 @@ static int dcp_v27_disp_dart_release(struct dcp_v27_sleep *s) return ret; } -/* Normal process-context cancellation: firmware was NEVER idled or stopped. */ +/* Reopen after cancellation, or after restarting the firmware on a real wake. */ static int dcp_v27_reopen_live(struct apple_dcp *dcp) { struct dcp_v27_sleep *s = dcp->sleep_v27; + /* Wake-only cycles must not stop firmware while undoing preparation. */ + unsigned int cycles = pm_resume_via_firmware() ? v27_rtkit_cycles : 0; unsigned int i; bool per_call; int ret; @@ -1086,7 +1091,7 @@ static int dcp_v27_reopen_live(struct apple_dcp *dcp) /* A500's wake form first; its failure does not stop the power-on. */ iomfb_v27_sleep_rpc(dcp, true, true); /* The wake's one restart: the rest of the wake runs in the session it starts. */ - if (s->soft_off && v27_rtkit_cycles >= 1) + if (s->soft_off && cycles >= 1) dcp_v27_rtkit_cycle(dcp, 0); if (s->soft_off && v27_a115) iomfb_v27_sleep_call(dcp, "A489", NULL, 0, 4); @@ -1101,7 +1106,7 @@ static int dcp_v27_reopen_live(struct apple_dcp *dcp) dev_warn(dcp->dev, "V27 wake: A115(1): %d\n", ret); } /* The dark-wake forms only: a restart, or a pause, before the display stage. */ - if (v27_rtkit_cycles >= 2) { + if (cycles >= 2) { iomfb_v27_sleep_rpc(dcp, true, true); dcp_v27_rtkit_cycle(dcp, v27_lit_delay_ms); } else if (v27_lit_delay_ms) { @@ -1115,7 +1120,7 @@ static int dcp_v27_reopen_live(struct apple_dcp *dcp) * Back to back with the hard power-on; only the dark-to-lit form idles * the DCP, with A500 first, between the calls. */ - per_call = v27_rtkit_cycles >= 3; + per_call = cycles >= 3; if (!per_call) dcp_v27_sessions(dcp, true); dcp_v27_display_stage(dcp, per_call, per_call && v27_session_rounds, per_call); diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index df6a8e976455e..9657f83bb8fbc 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -1514,10 +1514,12 @@ static void dcp_delayed_vblank(struct work_struct *work) static struct apple_dcp_afkep *dcp_afkep(struct apple_dcp *dcp, u8 endpoint) { - if (IS_ENABLED(CONFIG_APPLE_SOC_SLEEP) && - dcp->v27_j714s && endpoint >= 0x20 && endpoint < 0x40 && - READ_ONCE(dcp->sleep_v27_ep[endpoint - 0x20])) - return READ_ONCE(dcp->sleep_v27_ep[endpoint - 0x20]); + if (dcp->v27_sleep_transport && endpoint >= 0x20 && endpoint < 0x40) { + struct apple_dcp_afkep *ep = READ_ONCE(dcp->sleep_v27_ep[endpoint - 0x20]); + + if (ep) + return ep; + } /* The auxiliary endpoints of a desktop 26.x processor. */ if (dcp->fw_compat == DCP_FIRMWARE_V_26_6_DESKTOP && endpoint >= 0x20 && endpoint < 0x40) { @@ -1670,8 +1672,7 @@ static void dcp_recv_msg(void *cookie, u8 endpoint, u64 message) if (READ_ONCE(dcp->ext_dead)) return; /* Include traffic hidden by the fail-stop logging branch below. */ - if (IS_ENABLED(CONFIG_APPLE_SOC_SLEEP) && - dcp->v27_j714s && endpoint >= 0x20 && + if (dcp->v27_sleep_transport && endpoint >= 0x20 && endpoint != IOMFB_ENDPOINT && !dcp_afkep(dcp, endpoint)) WRITE_ONCE(dcp->sleep_v27_unhandled, true); @@ -1700,7 +1701,7 @@ static void dcp_recv_msg(void *cookie, u8 endpoint, u64 message) } ret = afk_receive_message(ep, message); - if (ret && IS_ENABLED(CONFIG_APPLE_SOC_SLEEP) && dcp->v27_j714s) + if (ret && dcp->v27_sleep_transport) WRITE_ONCE(dcp->sleep_v27_unhandled, true); } @@ -5505,6 +5506,34 @@ static int dcp_read_fw_version(struct device *dev, const char *name, return len; } +/* + * J716c shares the 27.0 endpoint-control wire format, not the J714s normal + * IOMFB method or panel profile. Establish this before RTKit can receive any + * application traffic, including traffic that invalidates a later inventory. + */ +static bool dcp_v27_sleep_transport_supported(struct apple_dcp *dcp) +{ + struct device *dev = dcp->dev; + char compat[DCP_FW_VERSION_STR_LEN]; + + if (!IS_ENABLED(CONFIG_APPLE_SOC_SLEEP)) + return false; + if (dcp->v27_j714s) + return true; + if (!of_machine_is_compatible("apple,j716c") || + !of_machine_is_compatible("apple,t6050") || + !(of_device_is_compatible(dev->of_node, "apple,t6050-dcp") || + of_device_is_compatible(dev->of_node, "apple,t6050-dcpext")) || + !dcp->hw.adopt_live_session || + dcp->hw.iomfb_method_profile != DCP_IOMFB_METHODS_DEFAULT || + dcp->fw_compat != DCP_FIRMWARE_V_27_0) + return false; + + /* The enum also covers later 27.x method tables. */ + return dcp_read_fw_version(dev, "apple,firmware-compat", compat) >= 0 && + !strcmp(compat, "27.0.0"); +} + static enum dcp_firmware_version dcp_check_firmware_version(struct device *dev) { const struct apple_dcp_hw_data *hw = of_device_get_match_data(dev); @@ -6336,6 +6365,10 @@ VISIBLE_IF_KUNIT void dcp_comp_unbind(struct device *dev, struct device *main, v afk_quiesce(dcp->ibootep); afk_quiesce(dcp->systemep); afk_quiesce(dcp->dcpavservep); + /* Auxiliary sleep endpoints retain DMA too, but must drain host work. */ + if (dcp->v27_sleep_transport) + for (int i = 0; i < ARRAY_SIZE(dcp->sleep_v27_ep); i++) + afk_quiesce(READ_ONCE(dcp->sleep_v27_ep[i])); cancel_delayed_work_sync(&dcp->bl_fallback_wq); dcp_backlight_stop(dcp); if (dcp->connector_type == DRM_MODE_CONNECTOR_eDP) { @@ -6737,6 +6770,7 @@ static int dcp_platform_probe_pipe(struct platform_device *pdev) if (fw_compat == DCP_FIRMWARE_V_27_0 && of_device_is_compatible(dev->of_node, "apple,t8142-dcp")) dcp->hw.iomfb_method_profile = DCP_IOMFB_METHODS_DEFAULT; + dcp->v27_sleep_transport = dcp_v27_sleep_transport_supported(dcp); /* The display such a processor finds at boot is its first sink. */ if (dcp_sink_metadata(dcp)) dcp_desktop_metadata_new_sink(dcp); From d2ff12e2b2d3c26c2c566deb4b9c383a794ef67c Mon Sep 17 00:00:00 2001 From: Erik Bourget Date: Mon, 16 Nov 2026 00:02:12 -0500 Subject: [PATCH 2/7] drm/apple: dcp-fabric: release a torn-down tunnel route for a sleep With a USB4 router that sleeps in place, the router's sleep entry tears down its DP IN displays (the DPTX port disconnected, the tunnel clock stopped) but leaves the tunnel route owned, and the display coprocessor's sleep then refused it as a tunnelled display. Release such a route as a DP IN detach does: retire its Thunderbolt binding and deactivate it. The coprocessor then sleeps as an idle one, and the router hands the display back after the wake. A tunnelled display still connected still refuses. Developed with Claude Code. Signed-off-by: Erik Bourget --- drivers/gpu/drm/apple/dcp-fabric.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp-fabric.c b/drivers/gpu/drm/apple/dcp-fabric.c index 824df5f341022..cf7683fe6d8f4 100644 --- a/drivers/gpu/drm/apple/dcp-fabric.c +++ b/drivers/gpu/drm/apple/dcp-fabric.c @@ -4869,8 +4869,22 @@ int dcp_fabric_sleep_release(struct apple_dcp *dcp, s64 ms[2]) if (!route) return 0; port = route->port; - if (route->tunnel || port->owner != route || port->secondary_owner || - port->split_dcp) + /* + * A USB4 router that sleeps in place has its DP IN's display torn down + * at its entry (the DPTX port disconnected, the tunnel clock stopped), + * but the tunnel route stays owned. Release it as a DP IN detach does; + * the router hands the display back once the sleep is over. + */ + if (route->tunnel) { + if (READ_ONCE(dcp->dptxport[0].connected) || port->split_dcp) + return -EBUSY; + dcp_tb_binding_retire(dcp, route); + start = ktime_get(); + ret = dcp_typec_route_deactivate(route); + ms[1] = ktime_ms_delta(ktime_get(), start); + return ret ?: 1; + } + if (port->owner != route || port->secondary_owner || port->split_dcp) return -EBUSY; if (port->safe_pending) return -EAGAIN; From 38d7486c131571a8ba296bd48b8909152b4c7112 Mon Sep 17 00:00:00 2001 From: Erik Bourget Date: Mon, 16 Nov 2026 00:29:06 -0500 Subject: [PATCH 3/7] drm/apple: v27 sleep: open an external processor's AV interfaces on 0x2b The sleep step starts every endpoint it closes. On a board whose external display processors have no DP audio (J716c), nothing had started endpoint 0x2b before, so it came up with no services. From then on the firmware announces its compact AV interfaces there at each plug (dispextN:dcpav-video-interface-, -audio-interface-), nothing matches them, and the unanswered announcement holds the plug: a display routed back through its DP tunnel after the wake never gets its HPD. Serve 0x2b as 0x29/0x2a are: open the video, audio and CEC interfaces when announced, one of each live, replaced at the next plug. Developed with Claude Code. Signed-off-by: Erik Bourget --- drivers/gpu/drm/apple/dcp-v27-sleep.inc | 35 ++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp-v27-sleep.inc b/drivers/gpu/drm/apple/dcp-v27-sleep.inc index c0ccea648573f..320cfc2d768fa 100644 --- a/drivers/gpu/drm/apple/dcp-v27-sleep.inc +++ b/drivers/gpu/drm/apple/dcp-v27-sleep.inc @@ -912,6 +912,30 @@ static const struct apple_epic_service_ops dcp_v27_ext_services[] = { {}, }; +static void dcp_v27_ext_av_teardown(struct apple_epic_service *service) +{ + afk_service_disable(service); +} + +/* + * The same holds for the AV interfaces (compact, cut to "dcpav-video-interface-" and + * so on) on endpoint 0x2b, which the sleep step starts when no audio did: left + * unanswered, the firmware never reports a display plugged after the sleep. One of + * each is live, re-announced at every plug. + */ +static const struct apple_epic_service_ops dcp_v27_ext_av_services[] = { + { .name = "dcpav-video-interface-epic", .compact_full = "dcpav-video-interface-epic:0", + .singleton = true, .init = dcp_v27_ext_service_init, + .teardown = dcp_v27_ext_av_teardown }, + { .name = "dcpav-audio-interface-epic", .compact_full = "dcpav-audio-interface-epic:0", + .singleton = true, .init = dcp_v27_ext_service_init, + .teardown = dcp_v27_ext_av_teardown }, + { .name = "dcpav-cec-interface-epic", .compact_full = "dcpav-cec-interface-epic:0", + .singleton = true, .init = dcp_v27_ext_service_init, + .teardown = dcp_v27_ext_av_teardown }, + {}, +}; + static void dcp_v27_ext_wq_destroy(void *data) { destroy_workqueue(data); @@ -931,8 +955,9 @@ static int dcp_v27_sleep_endpoints_open(struct apple_dcp *dcp) for (i = 0; i < ARRAY_SIZE(v27_sleep_endpoints); i++) { u8 id = v27_sleep_endpoints[i]; - bool served = s && dcp_v27_external(dcp) && t6050_ext_services && - (id == 0x29 || id == 0x2a); + bool ext = s && dcp_v27_external(dcp) && t6050_ext_services; + bool served = ext && (id == 0x29 || id == 0x2a); + const struct apple_epic_service_ops *ops = no_services; if (!apple_rtkit_has_endpoint(dcp->rtk, id)) return -ENODEV; @@ -945,7 +970,11 @@ static int dcp_v27_sleep_endpoints_open(struct apple_dcp *dcp) if (!s->ext_wq) return -ENOMEM; } - ep = afk_init(dcp, id, served ? dcp_v27_ext_services : no_services); + if (served) + ops = dcp_v27_ext_services; + else if (ext && id == AV_AUDIO_ENDPOINT_DESKTOP) + ops = dcp_v27_ext_av_services; + ep = afk_init(dcp, id, ops); if (IS_ERR(ep)) return PTR_ERR(ep); if (served) { From aee1f12795f47c226c9a98aed482cf3db0670fd6 Mon Sep 17 00:00:00 2001 From: Erik Bourget Date: Mon, 16 Nov 2026 05:42:03 -0500 Subject: [PATCH 4/7] drm/apple: v27 sleep: restart an external processor that took its sleep step An external display coprocessor whose sleep step completed (A484, A500, its sessions closed) and whose suspend was then refused by another device kept that firmware session: a display routed back to it through its DP tunnel was plugged by the firmware, which then went silent and never reported it. A real wake restarts every external processor once. Restart it the same way after such a refusal: the RTKit cycle and the external wake round now also run for a processor still prepared. On the J716c the restart needs the sleep controller's display power words, which the soc: apple: sleep change "a full deep-sleep profile for the J716c" serves there. Developed with Claude Code. Signed-off-by: Erik Bourget --- drivers/gpu/drm/apple/dcp-v27-sleep.inc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp-v27-sleep.inc b/drivers/gpu/drm/apple/dcp-v27-sleep.inc index 320cfc2d768fa..054cacf2f1f17 100644 --- a/drivers/gpu/drm/apple/dcp-v27-sleep.inc +++ b/drivers/gpu/drm/apple/dcp-v27-sleep.inc @@ -261,8 +261,12 @@ static int dcp_v27_rtkit_cycle(struct apple_dcp *dcp, unsigned int pause_ms) u32 status, run_status = 0; int ret; - /* A cancelled suspend must keep the inherited firmware session running. */ - if (!pm_resume_via_firmware()) + /* + * A cancelled suspend must keep the inherited firmware session running, unless it is an + * external processor's that already took its sleep step: that session does not report a + * display plugged again until it is restarted, as after a real wake. + */ + if (!pm_resume_via_firmware() && !(ext && s && s->phase == V27_PREPARED)) return -EPERM; if (s && s->cycle_failed) return -ECANCELED; @@ -582,7 +586,7 @@ static unsigned long dcp_v27_ext_round(struct apple_dcp *dcp) * sessions opened. Here with its DART, PMC bits and power words as there * (dcp_v27_rtkit_cycle()), and without the pause. */ - if (pm_resume_via_firmware() && v27_ext_cycles) { + if ((pm_resume_via_firmware() || dcp->sleep_v27->phase == V27_PREPARED) && v27_ext_cycles) { int ret = dcp_v27_ext_cycle_ready(dcp); if (!ret) { From 80e5781ad12c6e2ad9b5fb857fe978baa084b4b5 Mon Sep 17 00:00:00 2001 From: Erik Bourget Date: Mon, 16 Nov 2026 05:57:22 -0500 Subject: [PATCH 5/7] drm/apple: light the J716c panel again after its sleep step Without a panel size in the DT the driver did not treat the J716c's internal display as a panel: no backlight level was ever configured, and after the internal display coprocessor's sleep step (the firmware turns the backlight off) the panel stayed dark. The DT now gives the panel its size. Also queue the backlight fallback after any panel power-on that leaves the backlight unconfigured (an adopted, already running pipe got none), and refuse the internal coprocessor's sleep while no level is known. Developed with Claude Code. Signed-off-by: Erik Bourget --- drivers/gpu/drm/apple/dcp-v27-sleep.inc | 5 +++++ drivers/gpu/drm/apple/dcp.c | 13 ++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp-v27-sleep.inc b/drivers/gpu/drm/apple/dcp-v27-sleep.inc index 054cacf2f1f17..74247c3189156 100644 --- a/drivers/gpu/drm/apple/dcp-v27-sleep.inc +++ b/drivers/gpu/drm/apple/dcp-v27-sleep.inc @@ -1460,6 +1460,11 @@ static int dcp_v27_sleep_prepare(struct apple_dcp *dcp) } if (!dcp_v27_external(dcp) && !dcp->crtc) return -ENODEV; + /* The sleep turns the panel's backlight off: without a level it stays off after it. */ + if (!dcp_v27_external(dcp) && dcp_has_panel(dcp) && !dcp_backlight_active(dcp)) { + dev_info(dcp->dev, "V27 sleep: no backlight level to light the panel again\n"); + return -EBUSY; + } if (!dcp_v27_external(dcp) && !READ_ONCE(dcp->pipe_enabled_h17p)) return -EAGAIN; /* require the actual normal driver pipe-on ACK */ s->scanout = dcp->crtc ? dcp->crtc->base.dev->dev : NULL; diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index 9657f83bb8fbc..5a51e4d88bdff 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -4801,12 +4801,15 @@ void dcp_poweron(struct platform_device *pdev) WRITE_ONCE(dcp->crashed, true); return; } - /* The powerlog takeover report normally precedes this. */ - if (dcp_has_panel(dcp)) - queue_delayed_work(system_freezable_wq, - &dcp->bl_fallback_wq, - DCP_BL_FALLBACK_DELAY); } + /* + * The powerlog takeover report normally precedes this. A pipe adopted already + * running (J716c) gets none either: without a level, a panel the firmware turned + * off for a sleep could not be lit again. + */ + if (dcp_has_panel(dcp) && !dcp_backlight_active(dcp)) + queue_delayed_work(system_freezable_wq, &dcp->bl_fallback_wq, + DCP_BL_FALLBACK_DELAY); /* The loader report or fallback may initialize the policy later. */ if (!dcp_backlight_active(dcp)) return; From 0ad81c9ff69b33e6046c01ef32c716aeb089fadd Mon Sep 17 00:00:00 2001 From: Erik Bourget Date: Mon, 16 Nov 2026 06:02:25 -0500 Subject: [PATCH 6/7] drm/apple: v27 sleep: restart the internal processor after its sleep step After the internal display coprocessor's completed sleep step, a refused suspend left its firmware session in place: the panel's power-on then failed to open its video interface and its mode set and first present timed out, so the panel stayed dark. Restart it as a real wake does, like the external processors: the wake's RTKit cycle runs for a processor still prepared. Developed with Claude Code. Signed-off-by: Erik Bourget --- drivers/gpu/drm/apple/dcp-v27-sleep.inc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp-v27-sleep.inc b/drivers/gpu/drm/apple/dcp-v27-sleep.inc index 74247c3189156..19f8b5116bc2d 100644 --- a/drivers/gpu/drm/apple/dcp-v27-sleep.inc +++ b/drivers/gpu/drm/apple/dcp-v27-sleep.inc @@ -262,11 +262,11 @@ static int dcp_v27_rtkit_cycle(struct apple_dcp *dcp, unsigned int pause_ms) int ret; /* - * A cancelled suspend must keep the inherited firmware session running, unless it is an - * external processor's that already took its sleep step: that session does not report a - * display plugged again until it is restarted, as after a real wake. + * A cancelled suspend must keep the inherited firmware session running, unless the + * processor already took its sleep step: that session neither reports a display plugged + * again nor completes the panel's power-on until it is restarted, as after a real wake. */ - if (!pm_resume_via_firmware() && !(ext && s && s->phase == V27_PREPARED)) + if (!pm_resume_via_firmware() && !(s && s->phase == V27_PREPARED)) return -EPERM; if (s && s->cycle_failed) return -ECANCELED; @@ -1098,8 +1098,9 @@ static int dcp_v27_disp_dart_release(struct dcp_v27_sleep *s) static int dcp_v27_reopen_live(struct apple_dcp *dcp) { struct dcp_v27_sleep *s = dcp->sleep_v27; - /* Wake-only cycles must not stop firmware while undoing preparation. */ - unsigned int cycles = pm_resume_via_firmware() ? v27_rtkit_cycles : 0; + /* Undoing a partial preparation never stops the firmware; a completed sleep step does. */ + unsigned int cycles = pm_resume_via_firmware() || s->phase == V27_PREPARED ? + v27_rtkit_cycles : 0; unsigned int i; bool per_call; int ret; From 966a12179f9b417681a513887d958a12b12c59c9 Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Tue, 17 Nov 2026 14:21:27 -0500 Subject: [PATCH 7/7] selftests: apple-dcp: cover J716c sleep transport and DP-IN slot retirement Keep the host fixture declarations aligned with the production DCP fields. Cover clearing the released endpoint slot while preserving a replacement owner. The Clang build also checks the native AFK announcement fixtures. Signed-off-by: Diljit Singh --- tools/asahi/dcpext26-startup-tests.py | 2 +- .../selftests/drivers/gpu/apple-dcp/edid.py | 6 +++--- .../selftests/drivers/gpu/apple-dcp/recovery.py | 15 +++++++++++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/tools/asahi/dcpext26-startup-tests.py b/tools/asahi/dcpext26-startup-tests.py index 2774f4086a990..d6adc408d9b93 100644 --- a/tools/asahi/dcpext26-startup-tests.py +++ b/tools/asahi/dcpext26-startup-tests.py @@ -93,7 +93,7 @@ def run(name,code,reject=False): struct apple_epic_service_ops {const char *name;bool reusable,optional,open_later;int (*prepare)(struct apple_epic_service *,const char *,const char *,s64);int (*revalidate)(struct apple_epic_service *,const char *,const char *,s64);void (*init)(struct apple_epic_service *,const char *,const char *,s64);void (*teardown)(struct apple_epic_service *);void (*init_props)(struct apple_epic_service *,s64,const void *,size_t);}; struct apple_epic_service {struct apple_dcp_afkep *ep;const struct apple_epic_service_ops *ops;bool enabled,torndown,pending_open,defer_start;unsigned users;int lock;u32 channel;void *cookie;const char *pending_name,*pending_class;s64 pending_unit;int cmd_map[1];}; struct dptx_port {struct apple_epic_service *service;s64 unit;bool enabled,connected;int enable_completion;}; -struct apple_dcp {const void *push_out_prefill;bool native,ext26_services_open,v27_j714s;int fw_compat,index,dptx_controller_ready;struct {unsigned num_dptx_ports;int iomfb_method_profile;} hw;struct dptx_port dptxport[2];void *dev;struct apple_dcp_afkep *systemep,*ibootep,*dptx_controller_ep,*dcpavservep,*dptxep,*ext26_aux[3];}; +struct apple_dcp {const void *push_out_prefill;bool native,ext26_services_open,v27_j714s,v27_sleep_transport;int fw_compat,index,dptx_controller_ready;struct {unsigned num_dptx_ports;int iomfb_method_profile;} hw;struct dptx_port dptxport[2];void *dev;struct apple_dcp_afkep *systemep,*ibootep,*dptx_controller_ep,*dcpavservep,*dptxep,*ext26_aux[3];}; struct apple_dcp_afkep {struct apple_dcp *dcp;u32 endpoint,num_channels;bool wire_v2,stopping,match_epic_name,compact;int lock;void *wq,*service_work;const struct apple_epic_service_ops *ops;struct apple_epic_service services[AFK_MAX_CHANNEL];}; static bool dcp_is_ext26(struct apple_dcp *d){return d->native;} static bool dcp_fail_stop(struct apple_dcp *d){return d->native;} diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/edid.py b/tools/testing/selftests/drivers/gpu/apple-dcp/edid.py index 12683d28b9b0d..625c3d07c7b1d 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/edid.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/edid.py @@ -104,7 +104,7 @@ def function(file,signature): struct { bool lock,enabled;u64 epoch;int enable_completion;struct apple_epic_service *service,*opened; u64 opened_epoch,close_gen,terminated_epoch,close_epoch;bool opening;struct work_struct close_wq; } dcpavserv; /* A J714s firmware 27 processor's: this one is not. */ - bool v27_j714s; struct apple_dcp_afkep *panelav[0x20]; + bool v27_j714s, v27_sleep_transport; struct apple_dcp_afkep *sleep_v27_ep[0x20], *panelav[0x20]; }; '''+internal_inline(root,'dcp_fw_is_14_7')+internal_inline(root,'dcp_is_v14_7_external')+internal_inline(root,'dcp_is_v27_external')+r'''struct epic_cmd { u32 retcode;u64 rxbuf,txbuf;u32 rxlen,txlen; }; static unsigned int dma_frees,opens; @@ -651,7 +651,7 @@ def function(file, signature): void *dev; struct dcp_desktop_state { struct apple_dcp_afkep *graph[0x20]; } *desktop; /* A J714s firmware 27 processor's: none is one here. */ - bool v27_j714s, sleep_v27_unhandled; + bool v27_j714s, v27_sleep_transport, sleep_v27_unhandled; struct apple_dcp_afkep *sleep_v27_ep[0x20], *panelav[0x20]; }; struct drm_edid { int identity; }; @@ -891,7 +891,7 @@ def function(text, signature): struct { struct mutex lock; bool stopped; void *owner; } iomfb; struct dcp_desktop_state { struct apple_dcp_afkep *graph[0x20]; } *desktop; /* A J714s firmware 27 processor's: this one is not. */ - bool v27_j714s, sleep_v27_unhandled; + bool v27_j714s, v27_sleep_transport, sleep_v27_unhandled; struct apple_dcp_afkep *sleep_v27_ep[0x20], *panelav[0x20]; }; struct afk_receive_message_work { struct apple_dcp_afkep *ep; u64 message; struct work_struct work; }; diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/recovery.py b/tools/testing/selftests/drivers/gpu/apple-dcp/recovery.py index 01890f2c820bd..d9c1391897279 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/recovery.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/recovery.py @@ -51,7 +51,7 @@ def extract(text,signature): static void *dma_pool[2];static bool dma_busy[2];static unsigned int dma_cursor; static bool reuse_dma,ack_current,inject_late; static u8 current_reply[128],saved_reply[128];static size_t current_size,saved_size; - static u16 current_channel;static u8 current_tag; + static u16 current_channel __attribute__((unused));static u8 current_tag __attribute__((unused)); static void afk_v2_receive(struct apple_dcp_afkep *,u32,u32,const void *,size_t); static void *dma_alloc_coherent(void *dev,size_t n,dma_addr_t *address,int flags) { (void)dev;(void)flags;assert(n==32);void *p; @@ -312,6 +312,9 @@ def run(name,text,cases): static void destroy_workqueue(void *wq) { assert(wq && !destroyed);while(fifo_head) run_one_work();destroyed=true; } #define IS_ERR_OR_NULL(p) (!(p) || IS_ERR(p)) #define debugfs_remove_recursive(p) ((void)(p)) + #define cmpxchg(p,old,new) ({ __typeof__(*(p)) expected=(old); \ + __atomic_compare_exchange_n((p),&expected,(new),false,__ATOMIC_SEQ_CST,__ATOMIC_SEQ_CST); \ + expected; }) #define kzalloc(n,g) calloc(1,n) #define kvfree(p) free(p) #define ESHUTDOWN 108 @@ -415,8 +418,16 @@ def run(name,text,cases): afk_service_put(old);assert(!fifo_head && !old->users); assert(afk_receive_message(&ep,RBEP_RECV)==-ESHUTDOWN);assert(!fifo_head); afk_quiesce(&ep);assert(!fifo_head); - struct apple_dcp_afkep *empty=calloc(1,sizeof(*empty));assert(empty);empty->dcp=&d; + struct apple_dcp_afkep *empty=calloc(1,sizeof(*empty));assert(empty); + struct apple_dcp_afkep *replacement=calloc(1,sizeof(*replacement));assert(replacement); + empty->dcp=replacement->dcp=&d; + empty->endpoint=replacement->endpoint=0x20; + d.v27_sleep_transport=true; + d.sleep_v27_ep[0]=replacement; afk_release_context(empty); + assert(d.sleep_v27_ep[0]==replacement && "retired endpoint cannot clear its replacement"); + afk_release_context(replacement); + assert(!d.sleep_v27_ep[0] && "owned endpoint clears its own route"); cleanup(); } assert(!drain_warnings);