55 Commits
Author SHA1 Message Date
geramyloveless dc0229043a Display agent: close a mirroring process's pipe at end of file
The daemon read each mirroring process's output with a readabilityHandler
that ignored end of file. At end of file availableData is empty and the
handler fires again at once, so the handler spun and the read descriptor
stayed open after every child exit. A daemon up for 29 hours ran at
170-260% CPU holding 2,556 pipes, and the child output stopped reaching
the log.

followOutput (DisplayAgent.swift) closes the read end and clears the
handler at end of file, after the last chunk. The termination handler no
longer clears the readability handler, which could drop the last lines
and leave the descriptor open. A pipe whose process failed to start is
closed.

A mirroring process no longer ends when its STATUS poll is answered
kIOReturnBusy: the daemon's STATUS and PROBE and the child's own IMPORT
share the driver's display gate, and a collision ended the mirror, which
the daemon restarted 10 s later. IMPORT is asked again for up to 2 s on
kIOReturnBusy. The daemon logs a mirroring process's exit status.

test-display-agent runs 20 short processes through followOutput and
checks every byte arrives, the end is seen once, no descriptor is left
open and nothing spins afterwards.
2026-10-08 13:03:11 -07:00
geramyloveless 6a8305facd The host reads the GPU's Resizable BAR capability
MacLinuxGPUHost rebar prints, for each resizable BAR, the sizes the
device can decode and the size it decodes now. It reads the device's
configuration space through the sysfs "config" file as an observer,
like the pcie command, so it writes nothing and works beside a session.

The parser walks the extended capability list from 0x100 and accepts
the capability only as linuxu's pci_rebar_read does: version 1, one to
six entries inside the space, distinct BARs, and a selected size the
BAR supports. test-device-info checks it against the R9700's capability
(BAR0 256 MB of 256 MB to 32 GB, BAR2 2 MB of 2 MB to 256 MB) and
against malformed lists.

macOS sizes every BAR and the bridge windows above it once, when it
enumerates the device. IOPCIFamily never programs this capability and
takes no BAR above 1 GB, and DriverKit has no call to resize one, so
the size shown as now is the one the driver works with.
2026-10-06 16:10:58 -07:00
geramyloveless 3b10f769bb An upgrade hands over without Retire: ShutdownGPU, remembered until idle
Since the device stays up across clients (248), a previous instance whose
last client left keeps its session, and with it the GPU, open. It can
leave only once that session is closed, and Retire, the installer's way to
close it, needs the session-release authorization the signed app does not
have (kIOReturnNotPrivileged). So every upgrade stayed "terminating for
upgrade via delegate" until someone killed the old driver, which panics the
Mac, or power-cycled the GPU.

The installer now hands over without Retire when Retire is refused. It
opens a session client of its own on each previous instance and asks
ShutdownGPU, which any session client may ask and which closes the session
when no other client uses it. The display agents are already stopped for
the upgrade. The installer keeps asking until the instance is gone, and
says which programs still hold it.

When other clients still use the GPU, the driver now remembers the request
(s_closeWhenIdle, session state flag CLOSE_WHEN_IDLE): the last client's
leaving closes the session, even after the installer has given up. The
request goes with the session. Nothing about Retire's authorization
changes. Disconnect GPU uses the same path when its Retire DISCONNECT is
refused.

Tests: test-session-shutdown runs the production code for the upgrade with
no client left (ShutdownGPU closes the session at once, IOKit's Stop then
finishes) and with a client that leaves afterwards (refused, remembered,
closed by that client's leaving, then Stop). test-display-agent covers
reading ShutdownGPU's answers. A previous instance from before build 263
does not remember the request: the installer then asks again after the
clients leave.
2026-10-06 15:39:53 -07:00
geramyloveless 1e2edc1224 The display agent keeps a driver trail on disk
After a panic, the unified log is often missing its last seconds, and the
driver's retained ring dies with the driver. The display agent daemon
(always running) now polls, once a second on its own queue:
- the driver instances in the registry: a line when one appears, and an
  INSTANCE GONE line when one leaves, with the last state read from it and
  the last ring byte read;
- over its own observer client, the cached probe, session, power and reset
  state (a line when it changes) and the new bytes of the driver's log
  ring, read with the LLOG snapshot query exactly as read-driver-log.py
  reads it (bytes the ring overwrote first are counted, never hidden);
- a heartbeat every 30 s.
Lines are appended to ~/Library/Logs/MacLinuxGPU-driver-trail.log and
fsynced at once; the file rotates to .1 past 4 MB. After Disconnect GPU the
trail holds no client, like the rest of the agent, and records instances
only. Observer reads are cached and never claim PCI.

The model (TrailFile, TrailState, TrailLogReader, TrailLineBuffer) is
tested by test-display-agent against a synthetic ring.
2026-10-06 13:16:52 -07:00
geramyloveless 04ee55a519 SysfsWrite takes any observer client; every write is logged
The session-release entitlement is in Host.entitlements, but the signed
host app does not carry it: local signing with the approved profiles
leaves it out, in both the installed build and this one. Gating SysfsWrite
on it would refuse the menu's every write. Any process can already run
GPU work through a session client, so an observer client may make these
writes too. The allowlist bounds what can be set (four levels, a profile
index), and the driver logs each write with the client that made it.
2026-10-06 09:30:59 -07:00
geramyloveless 1912fd1e4e Menu bar: Performance controls, kept and set again whenever the GPU comes up
The menu bar's new Performance submenu has:
- Performance level (Auto, High, Peak, Low), which maps to
  power_dpm_force_performance_level (Peak is profile_peak).
- Power profile, listing every profile the card reports in
  pp_power_profile_mode except CUSTOM, which takes parameters. The list is
  read from the card, with friendly names for the known ones (Default,
  3D Fullscreen, Power Saving, Compute, ...).
- A live line with the current GFX and memory clocks, the temperature and
  the power, refreshed each second while the menu is open.
- A place for the runtime power-management modes still to come.

A choice is written at once through SysfsWrite and read back, then kept
in the display prefs (performanceLevel, and the profile by its card name).
A refused write is shown in the submenu, with the driver's reason, and
beeps. The display daemon writes the kept choices again whenever the GPU
comes up: when it opens the GPU (after a probe, a power cycle or an
upgrade) and after a reset that lost VRAM. A profile the card no longer
lists is an error that is shown, never a default. Nothing chosen means
nothing written, so the driver's Auto applies, as on Linux, since pinning
clocks costs idle power.

CLI: "MacLinuxGPUHost performance-level auto|high|peak|low",
"power-profile <name>" (a card name, menu title or index), and
"performance", which prints the current and kept settings and the live
line.

test-display-agent covers the levels and their sysfs spellings, parsing
the R9700's pp_power_profile_mode and the older one-line layout, profile
lookup, the live line, prefs persistence including files from before
these settings, and the reapply plan.
2026-10-06 09:27:35 -07:00
geramyloveless d9df9a3a17 Disconnect GPU closes the device for the programs on it
With the device kept up across programs (248), Disconnect GPU could no
longer bring the GPU down. Once the display daemon let go, the session
stayed up with or without programs. The menu bar said "still in use" for
any program with the driver open, even an observer such as mtopg, and
had no way to close the GPU for programs still using it.

- Retire gets a DISCONNECT op (session_state.h). It closes the session
  now through the normal close, as QUIESCE with FORCE does, whatever
  clients it has. Unlike QUIESCE it keeps admitting sessions, so the next
  program to start brings the GPU up again. A raw BAR mapping still
  refuses, since a close would quarantine. A quarantine is released only
  when provably quiescent, as for Retire. out[2] counts the clients that
  lose the GPU.
- The closed session's clients get kIOReturnNoDevice on every further
  call (session and Linux-file clients alike), and the driver log says
  once per client that the GPU was disconnected. They are never silently
  rejoined to a new session with stale state. HSA maps NoDevice to device
  lost and now says the GPU was disconnected and the program must
  restart.
- The menu bar and `disconnect-gpu` wait for the displays to stop. If the
  driver's session is still up, they close it with DISCONNECT. The GPU is
  safe to unplug once the session is closed, whatever programs still have
  the driver open. Those programs are named: they are told the GPU was
  disconnected if they use it.

Tests:
- session shutdown retire-disconnect: the session closes the normal way
  for every program with nothing refused, the old clients' generation is
  the disconnected one, the call reports IDLE once closed, and the next
  program opens a new session.
- retire-disconnect-raw-bar: refused, nothing changes.
- The observer policy admits the op.
- The display agent's readiness: safe with clients named, an open
  session means apps connected (even none), closing, and the messages.
2026-10-05 16:30:21 -07:00
geramyloveless 22b50726b0 Owner calls carry up to 16 scalar outputs
An async session call's completion holds 16 words: a 4-word header and
at most 12 scalar outputs. host/owner_call.h asked for no more than 12,
and the driver's owner_call capped the selector's outputs at 12. A
selector that answers more refused the call: QueryInfo's compute
topology (tag 10, 16 words) returned kIOReturnBadArgument. The HSA
runtime then never learned the driver's queue slots, fell back to one
queue, and refused the next hsa_queue_create with
HSA_STATUS_ERROR_OUT_OF_RESOURCES before calling the driver. LemonSeed
Engine's hrx creates several queues, so on build 245 its GPU backend
never came up and it ran on the CPU. Build 242 called QueryInfo
synchronously, with 16 outputs.

A caller may now ask for up to 16 scalars (IOKit's limit). Up to 12 come
inline in the completion as before. When there are more, the completion
carries their count and none of them, and OWNER_RESULT returns them
(n * 8 bytes), followed by any structure output. host/owner_call.h,
which the HSA runtime, the host app and libmlg_drm build from, and
scripts/mlg_owner_call.py fetch them so. The Python twin's IOReturn
constants for kIOReturnNotAttached and kIOReturnIPCError are corrected,
and it reports kIOReturnNoSpace by its own value.

test-client-transports (test-lx-transport before) now also runs the HSA
runtime's own IOKit transport, its sources unchanged, against the dext's
extracted dispatch. The GPU's session answers are those the installed
245 driver gave the runtime on an R9700, and each handler refuses a call
that asks for fewer scalars than it answers, as the driver's do. From a
cold GPU the runtime brings the device up (HostWindow, InitDevice), opens
the compute session and creates three MULTI queues with an error
callback, as hrx does. Before this change the second hsa_queue_create
fails with 0x1008 (OUT_OF_RESOURCES) after one queue, as on the
hardware. The test also checks owner_call.h's shapes: 16 scalars, 14
with a structure output, and a caller asking for fewer than a selector
answers getting the driver's refusal. test-owner-call covers the
driver's side of 16 scalars through OWNER_RESULT.
2026-10-05 11:10:24 -07:00
geramyloveless 17d2ec6733 Owner calls never wait without a bound
An async session call waited for its completion as long as the driver
answered Ping, so a selector the driver serves synchronously, sent
async, hung its caller for good (build 243's LX_MMAP_COMMIT). Every
owner call now has a bound: 300 s for InitDevice, ShutdownGPU and
DrmSelftest, 120 s for the rest (mlg_owner_call_bound_ms; a timed call's
0 means the selector's bound). Past it the call returns kIOReturnTimeout
and says on stderr which selector got no completion. The driver bounds
every call well inside these; they only catch a completion that will
never come. scripts/mlg_owner_call.py has the same bounds, and
test-owner-call checks they match.

test-owner-call runs the plain call against a mock driver that answers
Ping and never completes: it times out within its bound, the longer one
for InitDevice, and says so.
2026-10-05 09:58:40 -07:00
geramyloveless 7bf967c52c Display calls: the host's own call is tested against the driver's checks
Build 242's host started display ops without a structure output, and the
driver refused PROBE, SHOW, OFF, STATUS and MODES for it; the test of the
driver's side offered 4096 bytes in every mocked call, so nothing showed
it.

The start of a display op moves into host/display_call.h
(mlg_display_call_start), which the host app calls: an async call of the
display selector carrying MLG_DISPLAY_REPORT_MAX bytes of structure
output, every op's largest. test-display-async builds that header with
IOConnectCallAsyncMethod replaced by a capture, hands the driver's own
display_call what the kernel would (scalars, structure input, output
capacity, completion) for every op that can sleep, and requires each to
be accepted and completed; the same call without an output capacity is
refused. With the header passing no output the test fails.
2026-10-04 22:32:04 -07:00
geramyloveless 3b5682f402 Host: display ops carry their output capacity; the daemon fails loudly
The async display call passed no structure output. The driver checks
the call's output capacity (structureOutputMaximumSize) against its
report before PROBE, SHOW, OFF, STATUS and MODES and refused each with
kIOReturnBadArgument, so on 242 no monitor was ever found or mirrored,
and display-probe failed. The call now carries a buffer of the op's
output size; the output still comes with RESULT.

The daemon took a failed STATUS silently: it closed its clients and
opened a new session at once, a full upstream probe and teardown every
two seconds, until a probe failed (-12) and the driver quarantined. A
failed STATUS is now logged with its IOReturn; the clients are reopened
only when the connection is lost, otherwise the daemon waits 10 s. A
failed PROBE is logged too.
2026-10-04 22:28:50 -07:00
geramyloveless 5a8cc06fb5 Displays follow GPU recovery: re-mirror after a reset, let go when wedged
The display daemon reads the driver's recovery state (QueryInfo LRST,
cached and never blocking) at its 2 s poll:
- A queue reset (the generation moved): the outputs redraw by
  themselves; a mirror that ended around it starts again at once instead
  of after the 10 s retry delay.
- A reset that lost VRAM: every mirror stops and starts again (imports
  and lights afresh).
- Wedged (the reset failed; only a power-cycle brings the GPU back):
  the mirrors stop and the daemon lets go of the GPU as for "Disconnect
  GPU". The status carries gpuWedged, and the menu bar shows "The GPU
  stopped answering and its reset failed" with "Power-cycle the GPU,
  then choose Reconnect GPU". When the GPU leaves the bus the daemon
  reconnects to it on its return, as after Disconnect.

test-display-agent covers the decisions (the first read of an instance
only records it) and the status round trip.
2026-10-04 22:11:58 -07:00
geramyloveless a60b485890 Host: keep each connection's answer to the async-calls check
ff324ff's mlg_selector_call asks RuntimeBuild before every async call;
mlg_selector_call_on keeps the answer per connection. The host app now
keeps it with the open connection (reset on each open) for instances
that publish MacLinuxGPUSessionCalls = "async"; an instance without it
is still called with IOConnectCallMethod, so the installer can Retire a
pre-243 driver that the check would refuse.
2026-10-04 22:11:58 -07:00
geramyloveless 7d082e7be5 Merge feature/recovery (ff324ff) into display-c 2026-10-04 21:59:31 -07:00
geramyloveless cf09b0faf5 Host: Retire gives up loudly when its completion never comes
An instance that publishes MacLinuxGPUSessionCalls = "async" but never
completes a Retire would hold the upgrade, and the observer client the
instance waits on, for as long as it answers Ping. Retire now waits at
most 60 s (mlg_owner_call_timed, new in host/owner_call.h: the same wait
with a deadline, kIOReturnTimeout past it; a late completion is dropped
with the call's port). The installer reports which op timed out on which
instance.

test-owner-call also runs the host header against a driver that answers
Ping and never completes: the timed call returns kIOReturnTimeout on
time, and a driver that stops answering Ping ends an untimed wait.
2026-10-04 21:58:40 -07:00
geramyloveless ff324ff9a0 Clients refuse a driver that does not serve session calls async
An async session call to a driver older than this protocol is answered
synchronously and never completed, so a client that awaited it would
wait forever (a new runtime in /usr/local/lib talking to a driver that
is not yet replaced, or whose activation failed).

RuntimeBuild's compiled build (DEXT_RUNTIME_BUILD) is now 243, the first
to serve session calls async (MLG_SESSION_CALLS_ASYNC_BUILD).
host/selector_call.h asks it once per connection
(mlg_selector_call_on) before the first async call and, against an older
driver, fails at once with kIOReturnUnsupported; the HSA runtime keeps
the answer per connection and forgets it on close, libmlg_drm per
process, and both say on stderr that the installed driver is older than
build 243. scripts/mlg_owner_call.py refuses such a driver when it
connects. The Linux-file path needs nothing: an older driver refuses
LX_CALL_ASYNC as an unknown selector at once.

test-selector-call runs selector_call.h against mock drivers: build 242
and a three-word RuntimeBuild fail at once with no async call, a driver
that does not answer is reported gone, a 243 driver gets the async call,
the protocol is asked once per connection, and calls that never sleep
stay synchronous.
2026-10-04 21:55:03 -07:00
geramyloveless 121b63ba35 GPU recovery: hung queues reset as on Linux; a device reset wedges for now
With amdgpu_gpu_recovery off, a job on a hung ring never completed and
every wait on it lasted forever (build 241). Recovery is now upstream's
default: a job that times out resets its queue (amdgpu_job_timedout ->
ring->funcs->reset: a MES queue reset for compute and gfx, an SDMA queue
reset), the guilty job's fence gets -ETIME, its context reports the reset
(AMDGPU_CTX_QUERY2_FLAGS_RESET) and refuses further work, and the work
queued behind it from other contexts runs.

A device reset (mode1 on gfx12, after a failed queue reset, on a ring
without one, or requested by KFD or a user queue) needs platform work not
done yet over Thunderbolt: the PCI configuration's restore with its BARs,
MSI-X, client BAR mappings in the reset window. Until then
(rt_recovery_full_reset_available), rt/recovery.h turns every request for
one into what Linux ends in when a reset fails: the device wedges. The DRM
device is unplugged (new requests fail with -ENODEV), hardware access and
bus mastering stop, every ring's fences complete with -ECANCELED and keep
completing, and KFD's waiters get its reset event. Nothing waits forever
and nothing loops on resets.

rt_recovery_attach hooks this in after the probe without changing
upstream: each scheduler's timeout handler and each queue reset are
wrapped (upstream's run unchanged inside; every recovery handler runs on
the reset domain's one ordered queue), and the KFD and user-queue reset
works are redirected to the wedge. Each queue reset that succeeds, and
the wedge, advance a reset generation. The driver publishes it as
QueryInfo "LRST" (generation, wedged and VRAM-lost flags, queue resets,
VRAM-lost counter, last result), sets MLG_SESSION_FLAG_GPU_WEDGED in the
session state, logs both as unified-log events, and the host app and
read-driver-log.py say to power-cycle the GPU when it is wedged.

The CS fixture resets queues as MES does (fx_ring_reset, with a ring test
that runs on the engine). queue_reset_check hangs a compute job: the
timeout fires, the queue resets without a device reset, another
process's job behind it runs, the guilty context reports the reset and
refuses work, a new context works and the generation advances.
wedge_check (a process of its own) makes the queue reset fail: the device
wedges, blocked work and a wait with no deadline end, new requests fail
with -ENODEV, and no device reset is tried. ttm_evict_check's stalled
move now ends with an SDMA queue reset.
2026-10-04 21:55:02 -07:00
geramyloveless 974866828b Host: call a pre-243 driver instance the way it serves calls
From 243 every selector that can sleep is an async call, and the host
calls them with mlg_selector_call. An earlier driver runs such a call
synchronously and never completes it, so the async wait (whose Ping
only notices a driver that went away) never ends. The installer calls
Retire QUIESCE and TERMINATE on the previous instance over an observer
client: a 242 -> 243 upgrade would hang there, holding the very client
the previous instance waits for before it terminates.

The driver's personality now carries MacLinuxGPUSessionCalls = "async".
The host reads it with each instance and calls an instance without it
with IOConnectCallMethod, as that driver serves every selector.
2026-10-04 21:36:30 -07:00
geramyloveless 26ac79bab6 Host: a bounded sysfs read that overruns is not a missing file
From 243 SysfsRead is synchronous but bounded: a read over 250 ms returns
kIOReturnTimeout, and while it still runs the next is kIOReturnBusy. The
host read either as "unreadable", so a monitor whose EDID read overran
(a modeset or reset holding the display lock) was keyed by its connector
instead of its EDID, the daemon's choices no longer matched it, and the
hotplug epoch was already taken, so nothing read it again.

readSysfs and readConnectorEDID now report an overrun apart from a
failure. The daemon leaves the epoch unseen and reads the monitors again
on the next poll; a mirroring process ends with the overrun named (the
daemon restarts it); `pcie` says the read overran.
2026-10-04 21:34:23 -07:00
geramyloveless 9d10aa0e33 Session calls never run on the driver's incoming-call thread
DriverKit delivers every client's calls, and the driver's own Stop, on
one thread, and runs each under its target queue with a synchronous
dispatch. Session clients shared the owner's queue, and observers and
Linux-file clients hopped to it synchronously, so a session call that
slept there (a probe, an allocation that evicts, a fence wait, a session
close), or anything queued behind one, held every client; on a GPU that
stopped, forever (build 241).

Every client now has a queue of its own, and nothing on the delivery
thread waits for the owner's queue:
- Selectors that never sleep answer there: Ping, RuntimeBuild (from flags
  the session queue publishes; the context is never touched), the cached
  QueryInfo tags, the power query and the power wait's registration, and
  OWNER_RESULT (88).
- Every other selector must be called with IOConnectCallAsync*: the call
  returns at once with a token and runs on the owner's queue, in arrival
  order, exactly as it ran there before; it completes with its IOReturn,
  scalar outputs and structure output length, and OWNER_RESULT fetches the
  structure output once. EVENT_WAIT keeps its own completion; a wait that
  does not start completes at once with the reason. A synchronous call of
  such a selector is refused (kIOReturnNotPermitted, logged once per
  client).
- SysfsRead and DrmInfo stay synchronous but bounded: the read runs on a
  wait-pool thread (rt_bounded_run, new) and the call waits at most
  250 ms (kIOReturnTimeout; while one overruns, the next is kIOReturnBusy).
  The observer's self-test, Retire and ReleaseQuarantine are async calls.
- A session client's Stop, and an observer's FinishStop, run on the owner's
  queue after the client's queued calls. Linux-file clients join the
  session on the owner's queue with their first open (LX_CALL_ASYNC),
  and the first open's InitDevice and HostWindow are async calls.
- CopyClientMemoryForType no longer touches the session: BOMap makes the
  BO's descriptor on the owner's queue and the mapping looks it up; the
  raw BAR lease takes its own spinlock.

Clients: host/owner_call.h and host/selector_call.h (header-only) call a
selector as the driver serves it, synchronously or as an awaited async
call; the HSA runtime, the host app (callScalar, callStruct, callMethod)
and libmlg_drm use them, and scripts/mlg_owner_call.py does the same for
drm-selftest.py and display-test.py's initialization. A client older
than this driver fails at its first session call that can sleep, with
the reason in the driver log.

Tests: test-owner-call runs the production owner_call machinery
(extracted, DriverKit mocked) against a session call that sleeps: calls
return at once, cached queries and the power wait answer while it
sleeps, later calls queue in order, completions carry the right layout,
OWNER_RESULT once, BO memory is found without the session, and a hung
bounded read times out within its bound. test-bounded covers
rt_bounded_run on the real wait pool; test-session-shutdown checks the
selector rules and runs the Stop paths through the owner's queue.
2026-10-04 21:22:42 -07:00
geramyloveless 56165a894a Installer: libmlg_drm and libdrm_mlg go to /usr/local/lib with the HSA runtime
The Linux-file client library (libmlg_drm) and the libdrm over it
(libdrm_mlg, which RADV and other DRM clients load) now ship in the app's
runtime payload, signed by the team like the HSA runtime, and the
installer puts them in /Library/MacAMDGPU/runtime and /usr/local/lib in
the same transaction (staged, backed up, restored on failure), so local
apps pick up the libraries that match the driver on every update. Both
have @rpath install names, as before. activate.sh --install-hsa builds
them (make libdrm-mlg); the DMG check and the installer's validation
accept and verify exactly these files.
2026-10-04 19:26:47 -07:00
geramyloveless 347a44ec16 display: no op that can sleep runs on a client's call
On 241 a GPU ring hung (no recovery), and the display agent's OUTPUT then
pinned a framebuffer: TTM evicted, the blit waited for an IB from a pool
whose fences never signal, with no timeout, on the call itself. That was
the driver's incoming-call thread, so every client froze with it, the
observer's reads and Linux-file calls included, and the driver could not
even take its own Stop after the GPU was powered off.

Every display op that can sleep (PROBE, SHOW, OFF, STATUS, MODES, IMPORT,
VERIFY, RELEASE, OUTPUT) now needs an async completion: the call takes the
display gate, queues the op on a wait-pool thread (rt_wait_pool, the
threads that already sleep for event waits) and returns at once with a
token. The thread runs the op, keeps its structure output for RESULT
(op 10, once) in a slot the op shares with the client (an op may end after
the client stopped), and completes the call with the token, the op's
IOReturn, its two scalars and its output length. A synchronous call of
one is refused; one while another runs is kIOReturnBusy.

PRESENT stays synchronous and never sleeps: it takes no display gate, and
rt_display_present and rt_display_stats take the display lock with
trylock, -EBUSY while an op holds it. The agent then carries that frame's
damage (moves as rectangles) to the next PRESENT and forgets its tile
hashes, so no later frame moves or skips rows the driver never drew.
A stopped client's imports and output are released on a pool thread once
the display gate is free (after any op of its own that is finishing).
The daemon skips a STATUS poll that finds the display busy instead of
closing its clients.

The host app's display calls are async: IOConnectCallAsyncMethod with a
notification port, the completion received on the calling thread (up to
60 s, then kIOReturnTimeout), and RESULT for the output.

test-display-async runs the production display_call machinery, extracted
from the dext source, with DriverKit mocked and an OUTPUT that never
finishes: the call returns at once, the op does not run on it, PRESENT
and another client are answered meanwhile, a second op is busy, a stop
waits for the op, the completion and RESULT (once) carry its result, and
a refused thread leaves the display free. With the op run on the call
(the 241 behaviour) it fails within 20 s instead of hanging.
2026-10-04 19:12:11 -07:00
geramyloveless f813030984 Disconnect GPU: stop the displays and let go of the driver before unplugging
Like ejecting a disk. The menu bar's "Disconnect GPU…" (and
MacLinuxGPUHostApp disconnect-gpu) records the choice in displays.json;
the display daemon stops every mirroring process and closes its own
session and observer, so nothing of ours touches the GPU. The menu then
waits up to 20 s and says either that the GPU can be unplugged, or which
apps still use it ("Still using the GPU: amdgpu_mtopg (pid 692). Quit
it, then unplug the GPU.", from IOKit's client records), or that the
driver is still closing its session (participants or closing, from its
session state). "Reconnect GPU" (reconnect-gpu) undoes it, and the
daemon clears the choice itself once the GPU has left the bus, so a GPU
plugged back in mirrors again. Files from before the choice existed read
as connected.

This is in addition to sending every VRAM access through the kernel:
an unplug without disconnecting must not panic either.

The agent also prints how long OUTPUT (the modeset) and each capture
surface's IMPORT took, one-time measurements for the cost of the kernel
route (an import writes the GART page table for its pages).
2026-10-04 17:53:55 -07:00
geramyloveless 3fb002e707 display-agent: keep the virtual display composing; capture with no frame interval
Typing on the Dell lagged: a typed character could take 200 ms to show.
A type workload (a glyph-sized mark that changes 5 to 15 times a second
at random, each change followed to its flip) put the whole delay before
the frame reaches the agent: the WindowServer lets a virtual display's
update cycle idle when nothing on it changes, and the next change waits
to be composited. A probe in another process saw the same on the virtual
display (change to frame p90 157 ms, max 203 ms) and not on the built-in
one (p90 22 ms). The agent's part (frame handler to PRESENT, 0.3 ms;
PRESENT to flip, under a refresh) was never the cause.

DisplayKeepAlive: a 2x2 point window in a corner of the virtual display
changes its opacity every refresh between two values that composite to
the same pixels, so the WindowServer composes the display each refresh;
the frames it causes change nothing and the damage filter drops them, so
nothing is copied or flipped for it (idle desktop: 20 frames presented in
12 s with or without it; the agent's CPU 0.2% -> 0.6-1.3%, 9 -> 64
wakeups/s). The capture now has no minimum frame interval, so the stream
wakes right after each composition instead of on a grid of its own.

Typing, change to flip: p50 25-33 ms, p90 134-157 ms, max 218-222 ms
(10 to 14 of ~65 changes never shown on their own) before; p50 20 ms,
p90 28 ms, max 31 ms (none) after. Scrolling runs at 58 flips/s (50.6
before). refreshDeadline 0.004 measured no better and stays unset;
--frame-interval refresh and --keep-alive off restore the old behaviour
for measuring. A mirroring process also holds a latency-critical activity
(no App Nap timer coalescing) and creates the virtual display on a
user-interactive queue.

The type workload (--workload type) reports each stage's p50, p90 and
max: change to composition, composition to frame handler, handler to
PRESENT, PRESENT to flip, change to flip. Its marks are four black or
white squares that encode the change number in binary, which the
display's colour conversion cannot shift.
2026-10-04 09:50:22 -07:00
geramyloveless 43bdf4f8ae pci: the configuration space as sysfs "config"; a pcie command reads it
The PCI core's config file (drivers/pci/pci-sysfs.c pci_read_config) on
the runtime PCI device: cfg_size bytes through the driver's configuration
reads, a byte, a word, whole dwords, a word and a byte, little endian;
read-only (upstream also writes). Linux tools read it for lspci; here the
observer's sysfs read does.

MacLinuxGPUHostApp pcie decodes the PCI Express capability from it: link
speed and width against what the device can do, Max Payload and Max Read
Request against what it supports, extended and 10-bit tags, relaxed
ordering and no snoop. These are what Linux configures at enumeration
(pcie_bus_configure_settings, pcie_set_readrq, extended and 10-bit tags);
a device left at reset values moves data in smaller requests. Nothing
is written.
2026-10-04 08:16:53 -07:00
geramyloveless 20c3ec1a12 display-agent: Sidecar's capture settings as options; composition to handler time
For measuring before choosing defaults: --refresh-deadline S sets
CGVirtualDisplaySettings' refreshDeadline (a property the private header
now declares; 0, unset, is the default and Sidecar uses 0.004), and
--frame-interval zero gives the capture no minimum frame interval
(refresh, one refresh, stays the default). The measurement reports how
long after a frame's composition (its display time) the frame handler
runs.
2026-10-04 08:13:33 -07:00
geramyloveless 357098007a display-agent: find rows that scrolled and send them as moves
The damage filter's tile hashes also find scrolling: per dirty rectangle,
each row's new signature (its tiles' hashes) is looked up among the rows
as the driver has them, counting only rows whose old signature is unique
(blank rows say nothing); the shift most rows agree on is the scroll.
Changed rows that equal the row that far away become moves (runs of at
least 4 rows, at most 32 moves), rows that do not match (an edit, a clock
in a header) stay damage in their tiles, and rows the driver was never
given are never a move's source. Everything compares against the hashes
from before the frame, so overlapping rectangles agree; exact duplicates
are dropped. A frame that does not fit PRESENT becomes the whole frame.

The agent parses statistics version 3 (and 2 from a driver before 240)
and reports damage reported, kept and moved, rows moved in VRAM, moves
copied from the surface instead, and bytes copied in VRAM per flip. For
measuring: --damage raw|filtered|scroll (raw and filtered work with a
driver before 240) and a scroll workload (a text document scrolling 6
points a refresh under a header).
2026-10-04 08:12:15 -07:00
geramyloveless a132fea45a display-agent: drop damage that changes nothing on screen
ScreenCaptureKit reports regions redrawn with the same pixels as damage:
on the test desktop nearly every idle frame carried the menu bar's status
items (a system monitor's widgets and the clock, 0 pixels changed), and
every mouse move carries cursor-sized rectangles even with showsCursor
off. Each cost a copy and a flip, so an idle display did a frame's work
every refresh.

DamageFilter keeps a 64-bit hash of every 64-pixel row segment the driver
was given. A frame's dirty rectangles are hashed again and only the tiles
that differ are presented, in whole tiles (a tile is never recorded as
given while part of it was not), consecutive changed rows merged into
one rectangle; a frame with nothing left is not presented. Hashing a
whole 2560x1440 frame takes 0.4 ms. The measurement reports damage
reported and kept, frames that changed nothing, and the hashing time.
2026-10-04 07:44:06 -07:00
geramyloveless 07f810adf7 display-agent: wait for the compositor before PRESENT; hold buffers until read
ScreenCaptureKit delivers a capture buffer while the compositor's GPU may
still be writing it. Read without a lock at delivery, the damaged rows of
most frames during a moving window still held the previous frame (309 of
464 frames changed within 2 ms of delivery; none after IOSurfaceLock).
The driver's SDMA copy, submitted right away, could copy an old window
position, and since that region was then recorded as up to date, it
stayed on screen as dead lines behind a moving window. The agent now
takes a read-only IOSurfaceLock, which waits for those writes, before
PRESENT (246 us on average, 604 us at most for the move workload), and
reports the wait in the measurement.

Buffers were also released when the driver's flipped + replaced counts
reached a frame's received count, but a replacement counts the newest
frame while an older one taken by the worker may still be copying, so a
buffer could go back to ScreenCaptureKit before its copy. PresentedFrames
tells the two apart at the next PRESENT (the replaced count moved or not)
and holds a taken frame until its own flip.
2026-10-03 21:59:51 -07:00
geramyloveless 817a216a46 Installer: name the apps that keep the previous driver, and ask ours to let go
The 236 -> 237 upgrade hung: the 236 instance stayed "terminating for
upgrade via delegate" while amdgpu_mtopg (pid 692) kept an observer
connection to it, and the installer only reported that Retire was not
answered (kr=0xe00002c1).

0xe00002c1 is kIOReturnNotPrivileged: the driver refuses Retire unless
the caller carries the session-release entitlement, and the signing
flow takes the app's entitlements from its provisioning profile, which
cannot carry that custom key, so no shipped build has been able to
Retire a previous driver. The previous instance then leaves only once
every app connected to it has disconnected. The installer now says so
in those words.

While it waits, it names every app still connected to a previous
instance (from IOKit's IOUserClientCreator records, without its own
connection) and tells the user to quit them. Before each Retire it
posts a Darwin notification, com.geramyloveless.maclinuxgpu.driver-retiring,
whose state is the previous instance's registry ID, so monitoring apps
that follow it (amdgpu_mtopg) close their connection to that instance
and reconnect only to the new driver.
2026-10-03 21:42:08 -07:00
geramyloveless 192161bf1c A menu bar item to turn each monitor's display on and off
MacLinuxGPUHost menu-bar is a background item (never in the Dock) with,
for each monitor on the GPU, an On/Off toggle and its live state (off,
starting, mirroring at WxH @ Hz, or the last error), the "Start
displays automatically" setting, the log and the app. It never creates
a virtual display: it writes the user's choices and reads the
display daemon's status, with a Darwin notification each way
(DisplayControl, under ~/Library/Application Support/MacLinuxGPU). Its
template icon shows on, off or an error. It runs from its own per-user
LaunchAgent, which the installer registers with the display agent; the
app has a setting to hide it.

The daemon now mirrors each connected monitor the user has not turned
off in its own child (--connector), keyed by the monitor's EDID vendor,
product and serial, so a choice holds across reboots, replugs and
connectors. It holds a session so the GPU is up, reads the monitors from
the driver's cached hotplug state (probing when the hotplug epoch
moves), reconciles its children with the choices on every change, and
publishes what each child reports.

test_display_agent: choices persist and are keyed by identity, a
damaged file reads as defaults, the status round trip and summary, and
the mirroring process's lines. Verified on the R9700: turning the Dell
off removed its display and restored the monitor; on brought it back at
2560x1440.
2026-10-03 21:26:24 -07:00
geramyloveless d09de6b62b Installer: stop hand-started display agents before an upgrade or autostart
A display agent started by hand (or by an older app) holds a session,
which keeps the previous driver from handing over the GPU, and would
compete with the LaunchAgent for the monitor. The upgrade now stops
every display agent of the user (SIGTERM: each restores its monitor),
not only the LaunchAgent, and enabling autostart does the same before
it bootstraps the LaunchAgent with the installed app.
2026-10-03 21:12:58 -07:00
geramyloveless 8adbf9c9a2 display-agent: create the virtual display before becoming an app; one per process
On build 236 every virtual display stayed without modes in the agent's
process (CGDisplayCopyDisplayMode nil, while CGDisplayPixelsWide was
2560), so the agent and the daemon failed with "did not come online in
a mode the monitor listed" and the Dell stayed dark. Bisected on the
R9700 with re-signed host builds: the 3266899 agent works; adding either
NSApplication's setActivationPolicy/finishLaunching or a
CGDisplayRegisterReconfigurationCallback before the virtual display is
created is enough to break it.

The agent now becomes a background (accessory) app only after its
virtual display has its mode and the capture has started, registers no
reconfiguration callback, and waits for the mode as 235 did. Because a
process cannot create a second virtual display after that, the daemon
no longer mirrors in its own process: it watches the driver and runs
each mirroring as a child, display-agent --create --init
--follow-hotplug, which exits when the monitor leaves (0), finds none
(3) or fails, and is started again; SIGTERM stops the child, which
restores the monitor. The daemon itself never talks to the WindowServer
and never shows in the Dock.
2026-10-03 21:11:45 -07:00
geramyloveless bb6412357c Stop CPU access to the VRAM aperture once the GPU has left the bus
A Thunderbolt power-off of the R9700 with the display mirrored
panicked the Mac (panic-full-2026-10-03-200811: "LLC Bus error (Slave
error) ... NC Write ... uncorrectable", the panicked task the 235 dext).
The faulting thread, symbolized against the installed binary
(3C1A7727-6854-3A29-9D61-CD15EFA13081), was a DRM worker removing a
framebuffer (drm_mode_rmfb_work_fn, atomic_remove_fb): the output's
teardown deletes its scanout buffers, which commits the plane off, and
DC sent the DMUB its commands (set_pixel_clock_dmcub ->
dmub_srv_fb_cmd_execute) by copying them into the DMUB inbox in VRAM
with linuxu_device_memcpy, a CPU store through the dext's mapping of
BAR0. Registers and doorbells go through kernel IOPCIDevice calls,
which the kernel refuses for a vanished device (and the removal already
skips: no_hw_access); a store through a user mapping to a device that
is gone is an uncorrectable bus error on Apple silicon, not an error the
process can see.

Linux takes the aperture away on hot unplug (amdgpu_device_unmap_mmio).
Here it is gated: the device string functions (every memcpy, memset,
memmove and memcmp in the driver, which is how the DMUB inbox and
kmap'd VRAM are written) skip stores into the aperture and read all
ones from it once the device is known gone. It is known gone at the
first of: rt_removal_begin, the dext's removal notification, or a
register read of all ones after which the device no longer answers a
configuration read (checked at most every 10 ms, through the kernel),
which DC's own register reads (the DMUB inbox pointers) hit before it
writes the inbox. The display statistics now count the driver's CPU
accesses to the aperture.

test_display_pipeline: with the display live (flips writing registers,
copies on SDMA), the device leaves the bus with a frame queued; from
then on no register write, no SDMA copy and no store into the aperture
happen, aperture loads read all ones, and the output stops.
2026-10-03 20:27:48 -07:00
geramyloveless 5f74ae27b4 display-agent: an autostart daemon that follows the driver and the monitor
display-agent --create --daemon is the per-user LaunchAgent that makes
the monitor on the GPU a Mac display whenever the driver runs (a dext
cannot: the WindowServer is per user session). It waits for the driver
with IOKit matching notifications, opens its own session (bringing the
GPU up if needed), mirrors the connected monitor, follows hotplug from
the driver's cached state, tears down when the driver or the monitor
leaves and comes back when they return. SIGTERM ends it cleanly; it
logs with timestamps to ~/Library/Logs/MacLinuxGPU-display.log and
never shows in the Dock.

DisplayAutostart installs it as
~/Library/LaunchAgents/com.geramyloveless.maclinuxgpu.display-agent.plist
(Aqua sessions, restarted after a failure). The installer enables it
once the driver is verified unless the user turned it off; the app has
a toggle, and display-autostart on|off|status does the same from the
command line. A driver upgrade stops it before the previous driver
hands over the GPU (its session would hold that driver) and starts it
again afterwards.

The mirroring itself is now one function used by both the one-shot
agent and the daemon. The agent becomes a background agent before it
touches the WindowServer and registers a display reconfiguration
callback: CoreGraphics caches the display configuration a process has
seen, so without it a virtual display created later has no modes in
that process. Detached runs ignore SIGHUP.
2026-10-03 20:06:34 -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 c073a9b4bd display-agent: wait for the virtual display's mode with the run loop turning
Now that the agent is an NSApplication, the WindowServer's display
configuration reaches it through the run loop: the wait for the new
virtual display slept the thread, so it found the display online but
without a mode yet and failed ("macOS uses a mode ... the monitor did
not list"). The wait now turns the run loop and lasts until the
display is online in one of the monitor's modes; a failure names the
mode macOS chose.
2026-10-03 19:46:01 -07:00
geramyloveless 5be679f5b4 display-agent: run as a background agent from the start
The agent connects to the WindowServer (CGVirtualDisplay,
ScreenCaptureKit) from the app's own executable, but only the move and
full workloads made the app an accessory and finished launching, so in
still mode (and any unattended run) the Dock showed MacLinuxGPUHost
bouncing for as long as the agent ran. --create now sets the accessory
policy and finishes launching before anything else.
2026-10-03 19:41:38 -07:00
geramyloveless 994a5e516f display-agent: read the driver's statistics through an imported surface
The agent read the output worker's statistics with PRESENT, handle 0
and no rectangle, but the observer gate admits PRESENT only with a
nonzero handle, so on build 235 the read failed and the agent ended
the mirroring two seconds in (at the end of --warmup), reporting
FAILED. The agent now passes one of its imported surfaces' handles for
the read (the driver ignores it when there is no rectangle), opens the
measured window only once a surface exists, and never stops mirroring
because a statistics read failed: it says so and continues unmeasured.

The gate now admits handle 0 for PRESENT, as session_state.h
documents, and the gate test checks it. iokit_bridge.mm includes
time.h for the hold's clock.
2026-10-03 19:37:27 -07:00
geramyloveless 0a67e495c2 Merge feature/sysinfo: the R9700's identity in System Report
The display OUTPUT op republishes MacLinuxGPUDisplays with the lit
mode, as STATUS and the pattern ops do.
2026-10-03 17:14:14 -07:00
geramyloveless a56c499f91 Publish the GPU's identity and monitors for System Information
System Information builds a PCI GPU's entry from the IOPCIDevice merged
with the properties of its direct children, and properties a dext sets
with SetProperties() reach user space as top-level keys. The dext now
sets the keys it reads on its own service:

  model             the product name, from libdrm's table (Start)
  VRAM,totalMB      gmc.real_vram_size (after the probe)
  ATY,EFIVersionB   the VBIOS part number ("VBIOS Version")
  rom-revision      the VBIOS version string

so "Display" becomes "AMD Radeon AI Pro R9700" with its VRAM and VBIOS.
A device the table does not list gets no name; Metal and core-count keys
are not published because they would be false.

MacLinuxGPUDevice carries the rest of the identity (IDs, PCIe link, VRAM
type, CUs, ISA target, VBIOS details) and MacLinuxGPUDisplays the DRM
connectors with their monitors' EDID names and modes, updated by the
display operations and removed when the session closes. System
Information cannot list those monitors under this GPU (it only lists
IOFramebuffer kernel objects there), so MacLinuxGPUHost shows the GPU
with its monitors: "MacLinuxGPUHost device", and a GPU panel in its
window, both read from the IORegistry without a user client.

test-device-properties builds the property set with DriverKit container
substitutes, including every allocation failure; test-device-info checks
the host view.
2026-10-03 17:12:22 -07:00
geramyloveless 01ba9f85c3 display-agent: queue frames, hold their buffers until flipped, measure
PRESENT now carries the frame's capture time (ScreenCaptureKit's
display time, in the driver's clock) and returns once the frame is
queued. Because the driver copies after the call returns, the agent
keeps each presented frame's sample buffer until the driver's counters
show it flipped or replaced, so ScreenCaptureKit cannot reuse the
surface under a pending copy.

display-agent --create takes --workload still|move|full (a window
crossing the virtual display, or one covering it that changes colour
every refresh) and --warmup, and reports for the measured window:
frames captured, presented, flipped and replaced; the PRESENT call's
CPU and wall time and the frame handler's CPU; bytes, copy jobs, worker
submit time and GPU copy time per flipped frame; capture-to-scanout
latency; copy time against damage size; CPU and wakeups per second of
the agent (proc_pid_rusage) and of the driver process (top, which can
read it; --dext-pid overrides finding it).
2026-10-03 17:00:30 -07:00
geramyloveless d6ca8045c7 host: hand the GPU from the previous driver to the new one on upgrade
An activation request that replaces the driver does not stop the running
one, and the new driver attaches only after every old instance is gone. The
installer returned .replace and then checked attachment with a ping, which
the old driver answered. The old process stayed attached until someone
killed it.

The installer (the app's installer window and `activate`) now drives the
handover. It tells instances apart by IOUserServerCDHash against the
bundled dext's code signature:

- Before the activation request, each previous instance closes its session
  the normal way and admits no new one (Retire QUIESCE). Apps that still
  hold a session are listed.
- Once macOS has accepted the replacement, each previous instance is asked
  to terminate (Retire TERMINATE) and the installer waits for it to leave
  the registry. If it does not, it says why: the clients still attached, a
  BAR mapping, or a quarantine that needs a restart. It also gives the
  recovery steps and the systemextensionsctl state, and never kills it. A
  driver that predates Retire is named as such, with the enclosure power
  cycle (232 and later) or a restart as the way out.
- A failed or deferred replacement resumes the previous driver.
- Attachment is verified against the bundled driver only.
- When the bundled version is already enabled, a previous instance left by
  an earlier upgrade is retired as well.

New commands: `instances` lists attached driver instances with their
clients and session state. `retire-previous [--force] [--wait S]` finishes
a stuck upgrade, `resume-previous` cancels a quiesce, and `ping-bundled`
pings the bundled driver only. activate.sh retires the previous driver
after the new one is enabled and checks attachment with ping-bundled.
2026-10-03 16:43:29 -07:00
geramyloveless df33358aaa display: the GPU's reads decide the pinning check; no CPU view
On the R9700 (build 233) an IOSurface imported once and rewritten by
the agent every second read back through SDMA with no difference from
each new pattern and complete difference from the previous one, for 10
seconds: the client's pages stay mapped for the device after the import
call returns. The dext's read-only mapping of the same descriptor,
however, kept showing the pattern of the import call: on macOS 26 it is
a snapshot, not the client's live pages.

display-pin-test now passes or fails on the GPU's reads and reports the
CPU view's count only. IMPORT no longer maps the descriptor (each map
was a copy the size of a frame); VERIFY checks with the GPU alone.
2026-10-03 16:26:20 -07:00
geramyloveless 4ba7b56afd display: fixes from the first hardware run of build 232
- IMPORT failed on the R9700 with PrepareForDMA refusing the client's
  descriptor: the import asked for up to 64 segments, and
  IODMACommand::PrepareForDMA takes at most 32 (its IIG declaration
  passes IOAddressSegment segments[32]). DEXT_DMA_IMPORT_SEGMENTS_MAX is
  32, the mocks assert it, and a refused PrepareForDMA logs its code.
- PROBE, SHOW, OFF, STATUS and MODES failed with a bad argument from the
  host app: the frame ops raised MLG_DISPLAY_WORDS to 2 and these ops
  required it too. They take and return one status word again; the host
  app asks for two, which every build accepts.
2026-10-03 16:17:13 -07:00
geramyloveless bd63bcff87 host: display-pin-test and display-agent --create
display-pin-test [--seconds N] [--width W --height H] [--init] creates
an IOSurface, fills it with rt_surface_pattern(1), imports it once
(IMPORT: its pages as the structure input), and after the call has
returned rewrites it from the CPU every second. Each time the driver
reads it back with SDMA and through its own CPU view (VERIFY): the new
pattern must match exactly and the previous one must not. Then RELEASE,
after which the handle must be gone.

display-agent --create [--connector NAME] [--seconds N] [--init] mirrors
one connected monitor as a macOS display:
- a CGVirtualDisplay from the plan (name, IDs, size, primaries, the
  monitor's progressive modes, hiDPI 0), with the private CoreGraphics
  classes declared in CGVirtualDisplayPrivate.h;
- OUTPUT at the mode macOS picks for it;
- a ScreenCaptureKit stream of it in BGRA at that mode and refresh,
  each capture surface imported once, each frame's dirty rectangles sent
  with PRESENT;
- a mode chosen in System Settings relights the monitor at that mode;
- Ctrl-C, SIGTERM or --seconds end it: capture stopped, imports
  released, the monitor's previous configuration restored (OFF), the
  virtual display removed, and a summary of frames, average copy and
  flip times, bytes copied and the agent's CPU time.
It needs Screen Recording permission and says so when it is missing. Any
failing step ends the run with its errno; nothing else is tried.

The frame replies (verify result, present stats) and the damage
conversion live in DisplayAgent.swift, covered by test-display-agent.
2026-10-03 15:40:51 -07:00
geramyloveless 44aea908cb host: display-agent --once probes without STATUS and names missing ops
A single pass needs no hotplug epoch: it probes at once, so it runs on
drivers without the STATUS op. A driver without STATUS or MODES (before
build 231) now gets a message naming the op and the build, and a
connector without a plan still shows its decoded EDID.
2026-10-03 15:20:50 -07:00
geramyloveless 1c07048c01 Merge main into feature/display-c 2026-10-03 15:19:43 -07:00
geramyloveless 84b40028d2 Place the host window before InitDevice in the host app and the self-test
MacLinuxGPUHost init and drm-selftest.py --init called InitDevice
without placing the host window (selector 54), so compute start failed
with gart status -19. Query the aperture size, reserve it aligned, set
the base, then probe, as the HSA runtime does.
2026-10-03 15:16:21 -07:00
geramyloveless f09557da66 host: display-agent --dry-run
MacLinuxGPUHost display-agent --dry-run [--once] [--interval ms] [--init]
follows the GPU's connected monitors through an observer client. It polls
the cached connector state (selector 84 STATUS) and, when the hotplug
epoch moves, probes, reads each connected monitor's mode list (MODES)
and EDID (sysfs), and prints the CGVirtualDisplay it would create, then
the add, update and remove changes against what it had. It creates no
display; without --dry-run it refuses.

The plan takes the identity and colour from the EDID: the monitor name
(else PNP ID and product), the PNP ID word as vendor, the product, the
serial (or a stable hash of the serial string), the CIE primaries and
white point. It takes the modes from the driver's list for the link:
progressive only, duplicates dropped, preferred first, and the largest
mode as max pixels. The size comes from the driver's display_info (else
the EDID's). hiDPI is 0. A monitor with no valid EDID or no progressive
mode is reported and skipped.

The model (report/modes/EDID decoding, the plan, the agent's changes)
moves to host/DisplayAgent.swift, Foundation only, which the Xcode
target now builds; test-display-agent compiles it with a test of its
own. docs/macos-displays.md records what of the frame path exists.
2026-10-03 14:51:43 -07:00