Skip to content

media: apple: prores: preserve DMA ownership for bounded descriptor batches - #925

Closed
RyanTheTide wants to merge 4 commits into
integration/aurorafrom
fix/prores-staged-queue
Closed

RyanTheTide wants to merge 4 commits into
integration/aurorafrom
fix/prores-staged-queue

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

A descriptor-ring fetch cursor can reach the producer head before output DMA has finished. Returning buffers at that point permits their mappings to disappear while the encoder still owns them. This series retains the buffers, mem2mem scheduler slot and runtime-PM reference until completion, and prevents further submissions after a shared APR/DART domain reset. A failed reset quarantines ownership until machine recovery.

Publish a bounded batch of up to four descriptors at once, keeping depth 1 as the default. Require a separately acknowledged normal DONE for each descriptor, flush each ACK before another status observation, and use tail only to validate bounds and progress. Never extend a live batch or wrap within it. Dynamic-debug records allow qualification to verify actual head publication and completion counts.

This remains a draft hardware-depth experiment: sticky DONE status can coalesce events, which causes a conservative timeout rather than an inferred completion or early unmapping. Target runtime, interrupt-coalescing behavior, output exactness, compliance and performance remain unqualified. No throughput improvement or larger production default is claimed.

Validation:

  • Registered ASan/UBSan publication/IRQ/watchdog model: 7/7 checks, including six assertion-killed negative controls.
  • Descriptor/table/batch KUnit vectors through a userspace adapter: 12/12; not an in-kernel KUnit run.
  • Strict checkpatch for the hardware-depth commit: zero errors, warnings or checks.
  • Full Rust-enabled ARM64 fleet-config W=1 Image/modules/DTBs and signed install package build: PASS. Target qualification is pending.

Prepare up to four jobs while retaining the m2m slot and runtime PM reference until the whole batch has completed. Publish each descriptor only after DONE for the previous head: the fetch tail alone does not fence frame DMA. Keep buffers on the ready lists so drain and cancellation retain their existing ownership rules.

Use a validated depth parameter, defaulting to one. Stop further submissions after a domain reset, which also loses the shared DART translation state. Add completion-path host tests with fetch-ahead, error and early-release negative controls.
A failed or unavailable reset does not prove that MODE_OFF stopped frame DMA. Keep the m2m job slot, ready-list buffers and runtime PM reference instead of completing the batch. Mark both queues in error until a machine reset. Pin the fixed platform device and driver after any domain reset and disable manual unbind: a reload cannot restore the shared DART state.

Extend the host model to execute the actual watchdog with successful, failed and missing resets. Check that failure never releases buffers, PM or scheduler ownership, and add a negative control that frees the failed-reset batch.
Keep the qualified status-ACK then tail-read ordering before publishing the next descriptor. The readback completes posted ACK writes so an immediate handoff does not expose an old completion status to the new job.

Model posted W1C acknowledgements in the actual completion handler test, and detect moving the ACK after its readback.
Publish all descriptors in a bounded batch while retaining ready-list, scheduler and runtime-PM ownership until one separately acknowledged DONE has been observed for each descriptor. The fetch cursor can run ahead, so it only validates the batch bounds; it never supplies a completion count. Flush each posted ACK before sampling the next status. Never extend a live batch or wrap within a batch.

This is a conservative hardware-depth experiment, defaulting to one descriptor. Sticky status can coalesce DONE events; such batches fail closed through the existing watchdog/reset quarantine rather than infer completions or unmap live DMA. Neo runtime, interrupt-coalescing behavior and throughput qualification remain required before enabling a larger default.

Exercise the actual publication and IRQ/watchdog functions in the host model, including fetched-but-unfinished and coalesced batches, and add a stage-only negative control. Dynamic-debug publication/completion records distinguish real hardware queue depth from prepared jobs.
@RyanTheTide
RyanTheTide changed the base branch from aurora-wip to integration/aurora November 6, 2026 07:24
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Parking this PR. The queue-depth experiment no longer has a performance gap to close.

On 2026-11-09 I ran the Neo on fleet37 at depth 1 against macOS 26.6.2 VideoToolbox on the same input. 2160p 422 HQ: 429 fps on Linux vs 415 on macOS. 2160p 4444: 286 vs 278. 1080p: about 1670 vs about 850. Frame sizes were identical apart from macOS's padding. Before #848 and #899, Linux ran at about 60% of macOS at 2160p; that was the reason for queueing more than one descriptor. The method and data are in the #1248 body.

The rest of the series is the DMA-ownership rework. Its own depth-1 run showed DART "TTBR invalid" faults (t-4584), and there is no concrete root-cause hypothesis yet. If a ProRes timeout is ever seen in the field, the part worth keeping is a small depth-1 change on its own: keep the buffers, the mem2mem slot and the runtime-PM reference after a timeout or failed reset until the engine is proven quiescent.

🤖 Generated with Claude Code

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Closing as not needed: at queue depth 1 the current driver already beats VideoToolbox (2160p 422 HQ, 429 vs 415 fps), so bounded descriptor batching buys nothing measurable.

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