mirror of
https://github.com/lemonade-sdk/mac_linuxgpu.git
synced 2026-11-22 23:57:31 -10:00
Host to VRAM copies on the R9700 behind a TB5 enclosure top out at 1.65 GB/s (1.83 GB/s back), whatever the engine, chunk size or number of queues: the Gen2 x4 rate. IOPCIFamily shows why. The enclosure's downstream port (8086:5786, Link Capabilities 16 GT/s x4) and the GPU's switch upstream port (1002:1478) are linked at 5 GT/s x4. amdgpu_device_partner_bandwidth walks pci_upstream_bridge() past the dGPU's own switch ports and takes the platform's speed from the first other port's Link Capabilities. Our pci_upstream_bridge() returned NULL, so amdgpu_device_get_pcie_info took the platform speed as unknown and set the platform mask to Gen1|Gen2, and the SMU's PCIe DPM table is clamped to that: the link is held at 5 GT/s by policy, not by the hardware. DriverKit gives no configuration access past the endpoint, but the registry carries what IOPCIFamily read from each port. At Start the dext reads vendor-id, device-id, IOPCIExpressCapabilities and IOPCIExpressLinkCapabilities along its provider chain (CopyProviderProperties), skips the AMD entries as upstream does, and hands the first other port to the PCI shim (linuxu_pci_set_upstream_partner). pci_upstream_bridge() then returns a read-only stand-in for that port: vendor and device, and the PCIe Capabilities and Link Capabilities registers through pcie_capability_read_word/dword, so pcie_get_speed_cap, pcie_get_width_cap and pci_pcie_type answer for it. Every configuration access in the shim reaches the GPU endpoint whatever device it is given, so the stand-in refuses all of them rather than read or write the GPU's registers under the port's name. When the chain cannot be read, or has no such port, the dext says so in its log and amdgpu keeps its Gen1/Gen2 default. The other upstream callers stay as they were: the switch save/restore in amdgpu_device_cache_switch_state requires an AMD downstream port above the endpoint and returns on the stand-in's vendor, and amdgpu_device_gpu_bandwidth falls back to the endpoint's own capability as before. test-pci-dext covers the stand-in: absent until set, the registry's 16 GT/s x4 reported instead of the endpoint's 32 GT/s x16, downstream port type, no configuration reads or writes through it, cleared again. Not yet run on hardware: it needs a dext build, and the check is pp_dpm_pcie listing a 16 GT/s level and the host to VRAM rate rising past 1.65 GB/s.
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_debugfslater).
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).