Skip to content

Fix PD CFU timeout recovery - #129

Merged
asasine merged 5 commits into
OpenDevicePartnership:stable-v0.1.yfrom
asasine:pd-cfu-timeout-fixes-stable
Sep 4, 2026
Merged

Fix PD CFU timeout recovery#129
asasine merged 5 commits into
OpenDevicePartnership:stable-v0.1.yfrom
asasine:pd-cfu-timeout-fixes-stable

Conversation

@asasine

@asasine asasine commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Publish INT_EVENT_1 bits into durable software state before awaiting the destructive INT_CLEAR_1 W1C write. Pending clear masks survive failure or cancellation, retry idempotently, and suppress duplicate delivery while preserving both general Type-C flags and Cmd1Completed.
  • Reconcile command timeouts with the original caller output buffer. A conclusively successful CMD1/DATA1 result now returns Success with response bytes intact (including TFUq output); rejected, aborted, busy, malformed, and bus-error results retain their appropriate semantics.
  • Reserve an independent 500 ms post-reset verification margin for TFUc without inflating unrelated command timeouts.

Confirmed evidence

Captured traces showed Cmd1Completed read and W1C-cleared inside a 100 ms future, then cancelled at a 99.21 ms span before publication. The later command-timeout reconciliation read CMD1=Success but mapped it to Timeout and discarded the output buffer. A separate TFUc run exhausted RESET_DELAY_MS + 100 ms just before the APP1 mode read.

This change is based directly on public v0.1.1 / stable-v0.1.y commit 95d54c3caf36ab30fa093b1f9bef236e9829c060.

Tests

  • Focused interrupt read/clear, W1C cancellation/failure/retry/dedup, command timeout success/output/rejection/error, and TFUc boundary regressions
  • cargo fmt --all --check
  • cargo clippy
  • cargo test (162 passed)
  • cargo test --features embassy,log (178 passed)
  • cargo hack --feature-powerset --exclude-features defmt test --all-targets
  • cargo hack --feature-powerset check (16/16 combinations)

Publish interrupt flags before clearing W1C state so cancellation cannot
drop completions. Reconcile commands that finish at timeout and reserve
independent TFUc verification slack.

Assisted-by: GitHub Copilot:gpt-5.6-sol
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 3, 2026 23:06
@asasine
asasine requested a review from a team as a code owner September 3, 2026 23:06
@asasine
asasine requested review from gjpmsft and tullom September 3, 2026 23:06

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

🟡 Changes recommended

The timeout reconciliation path still collapses completed-but-non-success return codes into Timeout, and publish_interrupt can drop buffered flags if given an out-of-range port index.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR improves robustness around TPS6699x interrupt handling and command timeout recovery, targeting observed failure/cancellation edge cases and TFUc timing boundaries.

Changes:

  • Split interrupt handling into a read/publish phase and a retryable W1C-clear phase by persisting pending clear masks in software state.
  • Refine command timeout reconciliation so a command that actually completed successfully can return Success while preserving the caller’s output buffer.
  • Add a dedicated TFUC_VERIFICATION_SLACK_MS margin to TFUc timeouts and cover it with a focused unit test.
File summaries
File Description
src/command/mod.rs Adjusts TFUc timeout calculation by adding a dedicated post-reset verification slack constant and test.
src/asynchronous/internal/mod.rs Introduces durable pending_interrupt_clears state and new read_interrupt / clear_pending_interrupts APIs with updated tests.
src/asynchronous/embassy/mod.rs Publishes interrupts prior to W1C clears, adds timeout reconciliation that can preserve outputs, and adds regression tests for cancellation/failure scenarios.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 3
  • Review effort level: Lite

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

Comment thread src/asynchronous/embassy/mod.rs
Comment thread src/asynchronous/embassy/mod.rs Outdated
Comment thread src/asynchronous/embassy/mod.rs
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread src/asynchronous/embassy/mod.rs Outdated
asasine and others added 3 commits September 4, 2026 13:51
Return completed command values unchanged when timeout reconciliation
confirms that the device finished the command.

Assisted-by: GitHub Copilot:gpt-5.6-sol
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@asasine
asasine merged commit cd7f91f into OpenDevicePartnership:stable-v0.1.y Sep 4, 2026
13 checks passed
@asasine
asasine deleted the pd-cfu-timeout-fixes-stable branch September 4, 2026 23:05
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