Skip to content

DRAFT: J414c offline USB4 DP lifecycle prototype - #1

Draft
ice3186 wants to merge 12 commits into
codex/j414c-dock5-unifiedfrom
codex/j414c-offline-20260830
Draft

DRAFT: J414c offline USB4 DP lifecycle prototype#1
ice3186 wants to merge 12 commits into
codex/j414c-dock5-unifiedfrom
codex/j414c-offline-20260830

Conversation

@ice3186

@ice3186 ice3186 commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Status

Experimental and compile-tested only. This does not enable external video and has not been tested with the dock.

What this branch contains

  • Asahi DCP 14.7 follow-up fixes and ACIO/NHI teardown diagnostics.
  • Optional Thunderbolt DP source lifecycle hooks: prepare, enable, disable, and unprepare.
  • Apple trace-only callbacks that log the host DP-IN and remote DP-OUT.
  • No DCP, PHY, display-crossbar, or device-tree side effects.

Offline validation

  • Each new patch passes strict checkpatch.
  • The full Thunderbolt directory builds warning-free with W=1.
  • Image, modules, and DTBs build successfully with the pinned Rust 1.93.1 toolchain.
  • Claude reviewed the exact two-commit lifecycle prototype and returned PASS; its bandwidth rollback and idempotency suggestions were applied before publication.

Hardware gate

T602x DPIN0/DPIN1 register programming is not implemented or proven in the current display-crossbar driver. Do not enable atcphy2_xbar or add DCP routing until a macOS/m1n1 MMIO trace establishes the real sequence.

Dock-return next steps

  1. Run the trace-only branch on a one-shot detached boot and verify lifecycle ordering for host adapter 5.
  2. Capture macOS T602x ATC2 crossbar MMIO for DPPHY versus DPIN0.
  3. Resolve dcpext0 HDMI conflict versus dcpext1 availability.
  4. Design an asynchronous Apple-CIO-owned source manager and tunneled logical-PHY backend.
  5. Only then build a single-route video candidate.

Full PRD and tested/untested matrix: https://github.com/ice3186/j414c-dock-bringup/blob/main/J414C-USB4-DP-PRD.md

a-ramses and others added 6 commits August 30, 2026 18:02
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>
Add optional platform callbacks around DP tunnel activation.

Track completed phases so rollback only undoes work that succeeded.

Platforms without callbacks keep the existing path.

This experimental plumbing has no display-routing side effects.

It is compile-tested only and has not been hardware-tested.

Signed-off-by: Matthew Altman <matthewaltman2008@gmail.com>
Log the selected host DP-IN and remote DP-OUT at each phase.

The callbacks do not touch DCP, ATC PHY, crossbar, or DT state.

T602x DPIN routing remains unproven.

This is compile-tested only and does not enable hardware video.

Signed-off-by: Matthew Altman <matthewaltman2008@gmail.com>
@ice3186

ice3186 commented Aug 31, 2026

Copy link
Copy Markdown
Owner Author

Offline review/build update:

  • Final prototype commits: 052ab23b27 and 5b29ed3b64.
  • Strict checkpatch: clean per patch.
  • Focused Thunderbolt W=1 build: clean.
  • Full Image modules dtbs build: passed with pinned Rust 1.93.1; only pre-existing tree-wide warnings.
  • Grok retry and Claude code review agree this must remain trace-only until T602x DPIN MMIO is captured.
  • Prepared capture runbook and read-only tracer: https://github.com/ice3186/j414c-dock-bringup/blob/main/J414C-T602X-DPIN-TRACE-RUNBOOK.md

No package was created or installed, no DT node was enabled, and dock5-2 remains unchanged.

Move the experimental Apple DP source lifecycle behind an ACIO-owned ordered workqueue. Keep the callbacks limited to scalar reservation state while the worker only traces converged desired state.

Use session and token cookies to reject stale teardown, quiesce and flush the manager around ACIO shutdown, and add pure reducer KUnit coverage. This remains an offline trace-only prototype with no DCP, PHY, mux, MMIO, or DT side effects.

Signed-off-by: Matthew Altman <matthewaltman2008@gmail.com>
@ice3186

ice3186 commented Aug 31, 2026

Copy link
Copy Markdown
Owner Author

Offline checkpoint published at cc81ffa407 (thunderbolt: apple: queue DP source state asynchronously).

What this adds:

  • ACIO-owned ordered workqueue for Apple DP-source lifecycle events
  • session/token cookies and stale-event rejection
  • pure reducer plus KUnit cases for transitions, stale cookies, quiesce, coalescing, and counter wrap

Validation completed:

  • strict checkpatch: clean
  • focused normal-config W=1 Thunderbolt build: pass
  • isolated KUnit compile/link: pass
  • full Image modules dtbs with pinned Rust 1.93.1: pass
  • exact-diff reviews through Herdr: Claude PASS, Grok PASS, Linux-lifecycle reviewer PASS

Experimental boundary: this commit performs in-memory bookkeeping and trace logging only. It does not call DCP, select a PHY/crossbar, write MMIO, or enable DT nodes. KUnit runtime was not executed (no arm64 UML backend or aarch64 QEMU here; the global Rust KUnit config also hits unrelated existing DRM Rust test failures). It has not been run with the dock and is not a video fix.

The gating next steps remain T602x DPIN0/1 MMIO capture, tunneled logical-PHY design, DCP target/engine arbitration, DCP hot-unplug race fixes, and then a one-shot trace-first dock test. The known dock5-2 baseline remains untouched at bff95a179d1a0bfb01223a988a789ac48693accf.

Move the existing physical PHY operations behind per-port transport ops and install them before publishing each DPTX service. Preserve the native APCALL behavior while separating physical lane, rate, activation, and deactivation handling.

Add an unreachable logical USB4 model, remote-target helpers, and KUnit coverage. The logical model only records scalar link state and contains no PHY, Type-C, mux, MMIO, DT, or Thunderbolt operations. No production path selects it, and no DCP connect or timeout behavior changes.

Reject out-of-range remote target fields instead of silently masking them. This remains an offline compile-tested seam, not a video-producing route.

Signed-off-by: Matthew Altman <matthewaltman2008@gmail.com>
Model DPTX connection attempts explicitly so disconnect and shutdown can cancel an in-flight link-configuration wait without allowing the waiter to assert HPD or connect AV afterward. Correctly treat a zero wait_for_completion_timeout return as a timeout and propagate EPIC request and HPD errors.

Serialize completion reuse with attempt publication, distinguish remote display ownership from a fully connected output, drain connect callers before AFK shutdown, and quarantine every unsuccessful attempt until DCP reinitialization. The quarantine is intentionally conservative because firmware APCALLs carry no attempt token and a late APCALL must not satisfy a newer attempt.

Add KUnit coverage for success, timeout, cancellation, stale tickets, anomalous completion, generation wrap, and forced failure. This is compile-tested experimental infrastructure: KUnit runtime, native HDMI timeout behavior, and dock video remain hardware-untested.
@ice3186

ice3186 commented Aug 31, 2026

Copy link
Copy Markdown
Owner Author

Offline checkpoint pushed: db0c762 — drm/apple: harden DPTX connection lifecycle.

What changed:

  • fixes the zero-return wait_for_completion_timeout() bug;
  • serializes attempt publication with completion reset;
  • separates remote display ownership from fully connected state;
  • cancels and drains in-flight DPTX connects before AV/DPTX AFK shutdown;
  • prevents disconnect/shutdown waiters from double-releasing;
  • quarantines every unsuccessful attempt until DCP reinitialization because firmware APCALLs have no attempt token;
  • adds KUnit reducer coverage.

Verification on the exact commit:

  • strict checkpatch: clean;
  • focused Apple DRM W=1 build: pass (only pre-existing kerneldoc warnings);
  • full Image, modules, and dtbs build: pass;
  • fresh isolated CONFIG_KUNIT=y and CONFIG_DRM_APPLE_KUNIT_TEST=y compile/link: pass, including dptx-attempt-test.o and dptx-transport-test.o;
  • exact-diff reviews: Grok PASS through Herdr, Claude PASS through Herdr, independent lifecycle reviewer PASS.

Experimental boundary: KUnit runtime was not executed; native HDMI behavior with the corrected 2-second timeout and all dock/video behavior remain hardware-untested. This commit does not select the logical USB4 transport, enable ATC2 DPIN DT, or program T602x DPIN MMIO.

@ice3186

ice3186 commented Aug 31, 2026

Copy link
Copy Markdown
Owner Author

Offline crossbar observability checkpoint pushed: 8822dbe9bdmux: apple: trace display crossbar routing.

What changed:

  • adds apple_dpxbar_route events for invalid, conflict, connect, and disconnect results;
  • adds apple_dpxbar_rmw events using the already-read old value and software-computed mask/set/new value;
  • keeps all device-name/string capture outside the crossbar spinlock.

Verification on the exact commit:

  • focused tracing-enabled W=1 build: pass;
  • isolated tracing-disabled W=1 build: pass;
  • full incremental Image modules dtbs: pass;
  • tracepoint symbols present in the tracing-enabled object;
  • source MMIO call count unchanged at three readl() and two writel();
  • no DT changes;
  • exact-diff reviews through Herdr: Grok PASS, Claude PASS.

Experimental boundary: this commit does not enable atcphy2_xbar, change mux policy, add a register access, or select a USB4 DPIN route. Trace runtime and all dock/video behavior remain untested. The current stock 7.1.6 graphical path is separately blocked by a kernel/DTB mismatch; no /boot, GRUB, m1n1, or installed-kernel changes were made.

Add a pure, KUnit-only reducer for explicit dcpext engine leases and DP-IN sink ownership. Keep the model unreferenced by production code until J414c engine/core and T602x DPIN routing are proven. A future live integration must compose DPTX attempt failure with an engine-level quarantine or retained lease.
@ice3186

ice3186 commented Aug 31, 2026

Copy link
Copy Markdown
Owner Author

Offline ownership-model checkpoint pushed: d6f77bd41bdrm/apple: model external display source ownership.

What changed:

  • adds a pure Apple DRM reducer for explicit dcpext-engine leases and DP-IN sink identity {die, atc, dpin, core};
  • enforces one owner per physical (die, atc, dpin), stale-safe session/token cookies, strict disable-before-release, and ordered quiesce/drain;
  • saturates session/token namespaces with -EOVERFLOW rather than ever aliasing an old cookie;
  • leaves engine selection explicit and does not encode a J414c engine/core/DPIN policy.

Verification:

  • isolated CONFIG_KUNIT=y CONFIG_DRM_APPLE_KUNIT_TEST=y W=1 compile/link: pass, including the new ownership test object;
  • full Image modules dtbs: pass;
  • diff checkpatch: clean with only standard new-file/continuation diagnostics excluded;
  • exact updated-diff reviews: Grok PASS through Herdr, Claude PASS through Herdr, Apple-video reviewer PASS.

Experimental boundary: the header is included only by its KUnit test. No production DCP, Thunderbolt, mux, PHY, HPD, MMIO, DT, probe, or callback path references it. It does not select an engine or route and has not run on hardware. Before live wiring, DPTX FAILED must compose with an engine-level quarantine/retained lease, and actual J414c engine/core plus T602x DPIN policy must come from hardware evidence.

Model provider-selected ordered engine allocation without exposing engine policy to Thunderbolt. Add terminal sink-preserving quarantine and an owner-ticketed DPTX endpoint restart barrier that rejects active leases and stale completions.\n\nThis remains KUnit-only and has no production call sites, DT changes, MMIO changes, or hardware validation.
@ice3186

ice3186 commented Aug 31, 2026

Copy link
Copy Markdown
Owner Author

Published offline checkpoint 5c1b036.

Scope:

  • KUnit-only Apple display-source model
  • provider-internal ordered engine/core allocation
  • terminal engine/sink quarantine after ambiguous DPTX failure
  • owner-ticketed session/generation DPTX endpoint restart recovery
  • active leases and stale/duplicate restart completions cannot clear quarantine
  • explicit prepare reports quarantined engines/sinks as EIO

Hard exclusions:

  • no production include or call site
  • no J414c engine table
  • no DT, mux policy, MMIO, DCP, Thunderbolt, package, install, or boot change
  • no runtime KUnit or dock validation

Validation:

  • git diff --check
  • arm64 Apple DRM KUnit object and appledrm.o compile/link with W=1
  • full Image, modules, and dtbs build passed
  • Grok and Claude exact-diff PASS through Herdr
  • Apple-video and TB-lifecycle independent exact-diff PASS after their blockers were fixed

Docs checkpoint: https://github.com/ice3186/j414c-dock-bringup/commit/9b241b7

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.

2 participants