Files
mac_linuxgpu/linuxu/tests
geramyloveless 29b4e710d4 display: a presented frame no longer waits for its copy or flip
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.
2026-10-03 16:56:14 -07:00
..

linuxu tests

Standalone unit tests for the linuxu shim layer. Each test is a plain main() program using a local EXPECT() macro (no test framework — the dext cannot link gtest/libc-test deps).

Build & run

cd <repo>/linuxu
# host build (no DriverKit): -fsyntax-only first, then real link
clang -std=gnu11 -D__KERNEL__ -I<repo>/linuxu/headers \
  <test>.c <required shim .c files> -lpthread -o <test>
./<test>

The make test target (top-level Makefile) builds and runs all of them. Per-test required shim files:

test links with (shim sources)
test_kmemcheck kmem/kmemcheck.c kmem/kmemalloc.c kmem/string.c shims/printk.c
test_fake_mmio pci/pdev_mmio.c
test_vram amdgpu-rt/vram.c
test_irq amdgpu-rt/device.c pci/pci_stub.c shims/printk.c
test_workqueue work.c sync.c shims/printk.c
test_timer timer.c sync.c shims/printk.c
test_xarray xarray.c
test_rcu rcu.c shims/printk.c

What is REAL vs STUB

  • REAL (assertions exercise the actual algorithm): kmemcheck canaries, fake-MMIO token table + 16KB slots + readl/writel dispatch, vram bump allocator + pfn mapping, irq register/inject/unregister, workqueue (pthread worker + jiffy-delayed promotion + cancel_delayed_work_sync), timer_list (4ms reaper), xarray (node tree + xa_alloc), rcu (per-thread defer list + synchronize barrier).
  • STUB (documented, no assertions beyond "does not crash"): i2c (xfer → -ENOENT), acpi, mmu_notifier, dev_coredump, module, firmware (loader is REAL for the host build; the dext build swaps in the embedded-table path), debugfs/sysfs (table no-ops — could be extended with a test_debugfs later).

Running without a GPU

All tests run in-process on the host with no GPU, no IOKit, and no root. The fake-MMIO and vram backends use host shadow buffers; the LINUXU_DEXT compile flag switches them to the IOPCIDevice backends (compiled only for the dext bundle, not for these tests).