Skip to content

drm/apple: dptxep: don't refill a stalled port with HPD requests - #3360

Open
DjDeveloperr wants to merge 9 commits into
mainfrom
fix/dcp-afk-hpd-slot-exhaustion
Open

DjDeveloperr wants to merge 9 commits into
mainfrom
fix/dcp-afk-hpd-slot-exhaustion

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What: On a J316c (M1 Max), the external display processor (firmware 13.5) stopped answering its DPTX port after an s2idle. The Type-C SAFE retries then kept sending HPD lows. Each one that timed out kept one of the port's 16 AFK command slots, until every call on the port failed with -ENOSPC. With this change, an HPD request identical to the port's last one, which the firmware has not read yet, is not queued again: only its doorbell is rung again. The ring pointers of a timed-out command are now logged for every processor, so the stall itself can be traced.

Tested: no Mac at this head yet. Host only: apple-afkv2 passes with gcc and clang under ASan and UBSan, and --only afk 13/13, --only dptx 11/11. --only dcp is 102/103: three apple-dcp units don't compile, and fail the same way on main 37a630623169 alone, since #4013. With the merge onto 5fe340ace (before #4013) --only dcp was 103/103. drivers/gpu/drm/apple/ builds for arm64 at W=1 with 0 warnings, also with the display, parser and fabric KUnit suites, which are built, not run here (DRM_APPLE doesn't build under UML). checkpatch --strict is clean on the three new commits.

Risk: two-way · every Mac with a DCP (shared AFK code). The HPD change only acts after an HPD request has gone unanswered while the TX ring still holds unread entries. The new log line only prints on a command timeout.

Not yet:

  • A J714s row: external display, 3 sleeps and 3 replugs, no AFK slot exhaustion.
  • A J773g row: DP-3, no regression.
  • A J316c row (peer Mac): external DP on USB-C, s2idle cycles and replugs.
  • What stops the firmware from reading its queues after the s2idle. The ring log is there to capture it.
Details

How the slots run out (current main)

  1. dcp_typec_route_prepare() (dcp-fabric.c) handles SAFE. It sets safe_pending and calls dcp_dptx_disconnect_oob(), which sends dptxport_set_hpd(port, false) and returns its error. A timed-out HPD low fails the mux change, and the port stays safe_pending=1, safe_finish_ready=0.
  2. The DCP routes don't declare transient timeouts, so cd321x treats the -ETIMEDOUT as a failed update. cd321x_retry_revalidation() retries up to 3 more times per event, and every later event (resume revalidation, partner change) starts another series. Each attempt re-enters the prepare and lowers HPD again.
  3. In afk_send_command_common(), a command that timed out, or whose doorbell was lost after it was published, keeps its slot and its buffers (free_on_ack, no waiter) until the firmware answers. This is correct: the reply names the slot and is written into the command's buffer. But each repeat takes one more slot, and after 16 every call fails with -ENOSPC.
  4. A legacy HPD request takes 128 bytes of the TX ring. The J316c capture showed 16 held slots, all group 8 command 8, and 2048 unread bytes. So the firmware had read none of the 16 requests.

The fix. afk_service_call_ring_unread() looks at the command queued last on a service. If it is the same call with the same input, has no answer and no waiter, and the TX ring still holds unread entries, it rings the doorbell again and returns true. dptxport_set_hpd_timeout() then returns -ETIMEDOUT at once, as the first request did, without queuing a copy. A copy would do nothing: nothing else was queued on the port in between.

  • The other HPD level and any other call are sent as before.
  • A request the firmware has read, or answered, is sent again.
  • A call that the sender would refuse (stopping, transmit paused or closed, crashed, quiescing) is left to the sender, so its error is the same as before.
  • Compact EPIC is not covered: it keeps its timed-out commands apart.
  • Slots of unanswered commands are never reclaimed, so late replies stay safe.

This does not bring back a port whose firmware has stopped. It keeps the stall from taking every slot, so the failure stays a timeout, and a firmware that resumes has one request to answer, not 16.

What main already does. main (#3321) returns the error of a lost doorbell from afk_send_ret() to the caller and keeps the published command's slot. The earlier version of this branch did the first part a second way (int afk_send(), int dcp_send_message(), a doorbell counter) and is gone, with its stall report and the apple-afk-stall KUnit suite built on it.

  • A timed-out command now always had its doorbell delivered. A lost one fails the call at once (failed to complete: -110 with no timed out after line before it).
  • TX r/w in the timeout log tells whether the firmware still reads its queue, and running/crashed whether RTKit is up.

The J316c stall. Both endpoints of the same processor stopped: 0x29 (audio OPEN, the first timeout) and 0x2a (DPTX). That points at the coprocessor or its mailbox, not at the AV service. On this path (T600x dcpext, not dcp->external), dcp_platform_suspend() closes audio and keeps the domains on through device_set_wakeup_path(). dcp_platform_resume() then opens audio again, and that OPEN is the call that timed out first.

Related PRs

Route deferral (-61), not changed here. -ENODATA comes from dcp_modes_dup() in the route-follow prepare. The pipeline that owns the port's route has no admitted mode catalog for that connector. On a J316c, each Type-C port has two candidate pipelines (dcpext1, then dcpext0). The log fits this: the connector was on dcpext0's CRTC (289c00000.dcp) while dcpext1 (28cc00000.dcp, the processor that later stalled) owned the route. apple_crtc_atomic_enable() invalidates the CRTC's mode and sends a notify-only hotplug, so DRM keeps the CRTC active and the connector connected with nothing scanned out. Recovery is the owner's READY hotplug: dcp_hotplug() → dcp_retrain_active_crtc() resets the CRTC once the catalog arrives. When the owner's firmware is the one that stalled, that READY never comes. No separate code defect was found there.

Evidence

On main 37a630623169:

  • 0b35d733b33d, a4fa8d3fe580 and efd42a16294e: the earlier version.
  • 09938fa53392 drm/apple: afk: drop the stall report and the doorbell count
  • 75450d09821f merge of main, no conflict left after it
  • ea49e8fa4095 drm/apple: dptxep: ring again for an unread HPD request
  • 444bc2b0e386 drm/apple: afk: log the rings of every command that times out

Against main the branch changes 6 files: afk.c, afk.h, dptxep.c and three host-test files.

Host tests ran in the pinned host-tests container image. extract-send.py runs the real afk_send_command_common(), reply path and afk_service_call_ring_unread() on a legacy ring:

  • One HPD low, then 32 repeats, for a request that timed out and for one whose doorbell was lost: 1 slot held, 32 doorbells with the same write pointer, nothing more in the ring.
  • The other level, another group or command, and a call the sender refuses (paused, stopping, quiescing, crashed, service closed, compact) are not matched. Neither is one whose caller still waits, one that is answered, or one the firmware has read.
  • A late reply frees the slot, and the request is then sent again.
  • 14 mutations of the new function are all caught.

extract-hpd.py checks that dptxport_set_hpd_timeout() sends no copy and returns -ETIMEDOUT.

Build: arm64, clang 23, CONFIG_DRM_APPLE=m. afk.o and dptxep.o also build at W=1 at the merge commit and at each commit after it.

On a J316c (M1 Max, external display processor on firmware 13.5) the
DPTX port stopped answering after an s2idle: an HPD low timed out, and
every later call on the port timed out or failed with -ENOSPC. The log
held only the timeouts. What the host saw of the endpoint at that point
tells a firmware that stopped reading its queue from one that was never
told about the command, but it was printed only for the T6030 external
processor. A doorbell the mailbox failed to deliver was not reported at
all, except on firmware 14.7 and native26.

On the first timeout of a stall (until the service's next reply), report
once:
- the service's command slots, and how many hold timed-out commands;
- the TX ring pointers and how many bytes the firmware has not read yet,
  and the RX ring pointers;
- how many doorbells in a row the mailbox did not deliver, and why;
- whether RTKit runs or has crashed.

Say when a timed-out command is answered after all, and how long after it
was queued: that tells a slow firmware from a stopped one. Say once,
until the next reply, that a service has no free command slot left,
rather than only the caller's -ENOSPC.

dcp_send_message() now returns the mailbox result and warns, rate
limited, on every firmware. A lost doorbell is only counted: its entry
stays in the ring, and the next doorbell carries a later write pointer
that covers it.

Nothing here reads the coprocessor: the rings are host memory.

Signed-off-by: DjDeveloperr <hey@djdev.me>
A command that times out keeps its slot and its buffers until the
firmware answers it: the reply names the slot and lands in the command's
buffer, so neither can be reused before then (afk_recv_handle_reply()).
That keeps late replies safe, but a caller that repeats a call the
firmware does not answer takes one more of the service's 16 slots each
time.

The Type-C SAFE transition does that with a DPTX port's HPD low.
dcp_typec_route_prepare() lowers HPD through dcp_dptx_disconnect_oob()
and fails the transition when the HPD low times out. The port stays
safe_pending, the port controller retries the transition, and every
retry and every later cable event lowers HPD again. On a J316c whose
external display processor had stopped reading its queue (firmware 13.5,
after an s2idle), all 16 slots of the port ended up held by unanswered
HPD lows, with 2048 unread bytes in its TX ring. From then on the port
refused every call with -ENOSPC until a reboot.

A copy queued behind an identical request that is still unanswered does
nothing: no other call was queued on the service in between, so the
firmware takes it right after the first, with the same input. Add
afk_service_call_unanswered(), which tells whether the call queued last
on a service is this one, with the same input, and timed out unanswered.
dptxport_set_hpd_timeout() then returns -ETIMEDOUT at once, as the first
request did, without sending a copy. The other HPD level, and any other
call, is sent as before, and so is the same request once the firmware
has answered.

The slots of commands that did time out are not reclaimed, so late
replies stay safe. This does not bring back a port whose firmware has
stopped; it keeps the stall from taking every slot of the port.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 27, 2026 06:21
@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Merge readiness at e09a113e: not ready yet

Check Detail
CI at head ok 9 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head no no line with the head SHA e09a113e, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · every Mac with a DCP (shared AFK code). The HPD change only acts after an HPD request has gone unanswered while the TX ring still holds unread entries. The new log line only prints on a command timeout.

Areas: area:display

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Non-author review at a4fa8d3fe580: READY on the code, 0 blockers. The J316c and second-generation rows are owed before merge.

  • HPD de-duplication (a4fa8d3fe580):
    • afk_service_call_unanswered() matches only the command queued last on the service. That command must still hold its slot with no waiter (it timed out: completion == NULL, not done). It must also be the same standard service call (group 8, command 8), with the same input bytes.
    • It reads the command's buffer under service->lock, and that buffer can't be freed while the slot bit is set.
    • A different HPD level, another call queued after it, a late reply (which frees the slot) and compact EPIC all fall through to a normal send.
    • Returning -ETIMEDOUT at once gives the Type-C retry path the same error it saw before, only sooner. A stall now holds one slot instead of all 16.
  • Stall report (0b35d733b33d):
    • It prints only on the first timeout since the service's last reply, on a full slot map (each once until the next reply), and on a late reply (rate limited).
    • "Late" is exact: commands are only queued with a completion, and only the timeout path clears it.
    • afk_send() now returns the mailbox result, but afk_send_epic_token() still returns 0 and leaves the entry in the ring. A failed doorbell is only counted.
    • dcp_send_message() returns -ESHUTDOWN while quiescing. It now warns, rate limited, on a failed send on every firmware.
    • The KUnit static stub on afk_send() compiles away without KUnit.
  • Checks:
    • checkpatch.pl --strict: nothing but the MAINTAINERS notice for the new afk-stall-test.c.
    • Both commits are signed off, with no attribution, and the branch merges cleanly onto current main.
    • Apple DRM KUnit, which runs the display suites including the new apple-afk-stall, passed at this head.
    • The PR body matches the code.
  • CI at this head: 13/20 checks pass, 7 still pending at posting, 0 failing.
  • Owed before merge:
    • A J316c row at this head: external DP on USB-C, s2idle cycles and replugs.
    • Because this is shared AFK/DCP code: a second-generation row on a 13.5 external processor (M2 Pro/Max), and a 27.x Mac for the dcp_send_message() change.
    • CI green.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: Code approved at a4fa8d3fe580. Hardware evidence remains open.

The suppression test checks the live slot bitmap, tag, completion state and command bytes while holding the service lock. It leaves a different HPD level eligible and does not retry a doorbell with uncertain delivery. Hosted Apple build, KUnit and host tests pass. Before merge, record the J316c external-DP suspend/replug row and the requested 13.5 and 27.x peers. This avoids slot exhaustion after the stall; the original firmware stall remains a separate diagnosis.

@erikwb

erikwb commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

We carry this PR in our J716c (M5 Max, T6050) daily kernel.

When an external display processor stops answering its DPTX port (such as after sleep/resume), repeated Type-C retries previously queued duplicate unanswered HPD requests until all 16 AFK command slots were exhausted, leaving the port jammed without surfacing the underlying AFK stall.

Carried in our J716c daily kernel as protection against DPTX AFK slot exhaustion and to log stall diagnostics; running cleanly in daily use.

@github-actions github-actions Bot added merge-conflict Conflicts with the base branch (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Dec 1, 2026
The selftest EPIC service stub in edid.py takes both sides' fields: main's defer_start and started, and this branch's stall_reported, full_reported and last-call record.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Merged main (3d7cc83dffb1) into the branch as efd42a16294e. The only conflict was the EPIC service stub in the apple-dcp selftest edid.py, and it keeps both sides' fields. The merged diff against main touches the same 10 files as the PR.

On the merged tree:

  • run-afkv2-tests.sh passes, including "no copy of an unanswered request".
  • The apple-dcp edid group passes 4/4.
  • lifecycle gives 32/37. The 5 failures (cpuidle-s2idle, probe-mux-pm-dispatch, dwc3-teardown, same-handle-srcu-index, mux-release-stages) fail identically on main alone.
  • The apple-afk-stall KUnit suite runs in CI.

Still owed before merge: an independent approval, and the rows in Not yet: J316c external DP with s2idle and replug, plus a second generation. Our J414s (M2 Pro) can take the second-generation row, and J714s covers the 27.x dcp_send_message() path.

@github-actions github-actions Bot removed ci-failing A check failed at the PR head (bot) merge-conflict Conflicts with the base branch (bot) labels Dec 2, 2026
@joshuaswarren

Copy link
Copy Markdown
Contributor

Hardware row on the 16-inch M1 Max MacBook Pro (J316c, T6001), at head efd42a1: skipping the external-DP row — this machine currently has no external display attached, so the 3x s2idle + 3x replug sequence can't run. The internal panel (eDP-1) is the only connected connector. Will rerun if a display gets attached.

@github-actions github-actions Bot added merge-conflict Conflicts with the base branch (bot) and removed needs-hw-row No hardware row at the PR head (bot) merge-conflict Conflicts with the base branch (bot) labels Dec 2, 2026
Main now returns the error of an undelivered doorbell from
afk_send_ret() to the caller, keeps the slot and buffers of the
published command itself, and logs the failed call. A command that
times out has had its doorbell delivered. That replaces what this branch
did with an int afk_send(), a dcp_send_message() that returns the
mailbox result, and a count of undelivered doorbells.

The rest of the report (slots, late replies, the first stall only) is
not needed for the fix. Keep only the HPD check.

The apple-afk-stall KUnit suite stubbed the second afk_send() and goes
with it. The host tests run the real sender instead.

Signed-off-by: DjDeveloperr <hey@djdev.me>
With the stall report and the doorbell count gone, nothing conflicts:
afk_send_ret(), dcp_send_message_ret() and the transmit admission are
main's, and the branch adds the HPD check.

Signed-off-by: DjDeveloperr <hey@djdev.me>
The check that keeps an HPD request from being queued behind its own
unanswered copy also skipped the copy's doorbell. Main now fails a
command whose doorbell the mailbox did not deliver, and holds its slot
like that of a timed-out one. Skipping every repeat of such a request
would leave it without a doorbell until some other call is queued on
the endpoint, and a port in a Type-C SAFE retry queues no other call.
A request the firmware did read, but never answered, would also never
be sent again.

Match the request only while the TX ring still holds unread entries, and
ring the doorbell again for it. Every retry then pokes the firmware as
before, but takes no slot. Use main's transmit admission, and leave a
call that the sender would refuse to the sender, so its error stays the
same.

The slot of the command queued last is enough to find it: a set slot bit
means that it was not reused since.

Run the check and the sender together in the host tests, for a request
that timed out and for one whose doorbell was lost.

Signed-off-by: DjDeveloperr <hey@djdev.me>
The ring pointers tell whether the firmware still reads its queue, but
they were logged only for the T6030 external processor. The J316c stall
was on a T600x one (firmware 13.5), where the log held nothing but
timeouts. The snapshot reads host memory and RTKit's state, not the
coprocessor, so log it for every processor.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr DjDeveloperr changed the title drm/apple: dptxep: don't refill a stalled port with HPD requests; report AFK stalls drm/apple: dptxep: don't refill a stalled port with HPD requests Dec 3, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Merged main (37a630623169) and reworked the branch on top of it: head 444bc2b0e386.

  • What conflicted: afk.c, dcp.c, dcp.h and extract-send.py. drm/apple: m4: power down idle external DCPs at runtime #3321 had added afk_send_ret(), dcp_send_message_ret() and the transmit admission, and this branch had its own version of the first two.
  • Dropped, because main covers it: int afk_send(), int dcp_send_message() and the doorbell count. A lost doorbell now fails the call at once, and main keeps its slot. The stall report and the KUnit suite that stubbed the old afk_send() went with it.
  • Kept: the HPD check, which main doesn't have. It now only matches while the TX ring still holds unread entries, and rings the doorbell again instead of skipping it. Skipping would have left a request with a lost doorbell unread for good, as the SAFE retries queue nothing else. The existing ring log now prints on every processor, not only T6030.
  • Checks: apple-afkv2 passes (gcc and clang, ASan/UBSan), --only afk 13/13, --only dptx 11/11, --only dcp 102/103. The one failing job, apple-dcp (physical-disconnect, fast-replug-bounce, dropped-swap-teardown don't compile), fails the same on main alone, since drm/apple: dcp: rearm Type-C IOMFB HPD completion on deep-sleep DPTX release #4013. arm64 W=1 of drivers/gpu/drm/apple/ has no warnings, and checkpatch --strict is clean. The KUnit suites are built, not run.
  • Unverified: nothing ran on a Mac. The earlier approval was for the old version, so this needs a new look.
  • Rows owed: J714s external display (3 sleeps and 3 replugs, no AFK slot exhaustion), J773g DP-3 no regression, J316c from a peer.

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) needs-hw-row No hardware row at the PR head (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Dec 3, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 444bc2b

Checked: Ran the exact-head AFKV2 send and DPTX HPD controls with ASan and UBSan. Repeated identical HPD requests for a still-unread ring entry ring the doorbell again without spending another slot, including after the original doorbell was lost. A drained ring, different HPD payload, and refused TX admission retain the regular send path. The separate apple-dcp fixture issue from the base has been fixed on main in #4019.

@github-actions github-actions Bot removed ci-failing A check failed at the PR head (bot) labels Dec 3, 2026
afk_service_call_ring_unread() leaves a call that the sender would refuse
to the sender, but it checked only a part of what the sender checks. It
also rang while the firmware-27 sleep gate (sleep_v27_closed) is closed,
when nothing may reach the firmware, and read the ring pointers without
checking that the ring is set up. Check both, as afk_send_epic_token()
does.

The test covers both, and that with both HPD levels unread only the one
queued last is taken for a repeat. It passed before with last_slot never
recorded, where the second HPD low of low, high, low is dropped.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@RyanTheTide RyanTheTide closed this Dec 3, 2026
@RyanTheTide RyanTheTide reopened this Dec 3, 2026

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The endpoint ring check does not show that this HPD entry is unread. If firmware has consumed the HPD command without replying and another service has an unread entry on the same endpoint, the old HPD slot still matches and the ring pointers differ. This returns ETIMEDOUT without queuing the requested HPD retry. The fast path needs evidence that the matching HPD entry itself remains unread.

afk_service_call_ring_unread() took any unread entry in the endpoint's TX
ring for the call's. If the firmware had read the HPD request without
answering it, and another service's entry was still unread, the request
was not sent again.

Count the bytes the host has published in the ring, and note for each
command where its entry ends. The entry is unread if fewer bytes follow it
than the firmware has not read. Unlike a ring offset, that also tells it
from one that lies in the same place a lap later.

The test puts another service's entry behind the request, read and
unread, at every place in the ring.

Signed-off-by: DjDeveloperr <hey@djdev.me>

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict at e09a113e0dbb: merge once the rows below pass. A comment, because the PR and the last push are ours. Someone else has to approve this head.

Fixed here

  1. e09a113e0dbb: the point raised at 8c1bd117f567 is right. The check looked at the endpoint's ring, not at the HPD entry. A request the firmware had read without answering, with another service's entry unread, was not sent again. The host now counts the bytes it publishes in the ring and notes for each command where its entry ends. Only a call whose own entry is unread is matched, and an entry in the same place a lap later is not mistaken for it.
  2. 8c1bd117f567: the helper said it leaves to the sender what the sender would refuse, but it also rang while the firmware-27 sleep gate (sleep_v27_closed) is closed, and read the ring pointers without txbfr.ready. Both are checked now.
  3. The tests passed with last_slot never recorded, where the second low of low, high, low is dropped. They now cover low, high, low, with the other level unread, answered, and at every place in the ring.

Read

  • HPD edges: only the call queued last on that port's service is compared, level included. Another level, port or command goes to the sender.
  • A rebooted processor has a new or emptied service, and ring positions are relative to the write pointer.
  • Dead or off: stopping, tx_paused, rx_paused, crash, quiesce and the sleep gate refuse, and RTKit refuses a stopped endpoint.
  • Locks: the slot under service->lock, the ring under tx_lock and ep->lock as the sender, dma_rmb() before the pointers. The buffer can't go while its slot bit is set.

Checked: on main 5d5060423c0e, CI host-tests image: --only afk 13/13, dptx 11/11, dcp 103/103, and the same families with #2097 and #3398 merged (13, 11, 111). 11 mutants of the new check are killed. W=1 of drivers/gpu/drm/apple/: 0 C warnings, KUnit suites built, not run. checkpatch clean. Merges cleanly with main, #2097 and #3398. Not run: no boot, no hardware.

Rows left at this head

  1. J773g, DP-3: boot, 10 replugs, 3x DPMS, 2x s2idle, 2x deep sleep. Picture back each time, AFK timeout lines as base.
  2. Peer T6050 (J716c): external display, 3 sleeps, 3 replugs, 0 -ENOSPC. Our J714s has no external display.
  3. Peer J316c: external DP on USB-C, 5x s2idle, 3 replugs. If it stalls, one HPD slot at most, no -ENOSPC, ring line pasted.

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The per-entry ring arithmetic fixes my prior case. One synchronization issue remains: the retry helper reads cmd->tx_end unconditionally under service->lock, even when waits is false because the first caller still owns the slot. The first caller writes tx_end outside that lock. An overlapping retry can therefore race with that write. Read tx_end only when waits is true, or move the write under the same lock.

@aurora-silicon-review aurora-silicon-review Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: FINISH at e09a113

Failure: In afk.c, a retry can run while the original command still owns the slot with cmd->completion set. The retry predicate rejects the active slot, then reads cmd->tx_end unconditionally at line 3673. The original sender writes the same slot's tx_end at line 3930 outside service->lock. The retry's lock only protects the reader, so an overlapping retry gives the conflicting unguarded read/write Ryan reported. Read the end position only after the predicate confirms that the previous sender released the slot, or protect the writer with the same lock.

Checked: The per-command byte position fixes the earlier false retry suppression. The exact AFK sender passed under ASan and UBSan, including another service's unread entry and a full ring lap. The concurrency finding comes from the two exact call paths.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:display Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants