Skip to content

PM: sleep: consume only the dark-wake IRQ before device resume - #3846

Merged
DjDeveloperr merged 2 commits into
mainfrom
fix/pm-dark-wake-clear-wakeup-state
Dec 2, 2026
Merged

DjDeveloperr merged 2 commits into
mainfrom
fix/pm-dark-wake-clear-wakeup-state

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When a platform dark-wake callback (such as apple-sleep SMC power button, lid, port, or debug-link-cut dark wake) handles a wake during dpm_resume_noirq() and calls pm_set_dark_wake_irq(irq), pm_system_irq_wakeup() has already recorded that wake IRQ in wakeup_irq[0] and incremented pm_abort_suspend.

Without consuming that handled dark-wake event, the re-suspend loop in suspend_devices_and_enter() sees pm_wakeup_pending() still true on the next iteration, aborts the re-suspend, and wakes the system into userspace with the display off.

Simply zeroing wakeup_irq[] and pm_abort_suspend unconditionally (or blindly consuming wakeup_irq[0] without matching the classified dark-wake IRQ) would discard a sole unrelated wake IRQ, an unrelated IRQ recorded ahead of the dark-wake IRQ, or a second wake IRQ arriving during dpm_resume_noirq() or dpm_resume_early().

This change:

  • Adds pm_wakeup_consume_irq(unsigned int irq_number) in drivers/base/power/wakeup.c (with !CONFIG_PM_SLEEP stub in include/linux/suspend.h) to consume only a matching wakeup_irq[0], shift any second recorded IRQ from wakeup_irq[1] into wakeup_irq[0], and decrement pm_abort_suspend by one.
  • Tracks the classified dark-wake IRQ in pm_dark_wake_irq via pm_set_dark_wake_irq(unsigned int irq) (leaving pm_set_dark_wake() at IRQ 0 so firmware-only dark wakes never consume an unrelated Linux IRQ) and exposes apple_rtkit_rx_irq() so macsmc passes apple_smc_wake_irq(smc) through all four Apple dark-wake classifiers (apple_smc_dark_wake, apple_sleep_lid_closed_wake, apple_sleep_port_wake, apple_sleep_debug_link_cut_wake).
  • Calls pm_consume_dark_wake() in suspend_enter() right after dpm_resume_noirq() to atomically read/clear pm_dark_wake_irq and consume it only when nonzero and matching wakeup_irq[0]; if any wake IRQ or non-IRQ wakeup source remains pending, clears PM_SUSPEND_FLAG_DARK_WAKE so suspend_devices_and_enter() finishes resuming into userspace.
  • Clears PM_SUSPEND_FLAG_DARK_WAKE and pm_dark_wake_irq after suspend_enter() returns on error or late wake during dpm_resume_early(), and clears pm_dark_wake_irq in pm_suspend_clear_flags().
  • Adds CONFIG_PM_WAKEUP_KUNIT_TEST (drivers/base/power/wakeup-test.c, depending on PM_SLEEP && SUSPEND) with 10 UML KUnit subtests covering both pm_wakeup_consume_irq() and pm_consume_dark_wake(), including matching SMC IRQ, firmware-only dark wake, second-IRQ preservation, sole unrelated wake IRQ, unrelated IRQ recorded ahead of the SMC IRQ, and non-IRQ wakeup preservation.

Tested

Tested: 48237685b006 on J516s (T6030, M3 Pro) passed three physical deep-sleep cycles with a clean stock handback. A separate instrumented run (modes 1–5) verified dark-only re-entry, mixed-wake cancellation, firmware-only dark wake preservation, and preserved the RTC IRQ during a spontaneous mixed wake. Native UML KUnit (pm-wakeup-kunit-test) passed 10/10, and scripts/checkpatch.pl --strict --ignore FILE_PATH_CHANGES reported 0 errors, 0 warnings, 0 checks. Exact-head test details.

The J516s combined sleep-stack soak kernel (0f829697b087, which carries 48237685b006) completed 20/20 physical deep-sleep cycles and 20/20 NVMe readback checks, with zero kernel errors or GPU faults and clean stock handback. Combined soak receipt.

Risk: two-way · all firmware-sleep Macs

@DjDeveloperr
DjDeveloperr requested review from a team as code owners December 1, 2026 23:08
@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Merge readiness at 48237685: not ready yet

Check Detail
CI at head ok 47 checks passed
Review ok approved by satchlj
Requested changes ok none
Hardware row at head ok in the PR body at 48237685
Conflicts ok none
PR text ok Risk: two-way · all firmware-sleep Macs
Hold no labelled hold by a maintainer

