From 2c63310e00f64390441d02933e6da9fbe45eae2f Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 21 Nov 2026 11:46:10 +1100 Subject: [PATCH 1/8] iommu: apple-dart: report the streams a display DART has enabled A DCP whose device tree names its display power words but not its DART streams stops the streams its DARTs have enabled before its first power-down and enables them again at power-up. Let it read them: the first 32 streams of a T8110 DART, read while its domain is up. Signed-off-by: Ryan Murray --- drivers/iommu/apple-dart.c | 14 ++++++++++++++ include/linux/soc/apple/dart.h | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index 7d96ad49b0190..2427bb35bffbe 100644 --- a/drivers/iommu/apple-dart.c +++ b/drivers/iommu/apple-dart.c @@ -7761,6 +7761,20 @@ int apple_dart_display_streams(struct device *dev, u32 streams, bool on, bool fl } EXPORT_SYMBOL_GPL(apple_dart_display_streams); +/* + * The streams 0 to 31 a T8110 display DART has enabled, read while its domain is up: what + * a DCP whose device tree names no streams stops and enables again around its power cycle. + */ +u32 apple_dart_enabled_streams(struct device *dev) +{ + struct apple_dart *dart = dev_get_drvdata(dev); + + if (!dart || dart->hw->type != DART_T8110) + return 0; + return readl(dart->regs + DART_T8110_ENABLE_STREAMS); +} +EXPORT_SYMBOL_GPL(apple_dart_enabled_streams); + /* * A DART whose domain goes off with its consumer's, at runtime, while other users still map * into it: dark, maps reach memory only and their invalidations wait; lit, those run. Its diff --git a/include/linux/soc/apple/dart.h b/include/linux/soc/apple/dart.h index 0a7925025e628..1c263ff4e561e 100644 --- a/include/linux/soc/apple/dart.h +++ b/include/linux/soc/apple/dart.h @@ -187,6 +187,8 @@ int apple_dart_sleep_prepare(struct device *dev); void apple_dart_sleep_restore(struct device *dev); /* A display DART's streams around a display power cycle, see the DART driver. */ int apple_dart_display_streams(struct device *dev, u32 streams, bool on, bool flush); +/* The streams 0 to 31 a display DART has enabled. */ +u32 apple_dart_enabled_streams(struct device *dev); /* A GAPF slice released before its coprocessor's CPU domain comes up after a wake. */ int apple_dart_gapf_ready(struct device *dev); /* A display DART whose domain goes off at runtime while others still map into it. */ @@ -221,6 +223,11 @@ static inline int apple_dart_display_streams(struct device *dev, u32 streams, bo return -ENODEV; } +static inline u32 apple_dart_enabled_streams(struct device *dev) +{ + return 0; +} + static inline int apple_dart_gapf_ready(struct device *dev) { return 0; From d81cf764e45e42fe96270834c56e9cd62546e5c0 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 21 Nov 2026 11:46:10 +1100 Subject: [PATCH 2/8] drm/apple: dcp: stop a DCP for a deep sleep with its panel lit on every hw.s2r SoC The system-sleep stop ran with an active panel only where the power words are measured, or on the J813, so another SoC's internal DCP stayed running into a deep sleep unless DPMS had turned its panel off first, and the sleep was refused. A derived layout only survives probe with appledrm.s2r_untested set, which already decides it: drop the board check. Signed-off-by: Ryan Murray --- drivers/gpu/drm/apple/dcp.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index 26107506fb9f1..8de276ad5623a 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -9629,12 +9629,11 @@ static int dcp_platform_suspend(struct device *dev) return dcp_v27_sleep_suspend(dcp); /* - * J813 uses the same qualified stop as DPMS off. Probe already gates - * its derived power layout on appledrm.s2r_untested; without this - * system-suspend path an active panel leaves the DCP running. + * The same stop as DPMS off; without this system-suspend path an active + * panel leaves the DCP running. Probe already gates a derived power + * layout (T8142) on appledrm.s2r_untested. */ - if (pm_suspend_via_firmware() && dcp_s2r_capable(dcp) && - (!dcp->hw.s2r_untested || of_machine_is_compatible("apple,j813"))) { + if (pm_suspend_via_firmware() && dcp_s2r_capable(dcp)) { int ret = dcp_s2r_suspend(dcp); /* Lit by the last resume with its CRTC off: the next resume finds it off by DPMS. */ From c2696ec02a2b41546de43bc675715e9efffa402a Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 21 Nov 2026 11:46:24 +1100 Subject: [PATCH 3/8] drm/apple: dcp: stop the T8132 internal DCP's 27.2 firmware, with its power words from the device tree The M4 MacBook Air's internal DCP runs the firmware-27 backend on macOS 27.2 but has no firmware stop, so a deep sleep is refused with the processor still running, and DPMS off only darkens the backlight. Give it the hw.s2r stop the T8142 runs on 27.2: set_power_state(0), D572, the AP link's release (A550 in the 27.2 table), RTKit idle and the CPU stop, then the DCP DART's streams. It has no secure mailbox. Its power words are not a per-SoC table: a hw.s2r DCP without a layout in its hw data takes them from its device tree, the ones its deep sleep lowers. DISP_CPU is the first state of its power-domains, DISP_FE that state's parent and DISP_SYS theirs; the retention words are DISP_CPU's apple,retention-workaround, of which only the masked bits are written, the off value at power-off and the value read at probe at power-on; pmc-dcp counts it where the display-power node has that word; and the DART streams are the ones its DARTs have enabled before the first stop. Without those properties the firmware keeps running, as before. Signed-off-by: Ryan Murray --- drivers/gpu/drm/apple/dcp-internal.h | 10 ++ drivers/gpu/drm/apple/dcp.c | 131 +++++++++++++++++++++++++-- 2 files changed, 134 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp-internal.h b/drivers/gpu/drm/apple/dcp-internal.h index 06578d9ede42a..b852e28fce9e9 100644 --- a/drivers/gpu/drm/apple/dcp-internal.h +++ b/drivers/gpu/drm/apple/dcp-internal.h @@ -243,6 +243,13 @@ struct dcp_s2r_layout { u32 disp_streams; /* "pmc-dcp" counts the powered DCPs: T8132 and T8140 only */ bool pmc_dcp; + /* + * From the device tree (dcp_s2r_layout_from_dt()): only the @*_mask bits of a + * retention word are written, @*_off while off and the value read at probe back on. + * Zero masks: the whole words, as above. + */ + u32 ret_ff_mask, ret_ff_off, ret_ff_on; + u32 ret_mem_mask, ret_mem_off, ret_mem_on; }; /* @@ -861,6 +868,9 @@ struct apple_dcp { struct completion s2r_dart_done; struct device *s2r_disp_dart; struct device *s2r_dcp_dart; + /* hw.s2r without a layout in its hw data: the device tree's, see dcp_s2r_layout_from_dt() */ + struct dcp_s2r_layout s2r_dt_layout; + bool s2r_dt_layout_ok; /* eDP display without DP-HDMI conversion */ bool main_display; diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index 8de276ad5623a..1bc04fe052ef8 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -296,6 +296,92 @@ static int dcp_secure_port_init(struct apple_dcp *dcp) * without a secure mailbox says so (hw.s2r_no_secure_port), and one behind * appledrm.s2r_untested stops its firmware for DPMS off and J813 system sleep. */ +/* + * hw.s2r without a layout in its hw data takes its words from the device tree, the ones its + * deep sleep lowers: DISP_CPU is the first state of the DCP's power-domains, DISP_FE that + * state's parent and DISP_SYS theirs, each at its reg in the power manager whose block the + * display-power node's "ps" starts. The retention words are DISP_CPU's two + * apple,retention-workaround entries (power manager offset, mask, value while off), in the + * node's "pwrgate" block, and the value each reads now, with the DCP running, is the one it + * gets back at power-on. It counts in pmc-dcp where the node has that word. The DART streams + * are the ones its DARTs have enabled at the first stop, see dcp_s2r_find_darts(). + */ +static int dcp_s2r_layout_from_dt(struct apple_dcp *dcp) +{ + struct dcp_s2r_layout *l = &dcp->s2r_dt_layout; + struct device_node *power, *pmgr = NULL, *ps[3] = {}; + struct resource ps_res, gate_res, pmgr_res; + u32 off[3], ret[6]; + void __iomem *gate; + int i, err = -EINVAL; + + power = of_parse_phandle(dcp->dev->of_node, "apple,display-power", 0); + if (!power) + return -ENODEV; + if (of_address_to_resource(power, of_property_match_string(power, "reg-names", "ps"), + &ps_res) || + of_address_to_resource(power, of_property_match_string(power, "reg-names", "pwrgate"), + &gate_res)) + goto out; + ps[0] = of_parse_phandle(dcp->dev->of_node, "power-domains", 0); + for (i = 1; i < 3 && ps[i - 1]; i++) + ps[i] = of_parse_phandle(ps[i - 1], "power-domains", 0); + if (!ps[2]) + goto out; + pmgr = of_get_parent(ps[0]); + if (!pmgr || of_address_to_resource(pmgr, 0, &pmgr_res) || pmgr_res.start != ps_res.start) + goto out; + for (i = 0; i < 3; i++) { + struct device_node *parent = of_get_parent(ps[i]); + + of_node_put(parent); + if (parent != pmgr || of_property_read_u32(ps[i], "reg", &off[i]) || + off[i] > resource_size(&ps_res) - 4) + goto out; + } + if (of_property_read_u32_array(ps[0], "apple,retention-workaround", ret, 6) || + of_property_count_u32_elems(ps[0], "apple,retention-workaround") != 6) + goto out; + for (i = 0; i < 6; i += 3) { + u64 at = pmgr_res.start + ret[i]; + + if (at <= gate_res.start || at + 4 > gate_res.end + 1 || at % 4 || !ret[i + 1] || + ret[i + 2] & ~ret[i + 1]) + goto out; + } + gate = ioremap(gate_res.start, resource_size(&gate_res)); + if (!gate) { + err = -ENOMEM; + goto out; + } + *l = (struct dcp_s2r_layout){ + .disp_cpu = off[0], + .disp_fe = off[1], + .disp_sys = off[2], + .ret_ff = pmgr_res.start + ret[0] - gate_res.start, + .ret_ff_mask = ret[1], + .ret_ff_off = ret[2], + .ret_mem = pmgr_res.start + ret[3] - gate_res.start, + .ret_mem_mask = ret[4], + .ret_mem_off = ret[5], + .pmc_dcp = of_property_match_string(power, "reg-names", "pmc-dcp") >= 0, + }; + l->ret_ff_on = readl(gate + l->ret_ff); + l->ret_mem_on = readl(gate + l->ret_mem); + iounmap(gate); + dcp->s2r_dt_layout_ok = true; + dev_dbg(dcp->dev, "display power from the device tree: CPU %#x FE %#x SYS %#x, retention %#x/%#x on %#x/%#x\n", + l->disp_cpu, l->disp_fe, l->disp_sys, l->ret_ff, l->ret_mem, l->ret_ff_on, + l->ret_mem_on); + err = 0; +out: + for (i = 0; i < 3; i++) + of_node_put(ps[i]); + of_node_put(pmgr); + of_node_put(power); + return err; +} + static void dcp_s2r_check_dt(struct apple_dcp *dcp) { struct device_node *np = dcp->dev->of_node; @@ -308,6 +394,15 @@ static void dcp_s2r_check_dt(struct apple_dcp *dcp) !power ? "apple,display-power" : "secure mailbox"); dcp->hw.s2r = false; } + if (dcp->hw.s2r && !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 = false; + } + } if (dcp->hw.s2r_ext && !power) { dev_info(dcp->dev, "no apple,display-power in the device tree, the firmware keeps running\n"); dcp->hw.s2r_ext = false; @@ -7122,13 +7217,17 @@ static int dcp_s2r_pm_register(struct apple_dcp *dcp); * - num_dptx_ports 0: it drives the panel only. * - adopt_live_session: iBoot leaves it running with the 27.2 image and the * panel lit; Linux never starts its CPU. - * No sleep support: no firmware-27 sleep has run on this processor. + * - s2r: the firmware-27 stop (iomfb_v27.c) for DPMS off and deep sleep, + * with the 27.2 table's calls and the power words its device tree names + * (dcp_s2r_layout_from_dt()). It has no secure mailbox. */ static const struct apple_dcp_hw_data apple_dcp_hw_t8132_v27 = { .firmware_dma_bits = 41, .num_dptx_ports = 0, .adopt_live_session = true, .firmware_compat = DCP_FIRMWARE_V_27_0, + .s2r = true, + .s2r_no_secure_port = true, }; static const struct apple_dcp_hw_data apple_dcp_hw_t8132_dcpext_v27 = { @@ -7313,7 +7412,8 @@ static int dcp_platform_probe_pipe(struct platform_device *pdev) * A SoC with derived power words is offered the stop only when asked for, and only on * firmware 27.0, whose calls are the ones that ran with them. */ - if (dcp->hw.s2r && (!dcp->hw.s2r_layout || + if (dcp->hw.s2r && ((!dcp->hw.s2r_layout && + !of_property_present(dev->of_node, "apple,display-power")) || (dcp->hw.s2r_untested && (!s2r_untested || fw_compat != DCP_FIRMWARE_V_27_0)))) dcp->hw.s2r = false; @@ -8282,7 +8382,9 @@ static const struct dcp_s2r_layout *dcp_s2r_layout(struct apple_dcp *dcp) { if (dcp_s2r_is_t8142_ext(dcp)) return &dcp_s2r_t8142_ext[dcp->index - 1]; - return dcp->hw.s2r_layout ?: &dcp_s2r_t8140; + if (dcp->hw.s2r_layout) + return dcp->hw.s2r_layout; + return dcp->s2r_dt_layout_ok ? &dcp->s2r_dt_layout : &dcp_s2r_t8140; } #define DCP_PS_MIN GENMASK(19, 16) @@ -8322,6 +8424,15 @@ static void dcp_s2r_find_darts(struct apple_dcp *dcp) dcp->s2r_disp_dart = dcp_s2r_find_dart(piodma); of_node_put(piodma); } + /* A device-tree layout's streams: what its DARTs have on before the first stop. */ + if (dcp->s2r_dt_layout_ok && !dcp->s2r_dt_layout.dcp_streams && dcp->s2r_dcp_dart) { + dcp->s2r_dt_layout.dcp_streams = apple_dart_enabled_streams(dcp->s2r_dcp_dart); + if (dcp->s2r_disp_dart) + dcp->s2r_dt_layout.disp_streams = + apple_dart_enabled_streams(dcp->s2r_disp_dart); + dev_dbg(dcp->dev, "DART streams for the stop: DCP %#x, display %#x\n", + dcp->s2r_dt_layout.dcp_streams, dcp->s2r_dt_layout.disp_streams); + } } void dcp_s2r_dart_power(struct apple_dcp *dcp, u32 on) @@ -8791,6 +8902,12 @@ static void dcp_s2r_ps_lower(void __iomem *reg) writel((val & ~GENMASK(3, 0)) | GENMASK(9, 8), reg); } +/* A retention word: the whole of it from a hw-data layout, only its masked bits from the DT's. */ +static void dcp_s2r_ret_write(void __iomem *reg, u32 mask, u32 val, u32 word) +{ + writel(mask ? (readl(reg) & ~mask) | (val & mask) : word, reg); +} + /* Its display-power words, pmc-dcp only where the layout has one. */ static int dcp_s2r_map_power(struct apple_dcp *dcp, void __iomem **ps, void __iomem **pwrgate, void __iomem **pmc) @@ -8829,8 +8946,8 @@ static int dcp_s2r_domains_off(struct apple_dcp *dcp) if (val & BIT(28)) writel(val & ~(BIT(28) | GENMASK(9, 8)), ps + l->disp_cpu); if (l->ret_ff) { - writel(3, pwrgate + l->ret_ff); - writel(0, pwrgate + l->ret_mem); + dcp_s2r_ret_write(pwrgate + l->ret_ff, l->ret_ff_mask, l->ret_ff_off, 3); + dcp_s2r_ret_write(pwrgate + l->ret_mem, l->ret_mem_mask, l->ret_mem_off, 0); } dcp_s2r_ps_lower(ps + l->disp_cpu); dcp_s2r_ps_lower(ps + l->disp_fe); @@ -8881,8 +8998,8 @@ static int dcp_s2r_domains_on(struct apple_dcp *dcp) } writel(val | 0xf, ps + l->disp_cpu); if (l->ret_ff) { - writel(0, pwrgate + l->ret_ff); - writel(1, pwrgate + l->ret_mem); + dcp_s2r_ret_write(pwrgate + l->ret_ff, l->ret_ff_mask, l->ret_ff_on, 0); + dcp_s2r_ret_write(pwrgate + l->ret_mem, l->ret_mem_mask, l->ret_mem_on, 1); } writel(val | 0xf | BIT(28), ps + l->disp_cpu); if (pmc) From 6ece675665934e6c4d715e371cbe91a405d38121 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 21 Nov 2026 11:58:52 +1100 Subject: [PATCH 4/8] dt-bindings: display: apple,t8140-display-power: add the T8132 The T8132's words are T8140's: pmc-dcp, the power manager's power states and its power gate block. Signed-off-by: Ryan Murray --- .../bindings/display/apple,t8140-display-power.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/display/apple,t8140-display-power.yaml b/Documentation/devicetree/bindings/display/apple,t8140-display-power.yaml index 7d15745134267..89c84ca242d4e 100644 --- a/Documentation/devicetree/bindings/display/apple,t8140-display-power.yaml +++ b/Documentation/devicetree/bindings/display/apple,t8140-display-power.yaml @@ -4,7 +4,7 @@ $id: http://devicetree.org/schemas/display/apple,t8140-display-power.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: Apple T8140 and T8142 display power words +title: Apple T8132, T8140 and T8142 display power words maintainers: - Diljit Singh @@ -18,6 +18,7 @@ description: properties: compatible: enum: + - apple,t8132-display-power - apple,t8140-display-power - apple,t8142-display-power @@ -38,7 +39,9 @@ allOf: - if: properties: compatible: - const: apple,t8140-display-power + enum: + - apple,t8132-display-power + - apple,t8140-display-power then: properties: reg: From 2218023c37e100941f010001c662c3214f8186ac Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 21 Nov 2026 11:58:52 +1100 Subject: [PATCH 5/8] arm64: dts: apple: t8132-j713: the internal DCP's display power words Name the power manager blocks the internal DCP's firmware-27 stop writes, the ones the deep sleep lowers (pmc-dcp, the power states and the power gate block), and the DCP DART's clock-protection slice (42 in the ADT's dart-dcp) as its gapf word: the stop clears it after the DART's power-down flush so that DISP_CPU's power state can be written. Signed-off-by: Ryan Murray --- arch/arm64/boot/dts/apple/t8132-j713.dts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t8132-j713.dts b/arch/arm64/boot/dts/apple/t8132-j713.dts index e445896854733..8037c760a8f08 100644 --- a/arch/arm64/boot/dts/apple/t8132-j713.dts +++ b/arch/arm64/boot/dts/apple/t8132-j713.dts @@ -193,8 +193,31 @@ apple,clock-protection = <&ps_prot 8>; }; +/* + * The words the firmware-27 stop of the internal DCP writes (appledrm.s2r_untested), + * the same ones the deep sleep lowers: pmc-dcp, the PMGR power states and its power + * gate block. + */ +&soc { + dcp_power: display-power@3828a9c14 { + compatible = "apple,t8132-display-power"; + reg = <0x3 0x828a9c14 0x0 0x4>, + <0x3 0x80700000 0x0 0x14000>, + <0x3 0x80724000 0x0 0x2000>; + reg-names = "pmc-dcp", "ps", "pwrgate"; + }; +}; + +/* Clock-protection slice 42 (ADT dart-dcp): it guards DISP_CPU's power state. */ +&dcp_dart { + reg = <0x3 0x0a340000 0x0 0x20000>, + <0x3 0x8079cb80 0x0 0x4>; + reg-names = "dart", "gapf"; +}; + &dcp { apple,pmc-interface = <&pmc_disp0>; + apple,display-power = <&dcp_power>; panel: panel { compatible = "apple,panel-j713", "apple,panel"; From aed223c40c20964a866a5f34498c7673b05c3363 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sun, 22 Nov 2026 03:29:26 +1100 Subject: [PATCH 6/8] 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 7/8] 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 8/8] 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)