Skip to content

Verify EC timer wake from CPU standby - #182

Merged
dymk merged 6 commits into
OpenDevicePartnership:mainfrom
dymk:dymk/time-alarm-retention-uefi
Oct 16, 2026
Merged

dymk merged 6 commits into
OpenDevicePartnership:mainfrom
dymk:dymk/time-alarm-retention-uefi

Conversation

@dymk

@dymk dymk commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Add an opt-in UEFI test for EC-triggered CPU retention wake. The test programs the existing TimeAlarm relay, enters PSCI CPU standby, and checks the interrupt and GPIO state on return. It distinguishes GPIO1/INTID39 wake from the CNTV/INTID27 timeout guard, then clears the alarm and verifies interrupt-state restoration.

AC/DC sources are explicit test fixtures. This does not implement Windows sleep/resume, physical power detection, or asynchronous OS notifications. Part of OpenDevicePartnership/embedded-services#689.

Dependencies

The submodule commits are publicly fetchable through their upstream PRs but are not merged. The HAL fix is temporarily pinned to its approved personal fork. The retention target requires the new EC QEMU binary, selected with RETENTION_EC_QEMU; the default devcontainer image has not yet incorporated the builder prerequisite. Existing E2E targets are unchanged.

Results on the stacked commits

  • AC and DC connected: each 6 passed, 0 failed. Selected alarms and rearmed alarms returned from standby after about 4.98 seconds with INTID39, GPIO1 high, and PL061 bit1 pending.
  • AC and DC disconnected: each 4 passed, 0 failed. Only the guard returned, after about 10.01 seconds on INTID27. Inactive-source alarms also returned only through the guard.
  • GIC configuration and enable-state readback matched the saved state after every run.
  • Existing native TimeAlarm and Windows RTC regressions passed; Windows reported 40 passed, 0 failed with the new EC/HID/HAL stack.
  • Live GPIO/HID isolation and zero-gap I2C handshake checks, host-only negative evidence checks, compilation, and strict Clippy passed.

The low-level fixture includes explicit ownership, routing, guard, and restoration checks; it does not replace firmware exception vectors. Pinned Patina IRQ-query defects are bypassed with checked register snapshots. Leave this draft pending review and dependency approval.

Rebased onto the HID TimeAlarm integration from #184. The EC pin is 514fdbfeb43462000e28e490b2204429273fe8aa, retaining upstream HID/MCTP support plus the wake fixture. The new upstream QEMU image and RTC enumeration settings are preserved. All four AC/DC connected/disconnected retention runs passed with the updated host QEMU.

@dymk

dymk commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Reduced this PR from 1,223 to 923 added lines and from 15 to 12 files.

Removed 70 production lines, 192 test lines, and 38 documentation lines. The separate evidence, protocol, and GPIO-wrapper files are gone. Fixture construction and cleanup now share one lifecycle, and four named regressions replace the verbose predicate matrices. The new mocked launcher test file was removed.

Re-ran all four real AC/DC connected/disconnected cases. Also exercised real quoted executable/ELF paths, a deliberately failing non-wake EC run, socket/process cleanup, and rejection of incomplete result summaries. EFI build and strict Clippy pass. The dependent source-switch cases also pass with this reduction.

The remaining bulk is the interrupt/timer admission and restoration code needed to leave firmware state intact; those checks and real wake-cause validation are unchanged.

@dymk
dymk requested a balanced review from Copilot October 5, 2026 20:06

Copilot AI 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.

Note

Copilot was unable to run its full agentic suite in this review.

Copilot review overview

Review effort: Lite
Findings: 4 Medium severity · 2 Low severity

Open (6)
What changed in this PR

Adds an opt-in “TimeAlarm CPU-retention” end-to-end fixture that validates firmware CPU standby behavior (not OS suspend/resume), including new UEFI-side test logic, an execution script, and build/run targets; also updates EC QEMU orchestration to support a configurable QEMU binary and a wake socket.

Changes:

  • Introduce a new time-alarm-retention Rust e2e test (UEFI app) with platform interrupt/timer validation helpers and unit tests for core validation logic.
  • Add a retention runner script plus make retention-* targets to build/run the fixture with AC/DC and connected/disconnected cases.
  • Update EC-QEMU launcher to honor EC_QEMU and optionally expose EC_WAKE_SOCK; bump related submodules and document the new workflow.
File Description
scripts/​test-time-alarm-retention.sh New runner script wiring artifacts, sockets, and QEMU args for retention runs.
scripts/​lib/​ec-qemu.sh Allow overriding EC QEMU binary (EC_QEMU) and pass optional wake socket chardev.
mod/​uefi/​patina-qemu Submodule bump to a Patina/QEMU revision needed for the fixture.
mod/​ec Submodule bump for wake-capable EC support.
e2e-tests/​tests/​time-alarm-retention/​src/​platform.rs New low-level fixture to claim/route IRQs, enter standby, and restore device/IRQ state.
e2e-tests/​tests/​time-alarm-retention/​src/​main.rs New retention test program coordinating EC TimeAlarm commands with standby observations.
e2e-tests/​tests/​time-alarm-retention/​src/​interrupt.rs New shared constants/validation logic with unit tests.
e2e-tests/​tests/​time-alarm-retention/​Cargo.toml New crate manifest for the retention test.
e2e-tests/​Makefile New retention-* targets and options for building/running the fixture.
e2e-tests/​Cargo.toml Add the new retention test crate to the workspace.
docs/​src/​development/​e2e-tests.md Document how to build/run the opt-in retention fixture and its prerequisites.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread scripts/lib/ec-qemu.sh Outdated
Comment thread scripts/lib/ec-qemu.sh Outdated
Comment thread scripts/test-time-alarm-retention.sh
Comment thread scripts/test-time-alarm-retention.sh Outdated
Comment thread e2e-tests/tests/time-alarm-retention/src/main.rs Outdated
Comment thread scripts/lib/ec-qemu.sh Outdated
@dymk
dymk marked this pull request as ready for review October 9, 2026 18:41
@dymk
dymk requested a review from a team as a code owner October 9, 2026 18:41
dymk and others added 5 commits October 13, 2026 19:05
Add an opt-in UEFI retention fixture that identifies GPIO1 wake versus the timer guard and restores firmware interrupt state. Exercise AC/DC selection, inactive and disconnected cases, and clear/rearm through the existing relay.

Assisted-by: GitHub Copilot:gpt-6-astra

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Real retention runs already perform the readiness checks. Remove the extra mode and target while retaining rejection of incomplete test results.

Assisted-by: GitHub Copilot:gpt-6-astra

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the real wake checks while consolidating interrupt state helpers, simplifying fixture lifetime management, and replacing duplicated test scaffolding with focused regressions.

Assisted-by: GitHub Copilot:gpt-6-astra

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Treat an empty optional EC_QEMU override as unset. Preserve an existing failure status during socket cleanup and report cleanup errors without deleting unexpected files.

Assisted-by: GitHub Copilot:gpt-6-astra

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Document the required QEMU argument and record each cleanup result before running the next step. Keep all cleanup attempts and preserve the first failure.

Assisted-by: GitHub Copilot:gpt-6-astra

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dymk
dymk force-pushed the dymk/time-alarm-retention-uefi branch from 551d978 to 485d9b2 Compare October 13, 2026 19:11
Comment thread e2e-tests/tests/time-alarm-retention/src/platform.rs Outdated
Identify PL061 and GIC registers, architectural control bits, and PSCI values by their documented names. Separate QEMU platform addresses and fixture timing policy without changing values or access order.

Assisted-by: GitHub Copilot:gpt-6-astra

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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

:shipit:

@dymk
dymk merged commit 1fad884 into OpenDevicePartnership:main Oct 16, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants