21 Commits
Author SHA1 Message Date
geramyloveless c3c8521137 PCI restore puts back the BARs and MSI-X a device reset clears
A mode1 reset clears the GPU's configuration (BARs, command, MSI-X) and
nothing in macOS writes it again; upstream caches it before the reset
and restores it after (amdgpu_device_cache_pci_state/load_pci_state).
pci_restore_state refused any BAR change (-ESTALE, the transport-fault
latch) and never restored MSI-X, so a device reset could only end in a
quarantine.

The saved state now also holds the MSI-X capability's control word and
the table entries DriverKit programmed (read from the table's BAR
through the kernel, dext_pci_bar_read32), the vectors in use first.
Restore checks it is the same function with the same capability layout,
then writes back the header as the host assigned it (cache line and
latency, BAR0-5, the ROM BAR, the interrupt line) with memory decode off
until every BAR reads back its value, the PCIe controls, MSI-X (function
masked while the table is written, each entry verified, then the saved
control), and the command last. A BAR or table entry that does not take
its value fails the restore as before. The values are the host's own
assignment: nothing moves behind the host bridge.

test_pci_dext covers a reset that cleared the BARs, ROM and command, a
BAR that does not take its value, MSI-X saved and written back, and a
table entry that does not take its value.
2026-10-06 17:18:27 -07:00
geramyloveless eb16490b9c PCIe: give amdgpu the port above the GPU's switch, so the link can leave Gen2
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.
2026-10-05 16:46:33 -07:00
geramyloveless c282a82741 MMIO tokens live in their own address range; process memory is memory
The display's rejoin with LSE loaded knocked the GPU "off the bus" on 248
and 249. The new framebuffers' pin evicted LSE's VRAM, and the eviction's
SDMA copy maps its window through amdgpu_ttm_map_buffer. That calls
amdgpu_gart_map, and amdgpu_gmc_set_pte_pde writes the PTEs into the copy
job's IB, which is ordinary process memory, with writeq(). Linux allows
this. The DriverKit accessors decoded every address outside the BAR0
aperture as a synthetic token (address / 256 GB), so the IB at
0x127849020 became token 0, "a lost mapping". The first such write
recorded a definite MMIO transport fault, which closes PCI admission and
quarantines DMA. Upstream then reported "device lost from bus" with the
GPU still on it, and every client's work hung. The fault's call chain
(next commit) named the site.

The encoding also overlapped real memory in the other direction. A
process mapping above 256 GB decoded as a live token, and a store to it
went to that token's BAR.

Tokens now start at 2^48, above the arm64 user VA ceiling, where no
process memory can be. Token 0's range is never minted. Decoding means
"inside that range", nothing else. readX/writeX, memcpy_toio/fromio and
memset_io go to:
- the BAR0 aperture: the kernel, as before;
- the token range: MMIO for a live token, a loud fault for a stale or
  never-minted one;
- below 4 GB (__PAGEZERO, a null-based bug): a fault, as before;
- anything else: a plain load or store, ordered as Linux orders readX
  and writeX.

test_mmio_dk_accessors checks:
- a live register token goes to MMIO;
- PTE writes into an IB through amdgpu_gmc_set_pte_pde's own expression
  are plain stores, as are memset_io and memcpy_to/fromio on heap memory;
- a process mapping that the old scheme decoded as the live register
  token is plain memory;
- a stale token, token 0's range and a null-based address still fault
  and touch nothing.
2026-10-05 16:30:21 -07:00
geramyloveless 0ee07c4401 MMIO token numbers are renewed between sessions
Every DriverKit MMIO mapping takes a token number (1..511) that doubles
as its synthetic pointer. To keep a stale pointer from reaching a
different mapping, an unmapped number was never issued again, so each
session consumed about four for good: the register token, upstream's
register ioremap and the kernel doorbell kmap among them. After roughly
120 session open/close cycles none were left; the doorbell kmap failed
and the probe returned -ENOMEM (242: "kernel bo map failed",
quarantine, restart required).

The numbers are now renewed when the last mapping is unmapped. The
session's register token lives from dext_open to dext_close, so an empty
table means no session, no upstream module and no synthetic pointer
remain. Within a session an unmapped number is still never reissued.

test-session-cycles runs 300 session open/probe/close cycles through the
real upstream probe and the production PCI, MMIO-token and heap code
against a mock IOPCIDevice, and checks after every close that no MMIO
mapping survives and that heap, DART-mapped bytes and mappings, page
descriptors and threads are at their baseline. Before this change it
fails at cycle 255 with the probe returning -ENOMEM. The DriverKit token
bounds test also covers renewal and in-session non-reuse.
2026-10-05 00:25:22 -07:00
geramyloveless ec8198541d lx: no request that can sleep runs on the driver's incoming-call thread
On 241 a request that waited on a GPU ring that had stopped ran on the
one thread DriverKit delivers every client's calls on: every client froze,
and the driver could not take its own Stop after the GPU was powered off.

Every Linux-file request that can sleep now runs on a worker of the
client's process and completes through AsyncCompletion:
- mlg_lx_cmd_sleeps (lx_describe.c, shared by the client library and the
  driver) names the few requests that provably do not sleep: VERSION,
  GET_CAP, SET_CLIENT_CAP, the syncobj create, destroy, export, import,
  reset, signal, timeline signal, query and eventfd requests, a syncobj
  wait that only polls, and KFD GET_VERSION. Everything else is async,
  AMDGPU_CS, INFO, GEM and context requests included.
- LX_IOCTL runs only those, through rt_lx_ioctl_nosleep; any other is
  refused without running (kIOReturnNotPermitted) and logged with the
  request and the process.
- LX_CALL_ASYNC (selector 105) runs open, close, mmap and munmap on a
  worker; the synchronous selectors 96, 97, 101 and 103 are retired.
- A Linux-file client's Stop hands its process's exit to a thread of its
  own (rt_lx_client_retire) instead of waiting for its calls on the
  incoming-call thread; a session close waits for those exits
  (rt_lx_retire_drain) before the driver goes. On an unplug the Stop has
  already begun removal, which completes the GPU's fences, so the exits
  finish.
- An async call holds one of MLG_LX_MAX_ASYNC slots until its result is
  delivered: with the completion (the slot frees before it is sent) or by
  LX_RESULT, whose result is in place before the completion goes out. The
  client library keeps its calls within the limit, waiting on its own
  thread. A worker still sending a completion holds no slot, so a call
  queues for it instead of failing.
- The transport revision is MLG_LX_ABI 2: libmlg_drm's dylib
  compatibility version, and the text MLG_LX_ABI_TAG in the library for
  launchers to check. A client library older than this driver fails at
  its first sleeping request or open, with the reason in the driver log.

Events reach the unified log; routine lines stay in the retained ring.
The dext logged every line through os_log, and nothing from it reached
the unified log in the boot where 241 hung (probably quarantined for
volume), so the hang's cause was lost with the dext. Now only events go
there, prefixed "mac.linuxgpu: EVENT ": driver start, probe outcome,
removal, quarantine and release, session close, DMA mapping failures,
printk at error level and above (ring timeouts among them), and the head
of a device coredump, which dev_coredumpm now logs before freeing it.
Read them with
  log show --predicate 'eventMessage BEGINSWITH "mac.linuxgpu: EVENT"'

Tests: test_lx_files covers the table, the synchronous refusal, the
operations on workers, inline and fetched results and the new slot rules.
blocked_call_check (test-cs-selftest) blocks a client's AMDGPU_CS behind
amdgpu_sched_jobs submissions on a held compute engine and checks that
every call returns at once, the blocked client's non-sleeping request
runs and its sleeping one is refused synchronously, another client opens,
allocates and completes SDMA work, the blocked client's Stop returns at
once and its exit finishes when the engine runs, and, during the surprise
removal check, that removal ends a blocked submission and the client's
exit completes.
2026-10-04 20:27:43 -07:00
geramyloveless b4d1555088 linuxu: an ALLOC1 xarray never hands out index 0
xa_alloc ignored XA_FLAGS_ALLOC1, so the first DRM syncobj of every
render-node file got handle 0, which userspace and upstream read as "no
syncobj". Linux keeps index 0 busy in such an array; the shim now starts
its search at 1. DEFINE_XARRAY_ALLOC also defined an ALLOC1 array, unlike
upstream (where ALLOC counts from 0 and ALLOC1 from 1); DRM's minors use
it and would have moved to card1.

test_xarray_limit checks both kinds.
2026-10-04 20:27:43 -07:00
geramyloveless 4968adb4de VRAM only through the kernel: no CPU access through a BAR mapping
Unplugging the GPU with the display live panicked the Mac on 239 and 240
(LLC bus error, NC write, in the dext). On 240 the panicked thread was in
an atomic commit powering the display down after the agent's framebuffers
were removed: dmub_srv_fb_cmd_execute, with dmub_rb_push_front having
stored the command into DMUB's inbox in VRAM one byte at a time through
the dext's user-space mapping of BAR0. The removal was already under way
(Stop, removal_main, the aperture gate set); the error is reported only
after the store has retired, so no check before a store can prevent it.
Register accesses, through the kernel's IOPCIDevice MemoryRead/Write, ran
in the same commit after the link went down and never faulted.

So every access to the VRAM aperture goes through the kernel:
rt/aperture.h's read/write/copy/fill route through ops the dext installs
with the PCI device (BAR0 MemoryRead/MemoryWrite 8 to 64 bits, BAR0's
index and size read once). linux/io.h's readX/writeX, memcpy_toio,
memcpy_fromio and memset_io, the 64-bit MMIO atomics and the string
functions (memcpy, memset, memmove, memcmp) route aperture addresses
through them; the gate still skips writes and reads all ones once the
device is known gone. The GART page table in VRAM, written with writeq on
every GTT bind, now goes this way too.

dmub_cmd.h's inline dmub_rb_push_front (a byte loop) and
dmub_rb_flush_pending (READ_ONCE) reach the inbox with plain pointer
accesses no shim can route. A declared compile intervention for
dmub_srv.c (rt/dmub_inbox.h) includes dmub_cmd.h first and redirects its
two calls to the same operations written with dmub_memcpy, as upstream's
dmub_rb_out_push_front copies. Upstream sources stay unchanged.

Offline proof: the CS fixture gives the driver VRAM only as a no-access
alias of its pages, reached through the aperture's ops; the host
library's upstream objects alias the string functions as the dext's do.
Any direct load or store through a kernel VRAM pointer now crashes the
offline tests. With the two DMUB helpers redirected, every test passes:
the display pipeline (with its removal check now on the fixture's real
aperture), scanout, surface import, CS selftest, KFD and the rest.
2026-10-04 17:48:52 -07:00
geramyloveless 4b142d018e Merge feature/radv-apple-vram (d132e25) into display-c
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.
2026-10-04 10:08:00 -07:00
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
geramyloveless 3266899b74 display: copy a region redrawn in place once per flip
Measured on the R9700 (build 235, the Dell at 2560x1440): a window
redrawing a 1732x1140 region every frame made every flip copy about
24.8 MB from the capture surface, three times the region: the frame's
damage plus the same region again for each scanout buffer that had
missed it, kept as separate rectangles. At 0.73 ms per MiB over
Thunderbolt that is 17.3 ms of copy per 16.7 ms frame, so frames were
replaced before they could flip (55 flips/s) and the picture lagged; a
full-screen workload stopped the output when its copies backed up past
the flip timeout.

Damage now folds a rectangle into any it overlaps closely (contained,
equal, or overlapping so the box is no larger than the two), so the
region stays one rectangle and is copied once; damage covering nine
tenths of the frame becomes one whole-frame copy. The flip wait first
waits for its own copies (bounded at 2 s, as GPU work), then for the
flip (200 ms), and says which did not complete.

printk_once and the DRM *_ONCE messages are now once per call site:
DM's MST/DSC check logged "dsc precompute is not needed" on every
commit, sixty times a second, filling the kernel log.

The display agent also finishes launching as a background agent only
after its virtual display has a mode: made an NSApplication earlier,
the process never saw the new display's modes.

test_display_pipeline: a window redrawn in place with an item inside
it copies the window's bytes once per flip.
2026-10-03 20:01:06 -07:00
geramyloveless a7f4f41f99 linuxu: HZ is 1000
At HZ=100 a millisecond timeout became a 10 ms jiffy, so KFD's
WAIT_EVENTS and every msecs_to_jiffies timeout was rounded up to 10 ms.
Nothing ticks in linuxu (jiffies are read from the clock and every
sleep is a deadline), so a 1 ms jiffy costs nothing. The jiffies test
checks the 1000 Hz conversions.
2026-10-03 17:50:21 -07:00
geramyloveless aa0aca57a9 linuxu: waits park until woken instead of polling every millisecond
wait_event and its variants, schedule_timeout, completions, contended
mutexes, rw semaphores and semaphores, and dma_fence waits all slept in
1 ms (or 50 us) steps and re-checked, so every sleeping thread woke about
a thousand times a second, waiting or not.

They now park (rt/park.h): a futex over addresses, with condition
variables in hashed buckets, where the waker changes state and unparks
the key and the waiter re-checks under the bucket lock, so no wake is
lost. Tasks park on themselves and linuxu_task_wake unparks them, which
covers wake queues, wake_up_process, signals and kthread_stop.
wait_event queues the task on its wake queue as Linux does; fence waits
add a callback that unparks.

Every wait whose condition it can test is bounded by a backstop that
starts at 2 ms and doubles to 1 s while nothing happens, so an idle
waiter costs about one wakeup a second. A backstop that finds the
condition already true means its producer did not wake it: the wait
site is reported once (file and line, or the caller's address) and
counted. schedule_timeout returns early at the 1 s backstop, a spurious
wake as Linux allows.

test_wait_event checks that a wake_up wakes its waiter at once and not
another, that schedule_timeout ends at wake_up_process, that an idle
300 ms wait wakes 8 times rather than 300, and that the backstop finds
a producer that never wakes (its existing producer is one).
2026-10-03 17:50:21 -07:00
geramyloveless 457a75876b dext: survive the GPU leaving the bus
Unplugging the eGPU with a session open took the whole iPad down. When
its PCI provider and clients are terminated the device is already gone,
but the close treated it as a GPU that might still run: every teardown
step waited on hardware that never answered, the session quarantined
(retaining the provider, the DMA backing and the upstream driver), and a
dext that dies while it holds the device panics the kernel in
IOPCIFamily's client crash recovery, as on the Mac.

Detect the removal when a client or the driver stops: configuration
space no longer answers (asked on the provider directly, since a fault
may have closed admission). From then on nothing touches the device:
admission closes for good, nothing resets or isolates it, BAR0 CPU
accesses through the io accessors read ~0 and drop writes, and the
runtime's removal begins (GPU work completes with -ECANCELED). A device
off the bus can reach no memory, so DMA safety holds: the DMA seam lifts
a quarantine and its holds and completes retired descriptors at once,
compute stop and client release stop refusing on account of uncertain
GPU work, and no step quarantines. The close runs to the end, removes
the upstream driver after the removal thread stops, releases the BAR0
aperture and closes the provider once nothing is admitted and no
interrupt source is left, then reopens admission so the replugged GPU
probes afresh. A session already quarantined when the removal is seen is
released the same way. New session opens fail with kIOReturnNotAttached
meanwhile.

The power state goes to lost with the new cause "device removed" and
the link-down flag, so clients learn what happened; the session state
has a device-removed flag and read-driver-log.py names both.

Tests: the session shutdown fixture removes the device under a client's
open session whose compute stop fails, and under a session already
quarantined; neither resets, isolates or quarantines, every Stop
finishes, and a new client opens a new session. The production backend
stops a device whose legacy queue could not be removed once it is
removed.
2026-10-03 15:44:38 -07:00
geramyloveless 0f426a08de linuxu: surprise removal of the GPU
A GPU that leaves the bus (a Thunderbolt unplug) left every waiter on
its work waiting forever: fences of jobs the hardware will never run,
MES requests polled for their full timeout, and sessions that kept their
memory because nothing confirmed the GPU let go.

Give the runtime the state Linux's PCI core and amdgpu_pci_remove give a
surprise-removed device. struct pci_dev gets error_state, set to
pci_channel_io_perm_failure by linuxu_pci_mark_removed, so
pci_dev_is_disconnected and pci_device_is_present answer without
configuration access and amdgpu's removal takes its hot-unplug branches.
rt_removal_begin marks the device, sets no_hw_access, makes the DRM
device count as unplugged for drm_dev_enter (render-node ioctls then fail
with -ENODEV and guarded paths skip the hardware, GART writes among
them), and force-completes every ring's fences with -ECANCELED, as
amdgpu_fence_driver_hw_fini does for an unplugged device; a removal
thread keeps doing so for work submitted while the sessions close, until
rt_removal_end. MES requests then fail at once.

A removed device can reach no memory: a KFD session drops a queue whose
removal fails and a copy that never finished, the compute context
releases memory a timed-out copy left poisoned (and its fence), and the
CS self-test reaps a parked test once the device is gone.

Tests: on the CS fixture the device is removed with a compute job held,
an SDMA copy held and waited on without a timeout, a parked self-test
and an open render-node client; every wait returns with -ECANCELED, both
processes exit, new opens fail and nothing touches the hardware. A KFD
session closes cleanly after removal with MES dead and a copy pending,
and the compute context frees its poisoned memory.
2026-10-03 15:44:38 -07:00
geramyloveless 6dffacefc1 linuxu: keep uuid_t apart from the SDK's; constant FIELD_GET masks
linux/mod_devicetable.h now includes linux/uuid.h as upstream does, which
brings the kernel uuid_t into tests that also include <unistd.h>, where
the macOS SDK declares its own uuid_t. The kernel type is spelled
linuxu_uuid_t underneath and the SDK typedef guard (_UUID_T) is set, so
both orders compile.

The vendored upstream linux/bitfield.h rejects non-constant FIELD_GET()
masks at compile time, as Linux does; the primitive-headers contract now
checks a set of constant single-bit masks instead of a runtime loop.
2026-10-02 21:22:41 -07:00
geramyloveless 965c4af2be linuxu: library services the display code links against
- get_random_bytes()/get_random_u*() from the platform CSPRNG
  (arc4random_buf(), which DriverKit's libSystem also provides); DP MST
  uses it for sideband nonces.
- lib/uuid.c built unmodified as a helper (guid_gen(), guid_null for DP
  MST branch GUIDs), with hex_to_bin()/hex2bin()/bin2hex() from
  lib/hexdump.c and the upstream linux/hex.h.
- kstrtobool() and kstrtobool_from_user() from lib/kstrtox.c for the
  DC debugfs write handlers.
- vzalloc() for the DML/DML2 work areas.
- Upstream headers and helpers: linux/bitfield.h and linux/typecheck.h
  verbatim (kernel.h now uses the upstream typecheck()), the full
  linux/backlight.h and drm_privacy_screen_consumer.h (their
  !CONFIG inlines replace stray declarations), ffz(), might_sleep_if(),
  delayed_work_pending(), ARCH_KMALLOC_MINALIGN, linux/minmax.h, and
  linux/err.h from linux/dmi.h as the quirk tables need. ssleep() is the
  upstream inline now.
2026-10-02 20:56:28 -07:00
geramyloveless 285ef4bc61 linuxu: hrtimer on the timer service
Implement hrtimer_setup(), hrtimer_start_range_ns(), hrtimer_try_to_cancel(),
hrtimer_cancel(), hrtimer_active(), hrtimer_forward(),
hrtimer_cb_get_time() and __hrtimer_get_remaining() in linuxu/src/timer.c.
The existing worker thread now serves both timer_list (jiffies) and
hrtimer (nanosecond deadlines on CLOCK_MONOTONIC, CLOCK_REALTIME or
CLOCK_BOOTTIME), sleeping until the earliest of either.

Semantics follow kernel/time/hrtimer.c: the timer is dequeued before
its callback, HRTIMER_RESTART re-enqueues it at the expiry the callback
forwarded to, try_to_cancel() returns -1 while the callback runs,
hrtimer_cancel() waits for it, and a NORESTART timer is not touched after
its callback returns. drm_vblank's timer-based vblank and amdgpu_vkms use
this; the hrtimer stubs that called them unreachable are gone.

scripts/test-hrtimer.sh covers one-shot and periodic timers, forward
overrun arithmetic, cancel while running, the drm_vblank
active/try_to_cancel loop and coexistence with timer_list timers. The
timer service test now links timekeeping.c for the clocks.
2026-10-02 20:56:19 -07:00
geramyloveless 41aceb6fe0 linuxu: per-task per-CPU variables and kernel FPU sections
Linux gives a task exclusive use of its CPU's per-CPU copy between
preempt_disable() and preempt_enable(). linuxu threads all run as CPU 0
concurrently and preemption control excludes nobody, so one shared copy
would be raced. linux/percpu.h therefore keeps per-CPU variables per
task: the first this_cpu_*() access copies the definition's initial
value into storage owned by the task (released by put_task_struct()),
which is exactly what a pinned task observes on Linux. per_cpu() names
the boot copy; no built source inspects other CPUs' copies.

linux/fpu.h provides kernel_fpu_available()/kernel_fpu_begin()/end().
In a process the FP/SIMD registers belong to the running thread and the
OS preserves them across switches, so nothing is saved; the section is
tracked per task and nesting or an unbalanced end warns as on Linux.
This is what Display Core's dc_fpu.c (DC_FP_START/END and its per-CPU
recursion depth) runs on.

scripts/test-percpu-fpu.sh checks per-thread isolation of the copies,
initial values, the boot copy and the dc_fpu depth pattern under
ASan/UBSan.
2026-10-02 20:56:19 -07:00
geramyloveless 2effeb9871 linuxu: headers for the display tree and the DRM display helpers
Vendor the upstream display headers verbatim (drm/display/ DP, MST,
dual-mode, DSC, HDCP, HDMI, SCDC; drm_crtc_helper.h, drm_probe_helper.h,
drm_modeset_helper.h, drm_modeset_helper_vtables.h, drm_bridge_helper.h,
drm_audio_component.h, acpi/video.h, linux/average.h, linux/iopoll.h,
media/cec-notifier.h and the uapi linux/cec.h). The trimmed DP/MST
helper headers and the inline display stubs they carried give way to the
upstream declarations, now that the upstream helpers are built.

media/cec.h keeps only the upstream CONFIG_CEC_CORE=n API. Smaller
upstream pieces the display code reaches: fsleep()/ssleep() and
TICK_NSEC, noinline/noinline_for_stack, the in-place byteorder helpers
(kernel.h includes asm/byteorder.h as upstream does), the
DIV64_U64_ROUND_* family, the !CONFIG_ACPI companion helpers, guid_t
through mod_devicetable.h, str_*() through kernel.h/seq_file.h, and the
workqueue disable/current_work declarations.

The drm_simple_encoder_init() stub is removed: drm_simple_kms_helper.c
provides it, as drm_dp_helper.c and drm_panel_orientation_quirks.c now
provide what linuxu/src/drm/dp_helper.c carried.
2026-10-02 20:42:02 -07:00
geramyloveless 558edabfac display: build Display Core, the display helpers and the KMS helpers
Add drivers/gpu/drm/display/ to the sparse checkout and compile the
display side of upstream amdgpu:

- mk/upstream_sources.mk gains the 498 objects of AMD_DISPLAY_FILES
  (amd/display/Makefile and the Makefiles it includes, evaluated with
  DRM_AMD_DC=y, DRM_AMD_DC_FP=y, DEBUG_FS=y), the drm_display_helper
  module for the DRM_DISPLAY_* helpers amdgpu selects, the whole
  drm_kms_helper module and the panel orientation/backlight quirk tables.
  DCN 4.0.1 links the dcn10..dcn35 code it reuses, so every DCN is built.
- mk/kernel_config.mk and linux/autoconf.h enable DRM_AMD_DC, DC_FP and
  the display helper configs; CEC, DP AUX chardev/CEC, DP tunnel, bridge
  connector, SI DCE and secure display stay off.
- INCPATHS carries the subdir-ccflags-y include roots of the display
  Makefiles in upstream order.
- CONFIG_DRM_AMD_DC_FP is declared in patches/manifest.json as a config
  intervention: Kconfig drops it for clang+arm64 because of kernel FPU
  rules that do not apply to userspace. scripts/verify-upstream.py checks
  that each declared config intervention names a Kconfig symbol and is
  set in autoconf.h.
- linux/kconfig.h provides IS_ENABLED/IS_REACHABLE as kbuild's forced
  include does; autoconf.h pulls it in after the CONFIG table.

Display stays off at runtime by default; that gating follows separately.
2026-10-02 20:41:36 -07:00
geramyloveless 953cf0149c mac_linuxgpu: upstream Linux amdgpu on macOS
Runs the unmodified upstream Linux amdgpu and amdkfd drivers on Apple
Silicon Macs inside a DriverKit system extension, for AMD GPUs attached
over Thunderbolt. The Linux sources come from a pinned submodule and are
compiled against linuxu, a userspace implementation of the Linux kernel
APIs they use. Includes the HSA runtime, the host installer app, the
setup and firmware fetch scripts, and the offline test suite.
2026-10-02 18:49:17 -07:00