From 32ddf053cfe12a2f4b9bcdf31e6db218b1e02205 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Thu, 19 Nov 2026 23:36:17 +1100 Subject: [PATCH 1/2] soc: apple: sleep: Defer the SMC notice by the SoC's sleep profile The final SMC MBSE/AP IDLE notice waits for the peer stops because on T8142 ANS fails its IOP IDLE handshake when the SMC is told first. That is a property of the T8142 sleep sequence, but both the deferral (apple_sleep_smc_defer_notice()) and macsmc's bounded transport for it were selected by of_machine_is_compatible("apple,j813"), which leaves out J815 with the same SoC, SMC and ANS. Add smc_notice_after_peers to struct apple_sleep_soc, set it for apple,t8142-sleep, and read it instead of the board. macsmc picks its transport at probe, before the sleep controller binds, so add apple_sleep_smc_defer_notice_hw(), which answers the same from the device tree: an available sleep controller whose profile has the flag. Only J813 has an apple,t8142-sleep node today, so no board changes behaviour until a device tree adds one; T8140, T8132 and T6050 leave the flag clear. The TEST ONLY switch keeps its name. Fixes: f1aa5a53ac77 ("soc: apple: sleep: send J813's final SMC notice after peer stops") Suggested-by: Thomas Glanzmann Signed-off-by: Ryan Murray --- drivers/mfd/macsmc.c | 11 ++++++---- drivers/soc/apple/sleep.c | 36 +++++++++++++++++++++++++++++++-- include/linux/soc/apple/sleep.h | 5 ++++- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/drivers/mfd/macsmc.c b/drivers/mfd/macsmc.c index 5204c960ebe9d..2fec40b0f9f84 100644 --- a/drivers/mfd/macsmc.c +++ b/drivers/mfd/macsmc.c @@ -652,8 +652,11 @@ static int apple_smc_probe(struct platform_device *pdev) of_device_is_compatible(dev->of_node, "apple,t6050-smc"); if (smc->saved_enabled && of_machine_is_compatible("apple,j714s")) smc->wake_reasons = apple_smc_j714s_wake_reasons; - /* J813's late notice needs the bounded, IRQ-independent transport too. */ - if (of_machine_is_compatible("apple,j813")) + /* + * A sleep controller that sends the final notice after the peer stops (T8142) needs the + * bounded, IRQ-independent transport too. + */ + if (apple_sleep_smc_defer_notice_hw()) smc->saved_enabled = true; smc->sram_base = devm_platform_get_and_ioremap_resource(pdev, 1, &smc->sram); if (IS_ERR(smc->sram_base)) @@ -1229,7 +1232,7 @@ static int apple_smc_sleep_saved_end(void *data) } /* - * J813's ordinary wake notice belongs in macsmc's resume_noirq, after the + * A deferred notice's ordinary wake notice belongs in macsmc's resume_noirq, after the * device dependencies have resumed. Platform wake precedes every noirq * device callback; an AP ON there can wake the radio before its DMA path. * Release the bounded transport here, retaining ap_notified for the usual @@ -1360,7 +1363,7 @@ static const struct apple_sleep_smc_saved_ops apple_smc_saved_ops = { }; /* - * J813 retains its existing MBSE/AP sequence and delay floors. The transport + * The deferred notice keeps the existing MBSE/AP sequence and delay floors. The transport * is the saved lane: no scheduler, jiffies, IRQ worker or SRAM reuse is needed * after the peer stops. Unrelated notifications are retained until resume. */ diff --git a/drivers/soc/apple/sleep.c b/drivers/soc/apple/sleep.c index ce1bcee755574..68ca1ef672de2 100644 --- a/drivers/soc/apple/sleep.c +++ b/drivers/soc/apple/sleep.c @@ -657,6 +657,11 @@ struct apple_sleep_soc { u8 display_order[SLEEP_DISPLAYS_MAX]; const struct apple_sleep_region_profile *regions; const struct apple_sleep_smc_policy *smc_policy; + /* + * Without an smc_policy: the SMC's final MBSE/AP IDLE notice waits until ANS and the other + * peers have stopped (apple_sleep_smc_defer_notice()), as the native trace orders it. + */ + bool smc_notice_after_peers; bool early_context; /* The SoC's operations arm and read its wake sources: none of the common wake words */ bool own_wake; @@ -1775,12 +1780,17 @@ EXPORT_SYMBOL_GPL(apple_sleep_smc_policy); static bool sleep_j813_smc_late = true; module_param_named(j813_smc_late, sleep_j813_smc_late, bool, 0444); MODULE_PARM_DESC(j813_smc_late, - "TEST ONLY: J813 final SMC sleep notice after peer stops"); + "TEST ONLY: final SMC sleep notice after peer stops (SoCs with smc_notice_after_peers)"); +/* + * The SoC's sleep profile says whether the final SMC notice follows the peer stops: on T8142 + * ANS fails its IOP IDLE handshake if the SMC is told first. A property of the SoC's sleep + * sequence, so every board with that sleep controller gets it. + */ bool apple_sleep_smc_defer_notice(void) { return apple_sleep && READ_ONCE(sleep_j813_smc_late) && - of_machine_is_compatible("apple,j813") && pm_suspend_via_firmware(); + apple_sleep->soc->smc_notice_after_peers && pm_suspend_via_firmware(); } EXPORT_SYMBOL_GPL(apple_sleep_smc_defer_notice); @@ -9392,6 +9402,8 @@ static const struct apple_sleep_extra_off t8142_extra_off[] = { static const struct apple_sleep_soc t8142_sleep_soc = { .ops = &t8142_sleep_ops, .untested = true, + /* J813 battery lid wake: ANS failed IOP IDLE when the SMC's notice came first. */ + .smc_notice_after_peers = true, .regs_absent = t8142_regs_absent, .spmi_gen4 = true, .boot_wfi_delay_ms = 3, @@ -9504,6 +9516,26 @@ static const struct of_device_id apple_sleep_of_match[] = { { } }; +/* + * Whether this device tree's sleep controller defers the final SMC notice, read from the DT so + * macsmc can pick its bounded transport at probe, before this driver binds. + */ +bool apple_sleep_smc_defer_notice_hw(void) +{ + const struct of_device_id *match; + struct device_node *np; + bool ret = false; + + for_each_matching_node_and_match(np, apple_sleep_of_match, &match) { + const struct apple_sleep_soc *soc = match->data; + + if (of_device_is_available(np) && soc && soc->smc_notice_after_peers) + ret = true; + } + return ret; +} +EXPORT_SYMBOL_GPL(apple_sleep_smc_defer_notice_hw); + static struct platform_driver apple_sleep_driver = { .driver = { .name = "apple-sleep", diff --git a/include/linux/soc/apple/sleep.h b/include/linux/soc/apple/sleep.h index cec1e88452676..f037ee218125b 100644 --- a/include/linux/soc/apple/sleep.h +++ b/include/linux/soc/apple/sleep.h @@ -38,8 +38,10 @@ struct apple_sleep_smc_saved_ops { #if IS_ENABLED(CONFIG_APPLE_SOC_SLEEP) const struct apple_sleep_smc_policy *apple_sleep_smc_policy(void); -/* J813 experiment: send the final SMC notice after the peer idle handshakes. */ +/* Send the final SMC notice after the peer idle handshakes (the SoC's sleep profile). */ bool apple_sleep_smc_defer_notice(void); +/* The same, from the device tree alone: usable before the sleep controller binds. */ +bool apple_sleep_smc_defer_notice_hw(void); int apple_sleep_smc_register(struct device *dev, int (*late_notice)(void *data, u64 *sent, u64 *ack), void *data); int apple_sleep_smc_register_saved(struct device *dev, @@ -244,6 +246,7 @@ int apple_sleep_engine_reset(struct device *dev); #else static inline const struct apple_sleep_smc_policy *apple_sleep_smc_policy(void) { return NULL; } static inline bool apple_sleep_smc_defer_notice(void) { return false; } +static inline bool apple_sleep_smc_defer_notice_hw(void) { return false; } static inline int apple_sleep_smc_register(struct device *dev, int (*late_notice)(void *data, u64 *sent, u64 *ack), void *data) { return -EOPNOTSUPP; } static inline int apple_sleep_smc_register_saved(struct device *dev, From 8407d407ba8571eeb2c2bfa0d7216df147cbe563 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Thu, 19 Nov 2026 23:36:33 +1100 Subject: [PATCH 2/2] drm/apple: dcp: Stop the firmware at system sleep by apple,display-power The DCP firmware stop at system suspend skipped every DCP with derived power words (hw.s2r_untested, T8142) unless the machine was J813. The stop needs the display's power words, which the device tree gives the DCP as apple,display-power, and dcp_s2r_capable() already requires them: dcp_s2r_check_dt() clears hw.s2r without the property, and probe clears it for derived words unless appledrm.s2r_untested is set on firmware 27.0. Drop the board check, so the property selects the path. Today only J813 has apple,display-power on a T8142 DCP, so nothing changes until a device tree adds it (J815 shares J813's nodes); other SoCs were never behind the check. Fixes: b29e3c73048f ("drm/apple: dcp: stop the J813 firmware during system suspend") Suggested-by: Thomas Glanzmann Signed-off-by: Ryan Murray --- drivers/gpu/drm/apple/dcp.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index 7cde46e009096..0bdb7aeda981f 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -292,7 +292,7 @@ static int dcp_secure_port_init(struct apple_dcp *dcp) * once its secure port has gone idle. A device tree without those keeps the firmware * running: DPMS is the backlight alone and the display stays up across a sleep. A SoC * 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. + * appledrm.s2r_untested stops its firmware for DPMS off and system sleep. */ static void dcp_s2r_check_dt(struct apple_dcp *dcp) { @@ -476,13 +476,14 @@ static bool dcp_j714s_ext(struct device *dev) /* * The firmware stop on a SoC whose display power words were derived from its macOS device - * tree instead of measured (T8142). J813 supports DPMS off and system sleep with this - * opt-in. Off by default: such a DCP keeps its firmware running. + * tree instead of measured (T8142). DPMS off and system sleep use it with this opt-in, on + * a device tree that gives the DCP apple,display-power. Off by default: such a DCP keeps its + * firmware running. */ static bool s2r_untested; module_param(s2r_untested, bool, 0444); MODULE_PARM_DESC(s2r_untested, - "Stop the DCP firmware on DPMS off and J813 system sleep using derived T8142 power words (default 0)"); + "Stop the DCP firmware on DPMS off and system sleep using derived T8142 power words (default 0)"); bool dcp_t6041_ext_enabled(void) { @@ -9397,12 +9398,13 @@ 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. + * System sleep uses the same qualified stop as DPMS off. dcp_s2r_capable() + * already holds only with the DCP's apple,display-power in the device + * tree and, for derived power words (hw.s2r_untested), with + * appledrm.s2r_untested on firmware 27.0; without this system-suspend + * path an active panel leaves the DCP running. */ - 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. */