audit 0.21.0: rp2040 DCD/HCD follow-ups

Aperta
#4,531 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
8/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
c
Ambito
embedded-iot

Direzione di ricerca

These are four deferrable hardware-dependent defects in the RP2 DCD layer, each with cited lines: start with rp2040_usb.c:258,268,407 for the saved short/ZLP packet case, then dcd_rp2040.c:144,600,723 and rp2040_usb.c:92 for cached future bytes on cancel/stall, rp2040_usb.c:404 with dcd_rp2040.c:214 for the re-armed bulk OUT callback ordering, and dcd_rp2040.c:75,302 for reopen state retention. The adjudication notes list open spec questions (EP_ABORT_DONE quiescence, RP2350 short-packet-stop, MAIN_CTRL reads) that must be settled before any patch, and reproductions require RP2040/RP2350 boards. Done means a chosen storage/lifecycle design plus bench reproduction of consecutive short OUT transfers and ZLPs on both variants.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

follow-up Prio 📌

Deferred defects found in the repository audit of 0.21.0..ad7c83db8 (batch port-rp2). 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. A saved short packet smaller than the next receive is copied without completing that receive; a saved ZLP cannot be represented by future_len > 0. This differs from the normal completion path’s short-packet termination.
  • Where: rp2040_usb.c:258,268,407
  • Verdict: valid; introduced: Older; severity: medium
  • Hardware/spec dependence: Short/ZLP termination verified, D3; physical future-buffer reachability and RP2350 short-stop configuration need further checking
  • Overlap: None found
  • Remaining work and verification: Preserve packet presence separately from length and terminate on saved short/ZLP. Reproduce consecutive short OUT transfers and ZLPs on both RP2 variants before choosing storage changes.
2. Cancellation/stall paths preserve cached future bytes. A concrete MSC route is cached OUT data, a write callback failure causing OUT stall, then BOT reset and clear-halt: prepare_cbw() can consume those cached bytes. However, an ordinary ACTIVE transfer normally has no future data, and normal completion must preserve it.
  • Where: dcd_rp2040.c:144,600,723; rp2040_usb.c:92
  • Verdict: valid, with narrower trigger; introduced: Older retention behavior; new abort API inherits it; severity: medium
  • Hardware/spec dependence: Software replay path established; BOT flush requirements and hardware capture still pending
  • Overlap: #3962 is related, not full coverage
  • Remaining work and verification: Define reset/stall invalidation separately from normal rp2usb_reset_transfer(); clearing future data in every reset would break ordinary handoff.
3. A second completion can remain pending when the first completion invokes an application class’s xfer_isr. If that callback re-arms a bulk OUT receive, the remaining status can be applied to freshly armed buffers. Current built-in bulk classes defer callbacks; the supported application-driver hook supplies the concrete synchronous route.
  • Where: rp2040_usb.c:404; dcd_rp2040.c:214
  • Verdict: valid, conditional; introduced: Older; same callback-before-drain order at base; severity: medium
  • Hardware/spec dependence: D2 verifies double-status reassertion; abort/status-reset sequencing remains pending
  • Overlap: None found; #4476 concerns queued task events, a different mechanism
  • Remaining work and verification: Add a custom bulk xfer_isr reproducer; retire old status before allowing callback re-arm, with B0/B1 and RP2350 behavior checked.
4. Reopen resets buffer control but leaves ACTIVE/PENDING software state and pointers. E15 SOF can use that old state; cached future data also survives reopen. DPRAM capacity reuse does not create the lifecycle mismatch.
  • Where: dcd_rp2040.c:75,302
  • Verdict: valid; introduced: Older; base also preserved transfer state; severity: medium
  • Hardware/spec dependence: Software retention established; precise E15 wire consequence needs validation
  • Overlap: #4428 covers video reopen lifecycle; future-OUT variant overlaps C-F6 and is not explicitly covered
  • Remaining work and verification: Fix endpoint/class cancellation together; merely resetting DCD fields can leave usbd BUSY/CLAIMED and application ownership stranded.
Adjudication notes: port-rp2

No claim records were supplied. These are the limited inline read-doc records established during this pass; page numbers are physical PDF pages:

  • D1 — verified: double-buffer allocation premise. Calibre 2125, RP2040 Datasheet, February 2025, §4.1.2.7.3–4, pp389–390; 2124, RP2350 Datasheet, July 2025, §12.7.3.7.3–4, pp1150–1151. Both describe two 64-byte buffers. Combined with the allocator and CPU copy, this establishes S-F01/C-F1. Lookups 42ecede7c555, 34b255fe739c.
  • D2 — verified, limited: BUFF_STATUS can reassert after clearing when two buffers completed. Same books, Table 406 p405 and Table 1204 p1167, visually checked. This supports the stale-status premise, not every proposed abort/drain ordering. Lookups 92a2cf58e167, 182532389361.
  • D3 — verified, limited: USB 2.0 DATA0 reset and short/ZLP termination. Calibre 775, USB Specification 2.0, §9.4.5 p284 and §5.8.3 p81. These do not establish stream-style overflow retention or a universal clear-halt cancellation policy. Lookups f011c846b3f8, 857c96254976.
  • D4 — verified: RP2040-E2 prohibits EP_ABORT on B0/B1 and is fixed in B2; RP2350 documents the fix. Book 2125, Appendix B, pp631–632; book 2124, §12.7.2.1 p1144. The checked SDK’s RP2350 compatibility function returns 2, refuting a revision-gating mismatch. Lookups a148956b508f, eead83638517, 2930a1db38d5. E15 and RP2350-E12 were also consulted; neither establishes the proposed timing bounds.

Claims still needing read-doc completion:

  • S-F03/F05/F07, C-F7/F8: Precisely when do EP_ABORT_DONE and STOP_TRANS guarantee quiescence, what status survives buffer-control clearing, and when is a bounded discard safe on each affected revision?
  • S-F06: Does AVAILABLE alone determine the correct next PID after every host interrupt completion/error, in both directions and at low speed?
  • C-F4/F6, S-F04: What are the required device receive-overflow and BOT Reset Recovery buffer-discard semantics? Which cached bytes must survive a non-stalled clear-halt?
  • C-F5/F7: How does RP2350’s short-packet-stop configuration affect the second-buffer trigger in this driver?
  • S-F08/F09 and timing notes: Complete the E15-sensitive sequencing review. Maximum masked duration and XIP effects additionally require measurement.
  • S-F10: Confirm MAIN_CTRL read semantics before treating removal of its volatile reads as hardware-neutral.

No builds, unit tests, hardware reproductions or proposed changes were executed. Existing PR coverage was checked from live descriptions and relevant diffs; their reported bench results were not independently reproduced. The earlier review B blanket “no introduced actionable defect” conclusion is not sustained by N1–N3.

Files touched: none.

Lingua principale
C
Stelle
7.3k
Fork
1.6k
Merge medio
1g 19h
PR unite (30g)
67

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di hathach/tinyusb

Tutte le issue di hathach/tinyusb

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.