From b35c238b7d874b4342b2be655181520ff7fde02c Mon Sep 17 00:00:00 2001 From: Satya Benson Date: Tue, 1 Dec 2026 05:28:06 -0500 Subject: [PATCH 1/4] soc: apple: sleep: fix T8112 expectation in known_profiles KUnit test When #3647 merged main (cdbecbe2e04a), apple,t8112-sleep remained in the if-condition that main had narrowed to derived profiles (T8142 and T8122), causing apple_sleep_test_known_profiles to expect soc->derived == true and soc->untested == false for T8112. Check apple,t8112-sleep in its own branch with soc->untested == true while leaving the derived-profile checks for T8142 and T8122 intact. Signed-off-by: Satya Benson --- drivers/soc/apple/sleep-test.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/soc/apple/sleep-test.c b/drivers/soc/apple/sleep-test.c index a3e80bce4be68..af7a8c1427040 100644 --- a/drivers/soc/apple/sleep-test.c +++ b/drivers/soc/apple/sleep-test.c @@ -73,7 +73,6 @@ static void apple_sleep_test_known_profiles(struct kunit *test) KUNIT_ASSERT_LT(test, n, ARRAY_SIZE(apple_sleep_test_profiles)); KUNIT_EXPECT_STREQ(test, id->compatible, apple_sleep_test_profiles[n]); if (!strcmp(id->compatible, "apple,t8142-sleep") || - !strcmp(id->compatible, "apple,t8112-sleep") || !strcmp(id->compatible, "apple,t8122-sleep")) { const struct apple_sleep_soc *soc = id->data; @@ -82,6 +81,11 @@ static void apple_sleep_test_known_profiles(struct kunit *test) /* T8142 has run full deep sleeps and wakes; T8122 has not yet. */ KUNIT_EXPECT_EQ(test, (int)soc->untested, !strcmp(id->compatible, "apple,t8122-sleep")); + } else if (!strcmp(id->compatible, "apple,t8112-sleep")) { + const struct apple_sleep_soc *soc = id->data; + + KUNIT_ASSERT_NOT_NULL(test, soc); + KUNIT_EXPECT_TRUE(test, soc->untested); } } KUNIT_EXPECT_EQ(test, n, ARRAY_SIZE(apple_sleep_test_profiles)); From f10bbc884967f4d3354d1f5824cbfc33181d583a Mon Sep 17 00:00:00 2001 From: Satya Benson Date: Tue, 1 Dec 2026 03:56:21 -0500 Subject: [PATCH 2/4] soc: apple: sleep: support coprocessor SLP_DDR voters Add a refcounted apple_sleep_coproc_slp_ddr() voter alongside the existing USB voter so an always-on coprocessor that retains DRAM buffers across system sleep can vote for WAKE_SLP_DDR bit 0. Gate coprocessor votes on a per-SoC capability flag (coproc_slp_ddr) set when sleep_slp_ddr_bind() maps WAKE_SLP_DDR, so SoCs whose live coprocessors already survive full DRAM-off deep sleep (T8132, T8140, T8142) keep their existing behavior unchanged. Votes recorded before apple-sleep probes are applied when sleep_slp_ddr_bind() runs, and both deep_once and crashed-coprocessor overrides continue to clear bit 0. Add a KUnit test covering deferred binding, per-SoC gating, refcounting, USB OR-ing, deep_once and crash overrides. Signed-off-by: Satya Benson --- drivers/soc/apple/sleep-test.c | 104 ++++++++++++++++++++++++++++++++ drivers/soc/apple/sleep.c | 36 +++++++++-- include/linux/soc/apple/sleep.h | 10 +++ 3 files changed, 144 insertions(+), 6 deletions(-) diff --git a/drivers/soc/apple/sleep-test.c b/drivers/soc/apple/sleep-test.c index af7a8c1427040..f3368ad22d72f 100644 --- a/drivers/soc/apple/sleep-test.c +++ b/drivers/soc/apple/sleep-test.c @@ -611,6 +611,109 @@ static void apple_sleep_test_t6040_wdt_span(struct kunit *test) KUNIT_EXPECT_FALSE(test, t6040_wdt_resource_ok(&elsewhere)); } +struct apple_sleep_test_slp_ddr_saved { + bool usb; + unsigned int coproc; + bool coproc_en; + void __iomem *word; + bool crashed; + bool deep_once; +}; + +struct apple_sleep_test_slp_ddr_state { + u32 fake_wake; + struct apple_sleep_soc soc; + struct apple_sleep sleep; + struct apple_sleep_test_slp_ddr_saved saved; +}; + +static void apple_sleep_test_slp_ddr_restore(void *data) +{ + struct apple_sleep_test_slp_ddr_saved *saved = data; + + guard(spinlock_irqsave)(&sleep_slp_ddr_lock); + sleep_slp_ddr_usb = saved->usb; + sleep_slp_ddr_coproc = saved->coproc; + sleep_slp_ddr_coproc_en = saved->coproc_en; + sleep_slp_ddr_word = saved->word; + sleep_slp_ddr_crashed = saved->crashed; + sleep_slp_ddr_deep_once = saved->deep_once; +} + +static void apple_sleep_test_slp_ddr_voters(struct kunit *test) +{ + struct apple_sleep_test_slp_ddr_state *st; + + st = kunit_kzalloc(test, sizeof(*st), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, st); + + scoped_guard(spinlock_irqsave, &sleep_slp_ddr_lock) { + st->saved.usb = sleep_slp_ddr_usb; + st->saved.coproc = sleep_slp_ddr_coproc; + st->saved.coproc_en = sleep_slp_ddr_coproc_en; + st->saved.word = sleep_slp_ddr_word; + st->saved.crashed = sleep_slp_ddr_crashed; + st->saved.deep_once = sleep_slp_ddr_deep_once; + sleep_slp_ddr_usb = false; + sleep_slp_ddr_coproc = 0; + sleep_slp_ddr_coproc_en = false; + sleep_slp_ddr_word = NULL; + sleep_slp_ddr_crashed = false; + sleep_slp_ddr_deep_once = false; + } + KUNIT_ASSERT_EQ(test, + kunit_add_action_or_reset(test, apple_sleep_test_slp_ddr_restore, + &st->saved), 0); + + st->fake_wake = 0xdead0000U; + st->sleep.soc = &st->soc; + st->sleep.wake = (void __iomem __force *)&st->fake_wake; + + /* A coprocessor vote taken before sleep probes stays deferred until bind. */ + apple_sleep_coproc_slp_ddr(true); + KUNIT_EXPECT_EQ(test, st->fake_wake, 0xdead0000U); + + /* A SoC without coproc_slp_ddr ignores coprocessor votes (USB still works). */ + st->soc.coproc_slp_ddr = false; + sleep_slp_ddr_bind(&st->sleep); + KUNIT_EXPECT_EQ(test, st->fake_wake, 0xdead0000U); + + apple_sleep_usb_slp_ddr(true); + KUNIT_EXPECT_EQ(test, st->fake_wake, 0xdead0000U | WAKE_SLP_DDR_USB); + apple_sleep_usb_slp_ddr(false); + KUNIT_EXPECT_EQ(test, st->fake_wake, 0xdead0000U); + + /* A SoC with coproc_slp_ddr applies the deferred vote and preserves other bits. */ + st->soc.coproc_slp_ddr = true; + sleep_slp_ddr_bind(&st->sleep); + KUNIT_EXPECT_EQ(test, st->fake_wake, 0xdead0000U | WAKE_SLP_DDR_USB); + + /* Coprocessor votes are refcounted and guard against underflow. */ + apple_sleep_coproc_slp_ddr(true); + apple_sleep_coproc_slp_ddr(false); + KUNIT_EXPECT_EQ(test, st->fake_wake, 0xdead0000U | WAKE_SLP_DDR_USB); + apple_sleep_coproc_slp_ddr(false); + KUNIT_EXPECT_EQ(test, st->fake_wake, 0xdead0000U); + apple_sleep_coproc_slp_ddr(false); + apple_sleep_coproc_slp_ddr(true); + KUNIT_EXPECT_EQ(test, st->fake_wake, 0xdead0000U | WAKE_SLP_DDR_USB); + + /* deep_once overrides active votes for one sleep and restores on clear. */ + sleep_slp_ddr_set_deep_once(true); + KUNIT_EXPECT_EQ(test, st->fake_wake, 0xdead0000U); + sleep_slp_ddr_set_deep_once(false); + KUNIT_EXPECT_EQ(test, st->fake_wake, 0xdead0000U | WAKE_SLP_DDR_USB); + + /* A crashed unmanaged coprocessor permanently clears bit 0. */ + scoped_guard(spinlock_irqsave, &sleep_slp_ddr_lock) { + sleep_slp_ddr_crashed = true; + sleep_slp_ddr_write(); + } + KUNIT_EXPECT_EQ(test, st->fake_wake, 0xdead0000U); + apple_sleep_usb_slp_ddr(true); + KUNIT_EXPECT_EQ(test, st->fake_wake, 0xdead0000U); +} + static struct kunit_case apple_sleep_test_cases[] = { KUNIT_CASE(apple_sleep_test_layout), KUNIT_CASE(apple_sleep_test_t6050), @@ -627,6 +730,7 @@ static struct kunit_case apple_sleep_test_cases[] = { KUNIT_CASE(apple_sleep_test_wdt_handoff), KUNIT_CASE(apple_sleep_test_apcie_slots), KUNIT_CASE(apple_sleep_test_t6040_wdt_span), + KUNIT_CASE(apple_sleep_test_slp_ddr_voters), {} }; diff --git a/drivers/soc/apple/sleep.c b/drivers/soc/apple/sleep.c index 97c533a763602..15197ca9cec7a 100644 --- a/drivers/soc/apple/sleep.c +++ b/drivers/soc/apple/sleep.c @@ -855,6 +855,8 @@ struct apple_sleep_soc { bool wdt_wd1; /* The SMC gets pmVC and WKTP before slpa (gen 1, as t6000 has them) */ bool smc_gen1_keys; + /* Live coprocessors with DRAM buffers require WAKE_SLP_DDR across sleep. */ + bool coproc_slp_ddr; }; struct apple_sleep { @@ -1283,9 +1285,14 @@ bool apple_sleep_usb_aon_keep(unsigned int port, bool keep) } EXPORT_SYMBOL_GPL(apple_sleep_usb_aon_keep); -/* The USB host's vote, kept until the word is mapped. Only bit 0 is touched, as on macOS. */ +/* + * USB and live-coprocessor votes, kept until the word is mapped. Only bit 0 is + * touched, as on macOS. + */ static DEFINE_SPINLOCK(sleep_slp_ddr_lock); static bool sleep_slp_ddr_usb; +static unsigned int sleep_slp_ddr_coproc; +static bool sleep_slp_ddr_coproc_en; static void __iomem *sleep_slp_ddr_word; /* @@ -1306,7 +1313,8 @@ static void sleep_slp_ddr_write(void) if (!sleep_slp_ddr_word) return; val = readl(sleep_slp_ddr_word) & ~WAKE_SLP_DDR_USB; - if (sleep_slp_ddr_usb && !sleep_slp_ddr_crashed && !sleep_slp_ddr_deep_once) + if ((sleep_slp_ddr_usb || (sleep_slp_ddr_coproc_en && sleep_slp_ddr_coproc)) && + !sleep_slp_ddr_crashed && !sleep_slp_ddr_deep_once) val |= WAKE_SLP_DDR_USB; writel(val, sleep_slp_ddr_word); } @@ -1339,6 +1347,25 @@ void apple_sleep_usb_slp_ddr(bool up) } EXPORT_SYMBOL_GPL(apple_sleep_usb_slp_ddr); +void apple_sleep_coproc_slp_ddr(bool up) +{ + guard(spinlock_irqsave)(&sleep_slp_ddr_lock); + if (up) + sleep_slp_ddr_coproc++; + else if (sleep_slp_ddr_coproc) + sleep_slp_ddr_coproc--; + sleep_slp_ddr_write(); +} +EXPORT_SYMBOL_GPL(apple_sleep_coproc_slp_ddr); + +static void sleep_slp_ddr_bind(struct apple_sleep *s) +{ + guard(spinlock_irqsave)(&sleep_slp_ddr_lock); + sleep_slp_ddr_word = s->wake + WAKE_SLP_DDR; + sleep_slp_ddr_coproc_en = s->soc->coproc_slp_ddr; + sleep_slp_ddr_write(); +} + /* * From RTKit, for every firmware crash. One this driver stops and restarts around each sleep * doesn't run through it; for any other, every later sleep takes the deep path. It may come @@ -8572,10 +8599,7 @@ static int apple_sleep_probe(struct platform_device *pdev) ret = apple_sleep_alloc_books(s); if (ret) return ret; - scoped_guard(spinlock_irqsave, &sleep_slp_ddr_lock) { - sleep_slp_ddr_word = s->wake + WAKE_SLP_DDR; - sleep_slp_ddr_write(); - } + sleep_slp_ddr_bind(s); ret = apple_sleep_read_wake_sources(s); if (ret) diff --git a/include/linux/soc/apple/sleep.h b/include/linux/soc/apple/sleep.h index 6707370aa4466..ae171d7ac7968 100644 --- a/include/linux/soc/apple/sleep.h +++ b/include/linux/soc/apple/sleep.h @@ -186,6 +186,12 @@ void apple_sleep_usb_asleep_notifier_unregister(struct notifier_block *nb); */ void apple_sleep_usb_slp_ddr(bool up); +/* + * A coprocessor that stays live through a sleep with retained DRAM buffers + * votes to keep DRAM powered across sleep on SoCs whose sleep engine drops it. + */ +void apple_sleep_coproc_slp_ddr(bool up); + /* * A Type-C port in use asks for its always-on USB domain to stay up through the next sleep, * and takes the request back after it. Returns whether the domain will be kept. @@ -456,6 +462,10 @@ static inline void apple_sleep_usb_slp_ddr(bool up) { } +static inline void apple_sleep_coproc_slp_ddr(bool up) +{ +} + static inline bool apple_sleep_usb_aon_keep(unsigned int port, bool keep) { return false; From 8a7ac476d4d22bd628440b7e268913920bc46e8a Mon Sep 17 00:00:00 2001 From: Satya Benson Date: Tue, 1 Dec 2026 03:56:22 -0500 Subject: [PATCH 3/4] soc: apple: rtkit-helper: vote SLP_DDR for adopted DRAM buffers When a boot stage hands over a running RTKit session via apple,rtkit-handoff whose retained buffers live in reserved DRAM outside on-chip SRAM, the coprocessor remains running across system sleep and requires DRAM retention on SoCs whose sleep engine drops DRAM power. Record whether the inherited buffer inventory placed any buffer in reserved DRAM (only after the full inventory validates) and register a devm-managed apple_sleep_coproc_slp_ddr() vote when adopting the session. Sessions whose buffers all sit in SRAM, or cold-started helpers without a live handoff, do not vote. Add KUnit coverage for SRAM-only, DRAM-only, mixed and failed-inventory rollback tracking of dram_buffers. Signed-off-by: Satya Benson --- drivers/soc/apple/rtkit-helper-test.c | 64 +++++++++++++++++++++++++++ drivers/soc/apple/rtkit-helper.c | 44 +++++++++++++++--- 2 files changed, 101 insertions(+), 7 deletions(-) diff --git a/drivers/soc/apple/rtkit-helper-test.c b/drivers/soc/apple/rtkit-helper-test.c index 4e3aa1b0e07aa..7ee3ac26fc21a 100644 --- a/drivers/soc/apple/rtkit-helper-test.c +++ b/drivers/soc/apple/rtkit-helper-test.c @@ -431,6 +431,7 @@ static void rtkh_inherit_one_sram(struct kunit *test) KUNIT_EXPECT_NULL(test, b[0].shmem.buffer); KUNIT_EXPECT_PTR_EQ(test, (__force void *)b[0].shmem.iomem, ctx->sram_mem + 0x1000); + KUNIT_EXPECT_FALSE(test, ctx->helper.dram_buffers); } static void rtkh_inherit_max(struct kunit *test) @@ -459,6 +460,7 @@ static void rtkh_inherit_max(struct kunit *test) KUNIT_EXPECT_PTR_EQ(test, (__force void *)b[i].shmem.iomem, ctx->sram_mem + (b[i].shmem.iova - s)); } + KUNIT_EXPECT_FALSE(test, ctx->helper.dram_buffers); } static void rtkh_inherit_bad_count(struct kunit *test) @@ -569,6 +571,67 @@ static void rtkh_inherit_dma_mask_edge(struct kunit *test) KUNIT_EXPECT_EQ(test, rtkh_inherit(ctx, b), -EINVAL); } +#define RTKH_TEST_DRAM_START 0x9f0000000ULL +#define RTKH_TEST_DRAM_SIZE 0x10000 + +static void __iomem *rtkh_stub_map_dram(struct apple_rtkit_helper *helper, + const struct resource *res) +{ + struct kunit *test = kunit_get_current_test(); + struct rtkh_test *ctx = test->priv; + + if (res->start >= RTKH_TEST_DRAM_START && + res->end < RTKH_TEST_DRAM_START + RTKH_TEST_DRAM_SIZE) + return (__force void __iomem *)(ctx->sram_mem + (res->start - RTKH_TEST_DRAM_START)); + return ERR_PTR(-EINVAL); +} + +static void rtkh_inherit_dram_buffers(struct kunit *test) +{ + struct rtkh_test *ctx = test->priv; + struct apple_rtkit_inherited_buffer b[APPLE_RTKIT_HELPER_MAX_BUFFERS]; + const u64 s = RTKH_TEST_SRAM_START; + const u64 d = RTKH_TEST_DRAM_START; + const u32 dram_only[] = { 2, RTKH_HI(d + 0x1000), RTKH_LO(d + 0x1000), 0x2000, 0 }; + const u32 mixed[] = { + 1, RTKH_HI(s), RTKH_LO(s), 0x1000, 0, + 2, RTKH_HI(d + 0x2000), RTKH_LO(d + 0x2000), 0x1000, 0, + }; + const u32 dram_then_bad[] = { + 2, RTKH_HI(d), RTKH_LO(d), 0x1000, 0, + 4, RTKH_HI(s), RTKH_LO(s), 0x1000, 3, + }; + const u32 sram_only[] = { 1, RTKH_HI(s), RTKH_LO(s), 0x1000, 0 }; + + kunit_activate_static_stub(test, apple_rtkit_helper_map_dram, rtkh_stub_map_dram); + + /* A DRAM buffer followed by a bad tuple fails without setting dram_buffers. */ + rtkh_node(ctx, "apple,t8112-mtp"); + rtkh_inventory(ctx, dram_then_bad, ARRAY_SIZE(dram_then_bad)); + KUNIT_EXPECT_EQ(test, rtkh_inherit(ctx, b), -EINVAL); + KUNIT_EXPECT_FALSE(test, ctx->helper.dram_buffers); + + /* A valid reserved DRAM buffer records dram_buffers. */ + rtkh_node(ctx, "apple,t8112-mtp"); + rtkh_inventory(ctx, dram_only, ARRAY_SIZE(dram_only)); + KUNIT_ASSERT_EQ(test, rtkh_inherit(ctx, b), 1); + KUNIT_EXPECT_TRUE(test, ctx->helper.dram_buffers); + KUNIT_EXPECT_PTR_EQ(test, (__force void *)b[0].shmem.iomem, + ctx->sram_mem + 0x1000); + + /* Mixed SRAM and DRAM buffers also record dram_buffers. */ + rtkh_node(ctx, "apple,t8112-mtp"); + rtkh_inventory(ctx, mixed, ARRAY_SIZE(mixed)); + KUNIT_ASSERT_EQ(test, rtkh_inherit(ctx, b), 2); + KUNIT_EXPECT_TRUE(test, ctx->helper.dram_buffers); + + /* A subsequent SRAM-only inventory clears dram_buffers. */ + rtkh_node(ctx, "apple,t8112-mtp"); + rtkh_inventory(ctx, sram_only, ARRAY_SIZE(sram_only)); + KUNIT_ASSERT_EQ(test, rtkh_inherit(ctx, b), 1); + KUNIT_EXPECT_FALSE(test, ctx->helper.dram_buffers); +} + /* Sleep: the AP power notices */ static void rtkh_expect_calls(struct kunit *test, const bool *on, unsigned int n) @@ -891,6 +954,7 @@ static struct kunit_case apple_rtkit_helper_test_cases[] = { KUNIT_CASE(rtkh_inherit_bad_tuple), KUNIT_CASE(rtkh_inherit_bad_second), KUNIT_CASE(rtkh_inherit_dma_mask_edge), + KUNIT_CASE(rtkh_inherit_dram_buffers), KUNIT_CASE(rtkh_pm_fw_sleep_cycle), KUNIT_CASE(rtkh_pm_idle_late), KUNIT_CASE(rtkh_pm_no_fw_no_notice), diff --git a/drivers/soc/apple/rtkit-helper.c b/drivers/soc/apple/rtkit-helper.c index 2d0871dc5af5e..54410c70126ce 100644 --- a/drivers/soc/apple/rtkit-helper.c +++ b/drivers/soc/apple/rtkit-helper.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -44,6 +45,8 @@ struct apple_rtkit_helper { * it does not list must not replace storage the firmware still owns. */ bool strict_buffers; + /* Adopted buffers include reserved DRAM regions outside on-chip SRAM. */ + bool dram_buffers; /* The AP idle notice waits for .suspend_late, after the HID host's packets */ bool idle_late; /* The firmware was told the AP is going to sleep. */ @@ -130,6 +133,11 @@ static void apple_rtkit_helper_release(void *rtk) apple_rtkit_free_retaining_buffers(rtk); } +static void apple_rtkit_helper_release_slp_ddr(void *unused) +{ + apple_sleep_coproc_slp_ddr(false); +} + /* * MTP firmware cannot always be restarted once it has been taken to QUIESCED * or SLEEP, so a boot stage that used it hands the session over running. It @@ -203,6 +211,18 @@ static bool apple_rtkit_helper_retained_mtp(struct device_node *np) of_device_is_compatible(np, "apple,t6041-mtp"); } +static void __iomem *apple_rtkit_helper_map_dram(struct apple_rtkit_helper *helper, + const struct resource *res) +{ +#if IS_ENABLED(CONFIG_APPLE_RTKIT_HELPER_KUNIT_TEST) + KUNIT_STATIC_STUB_REDIRECT(apple_rtkit_helper_map_dram, helper, res); +#endif + /* DVA == PA is part of this retained-bypass handoff contract. */ + if (!apple_rtkit_helper_reserved(helper->dev->of_node, res)) + return ERR_PTR(-EINVAL); + return devm_ioremap(helper->dev, res->start, resource_size(res)) ?: ERR_PTR(-ENOMEM); +} + static int apple_rtkit_helper_inherit_buffers( struct apple_rtkit_helper *helper, struct apple_rtkit_inherited_buffer *buffers) @@ -211,6 +231,7 @@ static int apple_rtkit_helper_inherit_buffers( struct property *inventory; u32 cells[APPLE_RTKIT_HELPER_MAX_BUFFERS * APPLE_RTKIT_HELPER_BUFFER_CELLS]; int count, i, length, ret; + bool has_dram = false; /* T8140 producers predating the buffer inventory remain compatible. */ inventory = of_find_property(np, "apple,rtkit-buffers", &length); @@ -219,8 +240,10 @@ static int apple_rtkit_helper_inherit_buffers( return -EINVAL; return 0; } - if (!length) + if (!length) { + helper->dram_buffers = false; return 0; + } count = of_property_count_u32_elems(np, "apple,rtkit-buffers"); if (count < 0 || count > ARRAY_SIZE(cells) || count % APPLE_RTKIT_HELPER_BUFFER_CELLS) @@ -253,14 +276,13 @@ static int apple_rtkit_helper_inherit_buffers( if (helper->sram && resource_contains(helper->sram, &res)) { b->iomem = helper->sram_base + res.start - helper->sram->start; } else { - /* DVA == PA is part of this retained-bypass handoff contract. */ - if (!apple_rtkit_helper_reserved(np, &res)) - return -EINVAL; - b->iomem = devm_ioremap(helper->dev, res.start, resource_size(&res)); - if (!b->iomem) - return -ENOMEM; + b->iomem = apple_rtkit_helper_map_dram(helper, &res); + if (IS_ERR(b->iomem)) + return PTR_ERR(b->iomem); + has_dram = true; } } + helper->dram_buffers = has_dram; return count; } @@ -370,6 +392,14 @@ static int apple_rtkit_helper_probe(struct platform_device *pdev) ret = apple_rtkit_helper_pm_register(helper); if (ret) return ret; + if (helper->dram_buffers) { + apple_sleep_coproc_slp_ddr(true); + ret = devm_add_action_or_reset(dev, + apple_rtkit_helper_release_slp_ddr, + NULL); + if (ret) + return ret; + } /* There is no safe module-unload boundary for the retained session. */ __module_get(THIS_MODULE); From f27ce29f2ecad09775279e85af0cff9505165fe9 Mon Sep 17 00:00:00 2001 From: Satya Benson Date: Tue, 1 Dec 2026 03:56:22 -0500 Subject: [PATCH 4/4] soc: apple: sleep: wire SLP_DDR vote word on T8112 T8112 uses its own map_regs callback and never bound sleep_slp_ddr_word to wake + WAKE_SLP_DDR (0x00). On a T8112 laptop with an adopted live MTP session retaining DRAM buffers behind its bypass DART, committing deep sleep with WAKE_SLP_DDR clear drops DRAM power out from under the running MTP and hangs the commit until the watchdog resets. Bind sleep_slp_ddr_word in t8112_sleep_map_regs() and enable coproc_slp_ddr on t8112_sleep_soc so an adopted helper with DRAM buffers sets WAKE_SLP_DDR bit 0 while boards without one (such as T8112 desktops or boots without a live DRAM handoff) leave bit 0 clear for full DRAM-off deep sleep. Signed-off-by: Satya Benson --- drivers/soc/apple/sleep-t8112.h | 3 +++ drivers/soc/apple/sleep-test.c | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/drivers/soc/apple/sleep-t8112.h b/drivers/soc/apple/sleep-t8112.h index 24ef5ab871b39..5a9d5865b82b9 100644 --- a/drivers/soc/apple/sleep-t8112.h +++ b/drivers/soc/apple/sleep-t8112.h @@ -275,6 +275,8 @@ static int t8112_sleep_map_regs(struct apple_sleep *s) } } + sleep_slp_ddr_bind(s); + { int ret = apple_sleep_read_wake_sources(s); @@ -1222,6 +1224,7 @@ static const struct apple_sleep_soc t8112_sleep_soc = { .ops = &t8112_sleep_ops, .untested = true, .early_context = true, + .coproc_slp_ddr = true, .early_cpu_wfi = true, .boot_wfi_delay_ms = 2, .no_pmu_notes = true, diff --git a/drivers/soc/apple/sleep-test.c b/drivers/soc/apple/sleep-test.c index f3368ad22d72f..3774fa26749da 100644 --- a/drivers/soc/apple/sleep-test.c +++ b/drivers/soc/apple/sleep-test.c @@ -712,6 +712,14 @@ static void apple_sleep_test_slp_ddr_voters(struct kunit *test) KUNIT_EXPECT_EQ(test, st->fake_wake, 0xdead0000U); apple_sleep_usb_slp_ddr(true); KUNIT_EXPECT_EQ(test, st->fake_wake, 0xdead0000U); + + /* Only T8112 enables coprocessor SLP_DDR votes among matched profiles. */ + for (const struct of_device_id *id = apple_sleep_of_match; id->compatible[0]; id++) { + const struct apple_sleep_soc *soc = id->data; + bool want = !strcmp(id->compatible, "apple,t8112-sleep"); + + KUNIT_EXPECT_EQ_MSG(test, soc->coproc_slp_ddr, want, "%s", id->compatible); + } } static struct kunit_case apple_sleep_test_cases[] = {