Skip to content

fix(parlio): mock waitAllDone() pumps deferred ISR callbacks to mirror real-DMA semantics (#2992 follow-up) - #3010

Merged
zackees merged 1 commit into
masterfrom
fix/parlio-mock-isr-pump-on-waitalldone
Jun 14, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/parlio-mock-isr-pump-on-waitalldone

Conversation

@zackees

@zackees zackees commented Jun 14, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Closes the mock-vs-real-hardware gap introduced by feat: add ISR-backed channel poll wakeups #2992 ("feat: add ISR-backed channel poll wakeups"). That PR moved ParlioEngine's mTransmitting clear out of the txDone ISR and into poll(), switching beginTransmission() to true ASYNC mode. Two parlio_driver unit tests issue back-to-back beginTransmission() calls without an intervening poll() and have been failing on master since 2026-06-09 — every PR's unit tests linux job (feat(noexcept): annotate hot-path functions with FL_NOEXCEPT #2998, chore(deps): bump zccache floor to >=1.12.0 #3001, chore(deps): bump fbuild 2.2.22 -> 2.2.27 #3003) regresses the same way.
  • The mock previously fired txDone callbacks synchronously inside transmit() AND noop'd waitAllDone(). In ASYNC mode that leaves the engine's mTransmitting=true forever between transmissions, so the second beginTransmission() short-circuits with "transmission already in progress".
  • Fix: drive one ParlioEngine::poll() tick from the mock's waitAllDone() and deinitialize() — the two real-hardware-faithful boundaries where "no active DMA" is the contract. A single mSettlingEngine re-entrancy flag breaks the obvious recursion (poll calls waitAllDone(0)). The mock stays fully synchronous and single-threaded.

Why not fix the test?

The maintainer explicitly framed this as "the gap in the mock vs the real thing." On real hardware the engine's own line-1845 waitAllDone(100)-then-check-mTransmitting drain pattern at the top of beginTransmission() works because the ISR fires during the wait. The mock just didn't model that — waitAllDone() was a noop. Fixing the test would paper over the gap; fixing the mock makes it accurately model the real-DMA contract.

What was tested

  • bash test parlio_driver — passes (both originally failing tests: "ParlioEngine mock - transmission history clearing" at line 671, and "verify captured DMA data is non-zero" at line 1011).
  • bash test parlio_driver --debug — passes with ASAN/LSAN/UBSAN sanitizers enabled. No memory errors, no UB.
  • bash lint --cpp — clean.

No changes to the engine. No changes to any test. Single file touched:
src/platforms/esp/32/drivers/parlio/parlio_peripheral_mock.cpp.hpp (+47/-2).

Test plan

  • bash test parlio_driver passes (quick mode)
  • bash test parlio_driver --debug passes (ASAN/UBSAN clean)
  • bash lint --cpp clean
  • CI unit tests linux job goes green on this PR

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed transmission state management in the ESP32 mock peripheral to prevent stale states persisting across back-to-back transmissions.
    • Added re-entrancy protection to ensure proper state settlement during engine operations.

…r real-DMA semantics (#2992 follow-up)

After #2992 ("feat: add ISR-backed channel poll wakeups"), `ParlioEngine`
runs `beginTransmission()` in ASYNC mode: the last txDone ISR sets
`mStreamComplete=true` and the *next* `poll()` tick observes that flag
and clears `mTransmitting` (the gate that begins a new transmission).
The old engine cleared `mTransmitting` directly in the ISR, so callers
that issued back-to-back `beginTransmission()` calls without an
intervening `poll()` still worked. After #2992 they no longer do.

Two `parlio_driver` unit tests issue exactly that pattern and have been
failing on master since 2026-06-09 (every CI run on PRs #2998, #3001,
and the just-merged #3003 fails the same way):

  FAIL: ParlioEngine mock - transmission history clearing at
    tests/platforms/esp/32/drivers/parlio/parlio_driver.cpp:671
      :694: count2 > 0
      :695: mock.getTransmitCount() > count1
  REQUIRE FAILED: parlio_driver.cpp:1029: tx_ok

On real hardware the engine's own line-1845 drain pattern
(`mPeripheral->waitAllDone(100)` at the top of `beginTransmission()`)
gives the ISR a chance to fire and then a `poll()` tick can clear
`mTransmitting`. The mock, by contrast, fires txDone callbacks
synchronously inside `transmit()` and used to noop `waitAllDone()`, so
no `poll()` tick ever ran — `mTransmitting` stayed stuck at true
forever and the second `beginTransmission()` short-circuited with
"transmission already in progress".

Fix the mock, not the test (per the maintainer's "gap in the mock vs
the real thing" framing): drive one `ParlioEngine::poll()` tick from
the mock's `waitAllDone()` and `deinitialize()`. Those are the two
real-hardware-faithful boundaries where "no active DMA" is the
contract — `waitAllDone()` is the engine's own pre-transmission drain
point, and `deinitialize()` is what the engine calls from its
config-match re-init path at parlio_engine.cpp.hpp:1411 (the route
test 1029 takes). A single `mSettlingEngine` re-entrancy flag breaks
the obvious recursion (`poll()` itself calls `waitAllDone(0)`).

The mock stays fully synchronous and single-threaded — no new threads,
no new deferred-callback states, no churn in the existing
pumpDeferredCallbacks/mFiringCallbacks machinery. Only the engine
async-state contract gets one extra tick at each transmit boundary.

No engine changes. No test changes. Verified:
- `bash test parlio_driver` passes (both originally failing tests)
- `bash test parlio_driver --debug` passes (ASAN/LSAN/UBSAN clean)
- `bash lint --cpp` clean

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 14, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 303d0506-55b5-4faa-b230-1bd39501de94

📥 Commits

Reviewing files that changed from the base of the PR and between 9314cb4 and 9e281e6.

📒 Files selected for processing (1)
  • src/platforms/esp/32/drivers/parlio/parlio_peripheral_mock.cpp.hpp

📝 Walkthrough

Walkthrough

A mSettlingEngine re-entrancy guard and private settleEngineState() helper are added to ParlioPeripheralMockImpl. The helper drives ParlioEngine::poll() at teardown and completion boundaries; deinitialize() and waitAllDone() call it to flush stale async engine state. reset() clears the new guard flag.

Changes

Engine state settling at transmit boundaries

Layer / File(s) Summary
New field and method declarations
src/platforms/esp/32/drivers/parlio/parlio_peripheral_mock.cpp.hpp
Declares mSettlingEngine bool member and private settleEngineState() FL_NOEXCEPT on ParlioPeripheralMockImpl; initializes mSettlingEngine to false in the constructor.
settleEngineState wired into deinitialize, waitAllDone, and reset
src/platforms/esp/32/drivers/parlio/parlio_peripheral_mock.cpp.hpp
deinitialize() calls settleEngineState() before clearing lifecycle flags; waitAllDone() calls settleEngineState() then sets mTransmitting=false; settleEngineState() conditionally calls ParlioEngine::getInstance().poll() behind the re-entrancy guard; reset() clears mSettlingEngine.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A rabbit hops through async lanes,
Where engines poll and state remains,
A guard now stands at every door,
No stale mTransmitting anymore!
🐇✨ settleEngineState() — problem solved!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing a mock implementation gap where waitAllDone() needs to pump deferred ISR callbacks to match real DMA semantics.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/parlio-mock-isr-pump-on-waitalldone

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant