feat: PROVES USP radio integration (collapses PRs #1-#2) - #3
Conversation
…stuck Problem: if the USB host stops issuing IN tokens while a CDC-ACM TX transfer is in flight (e.g. a host-side driver that pauses polling without disconnecting), CDC_ACM_TX_FIFO_BUSY is left set indefinitely. The existing error-completion path clears the flag on disconnect or transfer cancellation, but a passive stall that never fires a completion leaves it stuck. Once stuck, uart_poll_out() keeps scheduling cdc_acm_tx_fifo_handler(), but the handler returns immediately on every invocation because the busy check short-circuits it, so the TX path stops draining permanently even after the host resumes polling. Mechanism: usbd_cdc_acm_disable() now clears CDC_ACM_TX_FIFO_BUSY, guaranteeing the flag starts clean on the next enable/reconnect cycle. Additionally, when cdc_acm_tx_fifo_handler() finds BUSY already set and the ring buffer still has data pending, it reschedules itself after a 10 ms delay instead of returning permanently. If BUSY clears normally when the in-flight transfer completes, the retry fires once more and is a no-op (the ring buffer is already drained). If BUSY is stuck because the host stopped acknowledging the IN endpoint, the handler keeps retrying every 10 ms at negligible CPU cost until the host resumes polling and the transfer completes. Fix: the pending retry re-arms the IN endpoint as soon as the host resumes issuing IN tokens, instead of requiring an explicit disable/enable cycle (e.g. USB replug) to recover the TX path. Signed-off-by: Michael Pham <phamlongmichael@gmail.com>
Problem: cdc_acm_poll_out() sleep-retries in an unbounded loop while the TX ring buffer is full and flow control is active. When a host session is attached but stalled (e.g. a host-side USB driver that stops issuing IN tokens for an extended period without disconnecting), this loop blocks for the full duration of the stall on every console byte written. Any thread that logs while this is happening backs up behind the stalled writer, and if enough producers share the same downstream queues, the backpressure cascades into a system-wide livelock rather than staying contained to the console path. Fix: cap the retry loop at 20 iterations of the existing 1 ms sleep (~20 ms total). Once the retry budget is exhausted, treat the still-attached-but-unresponsive session the same as the already-handled detached case: log once and discard the pending byte instead of continuing to block. This keeps the console best-effort under sustained backpressure while leaving the normal (non-stalled) flow-controlled path unaffected, since the loop still exits immediately once the ring buffer drains. Signed-off-by: Michael Pham <phamlongmichael@gmail.com>
…; retry when stuck
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Superseded by native GitHub stacked PRs #1 and #2 (stack zephyrproject-rtos#4, linked via Closing this integration PR; the |
Purpose
Collapses the two open CDC-ACM fix branches into a single integration branch off
v4.4.1-base, so the proves-core-reference superproject has one stablewestpin forzephyrinstead of tracking two separate branches.This branch is a
--no-ffmerge of PR #1 then PR #2, in order, ontov4.4.1-base. Both constituent PRs stay open for traceability/review; do not merge or close them as part of landing this branch.Constituent PRs
fix/cdc-acm-tx-fifo-drain-on-disable: clearsTX_FIFO_BUSYon CDC-ACM disable and retries when stuck, fixing a hang on repeated open/close of the USB CDC-ACM interface.fix/cdc-acm-poll-out-bound: bounds thepoll_outbackpressure wait in the CDC-ACM driver so it can no longer spin unbounded when the host stops reading.Both PRs touch
subsys/usb/device_next/class/usbd_cdc_acm.c; merge #2 applied cleanly on top of #1 (git auto-merge, no manual conflict resolution needed).Verification
Diffed the resulting
subsys/usb/device_next/class/usbd_cdc_acm.cagainst a pristinev4.4.1checkout with patches0005-fix-usbd-cdc-acm-stuck-tx-fifo-busy-on-disable-and-retry.patchand0007-fix-usbd-cdc-acm-bound-poll-out-backpressure-wait.patchapplied in order — byte-identical.Related