Skip to content

watchdog: apple: use WD2 simple-reconfig so expiry and reboot reset the SoC - #3029

Merged
DjDeveloperr merged 4 commits into
aurora-silicon:mainfrom
funkzy:pr/apple-wdt-simple-reconfig
Nov 25, 2026
Merged

DjDeveloperr merged 4 commits into
aurora-silicon:mainfrom
funkzy:pr/apple-wdt-simple-reconfig

Conversation

@funkzy

@funkzy funkzy commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What: Add an optional "reconfig" register to the apple,wdt binding and T6050 DT so apple_wdt drives WD2 bark-IRQ with simple-reconfig (making /dev/watchdog0 expiry, apple_wdt_restart(), and pre-probe watchdog takeover cold-reset the SoC instead of stalling), coordinated with apple_sleep via a DT-matched ownership handoff and T6050 wdt-aux + 0x2c save/restore across sleep.
Tested: J775D (Mac Studio, M5 Ultra, T6050) at 67f088391002 on main a3d477d03f8e (published Aura main f13056d95af6, 27.2 stub, default command line): boots, adopts pre-probe WD1 into WD2 simple-reconfig, WDT_IOCTL_PASS, live 8 s expiry self-reset (47 s), live apple_wdt_restart() self-reset (40 s), 2/2 baseline failed units, 0 new kernel errors (8 vs 9 baseline; ALARM has no SELinux); KUnit apple-sleep-soc-data 13/13, host tests 10/10 (0 regressions), dtbs_check 11/11 t6050-*.dtb, W=1 -Werror Kconfig matrix 10/10.
Risk: one-way door (adds optional "reconfig" DT binding property) · affects T6050 Macs (t6050-die0.dtsi: J714S/C, J716C, J775C/D) and shared apple_wdt / apple_sleep code (M1–M5 single-reg nodes keep legacy WD1).
Not yet: T6050 Mac with active apple_sleep node (J714S/J716C) two back-to-back PM_SUSPEND_MEM cycles + s2idle verifying 0x28833002c restore; non-simple-reconfig M1–M4 1-reg regression row.

Details

Problem

On Apple Silicon SoCs with a simple-reconfig watchdog (such as T6050 / M5 Ultra, J775D), apple_wdt currently drives WD1 with RESET_EN (0x4). On these parts WD1 expiry stalls the SoC instead of resetting it, leaving /dev/watchdog0 expiry, apple_wdt_restart(), and any watchdog already armed before probe unable to recover a hung machine cleanly.

Why this shape

The watchdog and routing policy lived in four places that could disagree: apple_wdt hardcoded WD1 RESET_EN for every SoC; drivers/soc/apple/sleep.c independently armed and cleared WD2 (WD2_BARK, WD2_CTL) across firmware-driven suspend (apple_sleep_begin() / apple_sleep_end()) assuming no other driver used WD2; T8142's sleep path (apple_sleep_arm_wd2() / t8142_wake()) saved and restored aon-misc + 0x2c (AON_WDT_SLEEP); and T6050's sleep DT sequence (apple,seq-commit-wdt = <0x0 37 0x2c 0x20> on J714S/J716C) wrote 0x20 to wdt-aux + 0x2c (0x28833002c, the same routing word) without saving or restoring it on wake.

