Skip to content

EDAC: apple_soc_edac: count a wake-latched event-log source after a wake, do not report it - #3659

Merged
DjDeveloperr merged 3 commits into
mainfrom
satchlj/edac-wake-latched
Dec 1, 2026
Merged

DjDeveloperr merged 3 commits into
mainfrom
satchlj/edac-wake-latched

Conversation

@satchlj

@satchlj satchlj commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

What: stop reporting the event-log source that every wake from system sleep latches as an uncorrectable error, while still reporting it outside the wake.

The problem: on T8112, the first access to the PMGR clock-mux block after a wake from deep sleep raises event-log source 2. The line then stays asserted until the next sleep. apple_soc_edac has no status or acknowledge for that source, so it masks and unmasks the line on its backoff. Each wake therefore logs 1–5 UEs that aren't errors. The analysis is in #3371.

Changes:

  • Binding: apple,wake-latched-sources lists the interrupt indices of such sources.
  • Driver:
    • A wake opens a window for the listed sources, from resume_noirq, before the lines are unmasked again. The window is timed from the wake, not from the line's last unmask before the sleep.
    • Inside the window, an assertion is counted and logged at debug, with no UE. The line keeps its existing mask and backoff.
    • A line that stayed quiet for a minute after its last unmask had cleared. When it fires again, the window closes and it reports as a UE.
    • Before the first wake, outside a window, and on every other source, nothing changes.
  • T8112 DT: marks source 2 (AIC 196, the clock-mux block window).
  • The window is driven by the DT property and by the line's own state. No chip check.

Tested: Current head 7cee228f4ea1 is the same code rebased onto main (from 396f5eebaa7b).

  • KUnit, 3 new cases:
    • an in-window assertion is counted, with no UE;
    • before any wake it reports;
    • a line that had cleared and fires again reports, and the window closes;
    • plus a case that only listed and claimed sources get a window, timed from the wake.
  • checkpatch --strict: 0/0/0.
  • J413 M2 Air at 396f5eebaa7b (applied unchanged on soc: apple: sleep: T8112 (M2) suspend-to-RAM, enabled on J413 #3647 ec5d52890140; sleep is off on T8112 at main): PASS, 3/3 deep wakes with ue_count 0, source 2 counted at debug, GPU renders after every wake, KUnit suite ok on the device. Without this PR the same kernel reported 7 UEs over three wakes.

Risk: two-way door. It only changes reporting for sources listed in the DT, which today is T8112 source 2.

@satchlj
satchlj force-pushed the satchlj/edac-wake-latched branch from 021b01f to 8120a6b Compare November 29, 2026 22:23
@satchlj

satchlj commented Nov 29, 2026

Copy link
Copy Markdown
Member Author

dt-checks fix: the event-log branch of the binding has additionalProperties: false, so it now lists apple,wake-latched-sources too. dt_binding_check and CHECK_DTBS for the T8112 DTBs are clean locally. Old head 021b01f25482, new head 8120a6bbc979; the C and DT commits are unchanged.

Hardware, J413 (M2 Air), on a kernel carrying these three commits on top of the T8112 sleep series (#3647 and #3595, plus local drain changes). This is not the exact PR head: sleep is off at main on T8112, so the exact head alone cannot take a deep wake.

  • 3 deep wakes (10 s RTC): ue_count stayed 0 before and after every wake. Source 2 asserted 7 times across the three wakes, each logged at debug as "asserted since the wake (n), not reported". The GPU rendered after each wake.
  • The KUnit suite on the device: 28/28 ok, including edac_test_irq_wake_window_closes (an assertion after the window closes is reported) and edac_test_open_wake_windows.
  • Untested on hardware: a real error on source 2 after the window closes, since none can be induced.

Next: a row on this head stacked on #3647

@satchlj

satchlj commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

8120a6bbc979 on J413 (M2 Air), PASS: 3/3 deep sleeps (10 s RTC wakes, mem_sleep=deep), with this PR's three commits applied unchanged on #3647 ec5d52890140 (sleep is off on T8112 at main). Modules from this tree, default command line plus the trial marker and watchdog.open_timeout=120.

  • ue_count 0 before the first sleep and 0 after every wake. Source 2 was counted at debug 7 times across the three wakes ("asserted since the wake (n), not reported").
  • Each wake from the PMU RTC alarm (NUB.SPMI0.SW3); GPU firmware back in 2.9 to 7.0 ms; a render check passed before and after every wake.
  • KUnit apple-soc-edac on the device: ok, no failing cases.
  • For comparison, the same soc: apple: sleep: T8112 (M2) suspend-to-RAM, enabled on J413 #3647 head without this PR reported 7 UEs across three wakes.
  • Untested on hardware: a real error on source 2 after the window closes.

@satchlj
satchlj marked this pull request as ready for review November 30, 2026 00:05
@satchlj
satchlj requested review from a team as code owners November 30, 2026 00:05

@aurora-silicon-review aurora-silicon-review Bot 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: FINISH, then merge at 8120a6bb

Blockers:

  1. apple_soc_edac_open_wake_windows() (drivers/edac/apple_soc_edac.c:169-176) does not refresh armed_jiffies, so the wake window closes immediately and reports false UEs whenever the system enters deep sleep after > 60 s of uptime:
    • irq_data->armed_jiffies is initialized once in apple_soc_edac_probe() (L469) and is only updated in apple_soc_edac_rearm() when a masked line is re-enabled after a backoff.
    • If the machine runs for more than APPLE_SOC_EDAC_BACKOFF_MAX_MS (60000 ms) after boot while source 2 is quiet and then enters deep sleep, apple_soc_edac_resume_noirq() -> apple_soc_edac_open_wake_windows() sets wake_window = true while armed_jiffies is still > 60 s stale.
    • On the first wake-latched assertion after resume, apple_soc_edac_irq_thread() (L198-203) checks time_after(jiffies, irq_data->armed_jiffies + msecs_to_jiffies(APPLE_SOC_EDAC_BACKOFF_MAX_MS)), which evaluates to true, immediately clears wake_window = false, and reports the wake's own assertion (and every subsequent backoff retry) via edac_device_handle_ue().
    • edac_test_irq_wake_window() (drivers/edac/apple_soc_edac-test.c:87-88) missed this because it manually assigns ctx->irq.armed_jiffies = jiffies instead of going through apple_soc_edac_open_wake_windows() with a stale armed_jiffies; a fresh-boot J413 test taken within 60 s of boot also avoids hitting the stale threshold.
    • Fix: Refresh armed_jiffies = jiffies (and reset retries/backoff_ms if already past the quiet window, with matching WRITE_ONCE/READ_ONCE pairing) in apple_soc_edac_open_wake_windows() (timekeeping_resume() runs in syscore_resume() before dpm_resume_noirq(), so jiffies is current), and add a KUnit regression test exercising apple_soc_edac_open_wake_windows() with armed_jiffies older than APPLE_SOC_EDAC_BACKOFF_MAX_MS followed by apple_soc_edac_irq_thread().

Checked:

  • Documentation/devicetree/bindings/edac/apple,soc-error-handler.yaml: adds apple,wake-latched-sources (uint32-array) and lists it in the apple,soc-event-log additionalProperties: false branch; hosted dt-checks passed SUCCESS.
  • arch/arm64/boot/dts/apple/t8112-peripherals.dtsi: marks apple,wake-latched-sources = <2> on m2_event_log_handler (index 2 = AIC_IRQ 196).
  • drivers/edac/apple_soc_edac.c: probe parsing checks n > 0 && i < n, idx >= hw->num_irqs, and !edac->irqs[idx].source before enable_irq(); NOIRQ_SYSTEM_SLEEP_PM_OPS + pm_sleep_ptr() wiring is clean.
  • drivers/edac/apple_soc_edac-test.c: existing 3 new cases cover pre-wake UE, in-window counting with fresh armed_jiffies, quiet-period window closure, and selective window opening.
  • Hardware row: J413 (M2 Air) 3/3 deep sleeps on 8120a6bb stacked on #3647 (0 UEs vs 7 UEs control), plus on-device KUnit PASS; after fixing armed_jiffies, please confirm a wake taken > 60 s after boot also reports 0 UEs.
Evidence
  • Diff: +139/-3 across 5 files, 3 commits (4a5b4b96, 4d42872f, 8120a6bb), DCO on all 3, MERGEABLE on main.
  • Nit (non-blocking): in edac_test_open_wake_windows() (drivers/edac/apple_soc_edac-test.c:119,132), ctx is unused apart from KUNIT_EXPECT_NOT_NULL(test, ctx).

@aurora-silicon-review aurora-silicon-review Bot 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.

resume_noirq opens wake_window without resetting the quiet-period baseline. armed_jiffies still dates from probe or the last rearm, so after more than a minute of quiet uptime the first wake assertion can close the fresh window and report the false UE. Track the start of the fresh wake window separately from the IRQ backoff bookkeeping and add a resume fixture with an old armed_jiffies.

@satchlj

satchlj commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

Review fix: resume opened the wake window without refreshing armed_jiffies, the time the window closes from. If the source was last unmasked more than a minute before the sleep, the first assertion after the wake closed the window at once and was reported. apple_soc_edac_open_wake_windows() now sets armed_jiffies for each source it opens, and edac_test_open_wake_windows checks it is refreshed from an unmask long before. Squashed into the EDAC commit; checkpatch clean.

Old head 8120a6bbc979, new head 396f5eebaa7b. The hardware row above is at the old head; a row at the new head will follow.

@satchlj
satchlj force-pushed the satchlj/edac-wake-latched branch from 8120a6b to 396f5ee Compare November 30, 2026 00:42

@aurora-silicon-review aurora-silicon-review Bot 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: HOLD at 396f5eeb

Blockers:

  • Hosted CI checks on 396f5eeb are still queued (dt-checks, host-tests, pr-text, readiness).
  • Exact-head 396f5eeb J413 hardware row is still pending (as noted in your latest comment; please include a wake after > 60 s of uptime confirming ue_count stays 0).

Checked:

  • Prior 8120a6bb blocker resolved cleanly: apple_soc_edac_open_wake_windows() (drivers/edac/apple_soc_edac.c:180-187) now refreshes irq_data->armed_jiffies = jiffies before WRITE_ONCE(irq_data->wake_window, true) for every claimed wake_latched source, preventing stale probe()/rearm() timestamps from closing the wake window on the first post-wake assertion after > 60 s of uptime.
  • edac_test_open_wake_windows() (drivers/edac/apple_soc_edac-test.c:130-134) now initializes irqs[2].armed_jiffies to 10 * APPLE_SOC_EDAC_BACKOFF_MAX_MS in the past and verifies it is refreshed to >= before.
  • Binding (apple,soc-error-handler.yaml), T8112 DT (t8112-peripherals.dtsi), probe bounds checks, and NOIRQ_SYSTEM_SLEEP_PM_OPS wiring remain clean (MERGEABLE on main, DCO on all 3 commits).
Evidence
  • Diff: +151/-3 across 5 files, 3 commits (4a5b4b96, cf850a99, 396f5eeb), DCO on all 3, MERGEABLE on main.
  • Code audit found no remaining blockers; ready to approve once hosted CI completes green and the exact-head 396f5eeb J413 row is posted.

@github-actions github-actions Bot added area:platform Area from CODEOWNERS (bot) blast:m2 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Merge readiness at 7cee228f: ready to merge

Check Detail
CI at head ok 6 checks passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok comment at 7cee228f
Conflicts ok none
PR text ok Risk: two-way · . It only changes reporting for sources listed in the DT, which today is T8112 source 2.

Areas: area:platform
Merge: gh pr merge 3659 --merge (Owners and Core through the bypass: add --admin).

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

@github-actions github-actions Bot added the ci-failing A check failed at the PR head (bot) label Nov 30, 2026
@satchlj

satchlj commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

396f5eebaa7b on J413 (M2 Air), PASS: 3/3 deep sleeps (10 s RTC wakes, mem_sleep=deep), with this PR's head applied unchanged on #3647 ec5d52890140 (sleep is off on T8112 at main). Default kernel config plus the KUnit suite, default command line plus the trial marker and watchdog.open_timeout=120.

  • ue_count 0 before the first sleep and 0 after every wake; source 2 counted at debug 7 times across the three wakes.
  • Each wake from the PMU RTC alarm (NUB.SPMI0.SW3); GPU firmware back in 2.6 to 5.6 ms; a render check passed before and after every wake.
  • KUnit apple-soc-edac on the device: ok, no failing cases (includes the refreshed-window check).
  • Untested on hardware: a real error on source 2 after the window closes.

@aurora-silicon-review aurora-silicon-review Bot 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 396f5eeb after hosted checks and the T8112 sleep integration.

Checked: Resume resets the baseline for claimed wake-latched sources, and KUnit covers a deliberately aged timestamp. The current EDAC head ran unchanged on the J413 sleep stack. Three deep wakes produced zero UEs, seven expected debug counts, and successful GPU rendering after each wake. The device KUnit run passed and hosted DT checks are green. This clears my source and J413 hold. Keep the hosted host-test result and the sleep-stack dependency in the train.

@github-actions github-actions Bot removed ci-failing A check failed at the PR head (bot) needs-hw-row No hardware row at the PR head (bot) labels Nov 30, 2026
On some SoCs a wake from system sleep latches an event-log source: the
first access to the block after the wake raises its line, and it stays
asserted until the next sleep. Add apple,wake-latched-sources, the
interrupt indices of such sources, so the driver can tell the wake's own
assertion from an error.

Signed-off-by: Satya Benson <[email protected]>
…t report it

A source listed in apple,wake-latched-sources is raised by every wake
from system sleep and stays asserted until the next sleep. Reported as
an uncorrectable error, it gives one to five false UEs per wake while
the line is masked and unmasked on its backoff.

Each wake opens a window for those sources, from resume_noirq, before
the lines are unmasked again. Inside it, an assertion is counted and
logged at debug, with no UE report, and the line keeps its mask and
backoff. A line that stayed quiet for a minute after its last unmask had
cleared: when it fires again the window closes and it reports as usual.
Outside a window, and on every other source, nothing changes.

Signed-off-by: Satya Benson <[email protected]>
…-latched

On T8112 the first access to the PMGR clock-mux block after a wake from
deep sleep raises event-log source 2, and it stays asserted until the
next sleep.

Signed-off-by: Satya Benson <[email protected]>
@satchlj
satchlj force-pushed the satchlj/edac-wake-latched branch from 396f5ee to 7cee228 Compare November 30, 2026 03:00
@satchlj

satchlj commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

Rebased onto current main (45d7f828e08a), which contains #3672: the apple-dcp host-test failure was #3672's case 90, missing from the old base, not this PR. Conflict-free; every commit keeps its patch-id.

Old head 396f5eebaa7b, new head 7cee228f4ea1. The J413 row at 396f5eebaa7b stands for the same code: no commit in this PR changed.

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 30, 2026

@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: MERGE at 7cee228f

Blockers: none.

Checked: only sources listed in apple,wake-latched-sources and claimed by a handler get a window, so every other source and every other SoC report as before. A wake resets each window's start, so a quiet minute before the sleep can't close it early, and the new KUnit case covers an aged timestamp. A line that fires again after a quiet minute closes the window and reports. The DT value is your own J413 measurement, and there's no chip check. The J413 row at 396f5eeb (same patch-ids) shows ue_count 0 over three deep wakes with source 2 counted at debug. CI is green.

Note (not blocking)

resume_noirq also runs after an s2idle wake, so source 2 is counted rather than reported for a minute after every s2idle resume too. That's fine for a line that only latches, but worth one line in the binding text.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 30, 2026
@satchlj

satchlj commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

No row from T6050 (J775c): apple_soc_edac does not bind there. Both error-handler@2220000000 and event-log@280040000 are status = "disabled" in t6050-peripherals.dtsi, and the driver matches no T6050 compatible, so a trial would not exercise this change. The second-generation row has to come from a machine where the driver probes.

@DjDeveloperr
DjDeveloperr merged commit 45648c6 into main Dec 1, 2026
9 of 11 checks passed
@DjDeveloperr
DjDeveloperr deleted the satchlj/edac-wake-latched branch December 1, 2026 00:33
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:m2 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants