audit 0.21.0: nrf5x DCD follow-ups

Open
#4,529 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
8/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Active
Tech stack
c
Domain
embedded-iot

Research direction

Start by reading dcd_nrf5x.c around the cited lines (490-526, 720, 1266) and the ISO teardown paths in audio_device.c:1087 and vendor_device.c:513, alongside the linked #4062 and #4067 threads. The payload defers nearly everything to open hardware questions (Q1-Q7) that require Nordic reference manuals and physical nRF52 boards, so the first real task is establishing the DMA quiescence contract before touching code. Done means a documented deactivation/timeout sequence verified with packet and canary tests on both Nordic rig boards.

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-nordic). 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. Unplug polling count is not a millisecond deadline.
  • Where: dcd_nrf5x.c:1266
  • Verdict: valid arithmetic concern. At the comment’s estimated 570 cycles/scan, 64,000 scans take about 570 ms. Neither that duration nor a documented 1 ms requirement was measured/established.; introduced: Yes, teardown changes.; severity: medium
  • Hardware/spec dependence: Timeout and safe shutdown depend on hardware; Q1 pending.
  • Overlap: #4062, partial: covers timeout/shutdown safety, not the excessive polling duration explicitly.
  • Remaining work and verification: Extend #4062 with the arithmetic. Establish an appropriate deadline and timeout recovery before shortening the loop; measure unplug latency during traffic on both Nordic rig boards.
2. Altsetting teardown leaves ISO directions enabled and their mps nonzero; a later opposite direction incorrectly selects split capacity.
  • Where: dcd_nrf5x.c:516,520,526,720; audio_device.c:1087,1111; vendor_device.c:513
  • Verdict: valid. Audio omits close under ISO_ALLOC; vendor “deactivation” calls activate with the old descriptor. Old dcd_edpt_close() cleared mps, the enable bit and restored OneDir. SOF continues; actual OUT DMA still requires started.; introduced: Yes, ISO API migration.; severity: medium
  • Hardware/spec dependence: H1 verifies capacity consequence. Safe deactivation sequence remains Q4.
  • Overlap: #4067 is related, not covering: stale ISO-IN completion, not deactivation/capacity.
  • Remaining work and verification: Restore an explicit deactivation contract across core/classes/DCD. Verify IN→alt0→OUT and reverse with packets >512 bytes, retained simultaneous duplex behavior, and stopped idle SOF on both Nordic boards.
3. ISO reactivation retires software state without quiescing DMA before buffer reuse.
  • Where: dcd_nrf5x.c:511
  • Verdict: valid ownership gap, with corruption unmeasured. SETUP’s DMA wait does not exclude another DMA starting before task-side SET_INTERFACE executes. Generation checks suppress completion, not memory access.; introduced: Reactivation path introduced; old ISO close also lacked an END wait, so the underlying lifetime hazard is older.; severity: medium
  • Hardware/spec dependence: nRF52840 END/buffer-release rule checked; all-variant shutdown/retirement record remains Q4.
  • Overlap: #4067 partial only: its completion-filter concern is already guarded at :972; it does not resolve DMA access to retired RAM.
  • Remaining work and verification: Extend the ISO lifetime handoff with this distinct memory-ownership requirement; stress SET_INTERFACE during ISO OUT and verify buffer canaries on both boards.
4. No rejection of simultaneously active ISO directions exceeding split capacity.
  • Where: dcd_nrf5x.c:490,520,526
  • Verdict: valid validation gap, but ignoring allocation size alone is not the right diagnosis: mutually exclusive large alternatives must remain legal.; introduced: Older capacity gap: old open also selected HalfIN without checking sizes. Allocator stub is new.; severity: low
  • Hardware/spec dependence: H1 verifies capacity limitation; exact active-configuration validation belongs with Q4.
  • Overlap: None fully covering it found.
  • Remaining work and verification: Combine with ISO lifecycle/capacity handoff. Validate actual concurrent activation, not the sum of maxima across mutually exclusive alternatives.
Adjudication notes: port-nordic

Claims still needing read-doc:

  • Q1 — DMA/reset/shutdown: For nRF52820/52833/52840/5340, can USBRESET or VBUS loss terminate DMA without END? What establishes quiescence after timeout, when may ownership/latch be released, and what deadline is justified? Also verify owner-specific polling and END-clear ordering before S-F03/F04/F13 changes.
  • Q2 — SETUP capture: Can SETUP registers remain unreadable beyond the current wait, and how long are they retained before a subsequent SETUP overwrites them? The checked PS does not establish the #4060-specific behavior.
  • Q3 — control identity: Which EP0 tasks can affect a newly received SETUP, and what hardware freshness protection must remain if core generations replace local guards?
  • Q4 — ISO lifecycle: What END/quiescence and register ordering are required before disabling, repartitioning or reactivating ISO endpoints and releasing their RAM? Capacity is verified; a safe implementation sequence is not.
  • Q5 — EP0DATADONE: Can it occur for no-data requests or status stages such that status_ep cannot substitute for the captured request direction?
  • Q6 — register/protocol effects: Verify SIZE.EPOUT release behavior, SIZE.ISOOUT/event-read side effects, and USB requirements for clearing halt on an already unhalted endpoint.
  • Q7 — IN disarm: Does the nrfx test-register disarm suppress a DMA already underway, or can its later completion arm the packet again? This needs vendor evidence or hardware measurement.

Verification limits and claim records:

  • H1 — verified capacity premise, recorded here: nRF52840 PS v1.7 §6.35.11 p545, book 1947, lookup 0387ad729ace; nRF52833 PS v1.5 §6.33.11 p528, 1864, caa557545c96; nRF52820 PS v1.4 §6.26.11 p386, 6541, 8d8c28dabc85; nRF5340 PS v1.3 §7.39.11 p709, 1949, 49aa6e44601e. All describe shared ISO storage whose full-direction capacity is reduced when split. Relevant errata were searched; nRF52840 [166] was read at pp16–17 (3da37fdb3a2c, dec429f1ffec), and its initialization workaround is present at dcd_nrf5x.c:1207. This verifies the capacity finding, not a deactivation patch.
  • H2 — verified latch-order premise, recorded here: nRF52840 rev3 errata v1.4 §3.30 [199], p27, book 2148, lookup 4ed47d4ede07, requires clearing the latch after DMA completion. The timeout branch does not establish that completion.
  • No builds, unit tests, timing measurements or hardware runs were performed. Hardware outcomes described as hypotheses remain unverified.
  • No additional untracked, verified defect introduced by this range was established beyond the findings above.
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.