Skip to content

PM / soc: apple: sleep: go to s2idle when a driver vetoes deep sleep - #4245

Merged
DjDeveloperr merged 10 commits into
mainfrom
fix/sleep-deep-veto-s2idle
Dec 4, 2026
Merged

DjDeveloperr merged 10 commits into
mainfrom
fix/sleep-deep-veto-s2idle

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

What: When a driver knows before a deep sleep starts that it would refuse it, mem now goes to s2idle for that sleep, instead of failing and leaving the Mac awake.

  • PM core: an optional platform_suspend_ops.deep_vetoed(). pm_suspend() asks it for PM_SUSPEND_MEM before anything is frozen. On a veto that one sleep is s2idle. /sys/power/mem_sleep stays as the user set it, and the next mem asks again. With no veto, the path is the same as before.
  • apple-sleep: devm_apple_sleep_deep_veto(dev, check). A driver vetoes every deep sleep (no check) or answers before each one, until it unbinds. It may register before the sleep driver probes. The sleep driver also answers from .begin's existing check for T8132 PCIe ports that no host sets up again (.begin keeps it).
  • USB4 (thunderbolt/apple.c): a port whose teardown would refuse a deep sleep because a PCIe function behind it can't be removed vetoes the sleep. That covers an eGPU (nouveau, snd_hda_intel) or a disk in use. The port asks main's apple_pcie_tunnel_can_remove_orderly() (from arm64: dts: apple: t8112-j413-fw27: enable deep sleep by default with PCIe-C s2idle fallback #3786), the same check the teardown uses. This PR no longer touches pcie-apple.c.

What it covers:

How it fits with #3786: the veto runs in pm_suspend() before the sleep starts. #3786's fallback runs in enter_state() when a deep sleep is refused at PM_SUSPEND_PREPARE. Both stay. The fallback still covers what the veto can't see: ports with strict_power_cycle (they don't register a veto), and an eGPU or busy disk that shows up between the veto and PREPARE.

#4207 makes s2idle the boot default when the DT shows legacy firmware. This PR handles a deep sleep that is vetoed at the moment it is asked for. They don't overlap. #4207's GPU refusal could register a veto later.

Tested:

  • Hardware, at head 9f9a73082144:
    • J700 (T8140, MacBook Neo): PASS, 3 of 3 deep sleeps on the main arm and 3 of 3 on this head, no veto or fallback lines, mem_sleep unchanged.
    • J413 (T8112, macOS 27.2 firmware), no eGPU: PASS (satchlj). PM: suspend entry (deep), woke, no veto or fallback lines, mem_sleep unchanged.
  • Host tests on head merged onto main 35ddf947b124, in the CI image (aurora-linux-host-tests:ubuntu2404): 26 suites, 81 of 81 runs pass. sleep-deep-veto 17/17, and each of its 3 mutants fails it; sleep-s2idle-fallback passes, and each of its 4 mutants fails it. The other 24 are every suite that reads a touched file, plus apple-wdt 12/12 and t6030-sleep-qblk for main's sleep.c changes since the last merge: apple-router-sleep, cio-native, dart-cio-owner, dart-sleep-power, dart-sleep-snapshot, dart-sleep-writer, sep-suspend-errors 22/22, sio-engine-reset, t8122-apcie-wake, t8132-sleep-refuse, tb-cio-sleep, display26, dcpext26-suspend-route, mtp-pm, apple-pwm-pm, neo-stability 11/11, pcie-adopted-clkpm, pciec-policy, radio-sleep-power, radio-sleep-snapshot, t8132-apcie-sleep and tb-dock-pm.
  • W=1 (arm64, clang 23) of kernel/power/suspend.o, kernel/power/main.o, drivers/soc/apple/sleep.o, drivers/thunderbolt/apple.o and drivers/pci/controller/pcie-apple.o on the same merge: 0 compiler warnings, the same as main. The kernel-doc lines are the same as on main.
  • checkpatch.pl --strict: the kernel commits are clean. In the test commit it flags only the fixture's kernel stubs (typedef, EXPORT stubs, macro arguments).

Risk: two-way door. Nothing changes unless something vetoes. On main only T8132 with orphaned ports or a USB4 port with an unremovable PCIe function vetoes, and both of those fail their deep sleep or fall back to s2idle at PREPARE today. A wrong veto, such as a disk that udev holds open for a moment, gives an s2idle instead of a deep sleep, never a failed suspend. The core change is one optional member in platform_suspend_ops.

Not yet:

  • The eGPU veto leg is not exercised on hardware: J413 with a Thunderbolt eGPU bound, where mem should go to s2idle with the veto line and no fallback line. No peer has a Thunderbolt eGPU. The host tests cover this path.
  • J414s on the old Stage 2 (aura 1.0.0b19) with soc: apple: pmp: take T6020 SRAM keep range from DT #4238 and the PMP commit (lab/j414s-4238-deep-veto 1a3cc12d9a9d): echo mem goes to s2idle and wakes. That needs soc: apple: pmp: take T6020 SRAM keep range from DT #4238.
  • pm_test at core or processors doesn't support s2idle, so a vetoed mem under those test levels returns -EAGAIN.

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 <hey@djdev.me>
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 <hey@djdev.me>
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 <hey@djdev.me>
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 <hey@djdev.me>
…heck

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 <hey@djdev.me>
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 <hey@djdev.me>
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 <hey@djdev.me>
kernel-doc -Wall found no description of its return value.

Signed-off-by: DjDeveloperr <hey@djdev.me>

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review at 1834a363, fixes pushed up to b089aa8f. One round from me. The design holds. Nothing changes unless something vetoes, and today every case that vetoes fails its deep sleep anyway. It still needs hardware rows before it can leave draft (list at the end).

Is there an Apple-only way with less code? I looked. The sleep driver already lowers mem_sleep_current at probe (binned parts, untested profiles), and #4207 does the same for legacy firmware. For #4238's PMP alone, that would give the same result with no PM-core change. It doesn't work for the vetoes that come and go: an eGPU or a busy disk behind a USB4 port, or T8132 ports whose host driver loads later. It would also change mem_sleep behind the user's back. The other routes don't work either. .valid() turns the sleep into -EINVAL. Running s2idle from .enter comes after the PREPARE notifier and suspend_late that do the refusing. So one optional member and seven lines in pm_suspend() is the smallest route, and this tree already carries PM-core changes (dark wake, pm_set_suspend_no_platform()). Fine as it is.

What I checked and found right:

  • Ordering. The question is asked before the sync, the notifiers and the freeze. At that point user space is running, as it still is at PM_SUSPEND_PREPARE, so the check and the teardown see the same state.
  • Lock order. The veto lock is taken first, then acio->lock, then pcie_tunnel_lock, then the rescan lock. That is the teardown's order.
  • Probe and unbind. The port registers after its drvdata and both mutexes exist, so a sleep that races its probe gets "no". On unbind, the devres drop runs before the mutexes are destroyed and before drvdata is cleared.
  • s2idle and shallow are never asked: state_store() maps mem to mem_sleep_current first.
  • Errors. The s2idle sleep's error is still returned.
  • Strict ports. Leaving out strict_power_cycle ports is right: they sleep through tb_apple_sleep_quiesce(), not the PCIe removal.

Fixed on the branch (4 commits):

  • d5bf9854: apple_pcie_tunnel_removable() repeated the removal's checks but not its wait (up to 500 ms) for a disk that udev opened just after it appeared. Right after you plug in a drive, a sleep that used to be deep went to s2idle. Both functions now call one helper, so the question always gets the removal's answer.
  • 64e55fd3: the port's check tested the requested/populated flags itself, but apple_cio_find_pcie_tunnel() already returns nothing until the tunnel is populated, so I dropped those two lines. The test's lookup stub ignored that. Its case "tunnel asked for, not up yet: s2idle" claimed a veto the driver never makes. The stub and that case now match the driver (deep).
  • 7ed82d75: the header now says a check must not take device_lock(dev). The unbind takes the list's lock to drop the veto, so a check that took the device lock would deadlock with it.
  • b089aa8f: a Return: section for the new function (kernel-doc -Wall).

Our rules for merged code:

  • No switch or module parameter.
  • No new magic constants: the 10 × 50 ms wait was moved, not added.
  • No new SoC or board gate: the port registers on the same hw-data flags that decide whether its teardown runs.
  • Nothing that the ADT carries.

Does the test fail on main? Yes:

  • On all of main it doesn't find the new functions.
  • With main's kernel/power/suspend.c and this branch's drivers, it fails with static veto: s2idle instead of deep: asked deep, entered deep.
  • Each of the 3 mutants fails it.

Follow-up, not blocking. A vetoed sleep is the same sleep as echo freeze with deep as the default. Four places decide "deep or not" from pm_suspend_default_s2idle() alone at PM_SUSPEND_PREPARE, so they already misread that sleep as deep today:

  • pcie-apple's Neo radio notifier;
  • DCP's J714s crashed-display refusal;
  • the T6050 combo PHY;
  • apple_cio_t6050_sleep().

None of them runs on a Mac that can veto at this head. The vetoes are the T6020 PMP (with #4238), T8132's orphan check, and USB4 ports on T8103/T8112/T6020/T6030/T8142/T6040. If a veto ever reaches J700 or J714s, those four should also check pm_suspend_no_platform(), as dwc3-apple and pcie-apple's other check do.

Tested at b089aa8f:

  • sleep-deep-veto-tests.py passes 17/17, and all 3 mutants fail it.
  • Host tests in the CI image: sleep 58/58, cio 6/6, pcie 10/10, apcie 2/2, tb- 4/4, sep-suspend 22/22, display26 1/1, sio-engine 1/1.
  • W=1 (arm64, LLVM, J700 aurora_defconfig) of the four objects: no compiler warnings. kernel-doc -Wall on the touched files gives the same warnings as main.
  • checkpatch --strict: the seven kernel commits are clean.

Owed before it leaves draft:

  • J700, deep stays deep with no veto (no-regression, second generation). Kit work/j700-linux4245-b089aa8f-veto-row-20261203 (manifest 7ebc4038), handed to the Neo lead. Arms: full kernels of main a0e5cf15 and this head, each 3× rtcwake -m mem -s 15 under the 60 s watchdog and the 30-min dead-man. Every sleep must log PM: suspend entry (deep) and no vetoed line, with mem_sleep s2idle [deep] throughout.
  • J414s on the old Stage 2 with #4238 plus the PMP veto commit (lab/j414s-4238-deep-veto 1a3cc12d9a9d): mem goes to s2idle and wakes. It goes in the next J414s PEER kit, as a fix arm against #4238 alone.
  • J413 with the eGPU bound. We don't have a J413, so this one needs a PEER row.

Brings the branch up to main after #3786 (s2idle fallback when deep
sleep is refused for retained PCIe-C, J413 fw27 deep by default) and
#3540 (thunderbolt: apple: lost-link recheck).

Conflicts:
- drivers/pci/controller/pcie-apple.c: both sides split the checks out of
  apple_pcie_tunnel_remove_orderly(). Main's helper,
  apple_pcie_tunnel_can_remove_orderly() and remove_orderly() are taken
  as they are. This branch's apple_pcie_tunnel_kept() and
  apple_pcie_tunnel_removable() stay for now; the next commit drops them.
- tools/asahi/run-host-tests.py: both test entries kept.

kernel/power/suspend.c merged without a conflict: the platform veto in
pm_suspend() runs before enter_state(), and main's fallback in
enter_state() still covers a deep sleep refused at PM_SUSPEND_PREPARE.

Signed-off-by: DjDeveloperr <hey@djdev.me>
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 <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Brought this branch up to main cacc5d311a9e with a merge commit. New head 9f9a73082144.

Commits

  • 5bd5c3f98a46: merge of main. Two conflicts. In pcie-apple.c, both sides had split the checks out of apple_pcie_tunnel_remove_orderly(), so I took main's helper, apple_pcie_tunnel_can_remove_orderly() and remove_orderly() unchanged. In run-host-tests.py, I kept both test entries. suspend.c, suspend.h and thunderbolt/apple.c (with drm/apple, usb: Type-C route and USB4 link-recovery follow-ups (#3040, #3109 reviews) #3540) merged without conflicts.
  • 9f9a73082144: the USB4 port's veto now calls main's apple_pcie_tunnel_can_remove_orderly(), and this branch's apple_pcie_tunnel_removable() and apple_pcie_tunnel_kept() are gone. They return the same thing in every case: 0 when removable or already stopped, -EOPNOTSUPP, -EBUSY after the same 10 × 50 ms wait for a disk udev just opened, -ENODEV, -EINVAL. The only difference is one more log line from the PCIe host saying why the hierarchy stays, the same line the teardown prints. pcie-apple.c and pci-apple.h now match main, so this PR no longer touches them.

The overlap with #3786
Both paths stay. They run at different points and don't step on each other:

Checks on the merged head (pc)

  • Host tests: sleep-deep-veto-tests.py passes and its 3 mutants fail it; sleep-s2idle-fallback-tests.py passes and its 4 mutants fail it. The other suites that read the touched files all pass: cio-native, display26, pcie-adopted-clkpm, pciec-policy, radio-sleep-power, radio-sleep-snapshot, sep-suspend-errors (22/22), sio-engine-reset, t8122-apcie-wake, t8132-apcie-sleep, t8132-sleep-refuse, tb-dock-pm, tb-cio-sleep.
  • W=1 (arm64, LLVM) of sleep.o, thunderbolt/apple.o, power/suspend.o, power/main.o and pcie-apple.o: 0 compiler warnings on main and on this head. The kernel-doc lines (194, all apple_cio/apple_nhi members) are the same on both apart from line numbers. Run with the J414s/J413 kit config and with J700 aurora_defconfig, the same result both times.
  • Warm Image + modules builds of this head: the J414s/J413 kit config (with the 3 DTBs), and J700 aurora_defconfig.

Kits at this head

  • J414s + J413 PEER v2: release peer-j414s-j413-linux4245-veto-9f9a7308-20261204 (https://github.com/aurora-silicon/linux/releases/tag/peer-j414s-j413-linux4245-veto-9f9a7308-20261204), tarball sha256 fd499dc6bcf14a636a51f8898ff98e6ca4f71b71ea2e785fbb572c267b1152f5, bash kit.sh --check gives CHECK 11/11 ok. Control is main cacc5d31 + soc: apple: pmp: take T6020 SRAM keep range from DT #4238 856939be; Fix is Control + this head + the PMP veto 1a3cc12d. On J414s the expectations are unchanged. On J413, Control with an eGPU bound now expects main's fallback (rtcwake rc 0, PM: suspend entry (deep), then PM: deep sleep refused (-95), falling back to s2idle) instead of a failed sleep, and Fix expects the veto to come first with no fallback line. J413 rows need 27.x firmware, since main only offers deep on T8112 where the DT has apple,sleep-tested.
  • J700 v2: work/j700-linux4245-9f9a7308-veto-row-v2-20261204 (manifest 321be176, check.sh PASS). Base is main cacc5d31, head is this head. Archives: base a5ea5dd3, head 4f863965. The row now also fails a sleep that logs main's falling back to s2idle, so a refused-and-retried sleep can't pass as deep. Queued with the Neo lead.

The v1 kits (peer-j414s-j413-linux4245-veto-b089aa8f-20261203 and work/j700-linux4245-b089aa8f-veto-row-20261203) are left as they were. They test the old head, so don't run them.

@satchlj

satchlj commented Dec 4, 2026

Copy link
Copy Markdown
Member

Verified the J413 NO-eGPU deep leg of peer-qualification kit v2 (peer-j414s-j413-linux4245-veto-9f9a7308-20261204, tarball SHA-256 fd499dc6bcf14a636a51f8898ff98e6ca4f71b71ea2e785fbb572c267b1152f5) on bare-metal Apple M2 MacBook Air (J413, T8112, 27.2 system firmware, Stage 2 1.0.0b19-31-g1ff3078b, default kernel command line with no apple_sleep.* overrides):

Kit & Boot Verification

  • bash kit.sh --check: CHECK 11/11 ok (judge.py selftest 39/39, stage2.py selftest ok).
  • Booted sealed Fix kernel 7.3.0-peer-j414s-4245v2-fix+, ELF Build ID 1f3e41ac390451b7332b88d5ada8db71d7c5c8e4 (one-shot trial boot; stock boot.bin and default kernel untouched).
  • Pre-sleep state: board=apple,j413, os_fw=27.2, /sys/power/mem_sleep = s2idle [deep], egpu_before=none, watchdog=1min 1, deadman=armed, cpus=0-7, net=up, nvme read_rc=0, display=eDP-1:connected, backlight=apple-panel-bl=25/525, bad_before=0.

run-j413-noegpu Result

  • rtcwake -d /dev/rtc1 -m mem -s 20: rc=0, wall time 25 s, same boot_id (eb5fe16e-2016-411c-9161-603145f91f73).
  • Suspend window kernel log:
    • PM: suspend entry (deep)
    • aurora 206400000.gpu: GPU prepared for deep sleep: submitted=1096 completed=1096 pending=0
    • PM: suspend devices took 0.615 seconds
    • apple-sleep 23b700000.sleep: back from sleep, boot object resumes 0 -> 1
    • PM: suspend exit
  • No veto / no fallback: veto_line, cio_line, fallback_line, and refuse_line all empty.
  • Post-wake state: suspend_stats/success 0 -> 1 (fail 0 -> 0), /sys/power/mem_sleep still s2idle [deep], cpus=0-7, net=up, nvme read_rc=0, pci unchanged (0 ffff), display=eDP-1:connected, backlight=apple-panel-bl=25/525, bad_after=0, faults=0, tainted unchanged (4 -> 4), deadman=disarmed.

Notes

  • Only the NO-eGPU deep leg was run (no Thunderbolt eGPU attached on this J413 host; run-j413-egpu and judge-j413 were not run).
  • Kit harness note (probe_gpu in kit.sh): judge.py --single passed 12/14 checks and flagged only the two gpu before/after checks (driver=none render=fail errs=0) because kit.sh's probe_gpu() matches only DRIVER=asahi, whereas this 27.2-firmware J413 kernel binds renderD128 (apple,agx-t8112) to DRIVER=aurora. Verified live on the same boot that /sys/class/drm/renderD128 reports DRIVER=aurora and DRM_IOCTL_VERSION succeeds cleanly with 0 GPU errors.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J700 (MacBook Neo, A18 Pro, T8140) row at the exact head 9f9a73082144: PASS. With nothing to veto, deep sleep stays deep: 3 of 3 sleeps on each arm, and mem_sleep is unchanged. On the J700 nothing can veto at this head, so this is the second-generation no-regression row for the new deep_vetoed() hook.

arm kernel trial boot deep sleeps
base (control) main cacc5d311a9e (7.3.0-main-cacc5d31) 6a333a53 3/3 PASS
head this PR (7.3.0-pr4245-9f9a7308) ae7c8063 3/3 PASS

Both arms are full kernels (Image, every module and the J700 DTB), built with the stock aurora_defconfig. Each arm ran one one-shot trial boot with the dead-man active, panic=10 and the 60 s systemd watchdog armed. On each boot the row ran three rtcwake -d rtc0 -m mem -s 15, 20 s apart. Each of the six sleeps showed:

The whole boot had 0 veto lines on either arm. The J700 was verified back on stock after each boot.

Not covered:

  • a driver that actually vetoes (none exists on T8140 at this head);
  • s2idle sleeps;
  • more than 3 sleeps per boot.

@DjDeveloperr
DjDeveloperr marked this pull request as ready for review December 4, 2026 05:00
@DjDeveloperr
DjDeveloperr requested review from a team as code owners December 4, 2026 05:00

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review at head 9f9a73082144, merged onto main 35ddf947b124. The merge is clean, and its diff against main is the same 8 files as against cacc5d31. Sound, merging.

What I checked in the code

  • With no veto, deep sleep is the old path. pm_suspend() only changes state when deep_vetoed is set and returns true. Every other platform leaves it NULL. The apple-sleep driver is built in, can't be unbound, and sets apple_sleep before suspend_set_ops(), so the callback never sees a NULL driver.
  • The order of the veto and the fallback. The veto runs in pm_suspend() before enter_state() takes system_transition_mutex. Nothing is frozen, no notifier has run and no device has suspended yet, so a veto can't leave anything half suspended or skip a resume. It only changes which state enter_state() gets. #3786's fallback in enter_state() only acts on PM_SUSPEND_MEM, so it never runs again after a veto. In the s2idle sleep, pm_suspend_no_platform() makes the port's PREPARE check and teardown step aside.
  • Locking. The list lock is taken by register, drop and the veto query. The port check takes acio->lock, then pcie_tunnel_lock, then the PCI rescan lock. That is the same order the teardown uses. Nothing takes the list lock while holding one of those three, so this can't deadlock.
  • Probe and unbind. The veto is registered after drvdata and both mutexes are set up. Before a cable is up, current_cable_info is 0 and the check returns false. On unbind, removing is checked first. The veto is dropped before acio and its mutexes go. If devm_add_action_or_reset() fails, it removes the list entry at once.
  • The port vetoes on any error from apple_pcie_tunnel_can_remove_orderly(), the same function and arguments the PREPARE check uses. The teardown refuses a deep sleep on any of those errors, so a veto turns a refusal into s2idle. It never stops a deep sleep that would have worked.
  • No runtime switch or module parameter, no magic constants, no new SoC or board gate. The port registers on the existing per-compatible sleep_removes_domains and strict_power_cycle flags. No ADT values are involved.

Checks on the merge (pc)

  • Host tests in the CI image: 26 suites, 81 of 81 runs pass. sleep-deep-veto 17/17, and each of its 3 mutants fails it. sleep-s2idle-fallback passes, and each of its 4 mutants fails it. Every suite that reads sleep.c, sleep.h, suspend.c, suspend.h or thunderbolt/apple.c passes, plus apple-wdt 12/12 and t6030-sleep-qblk for main's sleep.c changes since cacc5d31.
  • W=1, arm64, clang 23 (incremental, on the J414s/J413 kit config), for suspend.o, power/main.o, sleep.o, thunderbolt/apple.o and pcie-apple.o: 0 compiler warnings on the merge and on main. The 194 kernel-doc lines are the same on both.
  • checkpatch.pl --strict: the kernel commits are clean. The test commit only gets flags on its fixture stubs.
  • Hosted CI is green at the head.
  • Since then main has moved to bae84a38eab4 (#4267 tbnet, #4042 J815 thermal zones). It touches none of this PR's files, and GitHub still reports MERGEABLE.

Rows at this head

  • J700 (T8140): PASS. 3 of 3 deep sleeps on each arm, no veto or fallback lines.
  • J413 (T8112, macOS 27.2 firmware), no eGPU: PASS (satchlj). Deep sleep stays deep. The two GPU "fails" in that judge come from the kit: probe_gpu() only accepts DRIVER=asahi, and 27.2 binds aurora.

Not yet

  • The eGPU veto leg has not run on hardware. No peer has a Thunderbolt eGPU. The host tests cover that path.
  • J414s with #4238 and the PMP veto commit.
  • A vetoed mem under pm_test core or processors returns -EAGAIN.

I updated the PR text to match the head. It now names apple_pcie_tunnel_can_remove_orderly(), lists the rows and says the eGPU leg hasn't run on hardware. The head did not change.

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) area:usb Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 4, 2026
@DjDeveloperr
DjDeveloperr merged commit f778d6c into main Dec 4, 2026
15 checks passed
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown

Merge readiness at 9f9a7308: not ready yet

Check Detail
CI at head running running: pr-text / pr-text
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok comment at 9f9a7308
Conflicts ok none
PR text ok Risk: two-way · . Nothing changes unless something vetoes. On main only T8132 with orphaned ports or a USB4 port with an unremovable PCIe function vetoes, and both of those fail their deep sleep or fall back to s2idle at PREPARE today. A wrong veto, such as a disk that udev holds open for a moment, gives an s2idle instead of a deep sleep, never a failed suspend. The core change is one optional member in platformsuspendops.

Areas: area:gpu, area:platform, area:usb

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@DjDeveloperr
DjDeveloperr deleted the fix/sleep-deep-veto-s2idle branch December 4, 2026 05:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) area:usb Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants