The DART has no fixed DMA budget (the platform's refusal is the limit,
logged), page descriptors grow with RAM, and kmemcheck is compiled only
in debug builds.
Conflicts, both sides kept: the shutdown hold still waits up to
DEXT_DMA_HOLD_DRAIN_MS for operations in flight, now without a budget
argument; test_iokit_dma keeps the in-flight hold, aperture gate and
large-mapping tests; the fence wait-any test keeps one 2 s bound.
The DART layer refused any mapping past a hard-coded 1.5 GiB of live
DMA bytes. Every dext page is DMA-backed, so GTT objects failed with
ENOMEM at 1439 MiB (97 MiB already mapped at start) although amdgpu
reports 64 GiB of GTT; llama.cpp's 1 GiB staging buffer and pinned host
buffers could not be allocated.
The limits that exist are the platform's: memory and wiring (the user
wire limit here is 108.8 GiB of 128 GiB, with 19.2 GiB kept for the
kernel), and the DART's IOVA window for the device, which the device
tree gives a Thunderbolt port's dart-apciec as 2047 MiB (IOVAs from
2 GiB). DriverKit enforces both: IOBufferMemoryDescriptor::Create or
PrepareForDMA fails. So:
- dart.c only accounts live-mapped bytes (used/peak); a mapping fails
when the seam fails it. linuxu_dart_budget and rt_dart_ceiling are
gone (rt_dart_peak reports the high-water mark).
- The seam logs each refusal with its size, the refusing call, its
IOReturn and what is already mapped (a run of identical refusals
logs its first and every 256th).
- The shutdown and probe holds take no ceiling. They count the bytes
mapped at their start and those mapped during them; retired mappings
keep their DART IOVA until the endpoint reset, so the DART refuses a
teardown mapping that would not fit beside them. A ceiling at the
live total would refuse every probe allocation (nothing is mapped
when the probe hold starts).
- The dext's mapping table and dart.c's streaming slots were fixed at
4096 entries, another wall: both grow in chunks that never move.
test_iokit_dma models the DART window and adds large mappings: a
1.5 GiB + 16 KiB mapping, a refused 512 MiB one (logged), 4500 live
mappings, and a teardown mapping refused beside retired ones under
the shutdown hold. test_session_shutdown closes a session with 6 GiB
mapped. test_dma_dart maps 3 GiB and 6000 live mappings.
Each of the three framebuffers remembers the damage it missed while the
others were drawn, and a frame copied that again from the client's
surface, so a frame crossed PCIe with the damage of the last two or three
frames, not only its own. The worker now copies what its buffer missed
from the buffer it drew last (VRAM to VRAM, always the front or the
pending one, so never the one being drawn); only the frame's own damage
comes from the surface. The VRAM copies run on the first engine after the
copies that drew the source buffer (scheduler dependencies) and the
surface's copies on the other engine wait for them.
PRESENT takes moves (rows that scrolled): width x height at (x, y) are
the previous frame's pixels at (x, src_y). The worker copies them from the
buffer drawn last, which holds that frame, before the frame's damage.
A frame that replaces one in the mailbox, or comes before anything was
drawn, has its moves (and the replaced frame's) copied from the surface:
the rows they come from were never drawn. Moves outside the frame are
refused. The request's reserved word becomes the move count (old agents
send 0), moves follow the rectangles, at most 32 and 4096 bytes in all.
The statistics become version 3: bytes is what came from the surface,
vram_bytes what was copied in VRAM, moved_rows and moves_dropped.
test_display_pipeline: frames 2-4 take only their own damage from the
surface and the rest in VRAM; scrolling under a fixed header and inside
a window with mailbox replacement, and moves at the frame's edges, leave
every scanout pixel equal to the surface; moves past the frame refused.
PRESENT hands the frame to the output's worker and returns. The worker
copies the frame's damage (plus whatever the target buffer missed while
off screen) into one of three scanout buffers with SDMA, split in
64-row bands across both SDMA rings when a frame is a MiB or more, and
flips with a nonblocking atomic commit. The copy fences sit in the
buffer's reservation, so the commit waits for them on the GPU's
behalf (the implicit in-fence) and the CPU does not. The flip's
out-fence wakes the worker from the flip interrupt; no thread polls.
A frame that arrives while one is still waiting replaces it and their
damage adds up. Surfaces are reference counted so the worker's hold
outlives a RELEASE. Statistics (version 2) report frames received,
flipped and replaced, bytes and jobs, the worker's submit time, GPU
copy time, and capture-to-flip latency from the vblank timestamp.
PRESENT with no rectangle reads the statistics only.
test_display_pipeline brings up DM on the CS fixture with two SDMA
engines and a vblank thread that raises the HUBP flip interrupt.
With the device removed (rt/removal.h), every display op returns
-ENODEV, and turning a pattern or output off commits nothing: the
recorded configuration is dropped and the buffers and client go as on a
Linux unplug. Surface imports, copies and checks return -ENODEV;
releasing still works and the client's mapping is returned once the
removal has completed the BO's fences.
The dext releases what the display ops hold in one place
(release_display_owners): at a session close unless a quarantine keeps
every owner, or the device is gone; and when a removal releases a
session that was quarantined, before compute stop and upstream removal.
Tests: test-session-shutdown removes the device under a display agent
with an output on screen and two imports, in a plain session, one that
quarantines during the close, and one quarantined before it (released
only by the removal); test-surface-import removes the device with an
import held; test-dm-offline removes it with the pattern on screen and
turns it off without a register write.
rt_surface_verify() reads 64 ranges of 256 bytes spread over an
imported surface with SDMA into a GTT buffer and, given a CPU view of
the client's memory, with the CPU, and counts the dwords that differ
from rt_surface_pattern(seed) — the pattern the client wrote. It is the
hardware test of whether the client's pages stay mapped and coherent
after the call that imported them.
Imports are kept in a table by owner (a user client) and handle:
rt_surface_add/get/remove, remove_owner for a client's stop, remove_all
for a session close; the provider context and the geometry are
available to the caller.
test-surface-import: three seeds read back exactly by the GPU and the
CPU view, and a wrong seed mismatches every dword; the table's lookups,
refusals and the three removals each release their surfaces.
rt/surface.h: memory of another process that the platform mapped for the
device (a display agent's IOSurface, mapped by the dext's IODMACommand),
given as DMA segments, is imported the way Linux imports any foreign
buffer: an exporter whose sg_table carries those DMA addresses,
amdgpu_gem_prime_import() (an SG BO), pinned in GTT and bound in the
GART. rt_surface_copy() copies dirty rectangles from it into an amdgpu
VRAM buffer with the SDMA buffer functions on the TTM entity: one copy
packet per contiguous run (whole rows with equal pitches are one range),
up to 1024 packets per job, the last fence added to both buffers and
waited for with a bound. The CPU touches no pixel and no other copy
mechanism exists.
The provider's release runs exactly once, when the dma-buf is released:
after the BO is destroyed, which TTM delays until its fences signalled.
A failed import never runs it.
The DART layer gains imported mappings (linuxu_dart_import): charged to
the budget and live for containment while imported.
test-surface-import runs it on the CS fixture device, whose software
SDMA engine reads system memory through the GART table upstream filled
and faults on anything the DART does not map: a surface in three
separately allocated segments, a whole frame with differing pitches (360
row copies, one job), damage rectangles with clipping, 1100 rectangles
(two jobs), a band with equal pitches (one packet), refused imports and
destinations, and the release after the BO is gone.