ehci: schedule restart after a timed-out stop writes the enable bit while it differs from status
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- c
- Domain
- embedded-iot
Research direction
Start with ehci_disable_schedule() and ehci_schedule_wait() in src/portable/ehci/ehci.c, then trace the callers qhd_cancel_xfer() and iso_stop(). Read test_abort_stop_unacknowledged() in test/unit-test/host/ehci/test_xfer.c and test_close_stop_failure() in test/unit-test/host/ehci/test_iso.c first. Done means both paths defer re-enabling until status acknowledges the stop, recovery is defined for a missing acknowledgement, and the tests cover late and absent status clears; hardware validation also needs fault injection.
Written by the indexing model from the issue text.
Description
From #4562 (EHCI wave: splits >1-qTD transfers, retires the QH overlay on abort), CodeRabbit review finding r4611426467.
Problem
EHCI 4.6/4.8: software must not change the Async/Periodic Schedule Enable bit unless it equals the corresponding Status bit. After a timed-out schedule stop, the driver writes the enable bit again without checking that.
ehci_disable_schedule()(src/portable/ehci/ehci.c:353-367) waits up to 16 microframes inehci_schedule_wait()(:336-348) for status to follow the enable bit and returns false on timeout. A timeout in the first wait (status never matched enable) leaves enable at 1. A timeout in the second wait (after the enable bit was cleared) leaves enable 0 and status 1.qhd_cancel_xfer()(:851-855) callsehci_enable_schedule()and returns false on either timeout. After the second kind this writes enable while it differs from status.iso_stop()close path (:1307,:1311) ignores the stop result and re-enables unconditionally, same case.
Trigger: a controller that does not acknowledge the schedule stop within the wait (2 frames). Not reproduced on hardware; the source path is verified at 15fb5b661 and exercised in the unit-test harness only (test_abort_stop_unacknowledged() in test/unit-test/host/ehci/test_xfer.c:523, test_close_stop_failure() in test/unit-test/host/ehci/test_iso.c:1112).
Dropping the re-enable is worse: commit bdb8571e0 on #4562 did that, and a unit-harness reproduction (forced unacknowledged stop, later status clear, new transfer on another endpoint, ISR) settled at enable/status 0/0 with nothing restarting the schedule. Async stayed dead until the next control watchdog abort, periodic until a later periodic abort or reset. Commit 15fb5b661 restored the re-enable as the accepted limit.
Solution
- Tell a timeout before the stop write (enable still 1, nothing to restore) from one after it (enable 0, status 1).
- Restart a schedule only once its status has acknowledged the stop: a deferred re-enable, e.g. on the next submission or in the ISR.
- Define controller recovery when the acknowledgement never arrives.
- Apply to both
qhd_cancel_xfer()andiso_stop().
Verification: update the two unit tests above and add fault injection for a late or never-arriving status clear. Hardware validation needs a controller that does not acknowledge within 2 ms.
Deferred: needs a recovery design beyond #4562's scope (#2645 transfer split, #4532 item 3 overlay retire), and cannot be validated on hardware without fault injection.
Related: #4532 item 4 — close ignores a failed schedule shutdown (close ownership and teardown contract, not the enable-bit sequencing); the code comment at ehci.c:852 points at #4532 for this recovery but its items do not cover it. #4564 — three-state hcd abort result in usbh (return-value contract, not the enable-bit sequencing).
- 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from hathach/tinyusb
-
follow-up Port WCH USBFS Prio 📌
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 1 day
-
follow-up Prio 📌
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
hil-contract: a background hil_remote.py launch is killed at the Bash default 10 min timeoutPossibly taken @hathach claimed this 16 days ago. Openfollow-up Prio 📌
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
ch32v30x: debug UART loses queued bytes when its TX ring fillsPossibly taken @hathach claimed this 16 days ago. Openfollow-up Prio 📌
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
followup Prio 📌
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
-
Missing slice offset check in jvp_equal fast path corrupts slice comparison and aborts delpathsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 3 days
-
Difficulty 1/5 Under an hour Newbie friendliness 83/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
area9innovation/flow9#1805 ·
Maintainers usually reply within 3 days
-
AI:Robustness triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
open5gs/open5gs#5246 · 1 comment ·
Maintainers usually reply within 1 day