Skip to content

drm: apple: Drop the monitor EDID on disconnect - #654

Open
nr23730 wants to merge 213 commits into
AsahiLinux:bits/200-dcpfrom
nr23730:dcp-edid-disconnect
Open

nr23730 wants to merge 213 commits into
AsahiLinux:bits/200-dcpfrom
nr23730:dcp-edid-disconnect

Conversation

@nr23730

@nr23730 nr23730 commented Oct 25, 2026

Copy link
Copy Markdown

When using an external monitor the EDID is read. When disconnecting to another monitor, the old EDID entry stays.
This PR mirrors the drm_edid_free behavior already present in dcp_rtk_crashed.

Tested on MacBook Pro 13" M2.


Please check all boxes that apply:

  • This code was developed in accordance with the Asahi Linux Copyright Policy
  • I have not used generative AI/LLMs to develop this code, in accordance with the Asahi Linux LLM Policy
  • I have certified the above by adding a Signed-off-by: trailer to every commit

All boxes must be checked before your pull request can be reviewed.

jannau and others added 30 commits August 17, 2026 10:26
Add a DRM/KMS driver for Apple system on chips using the DCP
coprocessor, namely the Apple M1 and M1 Pro/Max/Ultra. The DCP was added
in Apple A14; this driver does not apply to older iDevices.

This driver targets the DCP firmware API shipped by macOS 12.1.
Currently no incompatibilities with macOS 12.0.1 or 12.2.1 are known.

drm: apple: Relicense DCP driver as dual MIT / GPL v2.0

Link: https://oftc.irclog.whitequark.org/asahi-dev/2022-03-20#30747564
Link: https://oftc.irclog.whitequark.org/asahi-dev/2022-03-20#30747570

drm/apple: Switch to nonblocking commit handling

The swap completes only after the async reply from DCP. Uses
drm_atomic_helper_wait_for_flip_done instead of
drm_atomic_helper_wait_for_vblanks. This should allow ius to get rid
of the scheduled fake vblanks.

drm: apple: Fix connector state on devices with integrated display

DCP issues hotplug_gated callbacks after SetPowerState() calls on devices
with display (macbooks, imacs). This must not result in connector state
changes on DRM side. Weston will not re-enable the CRTC after DPMS off
if the connector is not in connected state.
DCP provides with dcp_is_main_display() a call to query if the device has
an integrated display.

drm: apple: Brightness control via atomic commits

This abuses color_mgnt_change in drm_crtc_state and will be changed once
phase 2 of the "drm/kms: control display brightness through drm_connector
properties" RfC (linked below) is implemented.

The lookup of DAC values from brightness (nits) is not fully understood.
Since IOMFB reports te brightness back the easiest solution would be to
create our own lookup table or find a approximation which works.

DCP appears to report the brightness in nits by
"PropRelay::pr_publish(prop_id=15, value=...)" (scaled by
"Brightness_scale").

Link: https://lore.kernel.org/dri-devel/b61d3eeb-6213-afac-2e70-7b9791c86d2e@redhat.com/

drm/asahi: Fix backlight restores on non-microLED devices

Apparently what happens here is that the DCP's idea of backlight
brightness is desynced with the real brightness across power cycles.
This means that even if we just force an update after a power cycle, it
doesn't work since it considers it unchanged. To fix this, we need to
both force an update on poweron and also explicitly turn the backlight
off on poweroff, which makes DCP listen to us and actually update the
backlight state properly.

drm/apple: Schedule backlight update on enable_backlight_message_ap_gated

On non mini-LED displays the backlight comes out of power-off (DPMS)
with minimal backlight brightness. This seems to be a DCP firmware
issue. It logs "[BrightnessLCD.cpp:743][AFK]nitsToDBV: iDAC out of
range" to syslog although the brightness in the swap_submit call is
valid.

This fixes the issue only for clients using swap. For other clients an
atomic backlight update has to be scheduled via a work queue.

drm/apple: Enable 10-bit mode & set colorspace to native

This works on both 8-bit and 10-bit modes without any weirdness, and
gives us the native colorspace without any conversion. Color correction
should probably be handled in software anyway.

However, we need to use surface 1 (at least on t600x), since 0 seems
stuck in bg-sRGB mode for some reason...

drm: apple: Use components to avoid deferred probing

There was a report of a race between DRM device registration (and
removal of the simpledrm device) and GDM startup.

The component based device binding ensures that all necessary devices
are bind in the probe method of the last missing component.

Technically the piodma-mapper should be a component of dcp but since it
is only used for its iommu it can be a component of the display
subsystem.

Co-developed-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Hector Martin <marcan@marcan.st>
Co-developed-by:  Asahi Lina <lina@asahilina.net>
Signed-off-by: Asahi Lina <lina@asahilina.net>
Co-developed-by: Alyssa Rosenzweig <alyssa@rosenz.ca>
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenz.ca>
Co-developed-by: Janne Grunau <j@jannau.net>
Signed-off-by: Janne Grunau <j@jannau.net>
Signed-off-by: Janne Grunau <j@jannau.net>
Signed-off-by: Janne Grunau <j@jannau.net>
This adds support for multiple incompatible DCP firmware versions.
The approach taken here duplicates more than necessary. Unmodified calls
do not need to be templated. For simplicity and in the expectation that
more calls and callbacks are modified in the future everything is
templated.

Signed-off-by: Janne Grunau <j@jannau.net>
MacOS 13.2 does the same and it is unclear if surf[3] can be used at
all. PRobably not necessary but found during debugging to firmware 13.2.

Signed-off-by: Janne Grunau <j@jannau.net>
kwin 5.27.3 adds support for "Night Color" via drm "CTM" properties.
Wire CTM support up via the "set_matrix" iomfb call.

Link: https://bugs.kde.org/show_bug.cgi?id=455720
Signed-off-by: Janne Grunau <j@jannau.net>
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Janne Grunau <j@jannau.net>
Should result in drm apple to be registered as first DRM device
replacing simpledrm. Should resolve problems with userspace assuming
that card0 is the main displays device.

Signed-off-by: Janne Grunau <j@jannau.net>
This prevents the PD from being shut down on suspend, which we need
until we support runtime PM properly again.

Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Janne Grunau <j@jannau.net>
Signed-off-by: Janne Grunau <j@jannau.net>
Signed-off-by: Janne Grunau <j@jannau.net>
An atomic_commit for brightness changes will consume a DCP swap without
frame buffer updates and will result in a lost frame. After updating
the next brightness values wait for 1 frame duration (at 23.976 fps).
Check if the brightness update still needs to be send to DVCP or if a
swap did that in the meintime.

Signed-off-by: Janne Grunau <j@jannau.net>
It's only needed to configure the display contoller's iommu to share
buffers between the DCP co-processor and the display controller.
Possible concern is runtime PM for it and its iommu. If we don't set it
up the power domain might never go to lower power states even if it
could.

Signed-off-by: Janne Grunau <j@jannau.net>
The current use of of dma_get_sgtable/dma_map_sgtable is deemed unsafe.
Replace it with an unmanaged iommu domain for the piodma iommu to map
the buffers.

Signed-off-by: Janne Grunau <j@jannau.net>
The iommu scatter table/list mapping can only map full iommu page size
extents. Just align the actual the allocation to the iommu page size.
This could be handled differently using DARTs subpage protection but
there's no easy way to integrate that.

Signed-off-by: Janne Grunau <j@jannau.net>
Used on M2 Ultra During startup. Units are unclear.

Signed-off-by: Janne Grunau <j@jannau.net>
Removes support for all firmware versions which report as compatible to
13.3 except 13.5. This will be removed after m1n1 reports firmware 13.5
as "apple,firmware-compat" for a while.
The files with "v13_3" will be renamed at a later point to avoid
conflicts with development trees.

Signed-off-by: Janne Grunau <j@jannau.net>
Avoids ugly "__maybe_unused".

Signed-off-by: Janne Grunau <j@jannau.net>
It does not do anything for dcp and its iommu only child node.

Signed-off-by: Janne Grunau <j@jannau.net>
To match macOS behavior and in the hope to fix dcpext crashes on t8112.
Crashes still occur but let's keep this. Shouldn;t make a difference
since we're on the swaps to finish.

Signed-off-by: Janne Grunau <j@jannau.net>
DCP itself uses with the 13.5 firmware a timeout of 8 seconds for
modesets. Using a longer timeout prevents overlapping calls to dcp and
might improve reliabilty with slower displays.

Signed-off-by: Janne Grunau <j@jannau.net>
This is no longer necessary after introducing "apple,dma-range" for the
dart driver.

Signed-off-by: Janne Grunau <j@jannau.net>
This drivers adds support for the display crossbar used to route
display controller streams to the three different modes
(DP AltMode, USB4 Tunnel #0/AsahiLinux#1) of the Type-C ports.

Signed-off-by: Sven Peter <sven@svenpeter.dev>
chadmed and others added 26 commits August 23, 2026 23:04
Some of this is 0xaa padding, some of it is zeroes, and
there is a conspicuous empty byte at the end.

Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
DCP 14.7 expects its 0x234-byte extension before the pointer-null
flags. Linux placed it after the flags, so DCP read the flags at the
old offsets and rejected surface-clear requests.

Move the extension before the pointer-null flags.

Signed-off-by: a-ramses <abdicheramzi@gmail.com>
This reverts commit 47508c0.

The DCP 14.7 request layout now matches the firmware, so surface-clear
requests work and stale framebuffer references can be retired again.

Signed-off-by: a-ramses <abdicheramzi@gmail.com>
Apple Interchange is a tiled and compressed image layout used
for buffer exchange between Apple hardware blocks. It is
similar to the already-supported GPU_TILED_COMPRESSED layout.

Add a format modifier for Apple Interchange so that it can be
used for buffer exchange.

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenz.ca>
Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
Signed-off-by: Lyude Paul <lyude@redhat.com>
Link: https://patch.msgid.link/20261007-apple-interchange-modifier-v3-1-721fc44abf6b@gmail.com
Signed-off-by: Hojun Cho <ghwns6743@gmail.com>
Signed-off-by: Janne Grunau <j@jannau.net>
Signed-off-by: Sofus Forstreuter <sofus.c@icloud.com>
The score is not necessarily the best criterion for mode selection. The
"TimingElements" contain in addition a "IsPreferred" flag. Take this
into account by adding 2**32 to the score. This will result in marking
the mode with the highest score and "IsPreferred" as
DRM_MODE_TYPE_PREFERRED.

Signed-off-by: Oliver Clarke <oliverhenryc@gmail.com>
Signed-off-by: Janne Grunau <j@jannau.net>
DCP supports multiple addressing and framebuffer compression formats.
While DCP does seem to support direct scanout of AGX layout images
(APPLE_GPU_TILED/APPLE_GPU_TILED_COMPRESSED), macOS is never observed
doing this. Instead, it uses a secret third layout called Apple Interchange.

Apple Interchange is a tiled and compressed framebuffer format similar
to AGX's native format, albeit with slightly different addressing.
RGB images and the chroma channels of Y'CbCr images share a tile size
of 16x16, while the luma channel of Y'CbCr formats has a tile size of
32x32.

Define enums for both addressing format and compression mode, and add
known supported modes for each.

Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
Apple Interchange is a tiled and compressed framebuffer layout
used for sharing framebuffers between Apple hardware blocks
(AGX, AVD, DCP).

DCP can scan out framebuffers in Interchange format. Add support
for this to the Linux driver.

Co-developed-by: Oliver Bestmann <oliver.bestmann@googlemail.com>
Signed-off-by: Oliver Bestmann <oliver.bestmann@googlemail.com>
Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
Signed-off-by: Janne Grunau <j@jannau.net>
On DCPs which support scanout on >2 surfaces (T8112 and later), using
Interchange on all of them will cause the coprocessor to crash. It is
unclear why this is the case.

This is never observed on macOS for two reasons:
    1. macOS never uses more than two planes at a time; and
    2. The second plane is almost always a linear framebuffer,
       except when scanning out video from AVD.

On Linux, we can avoid these crashes by simply hiding Interchange from
one of the surfaces. Since the topmost surface on these DCPs will almost
always be used only for a cursor, and since a tiny cursor framebuffer
is not bandwidth-critical, simply advertise it as linear only. This fixes
spurious crashes on T602x and T8112.

Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
Signed-off-by: Janne Grunau <j@jannau.net>
Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
The image tile size calculation was being done by rounding up bits
per pixel and dividing by 8. The entire size in bytes needs to be
rounded up and divided by 8.

Fixes: cb69536 ("drm: apple: Add support for Apple Interchange framebuffers")
Signed-off-by: Sofus Forstreuter <sofus.c@icloud.com>
Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
Some pixel formats supported by both AVD and DCP do not have integer
bits per pixel values when using drm_format_info_bpp. Calculate the
bits per pixel "manually" instead.

Signed-off-by: Sofus Forstreuter <sofus.c@icloud.com>
Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
AVD's 10-bit semiplanar YCbCr output is in P030, P230 and P430 for
both video and full range. DCP firmware supports these, so add them
to the list of supported formats.

Signed-off-by: Sofus Forstreuter <sofus.c@icloud.com>
Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
Signed-off-by: Janne Grunau <j@jannau.net>
Signed-off-by: Niklas Reimer <niklas@backbord.net>
hitori-chan added a commit to hitori-chan/linux that referenced this pull request Nov 19, 2026
…kill word

A process killed with GPU work in flight held its queue's teardown for
the full 5 s wait, then the channel 2 s more (G15_DEAD_MS) until a host
stop failed every job in the firmware, other processes' included (AsahiLinux#647
killq-q.sh: 20 kills, 8 host stops, each 7.5-8.2 s after the dead job's
submission; the other client's job consumed, read = write, and
waiting).

macOS 27.2 ends a dead process's jobs 250 ms after it died with device
control 0x29. 14.8.3's kext has the same command as 0x21
(processExitTimeoutHandler, AGXG15C_1483 0xfffffe0008e51724) but never
arms its timer; the firmware still handles it (AGFA_ChannelConsumer
case 0x21): its one access to a node is a 64-bit store of 0 at +0xA8
(0x8b60), then it asks for a context store (reason 0xC) of the channel's
jobs on the GPU. Sent on the notifiers, whose +0xA8 is the cutoff the
scheduler's stale-job gate reads, it changed nothing (r221's g15_kill,
AsahiLinux#650: 14 of 14 consumed, 14 host stops): the store lands, and the stored
job then waits at the gate on itself.

Give each channel a kill word of its own in firmware-uncached memory,
armed to all-ones, and point the TA, 3D and CL records' stale cutoffs at
it (TA p(0x1B8), 3D p(0x1D0), CL +0x1B4) in place of the notifier's.
asahi.g15_kill (1, the default) sends 0x21 naming word - 0xA8 on each
channel of a destroyed queue whose jobs still run after the 250 ms
grace, waits until the control ring has consumed them (the handler reads
the job table unchecked: only for a channel of the current reset
generation, before its release, with its job index set), then waits out
the rest. The gate's cutoff stays as it was: a stored job resumes, its
context record reads its own cutoff as stale and it ends with its stamp
(AGFA_Executor 0x1a53c, 0x1a7c0); a fresh one ends without a kick. A
stale 3D whose scene is live is still kicked, as a store-only pass. A
channel whose command is not seen consumed is never reused; the others'
words are armed again when the channel is kept. Event 0xD counts the
commands done (debugfs asahi/perf "kills ... done"). The G15_DEAD_MS
comment said the scan skips stage-0 channels, which ours have not been
since the stage-2 change.

Static, 14.8.3 (27.2 the same order): a TA asked for a store mid-draw
sets its resume flag (sub_1E50C), rewinds to its context record and comes
back stale with its scene live; its finish reads a slot it never kicked,
which the last occupant's slot done (+0xC060) and the TA finish's zeroing
of the control words (0x1c688) leave idle (inferred: with ktrace off
nothing waits for it).

On the Mac (killq-q.sh, SIGKILL 0.2-0.9 s into the client, 20 kills a
run, 2026-11-19), with the test builds' [tr] 100 ms sleep inside the kill:
- AsahiLinux#654 (build 2, g15_kill=3): compute, GLES fragment and vertex draws of
  0.35 s and fragment draws beside a live client (187 runs, 0 failing):
  80 of 80 kills consumed, 0 host stops; regress.sh 30 of 30.
- Draws of about 1.5 s: g15_kill=0 (AsahiLinux#655) 7 host stops in 40 kills, 33
  torn down with jobs running; build 3 (AsahiLinux#656, g15_kill=3) 20 of 20
  fragment kills (teardown 515-562 ms) and 17 of 17 vertex kills (354-361
  ms: the grace, the sleep and 4-11 ms, so the TA was cut mid-draw, not
  run to its end), 0 host stops.
- AsahiLinux#656, compute and fragment draws of 1.5 s beside a live client (125
  runs, 0 failing): 40 of 40, 0 host stops; regress.sh 30 of 30.
No channel error or firmware crash in any run, and a checked compute run
passed after each.
hitori-chan added a commit to hitori-chan/linux that referenced this pull request Nov 20, 2026
…kill word

A process killed with GPU work in flight held its queue's teardown for
the full 5 s wait, then the channel 2 s more (G15_DEAD_MS) until a host
stop failed every job in the firmware, other processes' included (AsahiLinux#647
killq-q.sh: 20 kills, 8 host stops, each 7.5-8.2 s after the dead job's
submission; the other client's job consumed, read = write, and
waiting).

macOS 27.2 ends a dead process's jobs 250 ms after it died with device
control 0x29. 14.8.3's kext has the same command as 0x21
(processExitTimeoutHandler, AGXG15C_1483 0xfffffe0008e51724) but never
arms its timer; the firmware still handles it (AGFA_ChannelConsumer
case 0x21): its one access to a node is a 64-bit store of 0 at +0xA8
(0x8b60), then it asks for a context store (reason 0xC) of the channel's
jobs on the GPU. Sent on the notifiers, whose +0xA8 is the cutoff the
scheduler's stale-job gate reads, it changed nothing (r221's g15_kill,
AsahiLinux#650: 14 of 14 consumed, 14 host stops): the store lands, and the stored
job then waits at the gate on itself.

Give each channel a kill word of its own in firmware-uncached memory,
armed to all-ones, and point the TA, 3D and CL records' stale cutoffs at
it (TA p(0x1B8), 3D p(0x1D0), CL +0x1B4) in place of the notifier's.
asahi.g15_kill (1, the default) sends 0x21 naming word - 0xA8 on each
channel of a destroyed queue whose jobs still run after the 250 ms
grace, waits until the control ring has consumed them (the handler reads
the job table unchecked: only for a channel of the current reset
generation, before its release, with its job index set), then waits out
the rest. The gate's cutoff stays as it was: a stored job resumes, its
context record reads its own cutoff as stale and it ends with its stamp
(AGFA_Executor 0x1a53c, 0x1a7c0); a fresh one ends without a kick. A
stale 3D whose scene is live is still kicked, as a store-only pass. A
channel whose command is not seen consumed is never reused; the others'
words are armed again when the channel is kept. Event 0xD counts the
commands done (debugfs asahi/perf "kills ... done"). The G15_DEAD_MS
comment said the scan skips stage-0 channels, which ours have not been
since the stage-2 change.

Static, 14.8.3 (27.2 the same order): a TA asked for a store mid-draw
sets its resume flag (sub_1E50C), rewinds to its context record and comes
back stale with its scene live; its finish reads a slot it never kicked,
which the last occupant's slot done (+0xC060) and the TA finish's zeroing
of the control words (0x1c688) leave idle (inferred: with ktrace off
nothing waits for it).

On the Mac (killq-q.sh, SIGKILL 0.2-0.9 s into the client, 20 kills a
run, 2026-11-19), with the test builds' [tr] 100 ms sleep inside the kill:
- AsahiLinux#654 (build 2, g15_kill=3): compute, GLES fragment and vertex draws of
  0.35 s and fragment draws beside a live client (187 runs, 0 failing):
  80 of 80 kills consumed, 0 host stops; regress.sh 30 of 30.
- Draws of about 1.5 s: g15_kill=0 (AsahiLinux#655) 7 host stops in 40 kills, 33
  torn down with jobs running; build 3 (AsahiLinux#656, g15_kill=3) 20 of 20
  fragment kills (teardown 515-562 ms) and 17 of 17 vertex kills (354-361
  ms: the grace, the sleep and 4-11 ms, so the TA was cut mid-draw, not
  run to its end), 0 host stops.
- AsahiLinux#656, compute and fragment draws of 1.5 s beside a live client (125
  runs, 0 failing): 40 of 40, 0 host stops; regress.sh 30 of 30.
No channel error or firmware crash in any run, and a checked compute run
passed after each.
hitori-chan added a commit to hitori-chan/linux that referenced this pull request Nov 20, 2026
…kill word

A process killed with GPU work in flight held its queue's teardown for
the full 5 s wait, then the channel 2 s more (G15_DEAD_MS) until a host
stop failed every job in the firmware, other processes' included (AsahiLinux#647
killq-q.sh: 20 kills, 8 host stops, each 7.5-8.2 s after the dead job's
submission; the other client's job consumed, read = write, and
waiting).

macOS 27.2 ends a dead process's jobs 250 ms after it died with device
control 0x29. 14.8.3's kext has the same command as 0x21
(processExitTimeoutHandler, AGXG15C_1483 0xfffffe0008e51724) but never
arms its timer; the firmware still handles it (AGFA_ChannelConsumer
case 0x21): its one access to a node is a 64-bit store of 0 at +0xA8
(0x8b60), then it asks for a context store (reason 0xC) of the channel's
jobs on the GPU. Sent on the notifiers, whose +0xA8 is the cutoff the
scheduler's stale-job gate reads, it changed nothing (r221's g15_kill,
AsahiLinux#650: 14 of 14 consumed, 14 host stops): the store lands, and the stored
job then waits at the gate on itself.

Give each channel a kill word of its own in firmware-uncached memory,
armed to all-ones, and point the TA, 3D and CL records' stale cutoffs at
it (TA p(0x1B8), 3D p(0x1D0), CL +0x1B4) in place of the notifier's.
asahi.g15_kill (1, the default) sends 0x21 naming word - 0xA8 on each
channel of a destroyed queue that still has an unsignaled job after the
250 ms grace (a pass's TA and 3D channels included), and on no idle one,
waits until the control ring has consumed them (the handler reads the
job table unchecked: only for a channel of the current reset generation,
before its release, with its job index set), then waits out the rest.
The gate's cutoff stays as it was: a stored job resumes, its context
record reads its own cutoff as stale and it ends with its stamp
(AGFA_Executor 0x1a53c, 0x1a7c0); a fresh one ends without a kick. A
stale 3D whose scene is live is still kicked, as a store-only pass. A
channel whose command is not seen consumed is never reused nor stolen
(kill_unsure); the others' words are armed again when the channel is
kept. Event 0xD counts the commands done (debugfs asahi/perf "kills ...
done"). The G15_DEAD_MS comment said the scan skips stage-0 channels,
which ours have not been since the stage-2 change.

An idle channel gets no 0x21: it has nothing to end, and the
firmware's 0x21 acts on the one channel's job index and node it names
(submission.md, device control 0x21), so a compute job running beside
an idle pair would zero the pair's word or, with the command not seen
consumed, cost the pair for good. The kill takes the queue off the live
render queues and marks it dead (g15_rd_dead, which g15_rd_queue_put
shares) before it collects the channels: until the firmware consumed
the commands, another process short of a pair could steal the dying
queue's idle pair, and the firmware then zeroed its kill word under the
thief's jobs, or left it zeroed for it, every later job on the pair
ending without running. The dying queue takes no new pair, so its later
passes fail with ECANCELED or end as stale on the killed one.

Queue::drop marks its held runs dead and cancels them under the `held`
lock before its teardown wait, inside which the kill runs, not after
it: a job whose dependencies signalled during the wait could be run by
the scheduler, or a held-back run advanced by the poller, after the
kill, with nothing to end it, and a long one brought a host stop
through G15_DEAD_MS. run_g15 takes the same lock and cancels a run that
meets `dead`, so no command of the queue is rung after that point; one
held back while its queue is destroyed fails at once. The jobs already
rung are still waited for and killed after the grace.

Static, 14.8.3 (27.2 the same order): a TA asked for a store mid-draw
sets its resume flag (sub_1E50C), rewinds to its context record and
comes back stale with its scene live; its finish reads a slot it never
kicked, which the last occupant's slot done (+0xC060) and the TA
finish's zeroing of the control words (0x1c688) leave idle (inferred:
with ktrace off nothing waits for it).

On the Mac (killq-q.sh, SIGKILL 0.2-0.9 s into the client, 20 kills a
run, 2026-11-19), with the test builds' [tr] 100 ms sleep inside the
kill, 0x21 on every channel of the queue once one had a job running,
and the held runs cancelled after the teardown's wait:
- AsahiLinux#654 (build 2, g15_kill=3): compute, GLES fragment and vertex draws of
  0.35 s and fragment draws beside a live client (187 runs, 0 failing):
  80 of 80 kills consumed, 0 host stops; regress.sh 30 of 30.
- Draws of about 1.5 s: g15_kill=0 (AsahiLinux#655) 7 host stops in 40 kills, 33
  torn down with jobs running; build 3 (AsahiLinux#656, g15_kill=3) 20 of 20
  fragment kills (teardown 515-562 ms) and 17 of 17 vertex kills
  (354-361 ms: the grace, the sleep and 4-11 ms, so the TA was cut
  mid-draw, not run to its end), 0 host stops.
- AsahiLinux#656, compute and fragment draws of 1.5 s beside a live client (125
  runs, 0 failing): 40 of 40, 0 host stops; regress.sh 30 of 30.
No channel error or firmware crash in any run, and a checked compute run
passed after each.

With the idle channels' exemption, the queue taken off the live ones
before the kill, the steal's kill_unsure check and the earlier cancel
(r224, 2026-11-20): the debug kernel AsahiLinux#664 (lockdep, KASAN) through
killq-q.sh's compute, fragment and vertex runs, 29 kills, all done
(asahi/perf), a checked compute run passing after each, and storm.sh 16;
nothing reported. A steal during a kill was not forced.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.