Areas: area:platform, area:power

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

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) and removed needs-template PR body lacks Tested or Risk (bot) labels Dec 1, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J516s hardware verification for exact head 2304766d9e118824195babd0a5aac793ca3ccbc4:

  • Verified in merged T6030 S2R candidate (098d2b244e078adb3b5b9c23f220ef84fb76ab0a + #3532 a4204722c549, boot f713a241-9f3e-4536-bd6d-c27ec12643b1): 2 physical deep-sleep cycles (1×30s + 1×20s), suspend_stats success=2, fail=0, last_failed_errno=0.
  • Also verified across an uninterrupted 600 s physical deep-sleep soak (f1678207-2630-47e5-a754-9d28f813f331, wall_elapsed=601s) where a live macsmc dark wake at 492.563 s cleared stale wakeup state (irq=141, pending=1 -> 0/0), re-entered sleep cleanly, and woke on NUB.SPMI0.SW3, followed by 3×20 s rapid cycles (success=4, fail=0).
  • Stock 7.3.0 restored (boot_id=5c2faf10-ca29-4e2e-8b48-0b040cc2a613).

@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.

At this head, a second wake IRQ can disappear during dark-wake resume. suspend_enter() reenables IRQs and runs dpm_resume_noirq() and dpm_resume_early() before returning here. If a new wake IRQ reaches pm_system_irq_wakeup() in that window, it can occupy wakeup_irq[1] and increment pm_abort_suspend. pm_wakeup_clear(0) then erases both IRQ slots and zeroes that counter, allowing the dark-wake loop to re-enter sleep despite the new event. Please consume only the wake classified as dark and preserve later events. A dark wake followed by a separate wake IRQ before dpm_resume_early() returns should exit with userspace resumed.

@DjDeveloperr DjDeveloperr changed the title PM: sleep: clear dark-wake wakeup state before device resume PM: sleep: consume only the dark-wake IRQ before device resume Dec 2, 2026
@DjDeveloperr
DjDeveloperr force-pushed the fix/pm-dark-wake-clear-wakeup-state branch from 2304766 to ad97b96 Compare December 2, 2026 00:52
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Addressed the second-wake IRQ preservation finding in exact head ad97b966bf3456db9b0d745f84524c3f009ed34b:

  • Replaced unconditional wakeup-state clearing with pm_wakeup_consume_irq(unsigned int irq_number), which only consumes wakeup_irq[0] when it matches irq_number, shifts any second recorded IRQ from wakeup_irq[1] into wakeup_irq[0], and decrements pm_abort_suspend by one.
  • In suspend_enter(), suspend_consume_dark_wake() consumes only the handled dark-wake IRQ after dpm_resume_noirq() and clears PM_SUSPEND_FLAG_DARK_WAKE if another wake IRQ or non-IRQ wakeup source remains pending.
  • In suspend_devices_and_enter(), PM_SUSPEND_FLAG_DARK_WAKE is also cleared after suspend_enter() returns if error is non-zero or a new wake arrived during dpm_resume_early().
  • Added CONFIG_PM_WAKEUP_KUNIT_TEST (drivers/base/power/wakeup-test.c) covering single-IRQ consumption, second-IRQ preservation, mismatched-IRQ no-op, non-IRQ wakeup preservation, and zero-IRQ no-op.

Exact-head verification (ad97b966bf3456db9b0d745f84524c3f009ed34b)

  1. Native UML KUnit (pm-wakeup-kunit-test): 5/5 passed.
  2. checkpatch.pl --strict --no-signoff --ignore FILE_PATH_CHANGES: 0 errors, 0 warnings, 0 checks.
  3. J516s (M3 Pro) exact-head physical deep sleep (over #3818): 7.3.0-t6030s2r #71, Image SHA-256 55050efcc69c708b87b07dbfbaf99ff508d13ac37a9a4fb58c570d69c9de5b35, boot ID 69c735c5-ce72-4190-9a03-50bfbc9d0223 — 3/3 consecutive physical deep-sleep cycles passed (boot object resumes 0 -> 1 -> 2 -> 3, success=3, fail=0, RC=0, dcp_hotplug connected:1 valid_mode:1).
  4. J516s live second-wake preservation probe on physical deep sleep (boot ID 10f7086e-77e3-4df1-b34b-0b8383ab81d8, temporary suspend.c injector):
    • Mode 2 (dark wake IRQ 141 + dpm_resume_noirq IRQ 200): boot object resumes 0 -> 1, exited directly to userspace (RC=0, success=1, fail=0, /sys/power/pm_wakeup_irq == 200, dcp_hotplug connected:1 valid_mode:1, no re-suspend).
    • Mode 3 (dark wake IRQ 141 + dpm_resume_early IRQ 200): boot object resumes 1 -> 2, exited directly to userspace (RC=0, success=2, fail=0, /sys/power/pm_wakeup_irq == 200, dcp_hotplug connected:1 valid_mode:1, no re-suspend).
  5. Stock 7.3.0 handback: boot ID bc142b1f-ef41-411c-9565-4a8a1664d64a, both ESPs verified against stock SHA-256, grubenv empty, pacman -Qkk mesa 0 altered files, 0 failed units.

@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Dec 2, 2026

@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 of ad97b966bf34: the new J516s traces close the second-wake finding in both resume phases.

One blocker remains in drivers/base/power/wakeup-test.c. KUnit supports reruns from debugfs on a live kernel. The suite init and exit call pm_wakeup_clear(0), which zeroes the real IRQ buffer and abort counter, and the cases inject synthetic IRQs into the same globals. A rerun concurrent with resume can discard a genuine pending wake or substitute a fake one. Please exercise private test state or scope the suite to the UML environment that produced the 5/5 result.

When a platform dark-wake callback (such as apple-sleep SMC power
button or lid dark wake) handles a wake during dpm_resume_noirq() and
calls pm_set_dark_wake(), pm_system_irq_wakeup() has already recorded
that wake IRQ in wakeup_irq[0] and incremented pm_abort_suspend.

Without consuming that handled dark-wake event, the re-suspend loop in
suspend_devices_and_enter() sees pm_wakeup_pending() still true on the
next iteration, aborts the re-suspend, and wakes the system into
userspace with the display off.

Simply zeroing wakeup_irq[] and pm_abort_suspend unconditionally would
discard a second, real wake IRQ that arrives during dpm_resume_noirq()
or dpm_resume_early() (before the loop re-checks pm_dark_wake()).

Add pm_wakeup_consume_irq(unsigned int irq_number) to consume only the
recorded wake IRQ when it matches wakeup_irq[0]: it promotes any second
recorded IRQ from wakeup_irq[1] into wakeup_irq[0] and decrements
pm_abort_suspend by one. Call it from suspend_consume_dark_wake() right
after dpm_resume_noirq() completes; if another wake IRQ or non-IRQ
wakeup source is still pending after consuming the dark wake, clear
PM_SUSPEND_FLAG_DARK_WAKE so suspend_devices_and_enter() finishes
resuming into userspace. Also clear PM_SUSPEND_FLAG_DARK_WAKE after
suspend_enter() returns if an error occurred or a new wake arrived
during dpm_resume_early().

Add a KUnit test suite (CONFIG_PM_WAKEUP_KUNIT_TEST) covering single-IRQ
consumption, second-IRQ preservation, mismatched-IRQ no-op, non-IRQ
wakeup preservation, and zero-IRQ no-op.

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

Copy link
Copy Markdown
Contributor Author

Scoped CONFIG_PM_WAKEUP_KUNIT_TEST to UML (depends on KUNIT=y && UML in drivers/base/Kconfig) in exact head 013942c778ff8370a11d3ce03738d8d82d4f28c0 so the suite cannot be built into or rerun via debugfs on a live hardware kernel.

Production files (drivers/base/power/wakeup.c, include/linux/suspend.h, kernel/power/suspend.c) are byte-identical to ad97b966bf34.

Re-verification (013942c778ff8370a11d3ce03738d8d82d4f28c0)

  • scripts/checkpatch.pl --strict --ignore FILE_PATH_CHANGES: 0 errors, 0 warnings, 0 checks.
  • Native UML KUnit (./tools/testing/kunit/kunit.py run --kconfig_add CONFIG_SMP=n --kconfig_add CONFIG_SUSPEND=y --kconfig_add CONFIG_PM_WAKEUP_KUNIT_TEST=y pm-wakeup-kunit-test): 5/5 passed.
  • J516s exact-head physical deep-sleep and live Modes 2 & 3 second-wake receipts on the unchanged production code remain valid (69c735c5-ce72-4190-9a03-50bfbc9d0223 3/3 cycles, 10f7086e-77e3-4df1-b34b-0b8383ab81d8 Modes 2 & 3 WAKEUP_IRQ=200, stock 7.3.0 handback bc142b1f-ef41-411c-9565-4a8a1664d64a).

@DjDeveloperr
DjDeveloperr force-pushed the fix/pm-dark-wake-clear-wakeup-state branch from ad97b96 to 013942c Compare December 2, 2026 01:08

@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.

Rechecked 013942c. The UML and built-in KUnit dependencies keep the debugfs rerun off hardware kernels. The wakeup and suspend sources match ad97b96 byte for byte, so the J516s result still covers the runtime change. The five UML cases passed. No blocking code findings. Hosted checks and a second firmware-sleep generation row are still outstanding.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J516s (M3 Pro, T6030) hardware row at 013942c778ff8370a11d3ce03738d8d82d4f28c0: PASS (zero production-code diff from ad97b966bf34, which passed 3/3 consecutive physical deep-sleep cycles on 69c735c5-ce72-4190-9a03-50bfbc9d0223 and live second-wake IRQ preservation Mode 2 & Mode 3 on 10f7086e-77e3-4df1-b34b-0b8383ab81d8 with /sys/power/pm_wakeup_irq == 200, RC=0, fail=0, and clean stock 7.3.0 handback on bc142b1f-ef41-411c-9565-4a8a1664d64a; native UML KUnit pm-wakeup-kunit-test 5/5 passed at 013942c778ff).

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Dec 2, 2026

@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.

Blocking finding at 013942c in kernel/power/suspend.c, suspend_consume_dark_wake(): the firmware wake record does not identify the first Linux IRQ. Apple sets the dark-wake flag from latched SMC wake bits and a later SMC event. If an unrelated wake IRQ is the only IRQ recorded by Linux while noirq resume is in progress, pm_wakeup_consume_irq(pm_wakeup_irq()) removes that IRQ and its pending count, and the system can go back to sleep. The two-IRQ tests put the SMC IRQ first and miss this case. Pass the SMC IRQ identity when classifying the wake, consume only that IRQ when it is first, and preserve a sole unrelated IRQ. Please cover both a sole unrelated IRQ and an unrelated IRQ recorded before the SMC IRQ.

A firmware dark-wake record from Apple SMC does not prove that the first
Linux IRQ recorded in wakeup_irq[0] belongs to SMC. If an unrelated wake
IRQ arrived alone during noirq resume, or arrived ahead of the SMC IRQ,
calling pm_wakeup_consume_irq(pm_wakeup_irq()) blindly would drop that
unrelated wake event and allow the system to re-enter sleep.

Track the classified dark-wake IRQ in pm_dark_wake_irq via
pm_set_dark_wake_irq() (leaving pm_set_dark_wake() at IRQ 0 so
firmware-only wakes never consume an unrelated Linux IRQ) and expose
apple_rtkit_rx_irq() so macsmc passes its mailbox RX IRQ through all
four Apple dark-wake paths (apple_smc_dark_wake,
apple_sleep_lid_closed_wake, apple_sleep_port_wake, and
apple_sleep_debug_link_cut_wake).

In pm_consume_dark_wake(), atomically read and clear pm_dark_wake_irq
and only call pm_wakeup_consume_irq(irq) when irq is nonzero, preserving
both a sole unrelated wake IRQ and an unrelated IRQ recorded before the
SMC IRQ so dark wake is cancelled and resume continues to user space.
Also clear pm_dark_wake_irq on suspend_devices_and_enter() error/late
wake paths and in pm_suspend_clear_flags().

Expand pm-wakeup-kunit-test (CONFIG_PM_WAKEUP_KUNIT_TEST, now depending
on SUSPEND) to directly test pm_consume_dark_wake() across matching SMC
IRQ, firmware-only dark wake, SMC IRQ followed by unrelated IRQ, sole
unrelated IRQ, and unrelated IRQ recorded ahead of the SMC IRQ.

Signed-off-by: Diljit Singh <hey@djdev.me>
@github-actions github-actions Bot added the area:platform Area from CODEOWNERS (bot) label Dec 2, 2026
@github-actions github-actions Bot added area:power Area from CODEOWNERS (bot) needs-hw-row No hardware row at the PR head (bot) labels Dec 2, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Addressed the review finding from pullrequestreview-6143381070 in 48237685b006ac3d455f143d197e2c2303d9de6f:

  • Added pm_dark_wake_irq and pm_set_dark_wake_irq(unsigned int irq) (keeping pm_set_dark_wake() at IRQ 0 so firmware-only dark wakes never consume an unrelated Linux IRQ), and updated pm_consume_dark_wake() to atomically consume only pm_dark_wake_irq when nonzero and matching wakeup_irq[0].
  • Added apple_rtkit_rx_irq() and passed apple_smc_wake_irq(smc) through all four Apple dark-wake classifiers (apple_smc_dark_wake, apple_sleep_lid_closed_wake, apple_sleep_port_wake, apple_sleep_debug_link_cut_wake).
  • Expanded pm-wakeup-kunit-test (CONFIG_PM_WAKEUP_KUNIT_TEST, depending on PM_SLEEP && SUSPEND) to 10 subtests covering pm_consume_dark_wake() directly, including a sole unrelated wake IRQ (both with SMC IRQ and IRQ 0) and an unrelated wake IRQ recorded ahead of the SMC IRQ.

Verification at exact head 48237685b006ac3d455f143d197e2c2303d9de6f

  • Style: scripts/checkpatch.pl --strict --ignore FILE_PATH_CHANGES — 0 errors, 0 warnings, 0 checks (506 lines).
  • UML KUnit (pm-wakeup-kunit-test): 10/10 PASSED (CONFIG_SMP=n, CONFIG_SUSPEND=y, CONFIG_PM_WAKEUP_KUNIT_TEST=y), including pm_dark_wake_preserves_sole_unrelated_irq_test and pm_dark_wake_preserves_unrelated_irq_before_smc_test.
  • J516s (T6030, M3 Pro) Pass 1 — clean exact-head kernel (098d2b244e07 + 48237685b006, zero-flag cmdline, s2idle [deep], boot_id=f8ff563c-aebc-4bc9-937d-5be39cf7ff73):
    • Verified live /proc/kallsyms exports (pm_consume_dark_wake, pm_dark_wake_irq, apple_rtkit_rx_irq, pm_wakeup_consume_irq) and SMC mailbox RX IRQ 38 (36c408000.mbox-recv).
    • 3/3 consecutive physical deep-sleep cycles (rtcwake -m mem -s 15): boot object resumes 0 -> 1 -> 2 -> 3, suspend_stats success=3 fail=0 last_failed=0, FAILED_UNITS=0.
  • J516s Pass 2 — live physical deep-sleep dark-wake / mixed-wake verification (boot_id=a7787d84-6d76-4072-9a74-61866aac010c, SMC_IRQ=38, temporary local-only suspend.c hook):
    • Dark-only re-entry (mode=1): SMC IRQ 38 + pm_set_dark_wake_irq(38) -> post_irq=0 post_pending=0 post_dark=1, apple-drm: dark wake: outputs stay off, aurora-g16: dark wake: GPU firmware stays stopped, PM: dark wake: suspending again (deep), re-entered physical deep sleep and woke cleanly on RTC (boot object resumes 0 -> 1 -> 2, eDP-1:connected, fail=0).
    • Mixed wake — SMC first, unrelated second (mode=2): 38 then 200, pm_set_dark_wake_irq(38) -> post_irq=200 post_pending=1 post_dark=0, cancelled dark wake cleanly (2 -> 3, eDP-1:connected).
    • Sole unrelated IRQ (mode=3): 200 only, pm_set_dark_wake_irq(38) -> post_irq=200 post_pending=1 post_dark=0, preserved 200 and cancelled dark wake (3 -> 4, eDP-1:connected).
    • Spontaneous real-hardware race (mode=4 run 1): macsmc classified a real wifibt dark wake while macsmc-rtc (IRQ 87) was recorded in wakeup_irq[0] (orig_irq=87 orig_pending=1 orig_dark=1) -> pm_consume_dark_wake() preserved IRQ 87 (post_irq=87 post_pending=1) and cancelled dark wake (post_dark=0, 4 -> 5).
    • Clean unrelated-before-SMC (mode=4 run 2): orig_irq=0, 200 then 38, pm_set_dark_wake_irq(38) -> post_irq=200 post_pending=1 post_dark=0 (6 -> 7).
    • Firmware-only dark wake + sole unrelated IRQ (mode=5): 200 only, pm_set_dark_wake() (IRQ 0) -> post_irq=200 post_pending=1 post_dark=0 (5 -> 6, eDP-1:connected).
  • J516s Pass 3 — clean stock 7.3.0 handback (boot_id=dad54c09-78ba-48b4-8745-16cc02c46b25):
    • Both /boot/efi/m1n1/boot.bin and /boot/efi/aurora/boot.bin verified at stock SHA-256 efab68fa0457a177220d75ba50aa92bc6d93bbd757a0e42ff8c2332ec92f9fe7, empty grubenv, temporary /boot and /lib/modules/7.3.0+ files removed, aurora-sep 1-25, 0 failed units.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J714s (M5 Pro, T6050) tested integration candidate 730f0cadeb6d, which contains this exact head 48237685b006 and #3807 at ed67b5f6dbec, with the stock command line.

  • Independent RTC wake passed after 60.025 s. Firmware resume and suspend success each advanced by one, and rtcwake returned 0.
  • An isolated USB-C plug woke the machine after 7.233 s. The SMC classified it as a dark wake and PM attempted to suspend again. The second device prepare failed with apple_pcie_prepare() = -EIO at 1cb0000000.pcie. Userspace resumed before the RTC alarm, rtcwake returned 1, and the firmware resume counter advanced only once for this request.
  • The stock boot was restored and verified.

The retry needs to pass with the PCIe fix in the candidate. The J516s pass still covers the IRQ handling on T6030.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J516s (M3 Pro, T6030) Shared-Code Control Receipt — PASS

Candidate tree: origin/main (973ced809eba) + exact #3898 (6fd0b44b267f) + exact #3846 (48237685b006) + T6030 S2R stack (#3818 0a7df1d4469e, #3808 fa6a474aa3b2, #3810 a9ba3592318e, #3814 9305813f1a99, #3763 2f06f33dae05, #3409 793075bd411e), integration commit ae108162ce24. Zero-flag cmdline, mem_sleep=s2idle [deep], SMC_IRQ=38 (36c408000.mbox-recv).

Pass 1 — Clean exact-head kernel (7.3.0-m3-s2r-gae108162ce24, boot_id=43e0a6d2-5f93-47c4-b016-999232b43404):

  • Independent RTC/full deep-sleep cycles (rtcwake -d rtc0 -m mem -s 30 ×2): rc=0 both cycles, suspend_stats/success 0 -> 1 -> 2, fail=0, boot object resumes 0 -> 1 -> 2.
  • Normal PCIe endpoint recovery (580000000.pcie pci@0,0 BCM4388 WiFi+BT, pci@1,0 GL9755 SDXC), eDP-1 connected/enabled + backlight bounce 25->25->61->25, NVMe 16 MiB SHA-256 + write OK, aurora-g16 gpubench-vk transfer.ops CRC 55a4e6b1 (valid: true), aurora-sep sleeps 0->2, 0 failed systemd units, 0 PCIe/PM/GPU/BT/SEP/tipd errors.

Pass 2 — Live physical deep-sleep dark-wake & mixed-IRQ verification (7.3.0-m3-s2rp2-gf72c4b053d4d, boot_id=49fad723-188e-4eb9-af09-0bd0b504cdd8, local-only dw_test_mode hook in kernel/power/suspend.c exercising unmodified pm_consume_dark_wake() and apple_pcie_prepare()):

  1. Lone SMC dark wake -> re-entry (mode=1): injected SMC IRQ 38 + pm_set_dark_wake_irq(38) (orig_irq=0 orig_pending=0 orig_dark=0 -> post_irq=0 post_pending=0 post_dark=1). Logged apple-drm display-subsystem: dark wake: outputs stay off, aurora-g16 292400000.gpu: dark wake: GPU firmware stays stopped, PM: dw_test: rearm rtc0 +15s rc=0, PM: dark wake: suspending again (deep). Second dpm_suspend_start() / apple_pcie_prepare() succeeded with 0 errors and entered physical deep sleep a second time (boot object resumes 0 -> 1 -> 2, two firmware entries, one final thaw), rtcwake rc=0, suspend_stats/success 0 -> 1, fail=0.
  2. Mixed wake — SMC first (38), unrelated IRQ second (200) (mode=2): orig_irq=0 orig_pending=0 orig_dark=0 -> post_irq=200 post_pending=1 post_dark=0. Unrelated IRQ 200 survived, dark wake cancelled, no dark re-entry (boot object resumes 2 -> 3), rtcwake rc=0, suspend_stats/success 1 -> 2, fail=0.
  3. Mixed wake — unrelated IRQ first (200), SMC second (38) (mode=3): real hardware USB-C_plug dark wake also arrived at 8.930 s (orig_irq=0 orig_pending=0 orig_dark=1 -> post_irq=200 post_pending=1 post_dark=0). Unrelated IRQ 200 survived, dark wake cancelled, no dark re-entry (boot object resumes 3 -> 4), rtcwake rc=0, suspend_stats/success 2 -> 3, fail=0.
  • After every wake: 01:00.0 (BCM4388 WiFi, wld0 connected), 01:00.1 (BCM4388 BT, bootstage 2->0, BD_ADDR 60:3e:5f:4a:e8:c8 restored), 02:00.0 (GL9755 SDXC), card1-eDP-1 connected/enabled, post-Pass-2 gpubench-vk transfer.ops CRC 55a4e6b1 (valid: true), aurora-sep keystore=open, xart=enabled, 0 failed systemd units, 0 new PCIe/PM/GPU/BT/SEP/tipd errors. (Stock handback and m3hw lease release will follow after remaining G16 control rows on this lease.)

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verdict: MERGE at 48237685b006ac3d455f143d197e2c2303d9de6f
Blockers: none
Checked: no Apple material, no inappropriate model gating, default command-line compatibility, wakeup.c / suspend.c / macsmc.c / rtkit.c / sleep.c dark-wake IRQ consumption and rollback paths, UML KUnit scoping, hosted CI, exact-head J516s hardware receipts, PR text

Evidence
  • drivers/base/power/wakeup.c (pm_wakeup_consume_irq()): checks irq_number != 0, matches only wakeup_irq[0] under wakeup_irq_lock, promotes wakeup_irq[1] to wakeup_irq[0], and decrements pm_abort_suspend once via pm_system_cancel_wakeup() only when consumed. A second recorded IRQ, a mismatched first IRQ, or a non-IRQ wakeup remains pending.
  • kernel/power/suspend.c (pm_consume_dark_wake(), suspend_enter(), suspend_devices_and_enter()): atomically reads/clears pm_dark_wake_irq via xchg() right after dpm_resume_noirq() (before dpm_resume_early()), consumes only a nonzero matching IRQ, and clears PM_SUSPEND_FLAG_DARK_WAKE if any wake IRQ or non-IRQ wakeup source remains pending. suspend_devices_and_enter() also clears both PM_SUSPEND_FLAG_DARK_WAKE and pm_dark_wake_irq on error or late wake during dpm_resume_early(), and pm_suspend_clear_flags() resets pm_dark_wake_irq.
  • drivers/soc/apple/rtkit.c, drivers/mfd/macsmc.c, drivers/soc/apple/sleep.c, and headers: apple_rtkit_rx_irq() guards null pointers and non-positive IRQ numbers; all four Apple dark-wake classifiers propagate apple_smc_wake_irq(smc); !CONFIG_PM_SLEEP, !CONFIG_SUSPEND, and !CONFIG_APPLE_SLEEP stubs match.
  • drivers/base/Kconfig & drivers/base/power/wakeup-test.c: CONFIG_PM_WAKEUP_KUNIT_TEST depends on KUNIT=y && UML and PM_SLEEP && SUSPEND (keeping live-global test injection off hardware kernels) and covers single-IRQ, second-IRQ, mismatch, non-IRQ, firmware-only, sole unrelated IRQ, and unrelated-before-SMC cases (10/10 UML KUnit pass).
  • Hosted CI: all 12 checks passed (apple-build, host-tests, pr-text, readiness, KUnit plan, KUnit dcp-topology macsmc asahi); MERGEABLE with zero conflicts.
  • Hardware rows at exact head 48237685b006: J516s (M3 Pro, T6030) physical deep-sleep RTC control, live dark-wake re-entry (2 firmware entries / 1 thaw), mixed-IRQ cancel (SMC-first, unrelated-first, sole unrelated, spontaneous real-hardware race preserving macsmc-rtc IRQ 87 and real USB-C_plug), firmware-only dark wake, and 20/20 soak (#issuecomment-7332608358, #issuecomment-7333683556, #issuecomment-7343839905).

@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label Dec 2, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J714s (M5 Pro, T6050) exact-head row at 48237685b006ac3d455f143d197e2c2303d9de6f (+ #3898 6fd0b44b267f): PARTIAL (clean dark-wake retry queued next)

  • Candidate: origin/main (2225082e1d18) + exact #3846 (48237685b006ac3d455f143d197e2c2303d9de6f) + exact #3898 (6fd0b44b267fa74f8450fcc162d431fbeb9c6ee4) in b0ccb5fce773 (7.3.0-m5-pr3898-b0ccb5fc), boots 63bd561e-b30d-4ad1-942c-b4205ce9f924 and 40c311c4-ea02-4fa3-97b9-9b6327464b5a, SLC on (16 planes).
  • Verified: Mode 2 60 s RTC control passed 2/2 boots (rc=0, 60.128 s / 60.822 s, boot object resumes 0 -> 1, success 0 -> 1, fail 0 -> 0). In Run 1 Cycle 2, dark-wake classification (AP 127 SMC.OutboxNotEmpty, USB-C_plug), IRQ consumption, and physical deep-sleep re-entry mux: apple-display-crossbar: replace the T602x selector fields instead of OR-ing them #1 (PM: dark wake: suspending again (deep), boot object resumes 1 -> 2 -> 3, +2 firmware resumes in one rtcwake request, 0 PCIe/DART faults) succeeded cleanly.
  • Why PARTIAL: The disconnect trigger's 2 s automatic replug fired dark wake 2 whose 3rd entry hit apple-sleep: refused at .prepare_late: SMC scope: -16 (rtcwake rc=1, clean rollback), preventing final RTC exit (rc=0, success +1, fail +0). Retrying next with a non-replug dark-wake trigger and 2-0c kept quiet.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Merge-tree receipt: exact head 48237685b006 on main 9177b2d474f8 (local, x86_64 build host)

  • git merge-tree --write-tree 9177b2d474f8 48237685b006: clean, tree 1d22b203eaa8. The merge base is e6ed67890fcd, and main is 151 commits ahead of it. In that range, main changed rtkit.c, rtkit.h and mailbox.c. It added the private wrapper with rx_held, apple_rtkit_mailbox_status(), apple_rtkit_sleep_return_held() and apple_mbox_read_status(). None of this touches rtk->mbox or irq_recv_not_empty, which apple_rtkit_rx_irq() reads. Main adds no new callers of pm_set_dark_wake() or of the apple_sleep_*_wake() helpers whose signatures this PR changes.
  • apple-build config (arm64 defconfig + asahi.config, LLVM=1, clang 23.1.3, rustc 1.100.1). Built W=1 modules_prepare drivers/base/power/ kernel/power/ drivers/mfd/macsmc.o drivers/soc/apple/ drivers/gpu/drm/apple/apple_drv.o, with those objects forced to rebuild. Main tip: rc=0. Merge: rc=0. Both have the same warnings, which already exist on main: three -Wunused-but-set-global in display-gate.c and the SEP Rust dead-code warnings. The PR adds no warnings.
  • kunit.py run --make_options LLVM=1 --kconfig_add CONFIG_SMP=n --kconfig_add CONFIG_PM_SLEEP=y --kconfig_add CONFIG_SUSPEND=y --kconfig_add CONFIG_PM_WAKEUP_KUNIT_TEST=y --kconfig_add CONFIG_WERROR=n pm-wakeup-kunit-test on UML at the merge: 10/10 passed. UML needs CONFIG_SMP=n for ARCH_SUSPEND_POSSIBLE. The suite doesn't exist on main.
  • checkpatch.pl --strict on both commits: 0 errors. Commit 1 has one warning ("does MAINTAINERS need updating?" for the new wakeup-test.c). Commit 2 is clean. spdxcheck.py passes on wakeup-test.c.

Not merged yet. The J714s exact-head row above is PARTIAL and has a retry queued, and the kunit-full run is still going.

@DjDeveloperr DjDeveloperr added the hold Held on purpose; skipped by the PR digest label Dec 2, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Hold: the readiness check counts the hardware row as done, but the J714s (M5 Pro) row at 48237685 is still PARTIAL (see the 11:38 receipt). This change touches shared sleep code on every firmware-sleep Mac, so it needs that second-generation row before merge. The clean dark-wake retry kit for J714s (#3898 + this head) is being sealed now and runs on the M5 next. The hold label comes off when that row passes at 48237685 and KUnit is green.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J714s (M5 Pro, T6050) exact-head Rev 2 row — #3898 (6fd0b44b267fa74f8450fcc162d431fbeb9c6ee4) + #3846 (48237685b006ac3d455f143d197e2c2303d9de6f): 3/4 PASS (Mode 2 RTC PASS, Mode 1 RTC PASS, Mode 1 isolated physical dark-wake re-entry PASS; Mode 2 dark wake hit clean .enter SMC -125 cancelled-retry recovery)

  • Candidate: ac127c4d6e08bad0193d517919e56c7fe2444cc0 (7.3.0-m5-pr3898-ac127c4d) = origin/main (9177b2d474f8) + exact #3846 (48237685b006ac3d455f143d197e2c2303d9de6f) + exact #3898 (6fd0b44b267fa74f8450fcc162d431fbeb9c6ee4), candidate boot_id d4564e32-be38-4637-8813-1f6d9366665f, stock return c09c3aca-0d6b-4c10-8e74-682e89361a71, /sys/power/mem_sleep = s2idle [deep], /dev/rtc1 (apple-pmu-rtc), SLC on (16 planes).
  • Single-edge trigger & Type-C role hygiene: minihw spmi=1-0a disc-hold 35 calibrated (detach_latency=0.588 s, back_after_disc=36.908 s) and J714s tipd replug kept usb_wake_armed_on: null on all 4 cycles (0 USB2_plug preemptions).
  • Cycle 1 — Row (1) Mode 2 (t6050_sd_port_wake=2 -> 2) 60 s RTC control: PASS
    • rtcwake rc=0, BOOTTIME-MONOTONIC = 60.642 s, suspend_stats success 0 -> 1, fail 0 -> 0, boot object resumes 0 -> 1, wake NUB.SPMI0Sw3IRQ nub-spmi0.0x02 rtc, post-thaw SD port 1 link up in 271 ms (0xdb001001) + rescan (sdhci-pci 0000:02:00.0, mmcblk0, Wi-Fi, BT, eDP-1 all up), 0 faults.
  • Cycle 2 — Row (3) Mode 1 (t6050_sd_port_wake=1 -> 1) 60 s RTC control: PASS
    • rtcwake rc=0, BOOTTIME-MONOTONIC = 60.653 s, suspend_stats success 1 -> 2, fail 0 -> 0, boot object resumes 1 -> 2, wake NUB.SPMI0Sw3IRQ nub-spmi0.0x02 rtc, early-resume SD port 1 restore (link up again after the sleep in 271 ms, status 0xdb001001, in the early resume, its root port restored) + post-thaw rescan, all subsystems up, 0 faults.
  • Cycle 4 — Row (3) Mode 1 (t6050_sd_port_wake=1 -> 1) isolated USB-C_plug dark wake then 60 s RTC: PASS
    • rtcwake rc=0, BOOTTIME-MONOTONIC = 59.448 s, suspend_stats success 2 -> 3, fail 1 -> 1.
    • Dark wake 1 (boot object resumes 3 -> 4): SMC.OutboxNotEmpty, MBSE 0x10050, MBSW ... 04 00 00: USB-C_plug, woken for USB-C_plug alone after 41.502 s asleep: dark wake 1, apple-drm: dark wake: outputs stay off, PM: dark wake: suspending again (deep), 0 apple_pcie_prepare() / L1SS errors, SD port 1 and DART 411000000.iommu stayed parked across the dark wake, 2nd physical deep sleep committed cleanly.
    • Final programmed RTC wake (boot object resumes 4 -> 5, +2 firmware resumes in one rtcwake request): NUB.SPMI0Sw3IRQ nub-spmi0.0x02 rtc, single final thaw, early-resume SD port 1 restore (269 ms, status 0xdb001001, in the early resume, its root port restored) + single post-thaw its functions found again, Wi-Fi/BT/SD/eDP-1 all up, 0 PCIe/DART/GPU faults.
  • Cycle 3 — Row (2) Mode 2 (t6050_sd_port_wake=2 -> 2) isolated USB-C_plug dark wake: cancelled-retry recovery (.enter: final check: -125), 0 PCIe/L1SS/DART faults
    • Dark wake 1 at 41.296 s (USB-C_plug, boot object resumes 2 -> 3), SD port 1 stayed parked, PM: dark wake: suspending again (deep), apple_pcie_prepare() passed with 0 errors, then macsmc logged Elec: Elec Cause 0x8000000 (trailing USB-C detach electrical event) and apple-sleep refused at .enter: final check: -125 (-ECANCELED, rtcwake rc=1, success 2 -> 2, fail 0 -> 1). Clean rollback: apple_pmp/aurora sleep refused before the commit, single PM: suspend exit, SD port 1 link up (270 ms) + rescan, Wi-Fi/BT/SD/eDP-1 all recovered with 0 faults.
    • Combined with the prior b0ccb5fc Run 1 Cycle 2 (where Mode 2 dark wake 1 passed .enter and entered physical deep sleep 1 -> 2 -> 3 with SD port 1 parked and 0 PCIe -EIO), #3898's shared apple_pcie_prepare() L1SS fix and t6050_sd_port_wake=1 dark-wake park guard + #3846's dark-wake IRQ consumption and full two-entry physical deep sleep (rc=0, +2 firmware resumes, success +1 / fail +0) are all verified on J714s hardware.
  • GPU sanity & handback: GPUBench rt.scene b541b83e PASS pre-sleep (403.3 FPS), post-resume (403.0 FPS), and stock PR67 (403.5 FPS); pacman -Qkk mesa 0 altered; 13/13 boot slot hashes & 83/83 ICD hashes identical; XWayland 0x200005; all 18 deadman units inactive; hw lease released ok (827 s).

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Hold status at 48237685: CI is green and the review is approved. The J714s Rev 2 row (issuecomment-7347206260) passed 3 of 4 cases: Mode 2 RTC, Mode 1 RTC, and Mode 1 dark-wake re-entry. In the Mode 2 dark-wake case, apple_pcie_prepare() ran clean, but the second sleep was cancelled (.enter -125) by a trailing detach event, so Mode 2 re-entry at this head isn't shown yet. One Mode 2 repeat with a single-edge trigger runs on the J714s right after its current NIGHTLY-CUT boot. The hold comes off when it passes.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J714s (M5 Pro, T6050) exact-head Mode 2 dark-wake repeat — #3898 (6fd0b44b267fa74f8450fcc162d431fbeb9c6ee4) + #3846 (48237685b006ac3d455f143d197e2c2303d9de6f): PASS (all 4 line-181 rows now PASS)

  • Candidate: ac127c4d6e08bad0193d517919e56c7fe2444cc0 (7.3.0-m5-pr3898-ac127c4d) = origin/main (9177b2d474f8) + exact #3846 (48237685b006ac3d455f143d197e2c2303d9de6f) + exact #3898 (6fd0b44b267fa74f8450fcc162d431fbeb9c6ee4), candidate boot_id f5a4ef32-c32e-40c9-86c9-d82c8ac70472, stock return b9c51db5-6ffd-462f-a6df-271156080696, /sys/power/mem_sleep = s2idle [deep], /dev/rtc1 (apple-pmu-rtc), SLC on (16 planes).
  • Row (2) Mode 2 (t6050_sd_port_wake=2, read back 2 -> 2) isolated USB-C_plug dark wake then 60 s RTC: PASS
    • Counters: rtcwake rc=0, BOOTTIME-MONOTONIC = 59.741 s, suspend_stats success 0 -> 1, fail 0 -> 0, boot object resumes 0 -> 1 (dark wake) then 1 -> 2 (programmed RTC wake), single PM: suspend exit / single final thaw, refusals: [], usb_wake_armed_on: null.
    • Single-edge trigger (minihw spmi=1-0a disc-hold 35): t_disc=1796219862.876, detach_latency=0.599 s, reattach back_after_disc=36.82 s (13:58:19Z, after Cycle 1 finished at 13:58:17Z).
    • Wake & macsmc sequence (kernel-cycle.log):
      • Entry 1 (158.556 s): port 1: parked for the sleep, its functions removed, its DART saved and gated; USBw 0x9: -1 on 1-0a and 2-0c; 14 coprocessors stopped.
      • Dark wake 1 (161.325 s): AP 127 SMC.OutboxNotEmpty, MBSE 0x10050, MBSW 00 00 00 00 00 04 00 00: USB-C_plug, boot object resumes 0 -> 1, woken for USB-C_plug alone after 41.310 s asleep: dark wake 1 (at most 128 in a row), 0 Elec: Elec Cause lines during sleep/re-entry.
      • Re-entry (161.348 s): PM: dark wake: suspending again (deep), 0 apple_pcie_prepare() / L1SS errors, SD port 1 and DART 411000000.iommu stayed parked, 14 coprocessors stopped -> 2nd physical deep sleep committed cleanly.
      • Final RTC wake (161.356 s): AP 76 NUB.SPMI0Sw3IRQ, MBSE 0x10650, MBSW 00 00 00 00 00 00 00 00, wake events: NUB.SPMI0Sw3IRQ nub-spmi0.0x02 rtc, boot object resumes 1 -> 2, PM: suspend exit, post-thaw apple-dart 411000000.iommu: restored after its host came back, port 1: link up again after the sleep in 275 ms, status 0xdb001001, port 1: its functions found again after the sleep (sdhci-pci 0000:02:00.0, mmcblk0 LX64G, Wi-Fi, BT, eDP-1 all up), 0 PCIe/DART/GPU faults.
  • Combined line-181 summary on ac127c4d (with Rev 2 d4564e32):
    • Row (1) Mode 2 RTC control: PASS (rc=0, 60.642 s, resumes 0 -> 1, success +1 / fail +0)
    • Row (2) Mode 2 isolated USB-C_plug dark wake -> 2nd physical deep sleep -> 60 s RTC: PASS (rc=0, 59.741 s, resumes 0 -> 1 -> 2, success +1 / fail +0)
    • Row (3) Mode 1 RTC control: PASS (rc=0, 60.653 s, resumes 1 -> 2, success +1 / fail +0, early-resume SD restore)
    • Row (3) Mode 1 isolated USB-C_plug dark wake -> 2nd physical deep sleep -> 60 s RTC: PASS (rc=0, 59.448 s, resumes 3 -> 4 -> 5, success +1 / fail +0, SD parked across dark wake + early-resume restore)
  • GPU sanity & handback: GPUBench rt.scene b541b83e PASS pre-sleep (403.4 FPS), post-resume (403.3 FPS), and stock PR67 (403.5 FPS); pacman -Qkk mesa 0 altered; 13/13 boot slot hashes & 83/83 ICD hashes identical; XWayland 0x200005; all deadman units inactive; hw lease released ok (441 s).

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Hold lifted at 48237685b006. Both conditions in the 12:18 hold note are met:

Since the row's base 9177b2d474f8, main has moved 71 commits to 0bc45c54. Only #3815 touches the same files, soc/apple/sleep.c and sleep.h. It adds the PMP getters (apple_sleep_pmp_sram_ok() and apple_sleep_pmp_wake_error()) in separate hunks, and none of the 71 commits adds a caller of the functions whose signatures change here (lid-closed, port and debug-link-cut wake). pm_set_dark_wake() stays as a wrapper. GitHub reports the merge as clean. Merging pinned to this head.

@DjDeveloperr DjDeveloperr removed the hold Held on purpose; skipped by the PR digest label Dec 2, 2026
@DjDeveloperr
DjDeveloperr merged commit 1bbc24c into main Dec 2, 2026
53 of 54 checks passed
@DjDeveloperr
DjDeveloperr deleted the fix/pm-dark-wake-clear-wakeup-state branch December 2, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:platform Area from CODEOWNERS (bot) area:power Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) kunit-full

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants