From b57e1b307bfb746b082e72b31e70cba1072e74cd Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 00:43:55 +1100 Subject: [PATCH 1/7] iommu: apple-dart: remove the unused apple_dart_m5_restore() apple_dart_m5_restore() came in with the T6050 suspend-to-RAM work (5ce3491f2836b) without a caller, and nothing has called it since. The firmware 27 display sleep restores its DARTs through the v27 lease (apple-dart-v27-late.inc). Nothing ever writes the fields the function restores (m5_streams, m5_gapf, m5_diag, m5_error_mask, m5_protect, m5_lock), and m5_changed is only ever cleared, so even with a caller it would have restored zeros. Remove the function, its declaration and stub, and the fields only it used. m5_sleep_owner, m5_disp_streams and m5_display stay; the v27 code uses them. Signed-off-by: Ryan Murray --- drivers/iommu/apple-dart.c | 56 +--------------------------------- include/linux/soc/apple/dart.h | 7 ----- 2 files changed, 1 insertion(+), 62 deletions(-) diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index 4bb6491eedb8c..04dcdc3801174 100644 --- a/drivers/iommu/apple-dart.c +++ b/drivers/iommu/apple-dart.c @@ -375,9 +375,8 @@ struct apple_dart { bool sleep_flushed; /* The firmware 27 display sleep owns it: never replay locked trees. */ struct device *m5_sleep_owner; - u32 m5_streams, m5_gapf, m5_diag, m5_error_mask, m5_protect, m5_lock; u32 m5_disp_streams; /* the display pipe's streams before its domain went off */ - bool m5_released, m5_changed, m5_display, m5_failed; + bool m5_display; /* Optional cached evidence; never a sleep-ownership grant. */ struct mutex v27_lifecycle; struct list_head v27_clients; @@ -7766,59 +7765,6 @@ static int apple_dart_m5_idle(struct apple_dart *dart) } -int apple_dart_m5_restore(struct device *dev, struct device *owner) -{ - struct apple_dart *dart = dev_get_drvdata(dev); - u32 status; - int ret; - - if (!dart) - return -EINVAL; - guard(spinlock_irqsave)(&dart->lock); - if (dart->m5_sleep_owner != owner) - return -EINVAL; - if (dart->m5_failed) - return -EUCLEAN; - if (!dart->m5_changed) - goto done; - /* Caller proved power up. This is a retained warm path, never a cold - * mapper rebuild, PROTECT unlock, or firmware memory reallocation. - */ - if (!apple_dart_state_retained(dart) || - readl(dart->regs + DART_T8110_PROTECT) != dart->m5_protect || - readl(dart->regs + DART_T8110_PROTECT_LOCK) != dart->m5_lock) { - dart->m5_failed = true; - return -EUCLEAN; - } - /* A partial restore is uncertain too; only full readback clears poison. */ - dart->m5_failed = true; - writel(dart->m5_gapf, dart->gapf); - if (readl(dart->gapf) != dart->m5_gapf) - return -EIO; - writel(DART_T8110_TLB_CMD_POWERDOWN, dart->regs + DART_T8110_TLB_CMD); - ret = readl_poll_timeout_atomic(dart->regs + DART_T8110_TLB_CMD, status, - !(status & DART_T8110_TLB_CMD_BUSY), 1, DART_T8110_FLUSH_BUSY_TIMEOUT); - if (ret) - return ret; - if (dart->ctc_flush) - writel(0, dart->regs + DART_T8110_CTC_FLUSH); - writel(dart->m5_diag, dart->regs + DART_T8110_DIAG_LOCK); - writel(dart->m5_error_mask, dart->regs + DART_T8110_V2_ERROR_MASK); - writel(dart->m5_streams, dart->regs + DART_T8110_ENABLE_STREAMS); - if (apple_dart_m5_streams_unowned(dart, dart->m5_streams) || - readl(dart->regs + DART_T8110_ENABLE_STREAMS) != dart->m5_streams) - return -EIO; - WRITE_ONCE(dart->display_tlb_stale, false); - WRITE_ONCE(dart->display_dark, false); - done: - dart->m5_failed = false; - dart->m5_changed = false; - dart->m5_released = false; - dart->m5_sleep_owner = NULL; - return 0; -} -EXPORT_SYMBOL_GPL(apple_dart_m5_restore); - /* * T6050 (firmware 27): a display coprocessor's DART around a stop and restart of that * coprocessor after a wake, outside a system sleep, and the internal display pipe's DART diff --git a/include/linux/soc/apple/dart.h b/include/linux/soc/apple/dart.h index 0a7925025e628..fb9e50b65416c 100644 --- a/include/linux/soc/apple/dart.h +++ b/include/linux/soc/apple/dart.h @@ -191,8 +191,6 @@ int apple_dart_display_streams(struct device *dev, u32 streams, bool on, bool fl int apple_dart_gapf_ready(struct device *dev); /* A display DART whose domain goes off at runtime while others still map into it. */ void apple_dart_power_dark(struct device *dev, bool dark); -/* A DART's state kept across its consumer's own power cycle, outside a system sleep. */ -int apple_dart_m5_restore(struct device *dev, struct device *owner); /* T6050: a display coprocessor's DART around its restart, the display pipe's around its domain's. */ int apple_dart_m5_display_cycle(struct device *dev, bool on); int apple_dart_m5_display_snapshot(struct device *dev); @@ -230,11 +228,6 @@ static inline void apple_dart_power_dark(struct device *dev, bool dark) { } -static inline int apple_dart_m5_restore(struct device *dev, struct device *owner) -{ - return -EOPNOTSUPP; -} - static inline int apple_dart_m5_display_cycle(struct device *dev, bool on) { return -EOPNOTSUPP; } static inline int apple_dart_m5_display_snapshot(struct device *dev) { return -EOPNOTSUPP; } static inline int apple_dart_m5_display_rewrite(struct device *dev) { return -EOPNOTSUPP; } From 6090c7283e84607bf7a3e5bfbbe1873e57c1fa22 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 00:44:08 +1100 Subject: [PATCH 2/7] phy: apple: atc: remove the synchronous sleep finish and its flush The dwc3 glue finishes a sleep with apple_atcphy_sleep_finish_async() and polls apple_atcphy_sleep_finish_done() since a6671210b88c0 ("usb: dwc3: apple: keep USB teardown out of the PM notifier chain"). That removed the last caller of apple_atcphy_sleep_finish() and apple_atcphy_sleep_finish_flush(). Remove both exports and their stubs. The static atcphy_sleep_finish() stays; the finish work runs it. Signed-off-by: Ryan Murray --- drivers/phy/apple/atc.c | 18 ------------------ include/linux/phy/apple-atc.h | 14 +------------- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/drivers/phy/apple/atc.c b/drivers/phy/apple/atc.c index 34d3aa12b8f4c..b4dc012939466 100644 --- a/drivers/phy/apple/atc.c +++ b/drivers/phy/apple/atc.c @@ -7577,15 +7577,6 @@ static void atcphy_sleep_finish(struct apple_atcphy *atcphy, bool kept) atcphy_sleep_ss_up(atcphy); } -void apple_atcphy_sleep_finish(struct phy *usb2_phy, bool kept) -{ - struct apple_atcphy *atcphy = atcphy_from_usb2_phy(usb2_phy); - - if (atcphy) - atcphy_sleep_finish(atcphy, kept); -} -EXPORT_SYMBOL_GPL(apple_atcphy_sleep_finish); - static void atcphy_sleep_finish_work(struct work_struct *work) { struct apple_atcphy *atcphy = container_of(work, struct apple_atcphy, sleep_finish_work); @@ -7619,15 +7610,6 @@ bool apple_atcphy_sleep_finish_done(struct phy *usb2_phy) } EXPORT_SYMBOL_GPL(apple_atcphy_sleep_finish_done); -void apple_atcphy_sleep_finish_flush(struct phy *usb2_phy) -{ - struct apple_atcphy *atcphy = atcphy_from_usb2_phy(usb2_phy); - - if (atcphy) - flush_work(&atcphy->sleep_finish_work); -} -EXPORT_SYMBOL_GPL(apple_atcphy_sleep_finish_flush); - static struct apple_atcphy *atcphy_from_cio_phy(struct phy *phy) { struct apple_atcphy *atcphy; diff --git a/include/linux/phy/apple-atc.h b/include/linux/phy/apple-atc.h index f6beaeb901cb6..72e2a5b367bbe 100644 --- a/include/linux/phy/apple-atc.h +++ b/include/linux/phy/apple-atc.h @@ -40,15 +40,11 @@ int apple_atcphy_sleep_recover(struct phy *usb2_phy); /* * Ends a sleep that prepare took on, with the SuperSpeed side back as the mux wants it. * Without @kept the host was restarted; only a failure of the PHY's own then makes the - * controller stop for later sleeps. + * controller stop for later sleeps. It runs from the PHY's work, after a wake. */ -void apple_atcphy_sleep_finish(struct phy *usb2_phy, bool kept); - -/* The same from the PHY's work, for after a wake; the flush waits for it. */ void apple_atcphy_sleep_finish_async(struct phy *usb2_phy, bool kept); /* Nonblocking admission query; the caller serializes finish requests into epochs. */ bool apple_atcphy_sleep_finish_done(struct phy *usb2_phy); -void apple_atcphy_sleep_finish_flush(struct phy *usb2_phy); /* ACIO owns this transaction; @phy is its shared USB3 lane PHY handle. */ int apple_atcphy_cio_prepare(struct phy *phy); @@ -71,10 +67,6 @@ static inline int apple_atcphy_sleep_recover(struct phy *usb2_phy) return -EOPNOTSUPP; } -static inline void apple_atcphy_sleep_finish(struct phy *usb2_phy, bool kept) -{ -} - static inline void apple_atcphy_sleep_finish_async(struct phy *usb2_phy, bool kept) { } @@ -84,10 +76,6 @@ static inline bool apple_atcphy_sleep_finish_done(struct phy *usb2_phy) return true; } -static inline void apple_atcphy_sleep_finish_flush(struct phy *usb2_phy) -{ -} - static inline int apple_atcphy_cio_prepare(struct phy *phy) { return -EOPNOTSUPP; From 29adac5af8151bc51717409ce0f20f2e99f9ee3a Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 00:44:31 +1100 Subject: [PATCH 3/7] soc: apple: sleep: remove apple_sleep_smc_register() macsmc registers its sleep notices through apple_sleep_smc_register_saved(), which takes the full ops table. Nothing calls the older apple_sleep_smc_register(), which only took the late notice and refused to run once saved ops were registered. Remove it and its stub. Signed-off-by: Ryan Murray --- drivers/soc/apple/sleep.c | 18 ------------------ include/linux/soc/apple/sleep.h | 4 ---- 2 files changed, 22 deletions(-) diff --git a/drivers/soc/apple/sleep.c b/drivers/soc/apple/sleep.c index ce1bcee755574..b2e0ff148a54a 100644 --- a/drivers/soc/apple/sleep.c +++ b/drivers/soc/apple/sleep.c @@ -1784,24 +1784,6 @@ bool apple_sleep_smc_defer_notice(void) } EXPORT_SYMBOL_GPL(apple_sleep_smc_defer_notice); -int apple_sleep_smc_register(struct device *dev, - int (*late_notice)(void *data, u64 *sent, u64 *ack), void *data) -{ - struct apple_sleep *s = apple_sleep; - guard(mutex)(&apple_sleep_smc_lock); - - if (!s || !s->soc->smc_policy || !pm_suspend_via_firmware()) - return -EOPNOTSUPP; - if (!late_notice || s->smc.saved_ops || (s->smc.dev && s->smc.dev != dev)) - return -EBUSY; - if (!s->smc.dev) - s->smc.dev = get_device(dev); - s->smc.late_notice = late_notice; - s->smc.data = data; - return 0; -} -EXPORT_SYMBOL_GPL(apple_sleep_smc_register); - int apple_sleep_smc_register_saved(struct device *dev, const struct apple_sleep_smc_saved_ops *ops, void *data) { diff --git a/include/linux/soc/apple/sleep.h b/include/linux/soc/apple/sleep.h index cec1e88452676..aa5e6b1ebb7c3 100644 --- a/include/linux/soc/apple/sleep.h +++ b/include/linux/soc/apple/sleep.h @@ -40,8 +40,6 @@ struct apple_sleep_smc_saved_ops { const struct apple_sleep_smc_policy *apple_sleep_smc_policy(void); /* J813 experiment: send the final SMC notice after the peer idle handshakes. */ bool apple_sleep_smc_defer_notice(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, const struct apple_sleep_smc_saved_ops *ops, void *data); void apple_sleep_smc_unregister(struct device *dev); @@ -244,8 +242,6 @@ 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 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, const struct apple_sleep_smc_saved_ops *ops, void *data) { return -EOPNOTSUPP; } static inline void apple_sleep_smc_unregister(struct device *dev) {} From 14338ffca3ba0ac46090c3e9d2286f62c22fcbeb Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 00:44:37 +1100 Subject: [PATCH 4/7] soc: apple: rtkit: remove the unused devm_apple_rtkit_free() No driver frees a devm RTKit instance early: nothing in the tree, C or Rust, calls devm_apple_rtkit_free(). Remove it. Signed-off-by: Ryan Murray --- drivers/soc/apple/rtkit.c | 6 ------ include/linux/soc/apple/rtkit.h | 8 -------- 2 files changed, 14 deletions(-) diff --git a/drivers/soc/apple/rtkit.c b/drivers/soc/apple/rtkit.c index 22a7fad956426..7f59fd1e60e81 100644 --- a/drivers/soc/apple/rtkit.c +++ b/drivers/soc/apple/rtkit.c @@ -3471,12 +3471,6 @@ struct apple_rtkit *devm_apple_rtkit_init_m5_saved(struct device *dev, void *coo } EXPORT_SYMBOL_GPL(devm_apple_rtkit_init_m5_saved); -void devm_apple_rtkit_free(struct device *dev, struct apple_rtkit *rtk) -{ - devm_release_action(dev, apple_rtkit_free_wrapper, rtk); -} -EXPORT_SYMBOL_GPL(devm_apple_rtkit_free); - MODULE_LICENSE("Dual MIT/GPL"); MODULE_AUTHOR("Sven Peter "); MODULE_DESCRIPTION("Apple RTKit driver"); diff --git a/include/linux/soc/apple/rtkit.h b/include/linux/soc/apple/rtkit.h index 4db916bb89f09..75e94ea827c6c 100644 --- a/include/linux/soc/apple/rtkit.h +++ b/include/linux/soc/apple/rtkit.h @@ -142,14 +142,6 @@ struct apple_rtkit; struct apple_rtkit *devm_apple_rtkit_init(struct device *dev, void *cookie, const char *mbox_name, int mbox_idx, const struct apple_rtkit_ops *ops); -/* - * Frees internal RTKit state allocated by devm_apple_rtkit_init(). - * - * @dev: Pointer to the device node this coprocessor is assocated with - * @rtk: Internal RTKit state initialized by devm_apple_rtkit_init() - */ -void devm_apple_rtkit_free(struct device *dev, struct apple_rtkit *rtk); - /* * Non-devm version of devm_apple_rtkit_init. Must be freed with * apple_rtkit_free. From 238c40cb2bfdbcdb905821364ac2855167aae61c Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 00:45:00 +1100 Subject: [PATCH 5/7] soc: apple: pmp-display: remove the unused apple_pmp_j713_gpu_check() apple_pmp_j713_gpu_check() was added beside the GPU prepare and get helpers but has never had a caller. Remove it; pmp_power_check() keeps its display callers. Signed-off-by: Ryan Murray --- drivers/soc/apple/pmp-display.c | 6 ------ include/linux/soc/apple/pmp-display.h | 1 - 2 files changed, 7 deletions(-) diff --git a/drivers/soc/apple/pmp-display.c b/drivers/soc/apple/pmp-display.c index b32e155ec09f0..2a8c8593331e5 100644 --- a/drivers/soc/apple/pmp-display.c +++ b/drivers/soc/apple/pmp-display.c @@ -536,12 +536,6 @@ int apple_pmp_j713_display_check_release(struct device *consumer) } EXPORT_SYMBOL_GPL(apple_pmp_j713_display_check_release); -int apple_pmp_j713_gpu_check(struct device *consumer) -{ - return apple_pmp_j713_board() ? pmp_power_check(consumer, PMP_POWER_AGX, false) : -ENODEV; -} -EXPORT_SYMBOL_GPL(apple_pmp_j713_gpu_check); - int apple_pmp_j713_display_get(struct device *consumer) { return apple_pmp_j713_board() ? pmp_power_get(consumer, PMP_POWER_DISP) : -ENODEV; diff --git a/include/linux/soc/apple/pmp-display.h b/include/linux/soc/apple/pmp-display.h index e65effb337aa8..916d176389c3d 100644 --- a/include/linux/soc/apple/pmp-display.h +++ b/include/linux/soc/apple/pmp-display.h @@ -44,6 +44,5 @@ int apple_pmp_j713_display_check(struct device *consumer); int apple_pmp_j713_display_check_release(struct device *consumer); int apple_pmp_j713_gpu_prepare(struct device *consumer); int apple_pmp_j713_gpu_get(struct device *consumer); -int apple_pmp_j713_gpu_check(struct device *consumer); #endif From 5996b85e1212f26c581e95b7f1a7cf16bbcefd3e Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 00:45:25 +1100 Subject: [PATCH 6/7] media: apple: isp: drop the disabled conditional coprocessor reset isp_firmware_boot_stage1() carries an #if 0 block that reset the coprocessor only when a GPIO word read back a marker, disabled because it did not work well with system sleep. The unconditional isp_reset_coproc() right after it replaced it. Drop the block and the commented-out variable it needed. Signed-off-by: Ryan Murray --- drivers/media/platform/apple/isp/isp-fw.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/media/platform/apple/isp/isp-fw.c b/drivers/media/platform/apple/isp/isp-fw.c index 09b6912286505..186e4e9ae5142 100644 --- a/drivers/media/platform/apple/isp/isp-fw.c +++ b/drivers/media/platform/apple/isp/isp-fw.c @@ -508,7 +508,6 @@ static void isp_firmware_shutdown_stage1(struct apple_isp *isp) static int isp_firmware_boot_stage1(struct apple_isp *isp) { int err; - // u32 val; isp_restore_fw_memory(isp); @@ -526,16 +525,6 @@ static int isp_firmware_boot_stage1(struct apple_isp *isp) if (isp->hw->gen != ISP_GEN_T8140 && isp->hw->gen != ISP_GEN_T6040) isp_gpio_write32(isp, ISP_GPIO_CLOCK_EN, 0x1); -#if 0 - /* This doesn't work well with system sleep */ - val = isp_gpio_read32(isp, ISP_GPIO_1); - if (val == 0xfeedbabe) { - err = isp_reset_coproc(isp); - if (err < 0) - return err; - } -#endif - err = isp_reset_coproc(isp); if (err < 0) goto shutdown; From ac05cfaca46cf7926478f60f72680cc53f306d16 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 27 Nov 2026 16:28:35 +1100 Subject: [PATCH 7/7] Revert "phy: apple: atc: remove the synchronous sleep finish and its flush" This reverts commit 6090c7283e84607bf7a3e5bfbbe1873e57c1fa22. Review follow-up: open #2215 (T6040 suspend-to-RAM) still calls apple_atcphy_sleep_finish() and apple_atcphy_sleep_finish_flush(). The two PRs do not conflict in text, so landing both would break every file that includes . Keep the two exports until #2215 has settled; their removal can follow it. Signed-off-by: Ryan Murray --- drivers/phy/apple/atc.c | 18 ++++++++++++++++++ include/linux/phy/apple-atc.h | 14 +++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/phy/apple/atc.c b/drivers/phy/apple/atc.c index b4dc012939466..34d3aa12b8f4c 100644 --- a/drivers/phy/apple/atc.c +++ b/drivers/phy/apple/atc.c @@ -7577,6 +7577,15 @@ static void atcphy_sleep_finish(struct apple_atcphy *atcphy, bool kept) atcphy_sleep_ss_up(atcphy); } +void apple_atcphy_sleep_finish(struct phy *usb2_phy, bool kept) +{ + struct apple_atcphy *atcphy = atcphy_from_usb2_phy(usb2_phy); + + if (atcphy) + atcphy_sleep_finish(atcphy, kept); +} +EXPORT_SYMBOL_GPL(apple_atcphy_sleep_finish); + static void atcphy_sleep_finish_work(struct work_struct *work) { struct apple_atcphy *atcphy = container_of(work, struct apple_atcphy, sleep_finish_work); @@ -7610,6 +7619,15 @@ bool apple_atcphy_sleep_finish_done(struct phy *usb2_phy) } EXPORT_SYMBOL_GPL(apple_atcphy_sleep_finish_done); +void apple_atcphy_sleep_finish_flush(struct phy *usb2_phy) +{ + struct apple_atcphy *atcphy = atcphy_from_usb2_phy(usb2_phy); + + if (atcphy) + flush_work(&atcphy->sleep_finish_work); +} +EXPORT_SYMBOL_GPL(apple_atcphy_sleep_finish_flush); + static struct apple_atcphy *atcphy_from_cio_phy(struct phy *phy) { struct apple_atcphy *atcphy; diff --git a/include/linux/phy/apple-atc.h b/include/linux/phy/apple-atc.h index 72e2a5b367bbe..f6beaeb901cb6 100644 --- a/include/linux/phy/apple-atc.h +++ b/include/linux/phy/apple-atc.h @@ -40,11 +40,15 @@ int apple_atcphy_sleep_recover(struct phy *usb2_phy); /* * Ends a sleep that prepare took on, with the SuperSpeed side back as the mux wants it. * Without @kept the host was restarted; only a failure of the PHY's own then makes the - * controller stop for later sleeps. It runs from the PHY's work, after a wake. + * controller stop for later sleeps. */ +void apple_atcphy_sleep_finish(struct phy *usb2_phy, bool kept); + +/* The same from the PHY's work, for after a wake; the flush waits for it. */ void apple_atcphy_sleep_finish_async(struct phy *usb2_phy, bool kept); /* Nonblocking admission query; the caller serializes finish requests into epochs. */ bool apple_atcphy_sleep_finish_done(struct phy *usb2_phy); +void apple_atcphy_sleep_finish_flush(struct phy *usb2_phy); /* ACIO owns this transaction; @phy is its shared USB3 lane PHY handle. */ int apple_atcphy_cio_prepare(struct phy *phy); @@ -67,6 +71,10 @@ static inline int apple_atcphy_sleep_recover(struct phy *usb2_phy) return -EOPNOTSUPP; } +static inline void apple_atcphy_sleep_finish(struct phy *usb2_phy, bool kept) +{ +} + static inline void apple_atcphy_sleep_finish_async(struct phy *usb2_phy, bool kept) { } @@ -76,6 +84,10 @@ static inline bool apple_atcphy_sleep_finish_done(struct phy *usb2_phy) return true; } +static inline void apple_atcphy_sleep_finish_flush(struct phy *usb2_phy) +{ +} + static inline int apple_atcphy_cio_prepare(struct phy *phy) { return -EOPNOTSUPP;