Skip to content

drm/apple: isolate Type-C reconnect request budgets; cover two topology mutants - #3530

Open
RyanTheTide wants to merge 2 commits into
mainfrom
fix/dcp-typec-reconnect-gen-20261129
Open

RyanTheTide wants to merge 2 commits into
mainfrom
fix/dcp-typec-reconnect-gen-20261129

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

What: Two drm/apple follow-ups. (1) Type-C reconnect: a failing old reconnect worker could use up a newer request's retry budget, or replace its deadline. Each queued request now gets a generation number and its own budget under hpd_mutex, and a worker only counts a failure or re-arms a retry while it still owns its request. (2) The fabric topology KUnit (follow-up to linux#2833) now covers native26 at index 0 and a non-default 10-bit profile, so the two mutants that used to survive now fail.

Tested: Build and host tests only, no Mac row yet. Arm64 LLVM W=1 builds dcp.o and dcp-fabric.o with no warnings. The DCP lifecycle host suite passes 36/36 under ASan/UBSan, and removing any one of the three safeguards makes it fail. Topology KUnit passes 7/7, and each old mutant now fails a new assertion. Strict checkpatch is clean.

Risk: two-way · Type-C/USB-C external displays on every Mac. The success path makes the same transport calls as before.

Not yet: a Neo (J700) row with s2idle reconnect and external-display unplug/replug cycles, plus one regression Mac. Both go in the next combined boot (lanes/HWROWS-QUEUE.md).

Details

The counter reset moves into the enqueue helper. The callers' resets are removed, including the unlocked resets in dcp-fabric.c. A replacement request that is already pending is left for its own queued run, and retries re-arm without refilling their budget.

Evidence

Fixes: 9fd048b. Source items: LINUX-BACKLOG-B.md:105 (reproduced retry-budget bug, part of draft linux#2364), REVIEW-WAVE-3.md:30 (#2833 mutants).

A reconnect worker can fail after another caller has queued a new
request for the same fabric session, or for a sessionless output. Its
failure then consumes the new request's retry budget and can replace
that request's deadline with the old worker's retry delay. Resetting
the counter under hpd_mutex alone does not distinguish these requests.

Give each queued request a generation and a fresh budget under
hpd_mutex. Snapshot that generation before connecting, and account for
a failure or re-arm a retry only while it still owns the request.
If a replacement is already pending when an old worker starts, leave
it for the queued invocation. Retries continue to re-arm directly,
without creating a new request or replenishing their own budget.

Centralize the counter reset in the enqueue helper and remove callers'
resets, including the unlocked resets in the display fabric. Successful
connects still return immediately with the same transport calls; their
counter needs no reset because each new request initializes it.

Add host regressions using the actual enqueue and worker functions for
same-session and sessionless overlaps, pending replacements, exhausted
budgets and successful connects with the existing retry limits.

Fixes: 9fd048b ("drm: apple: recover Type-C displays across link interruptions")
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Give the 10-bit candidate an H17G method profile so the test rejects
treating every non-default profile as RGB8-only. Also put the native26
candidate first in a pipeline array to catch iteration that skips index
zero.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide
RyanTheTide requested review from a team as code owners November 28, 2026 13:11

@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, then merge at 2b2b96b8

Blockers:

  1. Hosted CI at 2b2b96b8 (21 jobs: apple-build, host-tests, kunit, pr-text, readiness, KUnit suites) is currently QUEUED; wait for green CI.
  2. Missing exact-head hardware row (J700 s2idle reconnect + external-display unplug/replug cycles plus one regression Mac; noted as queued in Not yet:).

Checked: no Apple material, no AI attribution, human DCO Signed-off-by on both commits, no chip/board/firmware gates, no parameters or hardcoded safety limits, full diff (+186/-20 across 6 files) verified, typec_reconnect_generation and typec_reconnect_tries are consistently guarded by hpd_mutex without holding hpd_mutex across dcp_dptx_connect*() calls, dcp_typec_reconnect_work() bails early on delayed_work_pending() and checks generation != dcp->typec_reconnect_generation before consuming budget or re-arming retries, dcp-fabric-topology-test.c covers ext26_first (index 0) and non-default 10-bit profile (DCP_IOMFB_METHODS_H17G), host lifecycle suite (36/36 ASan/UBSan) + KUnit (7/7) + arm64 LLVM W=1 + checkpatch --strict clean, PR body has Tested: and Risk: two-way, branch is MERGEABLE against main.

Evidence
  • drivers/gpu/drm/apple/dcp.c, dcp-fabric.c, dcp-internal.h (d23b5dbaf0): removes unlocked dcp->typec_reconnect_tries = 0 resets from all callers (dcp_typec_route_apply, dcp_tb_queue_reconnect, dcp_follow_attach, dcp_external_ready, dcp_external_retry_work, dcp_typec_attach_locked, dcp_poweron) and centralizes generation increment + tries reset in dcp_queue_typec_reconnect_locked() under hpd_mutex. On connect failure, dcp_typec_reconnect_work() re-acquires hpd_mutex and ignores the failure if generation != dcp->typec_reconnect_generation, preventing a stale worker from exhausting or overwriting a newer request's retry budget/deadline.
  • drivers/gpu/drm/apple/dcp-fabric-topology-test.c (2b2b96b8db): sets DCP_IOMFB_METHODS_H17G on RGB8_PLAIN and adds ext26_first ordering assertion.
  • tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py & run.py: compiles and exercises production dcp_queue_typec_reconnect_locked() and dcp_typec_reconnect_work() across all 6 (sessionless, flow) combinations for budget exhaustion, already-pending replacement, mid-connect replacement, success, and stale session.
  • Code is clean; ready to approve and merge once CI is green and the queued hardware rows land at 2b2b96b8.

@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 28, 2026
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Merge readiness at 2b2b96b8: ready to merge

Check Detail
CI at head ok 20 checks passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok comment at 2b2b96b8
Conflicts ok none
PR text ok Risk: two-way · Type-C/USB-C external displays on every Mac. The success path makes the same transport calls as before.

Areas: area:display
Merge: gh pr merge 3530 --merge (Owners and Core through the bypass: add --admin).

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

@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 2b2b96b8db96

Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.

Checked: no Apple material, no AI attribution, human DCO Signed-off-by on both commits, no chip/board/firmware gates, no parameters or hardcoded safety limits, full diff (+186/-20 across 6 files) verified, typec_reconnect_generation and typec_reconnect_tries are consistently guarded by hpd_mutex without holding hpd_mutex across dcp_dptx_connect*() calls, dcp_typec_reconnect_work() bails early on delayed_work_pending() and checks generation != dcp->typec_reconnect_generation before consuming budget or re-arming retries, dcp-fabric-topology-test.c covers ext26_first (index 0) and non-default 10-bit profile (DCP_IOMFB_METHODS_H17G), host lifecycle suite (36/36 ASan/UBSan) + KUnit (7/7) + arm64 LLVM W=1 + checkpatch --strict clean, PR body has Tested: and Risk: two-way, branch is MERGEABLE against main.

Follow-ups (not blocking): queued CI; J700 s2idle reconnect + unplug/replug row

@github-actions github-actions Bot added the ci-failing A check failed at the PR head (bot) label Dec 1, 2026

@DjDeveloperr DjDeveloperr 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.

Approve at 2b2b96b8db96. Every queued request now bumps typec_reconnect_generation and resets the tries under hpd_mutex. A worker re-reads the generation before counting a failure or re-arming, and returns when a newer request is already pending. Retries re-arm without bumping the generation, so one request keeps one budget. Dropping the scattered typec_reconnect_tries = 0 resets is safe, because every one of those sites queues through dcp_queue_typec_reconnect_locked(). The topology KUnit change is test-only. The J700 replug/s2idle row and one regression Mac are the remaining gate.

@github-actions github-actions Bot removed needs-review No approving review from Core or Omarchy Mac yet (bot) ci-failing A check failed at the PR head (bot) labels Dec 2, 2026
@DjDeveloperr

DjDeveloperr commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

J773g (M4 mini, T8132, 27.2) 2b2b96b8db96 PASS (7.3.0-j773g-comp5 on main b47fc630, boot_id=3a101384-2cfc-4aa6-835b-6d4f9a3692b5): Type-C DP-3 (3840x2160) 5/5 software DRM off->detect cycles (not physical Type-C unplug) restored connected/enabled/On (max 6 ms); initial s2idle pass was 0/3 (/dev/rtc0 lacks wakeup) and /dev/rtc1 rerun completed 3/3 s2idle reconnects cleanly (with 05e3:0f01 re-enumerated 3-1 -> 2-1, POST_SLEEP_USB_MATCH=0, from xHCI usb2/usb3 root-hub bus renumbering across resume), post-mem-refusal display intact; 0 dcp-fabric errors or stuck reconnect retries, 0 WARN/Oops/DART faults, 0 failed units.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed needs-hw-row No hardware row at the PR head (bot) ready-to-merge Meets the merge policy: merge it (bot) labels Dec 2, 2026

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) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants