Repository navigation
Conversation
T8140 exposes only the index-0 WFI fallback to avoid the unsupported CPU power-down path. The generic s2idle selector skips index 0, so this prevents tick_freeze() and timekeeping suspension from being reached. Copy the safe WFI state over the T8140 power-down entry instead of reducing state_count. This preserves an eligible nonzero s2idle entry without using CYC_OVRD, while leaving other Apple SoCs unchanged. On MacBook Neo, three 20-second RTC sleeps accounted for approximately zero suspended time before this change and 20.198, 19.808 and 20.419 seconds afterward using the identical BOOTTIME-minus-MONOTONIC test. Signed-off-by: Bartosz Nitka <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On T8140,
apple_cpuidle_probe()reducesstate_countto one to avoid the unsupported CPU-PD/CYC_OVRD path. This leaves only the index-0 WFI fallback.The generic
find_deepest_state()search starts at index 1, andcpuidle_enter_s2idle()callsenter_s2idle_proper()only for an index greater than zero. With the current T8140 registration, s2idle falls back without reachingtick_freeze()/tick_unfreeze()and timekeeping suspension.On an Apple MacBook Neo (T8140/J700), all six CPUs consequently reported zero
s2idle/usageafter completed RTC sleeps.CLOCK_MONOTONICadvanced through the entire suspended interval, just likeCLOCK_BOOTTIME.Fix
Keep the existing state count and replace the T8140 index-1 power-down entry with a copy of the safe WFI entry. This gives the generic s2idle selector an eligible nonzero entry without executing the unsupported deep-WFI register sequence.
Behavioral hardware A/B
The same runner and pass/fail criterion were used before and after the patch. For each RTC sleep:
For a requested 20-second sleep, the test accepts 17–23 seconds of accounted suspended time. The tolerance is a test allowance for RTC rounding/device transitions, not an API-specified bound. Each measurement also requires a matching RTC interrupt/deadline, cleared alarm, exactly one completed suspend, unchanged kernel failure counters, successful thaw, automatic Wi-Fi recovery, and unchanged monitored service PIDs/restart counts. An early or unrelated failed wake is not counted as a clock reproduction.
All three patched runs completed RTC wake/thaw and automatic Wi-Fi recovery without logind, timesyncd or NetworkManager restarting. All six CPUs recorded nonzero index-1 s2idle usage. CPU-idle counters are diagnostic only; the clock oracle does not depend on this patch's state layout.
The hardware A/B was performed on
3b2bd35a8591bcad766c60d0681e7f060cfd8cc7with our existing matched platform integration. The patched driver and generic cpuidle selector/wrapper are byte-identical to the corresponding files used by this PR on30812f491575ede27e5be059fd6afc4e985166f1. The complete newer branch has not been separately hardware-tested.Reproduction procedure
Use a boot with suspend/RTC wake support already qualified and no bound driver that vetoes sleep. On our test unit: AC connected, lid open, console target, Bluetooth unadmitted, encoder unloaded; RTC1 is the Apple PMU wake-alarm device. Run the measuring process as a root
system.sliceservice so it is outside the userspace slice frozen by systemd./sys/power/suspend_stats, RTC IRQ/activation counts and per-CPUcpuidle/state*/s2idle/usage.rtcwake --device /dev/rtc1 --mode no --seconds 20, then requestsystemctl suspend --no-block. Leave inputs/cables untouched.No watchdog crash is needed to reproduce the clock defect. In a separate unpatched 40-minute trial, logind and timesyncd hit their three-minute service watchdogs immediately upon resume, and NetworkManager remained asleep; a manual
Sleep(false)restored networking without a reboot or firmware reload. That longer failure is motivation, not a claim that extended suspend is fully qualified by the short A/B.Other validation
scripts/checkpatch.pl: 0 errors, 0 warnings.Clock semantics and boot-format scope
Hardware testing used raw booting. The current driver selects the T8140 restriction by DT compatibility, not boot format, so the same selection issue applies with this driver under Mach-O. Future qualified deep-idle support may supersede this WFI alias; Mach-O/deep-idle, battery drain, Bluetooth-enabled extended suspend and the earlier unexplained reset are not qualified by this patch's short-cycle tests.