3 Commits
Author SHA1 Message Date
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 c336a91260 scripts: display-test.py status and modes
status prints the cached connector state and the hotplug epoch without
detecting anything; modes <connector> lists that connector's probed
modes with refresh, pixel clock, the preferred mode and physical size.
2026-10-03 14:35:21 -07:00
geramyloveless 2d77cee5e9 scripts: display-test.py, the hardware display test runner
display-test.py drives selector 84 through an observer client:

  probe [--edid]      every connector with status, mode count, preferred
                      mode and EDID size; --edid reads each connected
                      EDID from sysfs (drm/cardN/cardN-<conn>/edid) and
                      decodes vendor, product, serial, name, size and
                      preferred timing
  show [--connector NAME] [--pattern bars|white|gradient] [--seconds N]
                      the pattern on every connected output, or one;
                      with --seconds it is turned off afterwards, also on
                      Ctrl-C
  off                 the recorded configuration restored

--init brings the GPU up through a session client held for the run (a
show then defaults to 30 seconds, since the session ends with the
script). Errors name the failing step's errno; nothing else is tried.
test-display-test runs it against a fake selector.
2026-10-03 14:08:36 -07:00