Files
mac_linuxgpu/linuxu/tests
geramyloveless e317a1fb11 The device spec comes back as a versioned structure
QueryInfo tag 8 was never served by this driver (it declined with
kIOReturnNotReady), and the HSA runtime asked for it as 32 scalar
outputs, twice IOKit's limit, so mac_hsa_agent_get_device_spec always
declined.

The driver now answers tag 8 with a structure output, session_state.h's
struct mlg_device_spec (version 1, the bytes filled, a mask of the field
groups present). An async call gets it through OWNER_RESULT. Every field
is upstream's own:
- the GC geometry (gfx.config) and the KFD node's per-CU properties;
- the CUs, shader arrays and render backends upstream left active
  (gfx.cu_info, backend_enable_mask, num_rbs);
- on GC 12, the shader-array disable registers upstream reads for its
  own SA bitmap, read the same way without a GRBM select.
No register is written. A caller with less room than the structure gets
its first bytes, at least the header.

mac_hsa_agent_get_device_spec keeps its 32-word layout. A group the
driver does not report is zero. Words 23-27 (SH_MEM_CONFIG/BASES, the
shader-array config registers and GRBM_GFX_CNTL) stay zero, since
reading them needs a select, which is a register write. The CU bitmap
words carry two shader arrays for each of four engines. mac_hsa.h says
so.

Tests: test-device-topology checks rt_device_spec against upstream
state and register reads, including no register read off GC 12 or
without hardware access. test-dext-compute-production checks the
structure and its room. test-client-transports checks the HSA runtime
reading it through an owner call and OWNER_RESULT; before this change it
declined (0x1001).
2026-10-05 11:57:22 -07:00
..
2026-10-03 17:50:21 -07:00
2026-10-03 17:50:21 -07:00
2026-10-03 17:50:21 -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).