Files
mac_linuxgpu/linuxu/tests/partial_ttm_driverkit_backend.cpp
geramyloveless c969e84507 dart: no fixed DMA budget; the platform's refusal is the limit, logged
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.
2026-10-04 09:29:20 -07:00

28 lines
950 B
C++

#include "driverkit_dma_mocks.h"
#include "../../dext/sources/iokit_bridge.mm"
extern "C" int dext_copy_bar_memory(uint8_t, uint64_t *, void **) { abort(); }
static IOPCIDevice test_pci;
extern "C" void partial_ttm_bridge_start(void)
{
assert(!dext_dma_set_pci(&test_pci));
assert(!dext_dma_begin_probe());
}
extern "C" void partial_ttm_bridge_check(unsigned live, unsigned retired)
{
unsigned active = 0, held = 0;
for (auto &entry : dext_dma_table) {
if (entry.in_use && !entry.retired) active++;
if (entry.in_use && entry.retired) held++;
}
assert(active == live && held == retired && !mock_complete_calls);
}
extern "C" void partial_ttm_bridge_finish(void)
{
assert(!dext_dma_begin_shutdown());
assert(!dext_dma_begin_shutdown_reset());
assert(!dext_dma_end_shutdown_reset(1));
assert(!dext_dma_live_count() && !dext_dma_fini());
assert(!mock_objects && !mock_dma_prepared && mock_allocations.empty());
mock_complete_calls = 0;
}