audit 0.21.0: EHCI and ChipIdea HS follow-ups (iTD/QH lifetime on close, IAA, abort)

Open
#4,532 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
12/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
c
Domain
embedded-iot

Research direction

This is a batch of seven hardware-dependent EHCI/ChipIdea HS defects, not one contained task. Start with the EHCI items in src/portable/ehci/ehci.c: read around lines 718, 819-836, 1055 and 1256-1276 alongside the cited EHCI spec sections E1-E3 to understand iTD/QH lifetime, IAA and overlay retirement. The ChipIdea items live in src/portable/chipidea/ci_hs/dcd_ci_hs.c around lines 189, 269, 556-565 and 725-749, with the existing close-failure test in test/unit-test/host/ehci/test_iso.c. Done means a defined quiescence/ownership contract plus RT1064 hardware validation, so expect spec reading before any patch.

Written by the indexing model from the issue text.

Description

follow-up Prio 📌

Deferred defects found in the repository audit of 0.21.0..ad7c83db8 (batch port-cihs-ehci). Each was validated against the source at ad7c83db8 and judged real but too large, or too hardware-dependent, for the audit PR's contained fixes.

1. HS idle test protects the transaction’s microframe, not the descriptor’s link lifetime. The controller can traverse the same iTD in another microframe while close zeroes/reuses it. busy == false also bypasses close’s wait entirely.
  • Where: src/portable/ehci/ehci.c:1055,1276
  • Verdict: valid; introduced: Yes: new ISO lifecycle; severity: high
  • Hardware/spec dependence: Yes; E1 supports traversal distinction; complete variant coverage pending
  • Overlap: None
  • Remaining work and verification: Separate transaction retirement from descriptor reclamation. Model a prefetched link; stress close/reopen during HS streaming on mimxrt1064_evk.
2. Every removing async QH is freed by the next IAA, without distinguishing removals made after that handshake began. A second doorbell cannot establish a separate generation while the first is outstanding.
  • Where: src/portable/ehci/ehci.c:718,1295
  • Verdict: valid; introduced: Older via device-close; endpoint-close exposure added; severity: high
  • Hardware/spec dependence: Yes; E2 verifies handshake scope
  • Overlap: None
  • Remaining work and verification: Track pending versus acknowledged removal batches and serialize doorbells. Test interleaved removals/IAA; validate bulk close/reopen on RT1064.
3. Stopping the schedule temporarily does not retire an active QH overlay. Abort changes next.terminate, frees the qTD, then resumes the schedule with overlay Active unchanged.
  • Where: src/portable/ehci/ehci.c:819–836
  • Verdict: valid; introduced: Older; present at 0.21.0; severity: high
  • Hardware/spec dependence: Yes; E3 verifies active-overlay execution bypasses queue advancement
  • Overlap: #4472 covers test infrastructure only, not this defect
  • Remaining work and verification: Retire/reset the overlay under a verified quiescence sequence, preserving required endpoint state. Test active-overlay abort and subsequent rearm; RT1064 bulk and interrupt IN.
4. Close ignores failed schedule shutdown, unlinks the TD, restarts the schedule and frees its storage. test_close_stop_failure() explicitly expects this unsafe success path.
  • Where: src/portable/ehci/ehci.c:1256–1276
  • Verdict: valid; introduced: Yes; severity: high
  • Hardware/spec dependence: Yes; source proves failure ignored; shutdown/recovery semantics still need lookup
  • Overlap: None
  • Remaining work and verification: Define a close failure/recovery contract that retains ownership until DMA stops; returning false alone is insufficient for all teardown callers. Fault-injection plus RT1064 close-under-load validation.
5. A downstream integration placing the fallback section in cacheable RAM now lacks descriptor maintenance. The warning does not enforce the new memory-placement contract.
  • Where: src/portable/chipidea/ci_hs/dcd_ci_hs.c:189; src/portable/ehci/ehci.c:216
  • Verdict: valid, conditional; introduced: New explicit requirement/removal of maintenance; old maintenance also had coherence limitations; severity: medium
  • Hardware/spec dependence: Yes; cache/MPU claim not yet covered
  • Overlap: None
  • Remaining work and verification: Decide explicit opt-in/error policy and migration guidance. Do not restore the unsafe whole-descriptor maintenance as a fallback. No failing downstream configuration was reproduced.
6. After late-reset recovery resets/reinitializes the controller, the ISR still consumes pre-reset int_status and pci_reason, potentially dispatching stale reset-end/resume events.
  • Where: src/portable/chipidea/ci_hs/dcd_ci_hs.c:269,725–749
  • Verdict: valid conditional path; introduced: Yes; severity: medium
  • Hardware/spec dependence: D1 supports late-reset recovery; complete simultaneous-status semantics pending
  • Overlap: None
  • Remaining work and verification: Return recovery status from bus_reset_begin() and terminate processing of the obsolete snapshot. Test both prior PCI reasons and reset failure; delayed-ISR reset/re-enumeration on RT1064.
7. dcd_edpt_iso_activate() ignores flush_endpoints() failure, rebuilds the QH and reports success despite failing to establish that the old transfer stopped.
  • Where: src/portable/chipidea/ci_hs/dcd_ci_hs.c:556–565
  • Verdict: valid conditional failure path; introduced: Yes: bounded failure replaced an unconditional wait; severity: medium
  • Hardware/spec dependence: D2 verifies successful flush requires acknowledgment and cleared endpoint status; other variants pending
  • Overlap: None
  • Remaining work and verification: Propagate failure before QH reinitialization and audit the caller’s ownership/retry behavior. Inject stuck FLUSH/STAT; validate repeated ISO alternate-setting changes on RT1064.
Adjudication notes: port-cihs-ehci

Checked the clean checkout at ad7c83db8 against 0.21.0. GitHub checks returned 190 open follow-up issues and 29 open PRs; “none” below means no matching coverage in those lists.

Paths: E = src/portable/ehci/ehci.c; D = src/portable/chipidea/ci_hs/dcd_ci_hs.c; T = test/unit-test/host/ehci/test_iso.c. C01 identifies the unnumbered review B P1 finding. “Valid cleanup” confirms duplication, not a correctness defect. Hardware claim references E1–E3/D1–D2 are recorded below; none were supplied with the request.

Read-doc claims still needing completion:

  • R01/R04/S10: For each supported ChipIdea host variant, when may software reclaim the entire iTD/siTD after unlink, including a cached next pointer? What recovery establishes DMA quiescence when PSS fails to clear? R01 is supported by the generic traversal model; a safe replacement sequence is not yet established.
  • R02/R03: Verify controller-specific async-handshake, overlay retirement and split-transaction constraints against base manuals and errata before implementing the generic-EHCI fixes.
  • R05: For the actual downstream linker/MPU configuration, are descriptor addresses cacheable and noncoherent? Which explicit configuration requirement should enforce safe placement?
  • R06–R08/A01: Complete LPC18xx/43xx, MCX, RW61x, HPM and other affected i.MX RT manual/errata coverage. Specifically: reset cleanup versus ordinary flushing; ENDPTPRIME timeout recovery; whether PCI/SLI/URI can remain co-pending across the stated histories; and which status must be discarded after controller reset.
  • Dropped hardware-changing proposals S04/S06–S08/S11–S14/S17/S18: Revive only with their specific claims checked: TT reservation/quirk applicability, register-read side effects and freshness, poll limits, memory-placement benefit, IST requirements, descriptor access widths, SBUSCFG presence/port restrictions, and SETUP word-read safety.

Read-doc evidence obtained, recorded here without creating a review file:

  • E1 — verified, generic traversal premise: Book 778, EHCI, Rev. 1.0, §4.7.1, PDF p77, lookup ba677bfd6a66: each frame-list entry is visited eight times; an inactive transaction still requires following its iTD’s next pointer. §4.7.2.1, p80, lookup 869b7cafa131, distinguishes transaction publication from caching. Book 2702, IMXRT1064RM, Rev. 2, §42.5.3.7.2.1, p2342, lookup 28be6d89f401, confirms per-microframe traversal despite “no caching.”
  • E2 — verified, generic handshake premise: Book 778, §4.8.2, pp82–83, lookups 869b7cafa131, de1706ad5f81: reclamation follows the handshake for the removed structures; the controller records reachable state when it observes the doorbell.
  • E3 — verified, generic overlay premise: Book 778, §§4.10.2–4.10.3, p91, lookup 3d3d58c830fb: Next-qTD termination governs queue advancement; an active overlay enters transaction execution.
  • D1 — refuted, R06’s normal-reset premise on RT1060: Book 2697, IMXRT1060RM, Rev. 4, §42.5.6.2.1, pp2394–2395, lookups 3e0f716518e6, e0fb3ff9feaf: prescribed cleanup writes FLUSH, checks reset is still active, then frees dTDs.
  • D2 — verified, ordinary-flush failure premise on RT1060: Book 2697, §42.5.6.6.5, pp2413–2414, lookups 29122174c5bd, 65e85737ef76: FLUSH acknowledgment alone is insufficient; endpoint status must clear, otherwise retry is required.

RT1060/1064 A/B USB errata were also searched/read: books 2528–2531, lookups 1c5d63d23e9b, 6658905000d6, f24833f4cccb, fc286e07a3a7. This does not constitute complete affected-variant coverage.

No builds, production unit tests or hardware runs were performed. An in-memory arithmetic reproduction confirmed R09 at now = 0x80000000, stale slot zero: scheduling retains the stale slot and completion treats it as future. Existing fixtures were inspected, not executed. No repository files were changed.

Dominant language
C
Stars
7.3k
Forks
1.6k
Avg merge
1d 19h
Merged PRs (30d)
67

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from hathach/tinyusb

All issues in hathach/tinyusb

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.