Skip to content

T6050 sleep: two lock checking reports at the first deep sleep - #3065

Open
axboe wants to merge 2 commits into
aurora-silicon:mainfrom
axboe:fix/t6050-sleep-lockdep
Open

axboe wants to merge 2 commits into
aurora-silicon:mainfrom
axboe:fix/t6050-sleep-lockdep

Conversation

@axboe

@axboe axboe commented Nov 24, 2026

Copy link
Copy Markdown

Problem

With CONFIG_PROVE_LOCKING=y the first deep sleep on a T6050 trips two reports in the sleep code, and lockdep turns itself off for the rest of the boot (debug_locks: 0). Nothing after that first entry is lock-checked. Seen on a K116s (T6050, M5 Pro), firmware 27.2.

BUG: workqueue leaked atomic, lock or RCU: kworker/u73:1[211]
locks held by kworker/u73:1/211:
 #0: (&dart->v27_lifecycle), at: apple_dart_v27_claim+0xf4/0xb80

WARNING: bad unlock balance detected!
 mutex_unlock
 apple_dart_v27_finish
 dcp_v27_late_disarm
RCU not watching for tracepoint
WARNING: include/trace/events/lock.h:47 at lock_acquire
 apple_spmi_fifo_trylock
 t6050_sleep_check_alarm
 apple_sleep_enter_saved
 cpu_suspend

WARNING: suspicious RCU usage
 work_busy
 apple_nvme_m5_last_check
 apple_sleep_enter_saved

Change

