Fix PD CFU timeout recovery - #129
Merged
asasine merged 5 commits intoSep 4, 2026
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
🟡 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
Successwhile preserving the caller’s output buffer. - Add a dedicated
TFUC_VERIFICATION_SLACK_MSmargin 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.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
RobertZ2011
reviewed
Sep 4, 2026
RobertZ2011
requested review from
felipebalbi,
jerrysxie,
kurtjd and
williampMSFT
September 4, 2026 19:08
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>
RobertZ2011
approved these changes
Sep 4, 2026
kurtjd
approved these changes
Sep 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
INT_EVENT_1bits into durable software state before awaiting the destructiveINT_CLEAR_1W1C write. Pending clear masks survive failure or cancellation, retry idempotently, and suppress duplicate delivery while preserving both general Type-C flags andCmd1Completed.CMD1/DATA1result now returnsSuccesswith response bytes intact (includingTFUqoutput); rejected, aborted, busy, malformed, and bus-error results retain their appropriate semantics.TFUcwithout inflating unrelated command timeouts.Confirmed evidence
Captured traces showed
Cmd1Completedread and W1C-cleared inside a 100 ms future, then cancelled at a 99.21 ms span before publication. The later command-timeout reconciliation readCMD1=Successbut mapped it toTimeoutand discarded the output buffer. A separateTFUcrun exhaustedRESET_DELAY_MS + 100 msjust before theAPP1mode read.This change is based directly on public v0.1.1 /
stable-v0.1.ycommit95d54c3caf36ab30fa093b1f9bef236e9829c060.Tests
cargo fmt --all --checkcargo clippycargo test(162 passed)cargo test --features embassy,log(178 passed)cargo hack --feature-powerset --exclude-features defmt test --all-targetscargo hack --feature-powerset check(16/16 combinations)