A narrower change—gating WD2 on a T6050 compatible or chip ID inside apple_wdt—would violate DT-driven hardware description, require per-SoC lists as more simple-reconfig parts arrive, silently collide with apple_sleep on T6050 boards with an active sleep controller (where apple_wdt_suspend() would disarm sleep's 120 s WD2 safety net and apple_sleep_end() would clear WD2_CTL on resume), and leave T6050's wake safety net running under sleep-commit routing (0x20) after commit.

Instead, this series uses the device tree as the single source of truth: an optional second reg entry named "reconfig" selects WD2 bark-IRQ mode with simple-reconfig (reconfig = 0x10, WD2_BITE = U32_MAX, WD2_CTL = IRQ_EN), while single-reg "wdt" nodes keep existing WD1 behavior unchanged (aside from guarding apple_wdt_get_timeleft() against cur_time >= reset_time underflow on both WD1 and WD2). Every WD2 arming path in apple_wdt (start(), restart(), pre-probe takeover, and apple_wdt_sleep_restore()) runs through one apple_wdt_wd2_arm() helper (CTRL = 0, BITE = U32_MAX, CUR = 0, BARK = ticks, W1C IRQ_STATUS clear, (void)readl(WD2_CTRL) ordering barrier ahead of the separate reconfig mapping, apple_wdt_enable_reconfig() with readback, and CTRL = IRQ_EN). Any watchdog already armed before probe (legacy WD1 RESET_EN or WD2 IRQ_EN/RESET_EN) is adopted through one takeover rule with WDOG_HW_RUNNING set before arming so the boot watchdog stays alive and resets cleanly.

To prevent two drivers from fighting over WD2 during suspend, drivers/soc/apple/sleep.c provides a lock-protected, DT-matched ownership handoff (apple_sleep_wdt_{register,unregister,active}()) matching the watchdog's reg[0] start address against available apple_sleep nodes regardless of probe order (so boards without apple_sleep, such as J775D, or secondary dies return 0 without taking the slot). On T6050, t6050_sleep_commit_wdt() / t6050_sleep_wake_wdt() reuse struct apple_sleep's existing aon_wdt_saved/aon_wdt_marked fields to save wdt-aux + AON_WDT_SLEEP before t6050_seq(T6050_SEQ_WDT) and restore it on wake after stopping WD2, W1C-clearing IRQ_STATUS, and ordering both cross-mapping transitions with readl(). T8142's aon_wdt_sleep OR path (no "reconfig" DT node in this series) and shared apple_sleep_set_wd2() (empirical J775D register checks show a stopped WD2 does not latch IRQ_STATUS past bark) are left untouched as named follow-ups.

Change

  1. dt-bindings: watchdog: apple,wdt: add optional simple-reconfig register (416ba83b2e73): Document the optional second reg entry ("reconfig"), require reg-names when reg has minItems: 2 (with required: [reg] in if:), and add a 2-reg example.
  2. soc: apple: sleep: hand off WD2 to apple_wdt and preserve T6050 reconfig across wake (9927b97fc390):
    • Add lock-protected, DT-matched apple_sleep_wdt_register(dev, wdt, restore, data), apple_sleep_wdt_unregister(dev), and per-device apple_sleep_wdt_active(dev) in include/linux/soc/apple/sleep.h and drivers/soc/apple/sleep.c (with inline no-op stubs when CONFIG_APPLE_SOC_SLEEP=n), clearing WD2_CTL and invoking restore under lock in apple_sleep_end().
    • Bracket T6050's t6050_seq(T6050_SEQ_WDT) in drivers/soc/apple/sleep-t6050.h (t6050_sleep_commit_wdt() / t6050_sleep_wake_wdt()) to save wdt-aux + AON_WDT_SLEEP before commit and restore it on wake after CTL = 0, W1C IRQ_STATUS clear, and readl() barriers.
    • Add isolated KUnit coverage (apple_sleep_test_wdt_handoff in drivers/soc/apple/sleep-test.c) for block matching, slot ownership, -EBUSY contention, and .end ordering.
  3. watchdog: apple: use WD2 simple-reconfig so expiry and reboot reset the SoC (0897a4c2b35e):
    • Select WD2 bark-IRQ + simple-reconfig mode when the optional "reconfig" register (>= 4 bytes, non-exclusive devm_ioremap) is present in DT.
    • Register the sleep handoff before touching any watchdog register so a registration failure writes zero registers and devm unregisters the watchdog before the sleep handoff.
    • Route all four WD2 arming paths through apple_wdt_wd2_arm() with W1C IRQ_STATUS clear and cross-mapping readl() barriers, unify pre-probe takeover of armed WD1 (RESET_EN) or WD2 (IRQ_EN/RESET_EN) with WDOG_HW_RUNNING set before arming, derive the 40 ms reboot bark delay from clk_rate, and guard apple_wdt_get_timeleft() against cur_time >= reset_time underflow.
    • Add tools/asahi/apple-wdt-tests.py (registered in tools/asahi/run-host-tests.py) compiling the real apple_wdt.c body and t6050_sleep_{commit,wake}_wdt() helpers under ASan/UBSan with --old-ref 70a00e583b032 and eight negative mutations.
  4. arm64: dts: apple: t6050: add watchdog simple-reconfig register (67f088391002): Add <0x2 0x8833002c 0x0 0x4> (reg-names = "wdt", "reconfig") to watchdog@28836c000 in arch/arm64/boot/dts/apple/t6050-die0.dtsi.

Named follow-ups (out of scope here)

Evidence

Testing

Own-base J775D (Mac Studio, M5 Ultra, T6050) A/B row

  • Base: main a3d477d03f8e (no extra PRs needed to boot).
  • Boot loader: published Aura main (f13056d95af6, aura-main-f13056d9), 27.2 stub, default command line, read-only root.
  • Baseline arm: kit wdtsr6b (window wdtsr6@20261124-0144) — bare a3d477d03f8e.
    • boot=ok, steps_rc=0, of_node/reg-names absent (legacy 1-reg WD1), /dev/watchdog0 held by systemd[1] (30s), 2 failed units (iwd.service missing kernel crypto options in default config, systemd-networkd-persistent-storage.service on read-only root), 9 kernel errors (ALARM has no SELinux, so no AVC count).
  • PR arm: kit wdtsr6 (window wdtsr6@20261124-0144) — a3d477d03f8e + this PR at 67f088391002.
    • boot=ok, steps_rc=0, of_node/reg-names = wdt,reconfig, adopted pre-probe legacy WD1 directly into WD2 simple-reconfig (apple-watchdog 28836c000.watchdog: taking over legacy WD1 watchdog as WD2 simple-reconfig), systemd[1] handed over cleanly (30s), WDT_IOCTL_PASS (timeout=30s timeleft=29s -> SETTIMEOUT(10) timeleft=9s -> 6s after 3.2 s -> KEEPALIVE back to 9s -> 4x 3 s pet loop -> magic close 'V' survived 12 s without reset -> systemd[1] re-acquired /dev/watchdog0 with EBUSY confirmed).
    • Regression: identical 2 failed units (iwd.service, systemd-networkd-persistent-storage.service), 8 kernel errors (0 new kernel errors vs baseline; 0 watchdog or sleep errors).

Live hardware cold-reset proofs on J775D (exact PR head)

On kit wdtsr6 (window wdtsr6rst@20261124-0149, same base a3d477d03f8e + 67f088391002, published aura-main-f13056d9, 27.2 stub, default command line):

  • Forced /dev/watchdog0 8 s expiry (apple_smc / macsmc-reboot active): armed timeout=8s timeleft=7s without petting -> SSH dropped at 14 s -> SoC performed a clean cold self-reset back to Linux in 47 s.
  • apple_wdt_restart() reboot path (macsmc-reboot unbound): reboot -f triggered apple_wdt_restart() -> SSH dropped at 10 s -> SoC performed a clean cold self-reset back to Linux in 40 s.
  • WD2 stopped-counter IRQ_STATUS latch check (J775D 0x28836c020..0x2c with RECONFIG=0x0): armed WD2 for 1 s, stopped (CTL=0) at 0.2 s, waited 1.5 s past BARK (CUR=0x26e4af3 > BARK=0x16e3600) -> WD2_CTL=0x0 (bit 1 does not latch while stopped).

Automated checks

  • KUnit (kunit-vz arm64 guest on 67f088391002, CONFIG_KUNIT=y, CONFIG_APPLE_SOC_SLEEP_KUNIT_TEST=y): 11 suites, 55/56 cases pass (0 fail, 1 baseline CONFIG_UCLAMP_TASK skip); apple-sleep-soc-data: 13/13 pass (including apple_sleep_test_wdt_handoff).
  • Host tests (tools/asahi/run-host-tests.py on Ubuntu GCC 15.2 + Clang 21.1 + ASan/LSan/UBSan): 500/501 passed on base a3d477d03f8e (g15-pb-growth-tests --mutations pre-existing FAIL on base); 510/511 passed on 67f088391002 (0 regressions; all 10/10 new apple-wdt-tests runs ok: positive run, --old-ref 70a00e583b032, and --mutation {ignore-sleep-handoff,no-bark-in-start,no-status-clear,reconfig-before-bark,register-after-arm,hwrunning-after-arm,no-wd1-adopt,no-t6050-wake-restore}).
  • dt_binding_check & CHECK_DTBS=y (DT_SCHEMA_FILES=watchdog/apple,wdt.yaml): dt_binding_check rc 0; dtbs_check rc 0 across all 11 t6050-*.dtb files; dt-validate: 0 lines, 0 new diagnostics vs base.
  • Bisect & Kconfig matrix (W=1 KCFLAGS="-Werror"): 10/10 clean across commits 2 & 3 (CONFIG_APPLE_SOC_SLEEP={y,n} x CONFIG_APPLE_WATCHDOG={m,y}) and final tree (CONFIG_KUNIT={y,m} x CONFIG_APPLE_SOC_SLEEP_KUNIT_TEST=y).

Cross-board rows requested

Our lab only has a J775D (Mac Studio, M5 Ultra, no apple_sleep node in DT). Because commit 4 enables "reconfig" in shared t6050-die0.dtsi (affecting J714S/C, J716C, J775C/D), rows from other board owners are needed:

  • T6050 Mac with active apple_sleep node (e.g., J714S / J716C): verify two back-to-back PM_SUSPEND_MEM (mem) suspend/resume cycles with /dev/watchdog0 active and one cycle after magic close (plus s2idle), confirming 0x28833002c matches its pre-entry value after wake, apple_sleep keeps its WD2 safety net during suspend, and apple_wdt is restored active (reconfig = 0x10, WDIOC_GETTIMELEFT ticking against wdd->timeout) after resume.
  • Non-simple-reconfig Mac (M1–M4, 1-reg DT node): verify unchanged legacy WD1 probe, ping, and regression counts (0 failed units, 0 new kernel errors).

@DjDeveloperr DjDeveloperr left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Formal adversarial §1–§6 pre-PR review at live head 0b808e1f6e63fa029b30092c849bf231bdd5138e (checked against live integration/aurora 5746ef8a5afd).

Checklist Audit (§1–§4, §6)

  • §1 No model gating: Pass. Cleanly DT-driven via optional "reconfig" reg entry and reg-names ("wdt", "reconfig"), keeping 1-reg boards on legacy WD1 without chip/compatible tables in apple_wdt.c. Confirmed t6050-dieX.dtsi and t6050-ultra.dtsi carry no duplicate watchdog nodes.
  • §2 Code, locking, lifetime & ordering audit:
    • Code blocker — Probe takeover write ordering hazard (drivers/watchdog/apple_wdt.c, lines 302–316 in patched file): When taking over an already-running WD2 (wdt_ctrl & APPLE_WDT_CTRL_IRQ_EN and !is_kdump_kernel()), probe calls apple_wdt_enable_reconfig(wdt) (routing WD2 bark to cold reset) before apple_wdt_set_timeout() resets WD2_CUR_TIME = 0 and programs WD2_BARK_TIME (and without clearing any latched APPLE_WDT_CTRL_IRQ_STATUS). If a prior stage left IRQ_EN set with a small/zero WD2_BARK_TIME (CUR_TIME >= BARK_TIME) or pending IRQ_STATUS while reconfig was 0, enabling reconfig = 0x10 first can immediately trigger a spurious cold reset during probe. Program WD2_BITE_TIME = U32_MAX, WD2_CUR_TIME = 0, and WD2_BARK_TIME (or stop WD2_CTRL = 0, program BITE/CUR/BARK, enable reconfig, then re-arm IRQ_EN) before routing bark to cold reset.
    • Non-blocking future-SoC note (drivers/soc/apple/sleep.c:5261): On T8142 (aon_wdt_sleep = 0x20), apple_sleep_arm_wd2() writes s->aon_wdt_saved | s->soc->aon_wdt_sleep without clearing bit 4 (0x10). T8142 does not wire "reconfig" in DT today (and T6050 uses apple,seq-commit-wdt which writes 0x20 directly), but if T8142 later adds "reconfig", 0x10 | 0x20 = 0x30 will corrupt bits 5:4. Masking GENMASK(5, 4) in apple_sleep_arm_wd2() would prevent that cleanly.
    • Locking/lifetime check: devm_add_action_or_reset(apple_wdt_sleep_unregister) is registered after devm_watchdog_register_device(), so teardown unregisters from apple_sleep before watchdog/MMIO teardown, serialized under apple_sleep_wdt_lock. apple_sleep_end() keeps apple_sleep_wd2_owned = true until after apple_sleep_wdt_restore() completes, preventing apple_wdt_ping() from racing apple_wdt_start().
  • §3 Safety: Pass. Reboot bark delay scales from clk_rate; legacy WD1 RESET_EN and stale WD2 RESET_EN are disarmed with a warning; get_timeleft() guards against unsigned underflow.
  • §4 Clean-room & Attribution: Pass. All 4 commits (36b2fe5830ff, 7829e6bd2eed, b36a10c83210, 0b808e1f6e63) have human author/committer (Jeff Queisser <funkzy@users.noreply.github.com>) and human Signed-off-by: only; zero AI commit trailers; Assisted-by: disclosed in PR body.
  • §6 Naming & CI: Pass. All 9 CI checks (dt-checks, host-tests, PMGR/SEP kunit, source, rust-build, 3× DWC3/ATC) are SUCCESS.

Blockers (§2, §5)

  1. §2 Probe takeover ordering (apple_wdt.c): Fix the WD2 takeover sequence so WD2_CUR_TIME/WD2_BARK_TIME/WD2_BITE_TIME are safe before apple_wdt_enable_reconfig() routes WD2 bark to cold reset.
  2. §5 Commit 2 (drivers/soc/apple/sleep.c WD2 handoff) has zero hardware verification: J775D has no apple_sleep node, so the entire apple_sleep_wdt_* handoff is untested on hardware. Please run an exact-head test on a T6050 Mac with apple_sleep (e.g., J716C or J714S) across PM_SUSPEND_MEM (mem) — note that apple_sleep_begin() returns early for state != PM_SUSPEND_MEM (sleep.c:6446), so s2idle alone does not exercise the apple_sleep WD2 handoff (test both s2idle and mem with /dev/watchdog0 active).
  3. §5 Missing regression Mac for shared code & clean regression counts: apple_wdt.c and drivers/soc/apple/sleep.c are shared across M1–M5 Macs; please add an exact-head regression row on a non-simple-reconfig (1-reg WD1) Mac (M1–M4) with 0 AVC denials, 0 failed units, and 0 new kernel errors on default cmdline (and clarify the 2 failed units and 10 vs 8 kernel error count delta on the J775D row, where two extra lines occurred vs one noted USB timeout).

Apple Silicon SoCs with a simple-reconfig watchdog (such as T6050 / M5
Ultra) route WD2's bark interrupt to a cold SoC reset via a separate AON
routing register, rather than resetting through WD1's RESET_EN bit.

Document an optional second reg entry ("reconfig") in apple,wdt.yaml and
require reg-names when both "wdt" and "reconfig" regions are present,
keeping existing single-reg nodes valid without reg-names.

Signed-off-by: Jeff Queisser <funkzy@users.noreply.github.com>
…fig across wake

drivers/soc/apple/sleep.c uses WD2 as its suspend/resume safety net
between apple_sleep_begin() and apple_sleep_end(). Once apple_wdt also
drives WD2 on SoCs with a simple-reconfig routing register, the two
drivers must coordinate ownership so apple_wdt_suspend() does not disarm
sleep's 120 s safety net and apple_sleep_end() restores an active
apple_wdt timer after clearing sleep's WD2 timer.

Add a lock-protected WD2 handoff API in include/linux/soc/apple/sleep.h
(with inline no-op stubs when CONFIG_APPLE_SOC_SLEEP=n):
- apple_sleep_wdt_register(dev, wdt, restore, data) matches @wdt's
  resource start against available apple_sleep DT nodes' "wdt" regions
  regardless of probe order; watchdogs without a matching sleep node
  (such as J775D or a secondary die) return 0 without taking the slot,
  while a second device claiming the same block returns -EBUSY.
- apple_sleep_wdt_active(dev) reports whether sleep currently owns WD2
  for @dev so only that watchdog yields during [begin .. end].
- apple_sleep_end() clears WD2_CTL, invokes @restore while holding the
  handoff lock, and clears ownership.

On T6050, apple,seq-commit-wdt writes 0x20 (sleep-commit routing) to
wdt-aux + AON_WDT_SLEEP (0x2c) during commit without restoring it on
wake. Bracket t6050_seq(T6050_SEQ_WDT) using struct apple_sleep's
existing aon_wdt_saved/aon_wdt_marked fields (matching T8142): save
wdt-aux + AON_WDT_SLEEP before commit, and in t6050_sleep_wake_regs()
stop WD2, W1C-clear IRQ_STATUS with a readl() barrier, restore the saved
routing word with a readl() barrier, and re-arm the 120 s wake net.

Leave T8142's aon_wdt_sleep OR path unchanged (T8142 has no "reconfig"
DT node in this series) and leave shared apple_sleep_set_wd2() unchanged
(empirical J775D register checks confirm a stopped WD2 does not latch
IRQ_STATUS past bark). Add isolated KUnit coverage for block matching,
slot ownership, and .end ordering in sleep-test.c.

Signed-off-by: Jeff Queisser <funkzy@users.noreply.github.com>
…he SoC

On Apple Silicon SoCs whose watchdog DT node provides the optional
"reconfig" routing register (such as T6050 / M5 Ultra), legacy WD1
RESET_EN stalls the SoC instead of performing a cold reset. Routing WD2's
bark interrupt via bits 5:4 = 01 of the "reconfig" register (with
WD2_BITE = U32_MAX and WD2_CTRL = IRQ_EN) triggers a clean cold reset on
both watchdog expiry and apple_wdt_restart().

When "reconfig" (>= 4 bytes, mapped non-exclusively via devm_ioremap) is
present:
- Register the apple_sleep WD2 handoff (matching the watchdog's reg[0]
  resource) before touching any watchdog registers so a registration
  error writes zero registers and devm unregisters the watchdog before
  the sleep handoff.
- Unify all four WD2 arming paths (start(), restart(), pre-probe
  takeover, and apple_wdt_sleep_restore()) into apple_wdt_wd2_arm():
  CTRL=0, BITE=U32_MAX, CUR=0, BARK=ticks, W1C clear IRQ_STATUS, a
  readl(WD2_CTRL) ordering barrier ahead of the separate reconfig
  mapping, apple_wdt_enable_reconfig() (with readback), and CTRL=IRQ_EN.
- Unify pre-probe takeover: always clear WD1_CTRL, and when either a
  legacy boot-loader WD1 (RESET_EN) or WD2 (IRQ_EN or RESET_EN) was
  armed before probe (outside kdump), set WDOG_HW_RUNNING before calling
  apple_wdt_wd2_arm() so a watchdog already armed at probe stays
  armed and resets cleanly instead of stalling or being dropped.
- Derive the 40 ms reboot bark delay from clk_rate and yield WD2 to
  apple_sleep when apple_sleep_wdt_active(dev) is true.

Single-reg DT nodes keep existing WD1 behavior unchanged aside from
guarding apple_wdt_get_timeleft() against cur_time >= reset_time
underflow on both WD1 and WD2. Add tools/asahi/apple-wdt-tests.py
(registered in run-host-tests.py) compiling the real driver body and
T6050 commit/wake WDT helpers under ASan/UBSan with --old-ref
70a00e5 and eight negative mutations.

Signed-off-by: Jeff Queisser <funkzy@users.noreply.github.com>
Add the optional "reconfig" register (<0x2 0x8833002c 0x0 0x4>) and
reg-names ("wdt", "reconfig") to watchdog@28836c000 in t6050-die0.dtsi
so apple_wdt selects WD2 bark-IRQ simple-reconfig mode on T6050 boards
for clean cold resets on watchdog expiry and reboot.

