From aed223c40c20964a866a5f34498c7673b05c3363 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sun, 22 Nov 2026 03:29:26 +1100 Subject: [PATCH 1/3] drm/apple: dcp: stop a T8132 firmware-27.2 external DCP for a deep sleep On 27.2 the M4 MacBook Air's DCPEXTs are handed over running, and nothing stopped their firmware for a deep sleep: the sleep powered them off with it, and their resume talked to a dead firmware until the watchdog reset the machine. Give them the external DCP stop and start that already exists (A550, RTKit idle, CPU stop, DART streams, then the domains), with the power words taken from the device tree the way the internal DCP's are: the DISPEXTn CPU/FE/SYS states from its power-domains chain, the retention words from the CPU domain's apple,retention-workaround, and the shared pmc-dcp count. An external DCP with such a layout takes the layout's power sequence rather than the fixed DISPEXT0 one, and needs no lab parameter. On the J713 both DCPEXTs point at the internal DCP's display-power node. Signed-off-by: Ryan Murray --- arch/arm64/boot/dts/apple/t8132-j713.dts | 12 +++++++++ drivers/gpu/drm/apple/dcp.c | 32 ++++++++++++++++++++---- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/arch/arm64/boot/dts/apple/t8132-j713.dts b/arch/arm64/boot/dts/apple/t8132-j713.dts index 5cb3f24cf815f..d2a5b039fff9f 100644 --- a/arch/arm64/boot/dts/apple/t8132-j713.dts +++ b/arch/arm64/boot/dts/apple/t8132-j713.dts @@ -410,9 +410,21 @@ &dcpext0 { memory-region = <&dcpext0_text>, <&dcpext0_data>, <&dcpext0_heap>; memory-region-names = "text", "data", "heap"; + /* + * Its deep-sleep stop writes the same words as the internal DCP's: its + * DISPEXT0 power states and retention in the same blocks, and pmc-dcp, + * which counts every powered DCP. + */ + apple,display-power = <&dcp_power>; }; &dcpext1 { memory-region = <&dcpext1_text>, <&dcpext1_data>, <&dcpext1_heap>; memory-region-names = "text", "data", "heap"; + /* + * Its deep-sleep stop writes the same words as the internal DCP's: its + * DISPEXT1 power states and retention in the same blocks, and pmc-dcp, + * which counts every powered DCP. + */ + apple,display-power = <&dcp_power>; }; diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index f7711da18ab88..e00f9831c6b3e 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -407,6 +407,15 @@ static void dcp_s2r_check_dt(struct apple_dcp *dcp) dev_info(dcp->dev, "no apple,display-power in the device tree, the firmware keeps running\n"); dcp->hw.s2r_ext = false; } + if (dcp->hw.s2r_ext && !dcp->hw.s2r_layout) { + int ret = dcp_s2r_layout_from_dt(dcp); + + if (ret) { + dev_info(dcp->dev, "display power words not in the device tree (%d), the firmware keeps running\n", + ret); + dcp->hw.s2r_ext = false; + } + } if (dcp->hw.s2r && dcp->hw.s2r_untested) dev_info(dcp->dev, "firmware stop enabled (appledrm.s2r_untested)\n"); } @@ -7237,6 +7246,9 @@ static const struct apple_dcp_hw_data apple_dcp_hw_t8132_dcpext_v27 = { .adopt_live_session = true, .firmware_compat = DCP_FIRMWARE_V_27_0, .sink_metadata_edid = true, + /* Its sleep stop and start, with the power words from the device tree. */ + .s2r_ext = true, + .s2r_no_secure_port = true, }; static int dcp_platform_probe_pipe(struct platform_device *pdev) @@ -8379,6 +8391,15 @@ static bool dcp_s2r_is_t8142_ext(struct apple_dcp *dcp) return of_device_is_compatible(dcp->dev->of_node, "apple,t8142-dcpext"); } +/* + * An external DCP powered by its layout's words (T8142's table, or the device tree's), not + * by the fixed DISPEXT0 sequence of the firmware-12 external DCPs. + */ +static bool dcp_s2r_ext_by_layout(struct apple_dcp *dcp) +{ + return dcp_s2r_is_t8142_ext(dcp) || dcp->s2r_dt_layout_ok; +} + static const struct dcp_s2r_layout *dcp_s2r_layout(struct apple_dcp *dcp) { if (dcp_s2r_is_t8142_ext(dcp)) @@ -8664,7 +8685,8 @@ static int dcp_s2r_stop_firmware(struct apple_dcp *dcp) static bool dcp_s2r_ext_capable(struct apple_dcp *dcp) { if (dcp->fw_compat == DCP_FIRMWARE_V_27_0) - return dcp->hw.s2r_ext && s2r_untested && dcp->v27_methods && + return dcp->hw.s2r_ext && (s2r_untested || dcp->s2r_dt_layout_ok) && + dcp->v27_methods && dcp->v27_methods[dcpep_unnamed_500].tag[0]; return dcp->fw_compat == DCP_FIRMWARE_H17P && dcp->hw.s2r_ext; } @@ -8992,7 +9014,7 @@ static int dcp_s2r_domains_on(struct apple_dcp *dcp) val = readl(ps + l->disp_fe) & ~(GENMASK(9, 8) | GENMASK(3, 0)); writel(val | 0xf, ps + l->disp_fe); val = readl(ps + l->disp_cpu) & ~(GENMASK(9, 8) | GENMASK(3, 0) | BIT(28)); - if (dcp_s2r_is_t8142_ext(dcp)) { + if (dcp_s2r_is_t8142_ext(dcp) || (dcp->hw.external_processor && dcp->s2r_dt_layout_ok)) { /* Retain the CPU when idle, as in the measured J813 wake sequence. */ val = (val & ~DCP_PS_MIN) | FIELD_PREP(DCP_PS_MIN, 4); writel(val, ps + l->disp_cpu); @@ -9035,7 +9057,7 @@ static int dcp_s2r_ext_domains_on(struct apple_dcp *dcp) u32 val; int i, ret = -ENODEV; - if (dcp_s2r_is_t8142_ext(dcp)) + if (dcp_s2r_ext_by_layout(dcp)) return dcp_s2r_domains_on(dcp); np = of_parse_phandle(dcp->dev->of_node, "apple,display-power", 0); @@ -9132,7 +9154,7 @@ static int dcp_s2r_ext_domains_off(struct apple_dcp *dcp) int i, ret = -ENODEV; u32 val; - if (dcp_s2r_is_t8142_ext(dcp)) + if (dcp_s2r_ext_by_layout(dcp)) return dcp_s2r_domains_off(dcp); np = of_parse_phandle(dcp->dev->of_node, "apple,display-power", 0); @@ -9191,7 +9213,7 @@ static bool dcp_s2r_ext_cpu_on(struct apple_dcp *dcp) of_node_put(np); if (!ps) return false; - on = FIELD_GET(GENMASK(7, 4), readl(ps + (dcp_s2r_is_t8142_ext(dcp) ? + on = FIELD_GET(GENMASK(7, 4), readl(ps + (dcp_s2r_ext_by_layout(dcp) ? dcp_s2r_layout(dcp)->disp_cpu : 0x328))); iounmap(ps); From 597f023daa17b7781329306d09b860de3eea2fc6 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sun, 22 Nov 2026 05:11:02 +1100 Subject: [PATCH 2/3] drm/apple: dcp: keep an external DCP's fixed stop when the device tree has no power words Deriving an external DCP's power words from the device tree cleared hw.s2r_ext whenever that failed. The MacBook Neo's (T8140) external DCP has s2r_ext and apple,display-power but no apple,retention-workaround on its DISPEXT0 CPU state, so it lost the fixed DISPEXT0 stop it uses for a deep sleep and went to sleep with its firmware running. Keep s2r_ext when the device tree has no layout. A firmware-27 external DCP without one is still not dcp_s2r_ext_capable() unless the lab parameter is set, so it refuses the deep sleep as before. Signed-off-by: Ryan Murray --- drivers/gpu/drm/apple/dcp.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index e00f9831c6b3e..3f307d4189d4e 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -407,14 +407,16 @@ static void dcp_s2r_check_dt(struct apple_dcp *dcp) dev_info(dcp->dev, "no apple,display-power in the device tree, the firmware keeps running\n"); dcp->hw.s2r_ext = false; } + /* + * Without a layout from the device tree, an external DCP keeps the fixed DISPEXT0 + * sequence it had before (T8140); a firmware-27 one is then not dcp_s2r_ext_capable() + * without the lab parameter and refuses a deep sleep instead. + */ if (dcp->hw.s2r_ext && !dcp->hw.s2r_layout) { int ret = dcp_s2r_layout_from_dt(dcp); - if (ret) { - dev_info(dcp->dev, "display power words not in the device tree (%d), the firmware keeps running\n", - ret); - dcp->hw.s2r_ext = false; - } + if (ret) + dev_dbg(dcp->dev, "display power words not in the device tree (%d)\n", ret); } if (dcp->hw.s2r && dcp->hw.s2r_untested) dev_info(dcp->dev, "firmware stop enabled (appledrm.s2r_untested)\n"); From 8d7df2306d93b688d97986ef0a91bf1a026d76e6 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sun, 22 Nov 2026 05:33:20 +1100 Subject: [PATCH 3/3] drm/apple: dcp, arm64: dts: apple: t8132-j713: finish the DCPEXT sleep stop Three gaps in the DCPEXT deep-sleep stop, found in review: - A firmware-27 DCPEXT is capable of the stop only with a power layout, the device tree's or a static one under the lab parameter. Without one, the lab parameter alone would send it down the fixed DISPEXT0 sequence, which is not its own. - A refused sleep powers a stopped DCPEXT off and on again (dcp_s2r_ext_cycle()). On the layout path its display DART was left powered on in the driver's view while its domains were off; mark it dark first, as the fixed sequence does. - On the J713 the DCPEXT DARTs had no GAPF slice to release, so the power-off on a refused sleep wrote DISPEXTn_CPU with its clock protection still on. Give dcpext0/1_dart their slices (5 and 30, at PS_PROT + 0x100 + 0x40 * n), as the internal DCP's DART has slice 42. Also describe the J713 DCPEXT's sleep in its hw data. Signed-off-by: Ryan Murray --- arch/arm64/boot/dts/apple/t8132-j713.dts | 16 ++++++++++++++++ drivers/gpu/drm/apple/dcp.c | 18 ++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/arch/arm64/boot/dts/apple/t8132-j713.dts b/arch/arm64/boot/dts/apple/t8132-j713.dts index d2a5b039fff9f..ca8cbb333cdf8 100644 --- a/arch/arm64/boot/dts/apple/t8132-j713.dts +++ b/arch/arm64/boot/dts/apple/t8132-j713.dts @@ -286,7 +286,15 @@ apple,clock-protection = <&ps_prot 18>; }; +/* + * Clock-protection slice 5 (ADT dart-dcpext0): it guards DISPEXT0_CPU's power + * state, and the DCPEXT's own stop and start release and restore it as the + * internal DCP's do. + */ &dcpext0_dart { + reg = <0x2 0x86340000 0x0 0x20000>, + <0x3 0x8079c240 0x0 0x4>; + reg-names = "dart", "gapf"; apple,clock-protection = <&ps_prot 5>; }; @@ -294,7 +302,15 @@ apple,clock-protection = <&ps_prot 4>; }; +/* + * Clock-protection slice 30 (ADT dart-dcpext1): it guards DISPEXT1_CPU's power + * state, and the DCPEXT's own stop and start release and restore it as the + * internal DCP's do. + */ &dcpext1_dart { + reg = <0x4 0x8a340000 0x0 0x20000>, + <0x3 0x8079c880 0x0 0x4>; + reg-names = "dart", "gapf"; apple,clock-protection = <&ps_prot 30>; }; diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index 3f307d4189d4e..ad2263b3885c2 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -7217,8 +7217,9 @@ static int dcp_s2r_pm_register(struct apple_dcp *dcp); * over; Linux never starts its CPU. * - sink_metadata_edid: the display it finds at boot is its first sink, * as on the T6041 dcpext. - * No sleep support: neither a firmware-27 sleep nor a link release has run - * on this processor. + * - s2r_ext: its deep-sleep stop and start (dcp_s2r_ext_suspend()), with the + * power words from the device tree; without them it keeps running and its + * deep sleep is refused. */ /* * T8132 internal display processor on firmware 27.2, admitted by @@ -8687,7 +8688,12 @@ static int dcp_s2r_stop_firmware(struct apple_dcp *dcp) static bool dcp_s2r_ext_capable(struct apple_dcp *dcp) { if (dcp->fw_compat == DCP_FIRMWARE_V_27_0) - return dcp->hw.s2r_ext && (s2r_untested || dcp->s2r_dt_layout_ok) && + /* + * Only with a power layout: the device tree's, or a static one under the lab + * parameter. Without one the fixed DISPEXT0 sequence below is not this DCP's. + */ + return dcp->hw.s2r_ext && + (dcp->s2r_dt_layout_ok || (dcp->hw.s2r_layout && s2r_untested)) && dcp->v27_methods && dcp->v27_methods[dcpep_unnamed_500].tag[0]; return dcp->fw_compat == DCP_FIRMWARE_H17P && dcp->hw.s2r_ext; @@ -9156,8 +9162,12 @@ static int dcp_s2r_ext_domains_off(struct apple_dcp *dcp) int i, ret = -ENODEV; u32 val; - if (dcp_s2r_ext_by_layout(dcp)) + if (dcp_s2r_ext_by_layout(dcp)) { + /* Its display DART goes off with the domains too: dark until they are back. */ + if (dcp->s2r_disp_dart) + apple_dart_power_dark(dcp->s2r_disp_dart, true); return dcp_s2r_domains_off(dcp); + } np = of_parse_phandle(dcp->dev->of_node, "apple,display-power", 0); if (!np)