From 73a7fbd99ce2f97d1a4a5cb9208cf453c50d6350 Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Thu, 3 Dec 2026 17:58:16 -0500 Subject: [PATCH 1/9] PM: suspend: take s2idle when the platform vetoes a deep sleep When the platform knows before a deep sleep starts that it would refuse it, because a driver that can't take part has said so, the sleep still runs until the refusal: the suspend fails and the machine stays awake, although suspend-to-idle, which needs nothing from the platform, would have worked. Add an optional deep_vetoed() callback to platform_suspend_ops. pm_suspend() asks it for PM_SUSPEND_MEM before anything is frozen and, on a veto, suspends to idle for that one sleep. mem_sleep keeps what user space chose, and the next "mem" asks again. A refusal found once the sleep has started still fails it, as before. Signed-off-by: DjDeveloperr --- include/linux/suspend.h | 10 ++++++++++ kernel/power/suspend.c | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/include/linux/suspend.h b/include/linux/suspend.h index 2fcb352878229..9a7ce5ae2337a 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -117,6 +117,15 @@ typedef int __bitwise suspend_state_t; * Called by the PM core if the suspending of devices fails. * This callback is optional and should only be implemented by platforms * which require special recovery actions in that situation. + * + * @deep_vetoed: Whether the platform already knows it would refuse the + * %PM_SUSPEND_MEM transition about to start, for example because a driver + * that cannot take part in it has said so. + * Called by pm_suspend() before tasks are frozen and before @begin(). If + * it returns true, the system suspends to idle instead, which needs nothing + * from the platform. A refusal found only once the transition has started + * still fails it. + * This callback is optional. */ struct platform_suspend_ops { int (*valid)(suspend_state_t state); @@ -129,6 +138,7 @@ struct platform_suspend_ops { bool (*suspend_again)(void); void (*end)(void); void (*recover)(void); + bool (*deep_vetoed)(void); }; struct platform_s2idle_ops { diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 93de42d73120d..b7a839831ad60 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -683,6 +683,13 @@ int pm_suspend(suspend_state_t state) if (state <= PM_SUSPEND_ON || state >= PM_SUSPEND_MAX) return -EINVAL; + /* Before anything is frozen: suspend-to-idle needs nothing from the platform. */ + if (state == PM_SUSPEND_MEM && suspend_ops && suspend_ops->deep_vetoed && + suspend_ops->deep_vetoed()) { + pr_info("deep sleep vetoed by the platform, suspending to idle\n"); + state = PM_SUSPEND_TO_IDLE; + } + pr_info("suspend entry (%s)\n", mem_sleep_labels[state]); error = enter_state(state); dpm_save_errno(error); From 95f0370d1f45b0efbb0b4afa8430dd372475e5b5 Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Thu, 3 Dec 2026 17:58:17 -0500 Subject: [PATCH 2/9] soc: apple: sleep: let a driver veto a deep sleep before it starts Some refusals of a deep sleep are known before it starts: a T6020 PMP whose boot loader didn't publish apple,sram-keep refuses every one (linux#4238), and a USB4 port refuses one while a PCIe function behind it can't be removed. They come after devices have suspended (the PMP's suspend_late) or after the freeze has begun (the port's PM notifier), so the suspend fails and the Mac stays awake. Add devm_apple_sleep_deep_veto(). A driver registers with a check that is asked before each deep sleep, or with none to veto every one, until it unbinds. The list is kept out of struct apple_sleep, so a driver may register before this one probes. The sleep driver answers the PM core's deep_vetoed() from that list and from .begin's check for PCIe ports no host sets up again after a deep sleep (T8132). Such a sleep then goes to s2idle. .begin keeps its check, for a host that leaves in between. Signed-off-by: DjDeveloperr --- drivers/soc/apple/sleep.c | 66 +++++++++++++++++++++++++++++++++ include/linux/soc/apple/sleep.h | 12 ++++++ 2 files changed, 78 insertions(+) diff --git a/drivers/soc/apple/sleep.c b/drivers/soc/apple/sleep.c index e6eaa106f88a1..8faa261ad895a 100644 --- a/drivers/soc/apple/sleep.c +++ b/drivers/soc/apple/sleep.c @@ -1478,6 +1478,70 @@ void apple_sleep_apcie_ports_owned(bool owned) } EXPORT_SYMBOL_GPL(apple_sleep_apcie_ports_owned); +/* + * A driver that knows, before a sleep starts, that it would refuse a deep one. Kept out of + * struct apple_sleep so that driver may probe before this one. + */ +struct apple_sleep_deep_veto { + struct list_head node; + struct device *dev; + bool (*vetoes)(struct device *dev); +}; + +static LIST_HEAD(sleep_deep_vetoes); +static DEFINE_MUTEX(sleep_deep_veto_lock); + +static void apple_sleep_deep_veto_drop(void *data) +{ + struct apple_sleep_deep_veto *veto = data; + + guard(mutex)(&sleep_deep_veto_lock); + list_del(&veto->node); +} + +int devm_apple_sleep_deep_veto(struct device *dev, bool (*vetoes)(struct device *dev)) +{ + struct apple_sleep_deep_veto *veto; + + veto = devm_kzalloc(dev, sizeof(*veto), GFP_KERNEL); + if (!veto) + return -ENOMEM; + veto->dev = dev; + veto->vetoes = vetoes; + scoped_guard(mutex, &sleep_deep_veto_lock) + list_add_tail(&veto->node, &sleep_deep_vetoes); + + return devm_add_action_or_reset(dev, apple_sleep_deep_veto_drop, veto); +} +EXPORT_SYMBOL_GPL(devm_apple_sleep_deep_veto); + +/* + * Asked by pm_suspend() for a deep sleep, before anything is frozen: what is known now to + * refuse it. That sleep then goes to s2idle, which needs none of it. What is found only + * later, as a device's suspend or the checks at .enter, still refuses the deep sleep. + */ +static bool apple_sleep_deep_vetoed(void) +{ + struct apple_sleep *s = apple_sleep; + struct apple_sleep_deep_veto *veto; + + /* The same check as .begin's, which stays for a host that leaves after this one. */ + if (sleep_apcie_ports_orphaned(s)) { + dev_info(s->dev, "deep sleep vetoed: no host sets the PCIe ports up again after one\n"); + return true; + } + + guard(mutex)(&sleep_deep_veto_lock); + list_for_each_entry(veto, &sleep_deep_vetoes, node) { + if (!veto->vetoes || veto->vetoes(veto->dev)) { + dev_info(s->dev, "deep sleep vetoed by %s\n", dev_name(veto->dev)); + return true; + } + } + + return false; +} + /* One APCIe port's host set it up again after a real sleep: the next commit may stop it. */ void apple_sleep_apcie_port_up(unsigned int idx) { @@ -7917,6 +7981,7 @@ static const struct platform_suspend_ops apple_sleep_ops = { .enter = apple_sleep_enter, .wake = apple_sleep_report, .end = apple_sleep_end, + .deep_vetoed = apple_sleep_deep_vetoed, }; /* For a SoC with early_context: the same, with the scopes its entry needs held */ @@ -7930,6 +7995,7 @@ static const struct platform_suspend_ops apple_sleep_early_ops = { .enter = apple_sleep_enter, .wake = apple_sleep_report, .end = apple_sleep_end, + .deep_vetoed = apple_sleep_deep_vetoed, }; static int apple_sleep_read_wake_sources(struct apple_sleep *s) diff --git a/include/linux/soc/apple/sleep.h b/include/linux/soc/apple/sleep.h index 39ab320931c91..b13ca352c71b2 100644 --- a/include/linux/soc/apple/sleep.h +++ b/include/linux/soc/apple/sleep.h @@ -148,6 +148,12 @@ void apple_sleep_coproc_unregister(struct device *dev); */ bool apple_sleep_request_deep_once(void); +/* + * Until @dev's driver unbinds: a deep sleep would be refused for @dev, as @vetoes says when + * asked before each one starts (always when NULL). Such a sleep goes to s2idle instead. + */ +int devm_apple_sleep_deep_veto(struct device *dev, bool (*vetoes)(struct device *dev)); + /* * For a registered coprocessor: the last of its stop that may still refuse the sleep, run * with interrupts off before any coprocessor's @last_stop. A negative return refuses, and the @@ -402,6 +408,12 @@ static inline bool apple_sleep_request_deep_once(void) return false; } +static inline int devm_apple_sleep_deep_veto(struct device *dev, + bool (*vetoes)(struct device *dev)) +{ + return 0; +} + static inline void apple_sleep_coproc_unregister(struct device *dev) { } From 39eeeaeda7fbf888c589d30c651fe25fb743d2d0 Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Thu, 3 Dec 2026 17:58:17 -0500 Subject: [PATCH 3/9] thunderbolt: apple: veto a deep sleep the port's teardown would refuse A deep sleep takes the port's domains down. At PM_SUSPEND_PREPARE its teardown removes the PCIe functions behind it, and refuses the sleep when one can't be removed: a driver other than nvme or igc, such as nouveau and snd_hda_intel for a Thunderbolt eGPU, or a disk in use. The suspend then fails and the Mac stays awake (J413 with a GTX 1080 enclosure, linux#3786). Add apple_pcie_tunnel_removable(), which answers what apple_pcie_tunnel_remove_orderly() would, without removing anything or waiting. The port asks it before each deep sleep starts and vetoes the sleep when the answer is no. That sleep goes to s2idle, which keeps the port and its functions up. Signed-off-by: DjDeveloperr --- drivers/pci/controller/pcie-apple.c | 35 ++++++++++++++++++++++++++++ drivers/thunderbolt/apple.c | 36 +++++++++++++++++++++++++++++ include/linux/pci-apple.h | 1 + 3 files changed, 72 insertions(+) diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c index 84b06ded5acdd..dd4b869e4721d 100644 --- a/drivers/pci/controller/pcie-apple.c +++ b/drivers/pci/controller/pcie-apple.c @@ -7193,6 +7193,41 @@ int apple_pcie_tunnel_remove_orderly(struct device *dev, bool in_use_too) } EXPORT_SYMBOL_GPL(apple_pcie_tunnel_remove_orderly); +/** + * apple_pcie_tunnel_removable - whether apple_pcie_tunnel_remove_orderly() would remove now + * @dev: the tunnelled host + * @in_use_too: also when a disk below it is open + * + * Changes nothing, and doesn't wait: a disk that udev holds open for a moment counts as in + * use. Returns 0, or the error apple_pcie_tunnel_remove_orderly() would return. + */ +int apple_pcie_tunnel_removable(struct device *dev, bool in_use_too) +{ + struct pci_host_bridge *bridge = dev_get_drvdata(dev); + struct apple_pcie_tunnel_use use = { .bridge = bridge }; + struct apple_pcie *pcie; + const char *other = NULL; + + if (!bridge || !bridge->bus) + return -ENODEV; + pcie = pci_host_bridge_priv(bridge); + if (!pcie->hw->tunneled) + return -EINVAL; + + pci_lock_rescan_remove(); + if (!pcie->bus_stopped) { + pci_walk_bus(bridge->bus, apple_pcie_tunnel_other_driver, &other); + if (!other && !in_use_too) + pci_walk_bus(bridge->bus, apple_pcie_tunnel_function_disks, &use); + } + pci_unlock_rescan_remove(); + + if (other) + return -EOPNOTSUPP; + return use.open ? -EBUSY : 0; +} +EXPORT_SYMBOL_GPL(apple_pcie_tunnel_removable); + /* * Bring the tunneled host back after apple_pcie_tunnel_quiesce(). The ports * need the restart that resume performs, and the hierarchy below them has to be diff --git a/drivers/thunderbolt/apple.c b/drivers/thunderbolt/apple.c index 429cfa75e93bb..809148fc0fe51 100644 --- a/drivers/thunderbolt/apple.c +++ b/drivers/thunderbolt/apple.c @@ -110,6 +110,7 @@ #include #include #include +#include #include #include #include @@ -4622,6 +4623,34 @@ static int apple_cio_sleep_release_displays(struct apple_cio *acio, bool pause) return hweight32(asked); } +/* + * Asked before a deep sleep starts. The PCIe functions behind this port that the teardown + * can't remove (a driver it doesn't remove, or a disk in use) would have it refuse that sleep + * at PM_SUSPEND_PREPARE; s2idle keeps the port and its functions up. + */ +static bool apple_cio_deep_vetoed(struct device *dev) +{ + struct apple_cio *acio = dev_get_drvdata(dev); + struct platform_device *pcie; + int ret = 0; + + guard(mutex)(&acio->lock); + if (acio->removing || acio->resume_recovery_failed || !acio->current_cable_info) + return false; + guard(mutex)(&acio->pcie_tunnel_lock); + if (!READ_ONCE(acio->pcie_tunnel_requested) && !acio->pcie_tunnel_populated) + return false; + pcie = apple_cio_find_pcie_tunnel(acio); + if (pcie) { + ret = apple_pcie_tunnel_removable(&pcie->dev, false); + put_device(&pcie->dev); + } + if (ret) + dev_info(dev, "PCIe devices behind this port can't be removed for a deep sleep (%d)\n", + ret); + return ret; +} + static int apple_cio_sleep_teardown(struct apple_cio *acio) { ktime_t start = ktime_get(), stop; @@ -5112,6 +5141,13 @@ static int apple_cio_probe(struct platform_device *pdev) if (!acio->hw) return -EINVAL; + /* A deep sleep takes this port down, and its teardown may refuse that. */ + if (acio->hw->sleep_removes_domains && !acio->hw->strict_power_cycle) { + ret = devm_apple_sleep_deep_veto(dev, apple_cio_deep_vetoed); + if (ret) + return ret; + } + acio->type7 = acio->hw->type7; if (acio->type7 && of_property_count_u32_elems(acio->np, "apple,tunable-rc") <= 0) diff --git a/include/linux/pci-apple.h b/include/linux/pci-apple.h index 769f4d6a0f6a5..6578bff21dd19 100644 --- a/include/linux/pci-apple.h +++ b/include/linux/pci-apple.h @@ -19,6 +19,7 @@ bool apple_pcie_tunnel_needs_cold_init(struct device_node *np); int apple_pcie_tunnel_prepare(struct device *dev, struct device_node *tunnel); int apple_pcie_tunnel_quiesce(struct device *dev); int apple_pcie_tunnel_remove_orderly(struct device *dev, bool in_use_too); +int apple_pcie_tunnel_removable(struct device *dev, bool in_use_too); int apple_pcie_tunnel_restore(struct device *dev); int apple_pcie_tunnel_check_state(struct device *dev); bool apple_pcie_tunnel_link_kept(struct device *dev); From 1834a363cdd7fc91116c11606a1f0cfd5b95da93 Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Thu, 3 Dec 2026 17:58:18 -0500 Subject: [PATCH 4/9] tools/asahi: test the s2idle fallback of a vetoed deep sleep Builds pm_suspend(), the sleep driver's veto list and the USB4 port's check from the tree, with the rest stubbed. A deep sleep goes to s2idle while a driver vetoes it (a static veto, orphaned T8132 PCIe ports, an eGPU or a disk in use behind a port) and is deep again once the veto is gone; s2idle and shallow are never changed, and the sleep's error is still returned. Three mutants, the PM core ignoring the veto, the list ignoring a driver's check, and a silent port, each fail it. Signed-off-by: DjDeveloperr --- tools/asahi/run-host-tests.py | 3 + tools/asahi/sleep-deep-veto-tests.c | 348 +++++++++++++++++++++++++++ tools/asahi/sleep-deep-veto-tests.py | 79 ++++++ 3 files changed, 430 insertions(+) create mode 100644 tools/asahi/sleep-deep-veto-tests.c create mode 100755 tools/asahi/sleep-deep-veto-tests.py diff --git a/tools/asahi/run-host-tests.py b/tools/asahi/run-host-tests.py index a805fbfd76ff0..420a200cab344 100644 --- a/tools/asahi/run-host-tests.py +++ b/tools/asahi/run-host-tests.py @@ -686,6 +686,9 @@ def mutations(flag, names, base, expect=KILL): 't8132-apcie-sleep-tests.py': [([], PASS)], 't8132-display-gate-tests.py': [([], PASS)], 't8132-sleep-refuse-tests.py': [([], PASS)], + # A deep sleep that a driver vetoes before it starts goes to s2idle instead. + 'sleep-deep-veto-tests.py': [([], PASS)] + + mutations('--mutation', ('core-ignores-veto', 'drivers-ignored', 'acio-silent'), []), 't8132-usb4-policy-tests.py': [(out('--output') + ['--dtc', '{dtc}'], PASS)], 'tb-cio-sleep-tests.py': [(out('--output'), PASS)], 'tb-dock-pm-tests.py': [(out('--output'), PASS)], diff --git a/tools/asahi/sleep-deep-veto-tests.c b/tools/asahi/sleep-deep-veto-tests.c new file mode 100644 index 0000000000000..69f185dfe899e --- /dev/null +++ b/tools/asahi/sleep-deep-veto-tests.c @@ -0,0 +1,348 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * A deep sleep that a driver vetoes before it starts: pm_suspend() takes s2idle for that one + * sleep, and deep again once nothing vetoes. The PM core, the sleep driver's veto list and the + * USB4 port's check are the production functions; the rest is stubbed. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef uint32_t u32; +typedef int suspend_state_t; +#define PM_SUSPEND_ON 0 +#define PM_SUSPEND_TO_IDLE 1 +#define PM_SUSPEND_STANDBY 2 +#define PM_SUSPEND_MEM 3 +#define PM_SUSPEND_MAX 4 +#define READ_ONCE(x) (x) +#define WRITE_ONCE(x, v) ((x) = (v)) +#define GFP_KERNEL 0 +#define EXPORT_SYMBOL(x) +#define EXPORT_SYMBOL_GPL(x) +#define __maybe_unused __attribute__((unused)) +#define container_of(ptr, type, member) ((type *)((char *)(ptr) - offsetof(type, member))) + +struct list_head { + struct list_head *next, *prev; +}; + +#define LIST_HEAD(name) struct list_head name = { &(name), &(name) } + +static void list_add_tail(struct list_head *node, struct list_head *head) +{ + node->prev = head->prev; + node->next = head; + head->prev->next = node; + head->prev = node; +} + +static void list_del(struct list_head *node) +{ + node->prev->next = node->next; + node->next->prev = node->prev; + node->next = NULL; + node->prev = NULL; +} + +static bool list_empty(const struct list_head *head) +{ + return head->next == head; +} + +#define list_for_each_entry(pos, head, member) \ + for (pos = container_of((head)->next, typeof(*pos), member); \ + &pos->member != (head); \ + pos = container_of(pos->member.next, typeof(*pos), member)) + +/* A mutex taken twice, or released when free, is a bug in the code under test. */ +struct mutex { + bool held; +}; + +#define DEFINE_MUTEX(name) struct mutex name + +static struct mutex *mutex_guard_take(struct mutex *lock) +{ + assert(!lock->held); + lock->held = true; + return lock; +} + +static void mutex_guard_release(struct mutex **lock) +{ + assert((*lock)->held); + (*lock)->held = false; +} + +#define GUARD_NAME_(n) guard_##n +#define GUARD_NAME(n) GUARD_NAME_(n) +#define guard(type) \ + struct type *__attribute__((cleanup(type##_guard_release))) \ + GUARD_NAME(__COUNTER__) = type##_guard_take +#define scoped_guard(type, lock) \ + for (struct type *scope_ = type##_guard_take(lock); scope_; \ + type##_guard_release(&scope_), scope_ = NULL) + +/* A device with what devres needs: its allocations and actions, undone at unbind. */ +struct device { + const char *name; + void *drvdata; + void *allocs[4]; + unsigned int nallocs; + void (*actions[4])(void *data); + void *action_data[4]; + unsigned int nactions; +}; + +struct platform_device { + struct device dev; +}; + +static const char *dev_name(const struct device *dev) +{ + return dev->name; +} + +static void *dev_get_drvdata(const struct device *dev) +{ + return dev->drvdata; +} + +static void *devm_kzalloc(struct device *dev, size_t size, int gfp) +{ + void *p = calloc(1, size); + + (void)gfp; + assert(p && dev->nallocs < 4); + dev->allocs[dev->nallocs++] = p; + return p; +} + +static int devm_add_action_or_reset(struct device *dev, void (*action)(void *data), void *data) +{ + assert(dev->nactions < 4); + dev->actions[dev->nactions] = action; + dev->action_data[dev->nactions++] = data; + return 0; +} + +static void unbind(struct device *dev) +{ + while (dev->nactions--) + dev->actions[dev->nactions](dev->action_data[dev->nactions]); + dev->nactions = 0; + while (dev->nallocs--) + free(dev->allocs[dev->nallocs]); + dev->nallocs = 0; +} + +static char logged[4096]; + +static void log_line(const char *prefix, const char *fmt, ...) +{ + size_t len = strlen(logged); + va_list ap; + + va_start(ap, fmt); + snprintf(logged + len, sizeof(logged) - len, "%s: ", prefix); + len = strlen(logged); + vsnprintf(logged + len, sizeof(logged) - len, fmt, ap); + va_end(ap); +} + +#define pr_info(fmt, ...) log_line("PM", fmt, ##__VA_ARGS__) +#define dev_info(dev, fmt, ...) log_line(dev_name(dev), fmt, ##__VA_ARGS__) + +/* The PM core around pm_suspend(). */ +struct platform_suspend_ops { + bool (*deep_vetoed)(void); +}; + +static const char *const mem_sleep_labels[] = { + [PM_SUSPEND_TO_IDLE] = "s2idle", + [PM_SUSPEND_STANDBY] = "shallow", + [PM_SUSPEND_MEM] = "deep", +}; + +static const struct platform_suspend_ops *suspend_ops __maybe_unused; +static suspend_state_t entered = PM_SUSPEND_ON; +static int enter_error, saved_errno = 1; + +static int enter_state(suspend_state_t state) +{ + entered = state; + return enter_error; +} + +static void dpm_save_errno(int error) +{ + saved_errno = error; +} + +/* The sleep driver. */ +struct apple_sleep_soc { + bool apcie_ports_host; +}; + +struct apple_sleep { + const struct apple_sleep_soc *soc; + struct device *dev; + bool apcie_ports_unowned; +}; + +static struct apple_sleep *apple_sleep; +static LIST_HEAD(sleep_deep_vetoes); +static DEFINE_MUTEX(sleep_deep_veto_lock); +static bool apcie_ports_host_owned; +static unsigned int asked; + +/* A USB4 port. */ +struct apple_cio { + struct mutex lock, pcie_tunnel_lock; + bool removing, resume_recovery_failed; + u32 current_cable_info; + bool pcie_tunnel_requested, pcie_tunnel_populated; +}; + +static struct platform_device tunnel_host = { .dev = { .name = "530000000.pcie" } }; +static bool tunnel_host_found = true; +static int tunnel_removable = 0, tunnel_refs; +static struct apple_cio *tunnel_acio; + +static struct platform_device *apple_cio_find_pcie_tunnel(struct apple_cio *acio) +{ + /* Under both of the port's locks, as the teardown looks it up. */ + assert(acio->lock.held && acio->pcie_tunnel_lock.held); + if (!tunnel_host_found) + return NULL; + tunnel_refs++; + return &tunnel_host; +} + +static void put_device(struct device *dev) +{ + assert(dev == &tunnel_host.dev && tunnel_refs > 0); + tunnel_refs--; +} + +static int apple_pcie_tunnel_removable(struct device *dev, bool in_use_too) +{ + assert(dev == &tunnel_host.dev && !in_use_too); + assert(tunnel_acio && tunnel_acio->lock.held && tunnel_acio->pcie_tunnel_lock.held); + return tunnel_removable; +} + +/* ACTUAL_FUNCTIONS */ + +static bool counted_vetoed(void) +{ + asked++; + return apple_sleep_deep_vetoed(); +} + +static const struct platform_suspend_ops apple_ops = { .deep_vetoed = counted_vetoed }; +static const struct platform_suspend_ops other_ops = { 0 }; + +#define sleep_as(state, expect, why) sleep_as_at(state, expect, why, __LINE__) + +static void sleep_as_at(suspend_state_t state, suspend_state_t expect, const char *why, int line) +{ + char want[64]; + + logged[0] = '\0'; + entered = PM_SUSPEND_ON; + assert(pm_suspend(state) == enter_error); + assert(saved_errno == enter_error); + snprintf(want, sizeof(want), "PM: suspend entry (%s)\n", mem_sleep_labels[expect]); + if (entered != expect || !strstr(logged, want)) { + fprintf(stderr, "FAIL line %d: %s: asked %s, entered %s\n%s", line, why, + mem_sleep_labels[state], mem_sleep_labels[entered], logged); + abort(); + } + assert(!strstr(logged, "vetoed") == (expect == state)); + printf("ok - %s\n", why); +} + +int main(void) +{ + static const struct apple_sleep_soc t8132 = { .apcie_ports_host = true }; + static const struct apple_sleep_soc other = { 0 }; + struct device sleep_dev = { .name = "23d2b0000.sleep" }; + struct device pmp = { .name = "2a0000000.pmp" }; + struct device port = { .name = "501ac0000.cio" }; + struct apple_cio acio = { .current_cable_info = 0x1 }; + struct apple_sleep s = { .soc = &other, .dev = &sleep_dev }; + + /* A platform without the callback: deep stays deep. */ + suspend_ops = &other_ops; + sleep_as(PM_SUSPEND_MEM, PM_SUSPEND_MEM, "no callback, deep"); + + /* A driver that knows at its probe, before the sleep driver's: it still counts. */ + assert(devm_apple_sleep_deep_veto(&pmp, NULL) == 0); + apple_sleep = &s; + suspend_ops = &apple_ops; + sleep_as(PM_SUSPEND_MEM, PM_SUSPEND_TO_IDLE, "static veto: s2idle instead of deep"); + assert(strstr(logged, "deep sleep vetoed by 2a0000000.pmp")); + + /* A sleep that isn't deep asks nothing and stays what it was. */ + asked = 0; + sleep_as(PM_SUSPEND_TO_IDLE, PM_SUSPEND_TO_IDLE, "s2idle stays s2idle"); + sleep_as(PM_SUSPEND_STANDBY, PM_SUSPEND_STANDBY, "shallow stays shallow"); + assert(!asked); + + /* An error from the s2idle sleep is still the caller's. */ + enter_error = -EBUSY; + sleep_as(PM_SUSPEND_MEM, PM_SUSPEND_TO_IDLE, "s2idle error returned"); + enter_error = 0; + + /* Unbound, it vetoes no more. */ + unbind(&pmp); + assert(list_empty(&sleep_deep_vetoes)); + sleep_as(PM_SUSPEND_MEM, PM_SUSPEND_MEM, "veto gone: deep again"); + + /* T8132 with no host that sets its PCIe ports up again after a deep sleep. */ + s.soc = &t8132; + s.apcie_ports_unowned = true; + sleep_as(PM_SUSPEND_MEM, PM_SUSPEND_TO_IDLE, "orphaned PCIe ports: s2idle"); + apple_sleep_apcie_ports_owned(true); + sleep_as(PM_SUSPEND_MEM, PM_SUSPEND_MEM, "host owns the ports: deep"); + s.soc = &other; + + /* A USB4 port asks its PCIe tunnel each time. */ + port.drvdata = &acio; + tunnel_acio = &acio; + assert(devm_apple_sleep_deep_veto(&port, apple_cio_deep_vetoed) == 0); + sleep_as(PM_SUSPEND_MEM, PM_SUSPEND_MEM, "port, no PCIe tunnel: deep"); + acio.pcie_tunnel_populated = true; + sleep_as(PM_SUSPEND_MEM, PM_SUSPEND_MEM, "port, removable tunnel: deep"); + tunnel_removable = -EOPNOTSUPP; + sleep_as(PM_SUSPEND_MEM, PM_SUSPEND_TO_IDLE, "eGPU behind the port: s2idle"); + assert(strstr(logged, "deep sleep vetoed by 501ac0000.cio")); + tunnel_removable = -EBUSY; + sleep_as(PM_SUSPEND_MEM, PM_SUSPEND_TO_IDLE, "disk in use behind the port: s2idle"); + acio.pcie_tunnel_populated = false; + acio.pcie_tunnel_requested = true; + sleep_as(PM_SUSPEND_MEM, PM_SUSPEND_TO_IDLE, "tunnel asked for, not up yet: s2idle"); + tunnel_host_found = false; + sleep_as(PM_SUSPEND_MEM, PM_SUSPEND_MEM, "no tunnelled host: deep"); + tunnel_host_found = true; + acio.current_cable_info = 0; + sleep_as(PM_SUSPEND_MEM, PM_SUSPEND_MEM, "nothing plugged in: deep"); + acio.current_cable_info = 0x1; + acio.removing = true; + sleep_as(PM_SUSPEND_MEM, PM_SUSPEND_MEM, "port going away: deep"); + acio.removing = false; + unbind(&port); + assert(list_empty(&sleep_deep_vetoes)); + sleep_as(PM_SUSPEND_MEM, PM_SUSPEND_MEM, "port unbound: deep"); + + assert(!tunnel_refs && !acio.lock.held && !acio.pcie_tunnel_lock.held); + return 0; +} diff --git a/tools/asahi/sleep-deep-veto-tests.py b/tools/asahi/sleep-deep-veto-tests.py new file mode 100755 index 0000000000000..761a9b72d4736 --- /dev/null +++ b/tools/asahi/sleep-deep-veto-tests.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-only +"""Build and run a deep sleep that a driver vetoes before it starts: "mem" goes to s2idle.""" +from pathlib import Path +import argparse +import re +import resource +import subprocess +import sys +import tempfile + +# python3 -I, as run-host-tests.py runs it, leaves this directory off sys.path. +sys.path.insert(0, str(Path(__file__).resolve().parent)) +from sleep_test_utils import function, structure # noqa: E402 + +MUTATIONS = { + # The PM core takes deep sleep whatever the platform says. + "core-ignores-veto": ("pm_suspend", "state = PM_SUSPEND_TO_IDLE;", ";"), + # Only the sleep driver's own check counts, no driver's veto. + "drivers-ignored": ("apple_sleep_deep_vetoed", "veto->vetoes(veto->dev)", "false"), + # A port whose PCIe functions can't be removed doesn't say so. + "acio-silent": ("apple_cio_deep_vetoed", "return ret;", "return false;"), +} + +parser = argparse.ArgumentParser() +parser.add_argument("--mutation", choices=sorted(MUTATIONS)) +args = parser.parse_args() + +resource.setrlimit(resource.RLIMIT_CORE, (0, 0)) +root = Path(__file__).resolve().parents[2] +sleep = (root / "drivers/soc/apple/sleep.c").read_text() +core = (root / "kernel/power/suspend.c").read_text() +acio = (root / "drivers/thunderbolt/apple.c").read_text() + +functions = {name: function(core, name) for name in ("pm_suspend",)} +functions |= { + name: function(sleep, name) + for name in ( + "sleep_apcie_ports_orphaned", + "apple_sleep_apcie_ports_owned", + "apple_sleep_deep_veto_drop", + "devm_apple_sleep_deep_veto", + "apple_sleep_deep_vetoed", + ) +} +functions["apple_cio_deep_vetoed"] = function(acio, "apple_cio_deep_vetoed") + +if args.mutation: + name, old, new = MUTATIONS[args.mutation] + assert functions[name].count(old) == 1, args.mutation + functions[name] = functions[name].replace(old, new) + +# Both of the sleep driver's tables answer the PM core. +for table in ("apple_sleep_ops", "apple_sleep_early_ops"): + body = re.search( + r"^static const struct platform_suspend_ops " + table + r" = \{(.*?)^\};", + sleep, + re.M | re.S, + ) + assert body and ".deep_vetoed = apple_sleep_deep_vetoed," in body[1], table + +# Only a port that a deep sleep takes down, and whose own driver stops it, asks. +assert re.search( + r"if \(acio->hw->sleep_removes_domains && !acio->hw->strict_power_cycle\) \{\s*" + r"ret = devm_apple_sleep_deep_veto\(dev, apple_cio_deep_vetoed\);", + function(acio, "apple_cio_probe"), +) + +fixture = Path(__file__).with_suffix(".c").read_text() +actual = structure(sleep, "apple_sleep_deep_veto") + "".join(functions.values()) +with tempfile.TemporaryDirectory(prefix="sleep-deep-veto-") as tmp: + c, exe = Path(tmp) / "test.c", Path(tmp) / "test" + c.write_text(fixture.replace("/* ACTUAL_FUNCTIONS */", actual)) + subprocess.run( + ["cc", "-std=gnu11", "-Wall", "-Werror", str(c), "-o", str(exe)], + check=True, + ) + # A failed check prints its line; the exit status says it failed. + sys.exit(1 if subprocess.run([str(exe)]).returncode else 0) From d5bf985496c67de608c6c88ac01e7868dd00ba46 Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Thu, 3 Dec 2026 18:22:55 -0500 Subject: [PATCH 5/9] PCI: apple: answer apple_pcie_tunnel_removable() with the removal's check apple_pcie_tunnel_removable() repeated the checks of apple_pcie_tunnel_remove_orderly() without its wait for a disk that udev opened just after it appeared. A deep sleep asked for in that half second went to s2idle, where before the removal waited and the sleep was deep. Move the checks, wait included, into one helper that both call, so the question always gets the removal's answer. Signed-off-by: DjDeveloperr --- drivers/pci/controller/pcie-apple.c | 69 ++++++++++++++++------------- 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c index dd4b869e4721d..3c423311fd2df 100644 --- a/drivers/pci/controller/pcie-apple.c +++ b/drivers/pci/controller/pcie-apple.c @@ -7126,6 +7126,30 @@ static int apple_pcie_tunnel_other_driver(struct pci_dev *pdev, void *data) return 1; } +/* + * Why the hierarchy can't be removed in order now, under pci_lock_rescan_remove(): -EOPNOTSUPP + * for a function driven by *@other, -EBUSY while a disk below it is open and @in_use_too is + * false. A probe by udev right after the disk appeared closes again within moments. + */ +static int apple_pcie_tunnel_kept(struct pci_host_bridge *bridge, bool in_use_too, + struct apple_pcie_tunnel_use *use, const char **other) +{ + unsigned int tries; + + pci_walk_bus(bridge->bus, apple_pcie_tunnel_other_driver, other); + if (*other) + return -EOPNOTSUPP; + for (tries = 0; tries < 10; tries++) { + use->disks = 0; + use->open = 0; + pci_walk_bus(bridge->bus, apple_pcie_tunnel_function_disks, use); + if (!use->open || in_use_too) + return 0; + msleep(50); + } + return -EBUSY; +} + /** * apple_pcie_tunnel_remove_orderly - remove a tunnelled hierarchy that is still reachable * @dev: the tunnelled host @@ -7150,7 +7174,7 @@ int apple_pcie_tunnel_remove_orderly(struct device *dev, bool in_use_too) struct pci_dev *pdev, *tmp; struct apple_pcie *pcie; const char *other = NULL; - unsigned int tries; + int ret; if (!bridge || !bridge->bus) return -ENODEV; @@ -7163,25 +7187,16 @@ int apple_pcie_tunnel_remove_orderly(struct device *dev, bool in_use_too) pci_unlock_rescan_remove(); return 0; } - pci_walk_bus(bridge->bus, apple_pcie_tunnel_other_driver, &other); - if (other) { - pci_unlock_rescan_remove(); - dev_info(dev, "PCIe-C: a function driven by %s is not removed for the sleep\n", other); - return -EOPNOTSUPP; - } - /* A probe by udev right after the disk appeared closes again within moments. */ - for (tries = 0; tries < 10; tries++) { - use.disks = use.open = 0; - pci_walk_bus(bridge->bus, apple_pcie_tunnel_function_disks, &use); - if (!use.open || in_use_too) - break; - msleep(50); - } - if (use.open && !in_use_too) { + ret = apple_pcie_tunnel_kept(bridge, in_use_too, &use, &other); + if (ret) { pci_unlock_rescan_remove(); - dev_warn(dev, "PCIe-C: %u of %u disk(s) behind the tunnel in use: not removed for the sleep\n", - use.open, use.disks); - return -EBUSY; + if (other) + dev_info(dev, "PCIe-C: a function driven by %s is not removed for the sleep\n", + other); + else + dev_warn(dev, "PCIe-C: %u of %u disk(s) behind the tunnel in use: not removed for the sleep\n", + use.open, use.disks); + return ret; } list_for_each_entry_safe(pdev, tmp, &bridge->bus->devices, bus_list) pci_stop_and_remove_bus_device(pdev); @@ -7198,8 +7213,7 @@ EXPORT_SYMBOL_GPL(apple_pcie_tunnel_remove_orderly); * @dev: the tunnelled host * @in_use_too: also when a disk below it is open * - * Changes nothing, and doesn't wait: a disk that udev holds open for a moment counts as in - * use. Returns 0, or the error apple_pcie_tunnel_remove_orderly() would return. + * Changes nothing. Returns 0, or the error apple_pcie_tunnel_remove_orderly() would return. */ int apple_pcie_tunnel_removable(struct device *dev, bool in_use_too) { @@ -7207,6 +7221,7 @@ int apple_pcie_tunnel_removable(struct device *dev, bool in_use_too) struct apple_pcie_tunnel_use use = { .bridge = bridge }; struct apple_pcie *pcie; const char *other = NULL; + int ret = 0; if (!bridge || !bridge->bus) return -ENODEV; @@ -7215,16 +7230,10 @@ int apple_pcie_tunnel_removable(struct device *dev, bool in_use_too) return -EINVAL; pci_lock_rescan_remove(); - if (!pcie->bus_stopped) { - pci_walk_bus(bridge->bus, apple_pcie_tunnel_other_driver, &other); - if (!other && !in_use_too) - pci_walk_bus(bridge->bus, apple_pcie_tunnel_function_disks, &use); - } + if (!pcie->bus_stopped) + ret = apple_pcie_tunnel_kept(bridge, in_use_too, &use, &other); pci_unlock_rescan_remove(); - - if (other) - return -EOPNOTSUPP; - return use.open ? -EBUSY : 0; + return ret; } EXPORT_SYMBOL_GPL(apple_pcie_tunnel_removable); From 64e55fd3920b21ffaf4c1c33f36a7655fabffea9 Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Thu, 3 Dec 2026 18:22:55 -0500 Subject: [PATCH 6/9] thunderbolt: apple: ask a port's PCIe tunnel only once it is up apple_cio_find_pcie_tunnel() finds no host until the tunnel is populated, so the deep-veto check's own test of the requested and populated flags added nothing: drop it. The test's lookup now does the same, and a tunnel that was asked for but isn't up yet no longer vetoes the sleep there either: the port's teardown doesn't refuse it. Signed-off-by: DjDeveloperr --- drivers/thunderbolt/apple.c | 2 -- tools/asahi/sleep-deep-veto-tests.c | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/thunderbolt/apple.c b/drivers/thunderbolt/apple.c index 809148fc0fe51..955e0fb0fadba 100644 --- a/drivers/thunderbolt/apple.c +++ b/drivers/thunderbolt/apple.c @@ -4638,8 +4638,6 @@ static bool apple_cio_deep_vetoed(struct device *dev) if (acio->removing || acio->resume_recovery_failed || !acio->current_cable_info) return false; guard(mutex)(&acio->pcie_tunnel_lock); - if (!READ_ONCE(acio->pcie_tunnel_requested) && !acio->pcie_tunnel_populated) - return false; pcie = apple_cio_find_pcie_tunnel(acio); if (pcie) { ret = apple_pcie_tunnel_removable(&pcie->dev, false); diff --git a/tools/asahi/sleep-deep-veto-tests.c b/tools/asahi/sleep-deep-veto-tests.c index 69f185dfe899e..19db2308dda5e 100644 --- a/tools/asahi/sleep-deep-veto-tests.c +++ b/tools/asahi/sleep-deep-veto-tests.c @@ -220,7 +220,7 @@ static struct platform_device *apple_cio_find_pcie_tunnel(struct apple_cio *acio { /* Under both of the port's locks, as the teardown looks it up. */ assert(acio->lock.held && acio->pcie_tunnel_lock.held); - if (!tunnel_host_found) + if (!acio->pcie_tunnel_populated || !tunnel_host_found) return NULL; tunnel_refs++; return &tunnel_host; @@ -329,7 +329,8 @@ int main(void) sleep_as(PM_SUSPEND_MEM, PM_SUSPEND_TO_IDLE, "disk in use behind the port: s2idle"); acio.pcie_tunnel_populated = false; acio.pcie_tunnel_requested = true; - sleep_as(PM_SUSPEND_MEM, PM_SUSPEND_TO_IDLE, "tunnel asked for, not up yet: s2idle"); + sleep_as(PM_SUSPEND_MEM, PM_SUSPEND_MEM, "tunnel asked for, not up yet: deep"); + acio.pcie_tunnel_populated = true; tunnel_host_found = false; sleep_as(PM_SUSPEND_MEM, PM_SUSPEND_MEM, "no tunnelled host: deep"); tunnel_host_found = true; From 7ed82d751665a0cfabb14f06df805612bd06771f Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Thu, 3 Dec 2026 18:22:55 -0500 Subject: [PATCH 7/9] soc: apple: sleep: say what a deep-veto check must not take The check runs under the veto list's lock, which the device's unbind takes to drop the veto. A check that took device_lock() would deadlock against that unbind. Signed-off-by: DjDeveloperr --- include/linux/soc/apple/sleep.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/soc/apple/sleep.h b/include/linux/soc/apple/sleep.h index b13ca352c71b2..1e4a52eb81c46 100644 --- a/include/linux/soc/apple/sleep.h +++ b/include/linux/soc/apple/sleep.h @@ -151,6 +151,7 @@ bool apple_sleep_request_deep_once(void); /* * Until @dev's driver unbinds: a deep sleep would be refused for @dev, as @vetoes says when * asked before each one starts (always when NULL). Such a sleep goes to s2idle instead. + * @vetoes runs under a lock that the unbind also takes: it must not take device_lock(@dev). */ int devm_apple_sleep_deep_veto(struct device *dev, bool (*vetoes)(struct device *dev)); From b089aa8f48b102dd025f5bc490192e639058d5ba Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Thu, 3 Dec 2026 18:35:46 -0500 Subject: [PATCH 8/9] PCI: apple: give apple_pcie_tunnel_removable() a Return: section kernel-doc -Wall found no description of its return value. Signed-off-by: DjDeveloperr --- drivers/pci/controller/pcie-apple.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c index 3c423311fd2df..c95aa17ba8b07 100644 --- a/drivers/pci/controller/pcie-apple.c +++ b/drivers/pci/controller/pcie-apple.c @@ -7213,7 +7213,9 @@ EXPORT_SYMBOL_GPL(apple_pcie_tunnel_remove_orderly); * @dev: the tunnelled host * @in_use_too: also when a disk below it is open * - * Changes nothing. Returns 0, or the error apple_pcie_tunnel_remove_orderly() would return. + * Changes nothing. + * + * Return: 0, or the error apple_pcie_tunnel_remove_orderly() would return. */ int apple_pcie_tunnel_removable(struct device *dev, bool in_use_too) { From 9f9a730821444558523a2c0da37d3f63dd9ff316 Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Thu, 3 Dec 2026 20:19:11 -0500 Subject: [PATCH 9/9] thunderbolt: apple: ask main's PCIe-C removal check for the deep veto Main gained apple_pcie_tunnel_can_remove_orderly() with #3786: the same non-destructive check as this branch's apple_pcie_tunnel_removable(), with the same returns (0 when removable or already stopped, -EOPNOTSUPP for a driver the teardown doesn't remove, -EBUSY for a disk in use, -ENODEV/-EINVAL for no tunnelled host). Use it for the port's deep veto and drop the copy, so pcie-apple.c and pci-apple.h are main's again. The only difference is that the PCIe host now logs why the hierarchy stays, as it does when the teardown asks. Signed-off-by: DjDeveloperr --- drivers/pci/controller/pcie-apple.c | 55 ----------------------------- drivers/thunderbolt/apple.c | 2 +- include/linux/pci-apple.h | 1 - tools/asahi/sleep-deep-veto-tests.c | 2 +- 4 files changed, 2 insertions(+), 58 deletions(-) diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c index 06a32c8589f55..c7a693a0f8f58 100644 --- a/drivers/pci/controller/pcie-apple.c +++ b/drivers/pci/controller/pcie-apple.c @@ -7192,30 +7192,6 @@ int apple_pcie_tunnel_can_remove_orderly(struct device *dev, bool in_use_too) } EXPORT_SYMBOL_GPL(apple_pcie_tunnel_can_remove_orderly); -/* - * Why the hierarchy can't be removed in order now, under pci_lock_rescan_remove(): -EOPNOTSUPP - * for a function driven by *@other, -EBUSY while a disk below it is open and @in_use_too is - * false. A probe by udev right after the disk appeared closes again within moments. - */ -static int apple_pcie_tunnel_kept(struct pci_host_bridge *bridge, bool in_use_too, - struct apple_pcie_tunnel_use *use, const char **other) -{ - unsigned int tries; - - pci_walk_bus(bridge->bus, apple_pcie_tunnel_other_driver, other); - if (*other) - return -EOPNOTSUPP; - for (tries = 0; tries < 10; tries++) { - use->disks = 0; - use->open = 0; - pci_walk_bus(bridge->bus, apple_pcie_tunnel_function_disks, use); - if (!use->open || in_use_too) - return 0; - msleep(50); - } - return -EBUSY; -} - /** * apple_pcie_tunnel_remove_orderly - remove a tunnelled hierarchy that is still reachable * @dev: the tunnelled host @@ -7267,37 +7243,6 @@ int apple_pcie_tunnel_remove_orderly(struct device *dev, bool in_use_too) } EXPORT_SYMBOL_GPL(apple_pcie_tunnel_remove_orderly); -/** - * apple_pcie_tunnel_removable - whether apple_pcie_tunnel_remove_orderly() would remove now - * @dev: the tunnelled host - * @in_use_too: also when a disk below it is open - * - * Changes nothing. - * - * Return: 0, or the error apple_pcie_tunnel_remove_orderly() would return. - */ -int apple_pcie_tunnel_removable(struct device *dev, bool in_use_too) -{ - struct pci_host_bridge *bridge = dev_get_drvdata(dev); - struct apple_pcie_tunnel_use use = { .bridge = bridge }; - struct apple_pcie *pcie; - const char *other = NULL; - int ret = 0; - - if (!bridge || !bridge->bus) - return -ENODEV; - pcie = pci_host_bridge_priv(bridge); - if (!pcie->hw->tunneled) - return -EINVAL; - - pci_lock_rescan_remove(); - if (!pcie->bus_stopped) - ret = apple_pcie_tunnel_kept(bridge, in_use_too, &use, &other); - pci_unlock_rescan_remove(); - return ret; -} -EXPORT_SYMBOL_GPL(apple_pcie_tunnel_removable); - /* * Bring the tunneled host back after apple_pcie_tunnel_quiesce(). The ports * need the restart that resume performs, and the hierarchy below them has to be diff --git a/drivers/thunderbolt/apple.c b/drivers/thunderbolt/apple.c index 8fff625487887..fcb4602e8cc38 100644 --- a/drivers/thunderbolt/apple.c +++ b/drivers/thunderbolt/apple.c @@ -4665,7 +4665,7 @@ static bool apple_cio_deep_vetoed(struct device *dev) guard(mutex)(&acio->pcie_tunnel_lock); pcie = apple_cio_find_pcie_tunnel(acio); if (pcie) { - ret = apple_pcie_tunnel_removable(&pcie->dev, false); + ret = apple_pcie_tunnel_can_remove_orderly(&pcie->dev, false); put_device(&pcie->dev); } if (ret) diff --git a/include/linux/pci-apple.h b/include/linux/pci-apple.h index bfdd747431843..6eb807d983e27 100644 --- a/include/linux/pci-apple.h +++ b/include/linux/pci-apple.h @@ -20,7 +20,6 @@ int apple_pcie_tunnel_prepare(struct device *dev, struct device_node *tunnel); int apple_pcie_tunnel_quiesce(struct device *dev); int apple_pcie_tunnel_can_remove_orderly(struct device *dev, bool in_use_too); int apple_pcie_tunnel_remove_orderly(struct device *dev, bool in_use_too); -int apple_pcie_tunnel_removable(struct device *dev, bool in_use_too); int apple_pcie_tunnel_restore(struct device *dev); int apple_pcie_tunnel_check_state(struct device *dev); bool apple_pcie_tunnel_link_kept(struct device *dev); diff --git a/tools/asahi/sleep-deep-veto-tests.c b/tools/asahi/sleep-deep-veto-tests.c index 19db2308dda5e..455a618e959ff 100644 --- a/tools/asahi/sleep-deep-veto-tests.c +++ b/tools/asahi/sleep-deep-veto-tests.c @@ -232,7 +232,7 @@ static void put_device(struct device *dev) tunnel_refs--; } -static int apple_pcie_tunnel_removable(struct device *dev, bool in_use_too) +static int apple_pcie_tunnel_can_remove_orderly(struct device *dev, bool in_use_too) { assert(dev == &tunnel_host.dev && !in_use_too); assert(tunnel_acio && tunnel_acio->lock.held && tunnel_acio->pcie_tunnel_lock.held);