Two commits, both in code every T6050 sleep runs (J714s, J716c, and the K116s with #2201).

  • iommu/apple-dart: hold a sleep lease with a semaphore, not a mutex. v27_lifecycle is taken by apple_dart_v27_claim() in the suspend's async work and released by apple_dart_v27_finish() at resume, from another task. A mutex has to be released by the task that took it; a lock that changes hands is a semaphore. Who waits for what is unchanged.
  • soc: apple: sleep: keep RCU watching while the T6050 entry prepares. On a SoC with early_context the whole entry is cpu_suspend()'s finisher, which is called after ct_cpuidle_enter(). Before the commit step this finisher takes the SPMI controller's lock for the alarm check, stops coprocessors, looks at work items and logs. The preparation now runs between ct_cpuidle_exit() and ct_cpuidle_enter(); the commit, the part that never returns, is as before.

Testing

Tested: K116s (T6050, M5 Pro), firmware 27.2, with and without lock checking; rows below. Host tests 503/503 at the head.

Risk: two-way · T6050 machines with the firmware-driven sleep (J714s, J716c; K116s with #2201).

The K116s does not sleep on main alone, so the rows are on a stack that contains these two commits unchanged: main + #2187 + #2201 + #2309 + #2877 + #2206 + my other K116s commits. The command line is not the default (idle=nop among others).

Kernel Lock checking Result
stack without these commits on both reports at the first deep sleep, debug_locks: 0 afterwards
stack with these commits on 4 deep sleeps on one boot, all resumed, 0 lockdep reports, debug_locks: 1 at the end
stack with these commits off boot and deep sleep, resumed, Wi-Fi back

Still to run

  • J714s and J716c: not run here, I have neither. Both run this code on every sleep.

  • Standalone on main: builds, host tests pass; no sleep row, see above.

  • Clean-room: no Apple code, strings, firmware, RE output or tuning values

  • No chip/board/firmware-version gate where a hardware property can decide

  • Works on the default kernel command line; no hacks, delays or lab-only paths

  • Safety limits come from the machine, not from constants in code

  • Hardware safety rules followed for every test boot

  • Third-party commits unchanged; reporters and testers credited

  • Commits: human Signed-off-by only; no AI attribution in commits or PR text

  • Tested on the affected hardware; no regression

v27_lifecycle is taken by apple_dart_v27_claim() and stays held for as
long as the sleep lease lasts. The claim runs in the suspend's async
work and the lease is finished by the resume, from another task. A mutex
has to be released by the task that took it. With lock checking on, the
first T6050 deep sleep reports both ends:

  BUG: workqueue leaked atomic, lock or RCU: kworker/u73:1[211]
  locks held by kworker/u73:1/211:
   #0: (&dart->v27_lifecycle), at: apple_dart_v27_claim+0xf4/0xb80

  WARNING: bad unlock balance detected!
   mutex_unlock
   apple_dart_v27_finish
   dcp_v27_late_disarm

and lockdep turns itself off for the rest of the boot.

A lock that changes hands is a semaphore. Make it one; no change to who
waits for what.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
On a SoC with early_context the whole entry runs as cpu_suspend()'s
finisher. cpu_suspend() calls the finisher after ct_cpuidle_enter(),
with RCU not watching, which fits a finisher that only powers the core
down. This one first checks the RTC alarm over SPMI under the
controller's lock, stops the coprocessors, looks at work items and logs.
With lock checking on, the first T6050 deep sleep reports each of them:

  RCU not watching for tracepoint
  WARNING: include/trace/events/lock.h:47 at lock_acquire
   _mutex_trylock_nest_lock
   apple_spmi_fifo_trylock
   t6050_sleep_pmu_xfer
   t6050_sleep_check_alarm
   apple_sleep_enter_saved
   cpu_suspend

  WARNING: suspicious RCU usage
   work_busy
   apple_nvme_m5_last_check
   apple_sleep_enter_saved

Leave the idle state for the preparation and enter it again before the
commit, which is the part that never returns.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
@axboe
axboe requested review from a team as code owners November 24, 2026 13:04
@axboe
axboe requested review from LiamRay11 and maralcbr November 24, 2026 13:04
@github-actions github-actions Bot added area:platform Area from CODEOWNERS (bot) blast:all 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 Nov 24, 2026
@github-actions

Copy link
Copy Markdown

Merge readiness at 7d64087e: not ready yet

Check Detail
CI at head running running: pr-text / pr-text, host-tests, rust-build, kunit, DWC3/ATC builtin-no-atc, DWC3/ATC modular-no-atc
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at 7d64087e
Conflicts ok none
PR text ok Risk: two-way · T6050 machines with the firmware-driven sleep (J714s, J716c; K116s with #2201). - 7d64087e37aa T6050 / K116s (M5 Pro), firmware 27.2: booted on a stack that contains these two commits unchanged (main 974efa5 + #2187 + #2201 v10 + #2309 + #2877 + the lock fixes + my other K116s commits, 7.3.0-m5pro-ge3fa7f0044df); 3 deep sleeps resumed on the same boot (raw rtcwake -m mem with Wi-Fi associated, logind suspend with an RTC alarm, raw rtcwake -m mem with Wi-Fi disconnected), panel and Wi-Fi back each time; 0 SELinux denials (not installed on this Debian), 0 failed units, 0 error-level kernel lines at boot, 0 new kernel errors at the wakes. The K116s does not sleep on main alone, so the rows are on a stack that contains these two commits unchanged: main + #2187 + #2201 + #2309 + #2877 + #2206 + my other K116s commits. The command line is not the default (idle=nop among others).

Areas: area:platform

Updated by pr-readiness on every push, edit and review, and every 30 minutes. Rules: merge policy · labels.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: MERGE at 7d64087e

Blockers: none

Checked:

  • drivers/iommu/apple-dart.c and drivers/iommu/apple-dart-v27-late.inc: verified every v27_lifecycle site (sema_init(..., 1) in apple_dart_probe, down_trylock / up polarity in apple_dart_v27_claim, apple_dart_v27_finish, and apple_dart_shutdown, plus DEFINE_GUARD down/up in apple_dart_remove). Cross-task lease handoff from async suspend work to resume no longer trips mutex ownership/workqueue-leak lockdep checks, and the lost: pinning path in apple_dart_v27_finish() still holds the semaphore across shutdown without blocking apple_dart_shutdown().
  • drivers/soc/apple/sleep.c and arch/arm64/kernel/suspend.c: verified ct_cpuidle_exit() / ct_cpuidle_enter() pairing in apple_sleep_enter_saved() against cpu_suspend() on both the error-return and resume paths. apple_sleep_enter_prepare() runs with RCU watching and hardirqs masked, t6050_sleep_after_ans() sets r->spmi_masked = true before ct_cpuidle_enter(), and apple_sleep_commit(0) / t6050_sleep_post_timer() perform raw MMIO/timer/WFI without locks, logging, or RCU. Non-early_context SoCs (t8140, t8132, t8142) are untouched.
  • Pre-PR checklist (§1–§6): no model gating, no workarounds or new cmdline/module params, clean-room diff, human author/committer/Signed-off-by only (208894259f59, 7d64087e37aa), all 9 CI checks passing on 7d64087e37aa, and exact-head T6050/K116s hardware evidence with CONFIG_PROVE_LOCKING=y (debug_locks: 1 across 4 deep sleeps) and off.
  • Minor non-blocking note: the comment at drivers/iommu/apple-dart-v27-late.inc:490 still reads Lifetime mutex/... (now a semaphore). J714s/J716c confirmation can follow on fleet merge as noted in the PR.
Evidence
  • Head verified: 7d64087e37aa9f17d7e2c1504ff6efb8a6300f28 (state: OPEN, mergeable: MERGEABLE, 2 commits: 208894259f59, 7d64087e37aa)
  • CI at 7d64087e37aa: host-tests, kunit, source, rust-build, DWC3/ATC builtin-no-atc, DWC3/ATC modular-no-atc, DWC3/ATC builtin-modular-atc, pr-text / pr-text, readiness / readiness — all completed / success
  • Hardware evidence in PR body at 7d64087e37aa: K116s (T6050, M5 Pro, fw 27.2), CONFIG_PROVE_LOCKING=y (4 consecutive deep sleeps, 0 lockdep reports, debug_locks: 1) and lock checking off, 3 deep sleeps resumed on same boot with panel and Wi-Fi back, 0 SELinux denials, 0 failed units, 0 new kernel errors

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) blast:all 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