Skip to content

Serialize DMA transfers on the dext's descriptor ring and check the completed count - #94

Merged
timkpaine merged 1 commit into
mainfrom
tkp/dext-ring-lock
Oct 23, 2026
Merged

timkpaine merged 1 commit into
mainfrom
tkp/dext-ring-lock

Conversation

@timkpaine

@timkpaine timkpaine commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Closes V2 of the flip review, pending a build and a run on the mac with the card.

The macOS dext has one descriptor ring for both engines. DMATransfer writes each transfer's chain into it from index 0, so an H2C and a C2H transfer running at the same time could rewrite each other's descriptors mid-flight. Success was also judged from the status bits alone; the completed-descriptor count was read only for the failure log.

  • An IOLock in the driver's ivars, allocated in init and freed in free, is held from writing the chain until the completed count has been read, so one transfer owns the ring at a time. Nothing returns between the lock and the unlock.
  • completed == segCount is now part of success, so an engine that stops early without an error bit is a failed transfer.
  • test_concurrent_transfers_on_both_engines_round_trip (hardware, skipped elsewhere) runs two threads that each write a 1 MiB pattern and read it back 64 times, so their transfers interleave across both engines. It needs DAU_XDMA_MACOS=1 and DAU_XDMA_SCRATCH_ADDRESSES=<a>,<b>, two device addresses that are safe to overwrite, since which memory is free is board geometry.

Compiled, not run. make compile-unsigned (Xcode 27.1, DriverKit SDK) builds the dext for x86_64 and arm64 with no warnings or errors from the source, and the binary links IOLockAlloc, IOLockLock, IOLockUnlock and IOLockFree. To test on the card: build the dext in Xcode with CFBundleVersion above the installed one (the activated dext reports 8; Info.plist in the tree still says 7), activate it, then run the hardware tests above. Running the new test against the current dext first would show whether the race reproduces.

…ompleted count

Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.05%. Comparing base (459374b) to head (04f2f35).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #94   +/-   ##
=======================================
  Coverage   90.05%   90.05%           
=======================================
  Files          41       41           
  Lines        4132     4132           
  Branches      376      376           
=======================================
  Hits         3721     3721           
  Misses        305      305           
  Partials      106      106           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown

Test Results

220 tests  +1   217 ✅ ±0   6s ⏱️ ±0s
  1 suites ±0     3 💤 +1 
  1 files   ±0     0 ❌ ±0 

Results for commit 04f2f35. ± Comparison against base commit 459374b.

@timkpaine
timkpaine marked this pull request as ready for review October 23, 2026 19:36
@timkpaine
timkpaine merged commit 8f3583d into main Oct 23, 2026
9 checks passed
@timkpaine
timkpaine deleted the tkp/dext-ring-lock branch October 23, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant