2 Commits
Author SHA1 Message Date
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 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