Signed-off-by: Jeff Queisser <funkzy@users.noreply.github.com>
@github-actions github-actions Bot added area:bringup Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026
@funkzy
funkzy force-pushed the pr/apple-wdt-simple-reconfig branch from 0b808e1 to 67f0883 Compare November 24, 2026 21:07
@funkzy
funkzy requested review from a team as code owners November 24, 2026 21:07
@funkzy
funkzy requested review from Acelogic and malik-na November 24, 2026 21:07
@funkzy

funkzy commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review — pushed the updated series (67f088391002, verified on main a3d477d03f8e) addressing Blocker 1 plus a deeper structural hardening pass across apple_wdt and T6050 apple_sleep, and updated the PR body to the What / Tested / Risk / Not yet format (zero AI attribution):

  1. Blocker 1 (probe-takeover write ordering & stale IRQ_STATUS):

    • Unified all four WD2 arming paths (start(), restart(), pre-probe takeover, and apple_wdt_sleep_restore()) into apple_wdt_wd2_arm(): CTRL = 0, BITE = U32_MAX, CUR = 0, BARK = ticks, W1C IRQ_STATUS clear, (void)readl(WD2_CTRL) ordering barrier ahead of the separate reconfig mapping, apple_wdt_enable_reconfig() (with readback), and finally CTRL = IRQ_EN.
    • Moved watchdog_init_timeout() before takeover and unified pre-probe takeover under one rule: any armed pre-probe legacy WD1 (RESET_EN) or WD2 (IRQ_EN/RESET_EN) clears WD1, sets WDOG_HW_RUNNING before arming, and hands directly over to WD2 simple-reconfig instead of dropping the boot watchdog.
    • Registered the apple_sleep handoff (now DT-matched by reg[0] start address and per-device apple_sleep_wdt_active(dev)) before touching any watchdog register so a registration failure writes zero registers and devm unregisters the watchdog before the sleep handoff.
  2. T6050 reconfig across sleep & T8142 note:

    • Auditing the T6050 sleep paths showed apple,seq-commit-wdt = <0x0 37 0x2c 0x20> on J714S/J716C writes 0x20 to wdt-aux + 0x2c (0x28833002c, the same routing word) without restoring it on wake. t6050_sleep_commit_wdt() / t6050_sleep_wake_wdt() now reuse struct apple_sleep's existing aon_wdt_saved/aon_wdt_marked fields to save before commit and restore on wake after CTL = 0, W1C IRQ_STATUS clear, and readl() barriers.
    • Left T8142's aon_wdt_sleep OR path unchanged in this series because T8142 has no "reconfig" DT node here (named as a follow-up for when T8142 enables "reconfig" with a T8142 hardware row), and left shared apple_sleep_set_wd2() unchanged after an empirical J775D register check confirmed a stopped WD2 (CTL = 0) does not latch IRQ_STATUS past BARK.
  3. Exact-head J775D A/B row, live reset proofs, KUnit, and host tests (67f088391002):

    • J775D own-base A/B row (main a3d477d03f8e, published aura-main-f13056d9, 27.2 stub, default command line, read-only root): baseline kit wdtsr6b (window wdtsr6@20261124-0144) vs PR kit wdtsr6 (window wdtsr6@20261124-0144) — boot=ok, steps_rc=0, live pre-probe legacy WD1 takeover (taking over legacy WD1 watchdog as WD2 simple-reconfig), WDT_IOCTL_PASS, identical 2 baseline failed units (iwd.service, systemd-networkd-persistent-storage.service), 8 vs 9 kernel errors (0 new kernel errors). (In the earlier r1 run's 10 vs 8, the two extra lines were two retries of a transient USB hub timeout usb 3-1: device descriptor read/64, error -110.)
    • Live cold-reset proofs on kit wdtsr6 (window wdtsr6rst@20261124-0149): forced 8 s /dev/watchdog0 expiry self-reset cleanly to Linux in 47 s; apple_wdt_restart() with macsmc-reboot unbound self-reset cleanly to Linux in 40 s.
    • KUnit (kunit-vz arm64): apple-sleep-soc-data 13/13 pass (including new isolated apple_sleep_test_wdt_handoff); total 55/56 pass (1 baseline CONFIG_UCLAMP_TASK skip).
    • Host tests (run-host-tests.py, GCC 15.2 + Clang 21.1 + ASan/LSan/UBSan): 510/511 vs 500/501 base (0 regressions; all 10/10 apple-wdt-tests runs ok, covering apple_wdt.c + t6050_sleep_{commit,wake}_wdt() + --old-ref + 8 mutations). dt_binding_check / CHECK_DTBS=y (0 new diagnostics across 11 t6050-*.dtb) and W=1 -Werror 10-combo Kconfig/KUnit bisect matrix (10/10) all pass.
  4. Blockers 2 & 3 (cross-board hardware rows):

    • Updated the PR body to ask T6050 apple_sleep board owners (J714S / J716C) for two back-to-back PM_SUSPEND_MEM (mem) suspend/resume cycles with /dev/watchdog0 active + one after magic close (verifying 0x28833002c is restored on wake), plus s2idle and the M1–M4 1-reg regression row.

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

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Merge readiness at 67f08839: not ready yet

Check Detail
CI at head no failing: pr-text / pr-text
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok in the PR body at 67f08839
Conflicts ok none
PR text ok Risk: one-way · (adds optional "reconfig" DT binding property) · affects T6050 Macs (t6050-die0.dtsi: J714S/C, J716C, J775C/D) and shared applewdt / applesleep code (M1–M5 single-reg nodes keep legacy WD1).

Areas: area:bringup, area:gpu, area:platform

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

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: FINISH, then merge at 67f088391002: the code point is fixed; it needs rows at this head.

Blockers: none in the code. Probe now disarms WD2 and programs bite, counter and bark before it routes a bark to cold reset (apple_wdt_wd2_arm()), so a counter the loader left past the bark time can't reset the SoC during probe.

Rows before merging: commit 2 (the WD2 handoff in drivers/soc/apple/sleep.c) hasn't run, since the J775D has no apple_sleep node. It needs a T6050 laptop through a mem sleep and wake at this head, with the watchdog still armed after the wake; we'll run it on our J714s. apple_wdt.c runs on every Mac, so it also needs one boot at this head on another generation with the watchdog as before (armed, and a reboot resets).

Checked: thank you. No Apple material. The reconfig path is chosen by the new optional register in the tree, the binding adds the WD2 register range, and the J775D A/B shows expiry and reboot resetting the SoC through WD2.

@DjDeveloperr
DjDeveloperr dismissed their stale review November 24, 2026 22:59

Superseded by the review at 67f0883

@github-actions github-actions Bot removed changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 24, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

67f0883 (cherry-picked cleanly onto fleet85 2ad96595 for J713 27.2 boot; apple_wdt.c, sleep.c, sleep.h byte-identical to 67f0883) J713 (M4 Air, T8132) PASS: guarded one-shot, default cmdline (systemd.watchdog_sec=60); pre-sleep /sys/class/watchdog/watchdog0 (Apple SoC Watchdog) state=active timeout=60 timeleft=45 status=0x8300; RTC s2idle 1/1 (15.567 s suspended); post-wake watchdog0 remained armed and counting (state=active timeout=60 timeleft=56->53 over 3 s, status=0x8300), 0 watchdog/sleep errors, Enforcing, 0 failed units, 0 AVC, 0 new kernel errors vs saved fleet85; ordinary saved reboot cleanly reset SoC back to saved 7.3.0-aurora-fleet85 (Enforcing, 0 failed, next_entry empty).

DjDeveloperr commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Post-merge J714s hardware row

Deep sleep PASS (2/2) on a 14-inch MacBook Pro (J714s, M5 Pro/T6050, G17S B1), kernel 7.3.0-m5-rows-base3. The boot used main at 15695c3ba53291e78bf62140598dbdffc7fb2b72 (includes #3029 head 67f0883910025e639cebe9abf66c243771466926) with Clang fix 0050f580cc54892302f38e458e609d1b793010e0, which has since merged.

  • Both consecutive deep mem cycles returned on the same boot, in 31.0 s and 31.3 s. WD2 route bits 5:4 at 0x28833002c read 01 before and immediately after each resume. The first post-wake ioctl sample showed 29 s remaining of its 30 s timeout on both cycles. Zero unexpected resets in the two deep cycles.
  • After selecting s2idle and arming a +12 s PMU alarm, SSH and the suspend result stayed unavailable for the 72 s wait. No autonomous reset was observed before the checked recovery reboot. WD2 is expected to be stopped during system suspend. The unchanged older default, 7.3.0-m5-cdirect16, also stayed unreachable after the same +12 s RTC0 alarm in s2idle. Both attempts required a checked VDM reboot. The s2idle non-return therefore predates this PR on the J714s.
  • The command line matched the default. SELinux was disabled. The only failed unit was the pre-existing tailscaled.service. No kernel WARNING: lines appeared during the two completed cycles. DCP's pre-existing clock-index error count went from 6 at boot to 10 and then 14. After recovery, 7.3.0-m5-cdirect16 was running and all 253 ESP file hashes matched.

Earlier pre-merge row

J714s (M5 Pro / T6050 / G17S B1), exact head 67f0883910025e639cebe9abf66c243771466926. WD2 handoff PASS for this cycle. The full suspend call exceeded the requested timing window. Single boot of 7.3.0-m5-p3077-3080-3029-r from candidate ce750bc940a127590ec521d413420581e61732e1 on main 38ffa67c1ec0f99c5bff57d69dbfe92de504cf06. All four PR heads are unchanged ancestors and their applied patch IDs match.

Headless gpubench-vk passed 13/13 before and 5/5 after wake, with 0 errors. Median compute.light at depth 1 was 108.04 µs/submit before and 107.58 µs/submit after wake. Headless dEQP-VK had 116 pass, 0 fail, 1 unsupported (compute 80/81 and synchronization2 cross-queue compute 6/6).

RTC0 was set for +28 s. One deep suspend returned on the same boot in 34.04 s with the RTC wake event recorded. Apple WD2 was active and counting before and after, with 29 s remaining at the first sample after resume. There were 0 panics, GPU faults, recoveries, or observed AVC denials (SELinux inactive). The one failed unit, tailscaled.service, was already failed on the default. All 12 boot error-priority lines matched baseline patterns. There were 49 additional lines after resume, 47 from DCP. ESP file hashes and default GPU liveness were verified after restoration.

@DjDeveloperr
DjDeveloperr merged commit ef99c02 into aurora-silicon:main Nov 25, 2026
13 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:bringup Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) blast:m1 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:one-way Revertible or not, from Merge risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants