Skip to content

EDAC: apple_soc_edac: read and acknowledge DT-described event-log status words - #3825

Closed
satchlj wants to merge 4 commits into
mainfrom
satchlj/edac-event-log-ack
Closed

satchlj wants to merge 4 commits into
mainfrom
satchlj/edac-event-log-ack

Conversation

@satchlj

@satchlj satchlj commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

What: add DT-driven status read and write-1-to-clear acknowledge for Apple SoC event-log sources, and populate T8112's event-log status words from the ADT.

Background:

Changes:

  • Binding (Documentation/devicetree/bindings/edac/apple,soc-error-handler.yaml): document the optional apple,event-logs matrix of <interrupt-index reg-index offset> triples.
  • Driver (drivers/edac/apple_soc_edac.c, drivers/edac/apple_soc_edac-internal.h):
    • Parse apple,event-logs at probe and map each referenced reg aperture once without requesting an exclusive memory region (event-log apertures span shared SoC blocks whose sub-ranges are claimed by clock-controller, watchdog, reset-controller, and sleep drivers), while honoring IORESOURCE_MEM_NONPOSTED.
    • In the IRQ thread, read every configured status word for the firing line, log non-zero values, write observed bits back, and read back to verify clearing.
    • If all set words clear, return IRQ_HANDLED without masking the line. If any word stays set or no word was set, fall through to the existing mask-and-backoff path so sticky lines cannot storm.
    • Inside a wake_window (for apple,wake-latched-sources), log at debug with no UE report, stay unmasked if the acknowledge clears the line, and avoid double-counting if a sticky word falls through to backoff.
  • T8112 DT (arch/arm64/boot/dts/apple/t8112-peripherals.dtsi): add all 18 <line reg offset> triples from the T8112 ADT to m2_event_log_handler. apple,wake-latched-sources = <2> is retained, as hardware testing below confirmed both source 2 words stay 0x1 after W1C.
  • KUnit (drivers/edac/apple_soc_edac-test.c): add 6 tests covering multi-word read/ack, zero status, sticky status, normal IRQ handling, empty/sticky backoff, and wake-window interaction.

Tested:

  • Row: 5e4086d + J413 (MacBook Air 13" M2, T8112, 27.2 stub) + PASS
    • Exact head 5e4086dba70e with its own t8112-j413-fw27.dtb (/proc/device-tree/soc/event-log@23b700000/apple,event-logs, 216 bytes = all 18 triples): probed cleanly across overlapping MMIO apertures (0 -EBUSY, monitoring 16 error sources, 0 failed units).
    • 3/3 s2idle RTC wakes (boot_id=0dfa0434-b866-4ffb-8da8-a7e4fb1e1d31): 0 event-log interrupts, ue_count=0.
    • 3/3 committed deep-sleep RTC wakes (boot_id=e6a7d3b3-7b59-4411-836c-43a087c2bd5f, apple_sleep.deep=1 apple_sleep.untested_commit=1 apple_soc_edac.dyndbg=+p, boot object resumes 0 -> 1 -> 2 -> 3):
      • Both source 2 status words read 0x1 on wake and stayed 0x1 after the W1C acknowledge (event-log source 2: status 0x1 at reg 2 +0x28000, 0x1 after the acknowledge and status 0x1 at reg 2 +0x6c004, 0x1 after the acknowledge).
      • Sticky-word fallback cleanly masked the line and backed off exponentially (89.23 s -> 90.24 s -> 92.29 s -> 96.32 s -> 104.64 s -> 121.03 s -> 153.28 s), keeping ue_count=0 with no IRQ storm and no error output when dyndbg is off.
      • Confirms apple,wake-latched-sources = <2> must stay on T8112 (whether the latch clears via another underlying register or only on power-off is left for follow-up).
  • KUnit (drivers/edac/apple_soc_edac.kunitconfig, arm64, LLVM=1): 34/34 PASS (28 existing + 6 new).
  • W=1 LLVM=1 compile: 0 warnings for both CONFIG_EDAC_APPLE_SOC_KUNIT_TEST=y and modular CONFIG_EDAC_APPLE_SOC=m (KUNIT=n).
  • dt_binding_check (DT_SCHEMA_FILES=edac/apple,soc-error-handler.yaml): clean.
  • CHECK_DTBS=y (t8112-j413.dtb, t8112-j413-fw27.dtb, t8112-j473.dtb, t8112-j493.dtb): 0 warnings on event-log / error-handler.
  • scripts/checkpatch.pl --strict --git origin/main..HEAD: 0 errors, 0 warnings, 0 checks across all 3 commits.

Untested on hardware:

  • The W1C clear-and-stay-unmasked path on a non-sticky hardware event-log source (other T8112 sources 0–1 and 3–15 did not fire during boot or sleep; that path is covered by KUnit edac_test_event_log_status_words, edac_test_irq_event_log_error, and edac_test_irq_event_log_wake_window).

Risk: two-way door · T8112 Macs (and any future SoC adding apple,event-logs). Nodes without apple,event-logs keep identical behavior; on T8112, mapping is non-exclusive and any word that does not clear on W1C falls back to the existing mask-and-backoff path.

Document the optional apple,event-logs property describing per-source
event-log status words from the ADT event-logs property as
<interrupt-index reg-index offset> triples.

Signed-off-by: Satya Benson <satya@benson.earth>
…tus words

Parse the optional apple,event-logs property (<interrupt-index reg-index
offset> triples) during probe, mapping each referenced reg aperture once
without claiming an exclusive memory region (event-log apertures span
shared SoC blocks whose sub-ranges are claimed by other drivers) while
honoring nonposted-mmio.

When a configured event-log line fires, read all of its status words,
log any non-zero words, and acknowledge them by writing the observed
bits back. If every set word reads back clear, return IRQ_HANDLED
without masking the line; if any word stays set or no status word is
set, fall through to the existing mask-and-backoff path so sticky lines
cannot storm.

Wake-latched sources inside their post-wake window keep counting at
debug with no UE report, stay unmasked if the acknowledge clears them,
and avoid double-counting if a sticky word falls through to backoff.

Add six KUnit cases covering multi-word read/ack, empty and sticky
status words, normal IRQ handling, and wake-window interaction.

Signed-off-by: Satya Benson <satya@benson.earth>
Populate apple,event-logs on m2_event_log_handler from the T8112 ADT
/arm-io/event-log-handler event-logs table (18 <line reg offset> triples
across the 16 event-log interrupt lines, including source 2 at reg 2
+0x28000 and +0x6c004).

Keep apple,wake-latched-sources = <2> until live deep-wake testing
confirms whether source 2 clears on acknowledge or stays latched until
power-off.

Signed-off-by: Satya Benson <satya@benson.earth>
@satchlj
satchlj marked this pull request as ready for review December 1, 2026 19:47
@satchlj
satchlj requested review from a team as code owners December 1, 2026 19:47
@satchlj
satchlj requested review from LiamRay11 and maralcbr December 1, 2026 19:47
@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-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Merge readiness at b400ecf5: not ready yet

Check Detail
CI at head ok 5 checks passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok comment at b400ecf5
Conflicts no merge conflicts with main: merge it in (no force push)
PR text ok Risk: two-way · T8112 Macs (and any future SoC adding apple,event-logs). Nodes without apple,event-logs keep identical behavior; on T8112, mapping is non-exclusive and any word that does not clear on W1C falls back to the existing mask-and-backoff path.

Areas: area:platform

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

@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 5e4086d

Checked:

  • DT: each of the 18 <line reg offset> triples lies inside its reg window in m2_event_log_handler (e.g. reg 2 is 0x70000 long, so +0x28000 and +0x6c004 fit; regs 4–10 are 0x4000 long, so +0x3ff0 fits; regs 14/15 are 0xc000 long, so +0x400c fits). All offsets are 4-aligned, so probe's own bounds/alignment checks pass on T8112. Nodes without apple,event-logs return 0 from the parse with no other change.
  • IRQ thread: a set word that clears on W1C returns IRQ_HANDLED unmasked. If the line is still asserted for an undescribed reason, the next invocation reads all words zero and falls to mask + backoff, so it can't storm beyond one extra round. A sticky word (source 2 on wake, as your J413 deep rows show) reaches the existing backoff with reported set, so the UE isn't double-counted and the wake count isn't bumped twice. Moving the wake-window expiry above the status read keeps its old semantics.
  • Writing back a non-W1C word: writing the same value back is a no-op, and the mapping is non-exclusive (no region request), so the drivers that own those sub-ranges keep probing. Your 0 -EBUSY row agrees.
  • Exact-head J413 row (boot, 3 s2idle, 3 committed deep wakes with backoff), KUnit 34/34.

Follow-ups (non-blocking):

  • apple_soc_edac_parse_event_logs() runs after the IRQs are requested. The thread reads nevent_logs without a barrier against the event_logs[] fill. Either parse before requesting the IRQs, or publish nevent_logs with smp_store_release() and read it with smp_load_acquire(). It's only a window at probe, but it's cheap to close.
  • A line with event logs that fires with no word set now logs "asserted with no status set" and backs off without a UE report. That's reasonable, but worth one line in the commit message.

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

Two issues in drivers/edac/apple_soc_edac.c. First, apple_soc_edac_parse_event_logs() uses the DT register index to size the arrays before checking that a matching memory resource exists. A malformed index can wrap max_reg or leave it undersized, and the second pass indexes mapped[] and sizes[] before platform_get_resource() can reject it. Validate each register resource in the first pass before sizing or indexing. Second, the successful wake-ack path returns with wake_window still open, which the new KUnit test explicitly expects. Once all wake status bits read back clear, a second assertion in that minute is a fresh event, but the handler suppresses its UE too. Close the window on a successful wake acknowledge and cover a second fresh interrupt in the test. The J413 sticky-word row is useful and still covers the fallback.

@github-actions github-actions Bot added the changes-requested A reviewer requested changes (bot) label Dec 1, 2026
… window on clear

Validate each apple,event-logs register index and word offset against platform_get_resource(IORESOURCE_MEM) during pass 1 before sizing the shared-mapping table, avoiding oversized or wrapped allocations on malformed DT properties.

Close wake_window once a wake-latched event-log interrupt clears all set status words so a subsequent assertion within the same minute reports as a fresh uncorrectable error, and extend the KUnit wake-window test to verify that second interrupt.

Parse apple,event-logs and apple,wake-latched-sources before requesting threaded IRQs in probe so all per-IRQ state is initialized before registration.

Signed-off-by: Satya Benson <satya@benson.earth>
@satchlj

satchlj commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Addressed in b400ecf5a55d:

  1. Pass-1 register & offset validation (apple_soc_edac_parse_event_logs): validate platform_get_resource(pdev, IORESOURCE_MEM, reg_idx) and offset bounds before incrementing counts[idx] or updating max_reg, removing the separate sizes[] array and guaranteeing mapped[] is bounded by actual IORESOURCE_MEM resources.
  2. Close wake_window on cleared wake ack (apple_soc_edac_irq_thread): clear irq_data->wake_window once all set event-log status words read back clear during a wake window, so a second assertion within that minute reports as a fresh UE. Extended edac_test_irq_event_log_wake_window to cover that second fresh interrupt before re-opening the window for the sticky/empty fallback and quiet-minute expiry checks.
  3. Probe ordering (apple_soc_edac_probe): moved apple_soc_edac_parse_event_logs() and apple,wake-latched-sources parsing ahead of devm_request_threaded_irq() so all per-IRQ state is initialized before registration.

Verified offline: KUnit drivers/edac/apple_soc_edac.kunitconfig 34/34 PASS (arm64, LLVM=1), W=1 0 warnings on drivers/edac/apple_soc_edac.o, checkpatch.pl --strict 0 errors / 0 warnings / 0 checks. Rebuilding for an exact-head J413 hardware row at b400ecf5 next.

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

Both findings are fixed. The first pass validates each active entry’s register resource, alignment, and offset before sizing or indexing the mapping array. A cleared wake acknowledge now closes the window, and KUnit covers the next assertion reporting as a fresh UE while sticky status still backs off. Probe initializes the per-IRQ state before registration. Hosted CI and the updated J413 row remain open.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 1, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging at b400ecf5a55d (B2 merge train, 12-01 merge bar). Approval at this head: DjDeveloperr. Row: the hardware row at b400ecf that the readiness check found (PR body or comment). CI: train L17 = main 539585d + #3836 #3839 #3825: Apple build + changed .c objects (incl. drivers/edac) + DTBs pass; hosted host-tests reds = main's pre-existing fails Revert: git revert -m 1 <merge commit>.

@RyanTheTide

Copy link
Copy Markdown
Contributor

This landed on main as merge commit 5d023f634eee (second parent = this head b400ecf5), in merge train L17 (Apple build, a compile of drivers/edac, and DTBs passed). GitHub's merge call returned 'Merge already in progress' and the PR state didn't update. If it stays open, I'll close it as merged with this note. Revert: git revert -m1 5d023f634eee.

@github-actions github-actions Bot added merge-conflict Conflicts with the base branch (bot) and removed ready-to-merge Meets the merge policy: merge it (bot) labels Dec 1, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

Closing: this is merged. main carries it as merge commit 5d023f634eee, whose second parent is this head, b400ecf5. GitHub's merge state didn't update.

@RyanTheTide RyanTheTide closed this Dec 1, 2026
@satchlj

satchlj commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Row: b400ecf + J413 (MacBook Air 13" M2, T8112, 27.2 stub) + PASS

  • Default-cmdline boot (boot_id=5b79a710-1065-4830-a0b6-16149e9fd3fd) with exact-head t8112-j413-fw27.dtb (/proc/device-tree/soc/event-log@23b700000/apple,event-logs 216 B, apple,wake-latched-sources 4 B): probed cleanly across overlapping MMIO apertures (0 -EBUSY, monitoring 2 + 16 error sources, 0 failed units, ue_count=0, ce_count=0).
  • Full sleep row (boot_id=51ef3703-bbfb-4d09-be64-eeafe51c2563, apple_sleep.deep=1 apple_sleep.untested_commit=1 apple_soc_edac.dyndbg=+p):
    • 3/3 s2idle RTC wakes: 0 event-log interrupts, ue_count=0, ce_count=0.
    • 3/3 committed deep-sleep RTC wakes (boot object resumes 0 -> 1 -> 2 -> 3, NUB.SPMI0.SW3): both source 2 words read 0x1 and stay 0x1 after W1C (reg 2 +0x28000 and +0x6c004), keeping wake_window open on the sticky fallback and backing off cleanly (55.65 s -> 56.67 s -> 58.71 s -> 62.74 s -> 70.80 s -> 87.17 s, events (1)–(6)), ue_count=0, ce_count=0.

techmore pushed a commit to techmore/linux that referenced this pull request Dec 1, 2026
…ac-event-log-ack

EDAC: apple_soc_edac: read and acknowledge DT-described event-log status words
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) merge-conflict Conflicts with the base branch (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants