Skip to content

s2r_dcp_pkt: T6050 DCP DART sids, whole-packet copies (debug only) - #560

Merged
RyanTheTide merged 9 commits into
mainfrom
fix/s2r-dcp-pkt-t6050-whole
Nov 29, 2026
Merged

RyanTheTide merged 9 commits into
mainfrom
fix/s2r-dcp-pkt-t6050-whole

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Debug-only SPTM-virt trace (AURA_S2R_DCP_PKT). Two fixes, needed to trace macOS's IOMFB calls (ep 0x37) on the K114s (M5 Pro) for display parity (VRR, HDR/EDR, colour, brightness).

  1. No packet was ever copied on T6050. Every K114s guest session logs dcp-pkt dva 0x100000xx000 not found (walkable sids 0x0). The DART walk tried sids 0-15, but T6050's dart-dcp has sid-count = 32 and the DCP's stream is sid = 23 (pt-region-23). The walk now uses the DART node's sid-count (up to 32) and tries its own sid first. Other SoCs still walk 16 sids.
  2. Whole packets on request. The trace copies 128 input bytes and 56 output bytes per packet, which is too few for the swap and EDR calls (the swap record runs past 0x6e0). New host knobs, with defaults that keep the old behaviour:
    • AURA_S2R_DCP_PKT_MAX: input bytes per packet (default 128)
    • AURA_S2R_DCP_PKT_FULL=A407,A408: up to 4 tags whose input and output are copied whole
    • AURA_S2R_DCP_PKT_FULLMAX: bytes each way for those (default 4096)
    • AURA_S2R_DCP_PKT_EVERY: copy only one in N of each such tag, so a 120 Hz swap doesn't fill the 8 MiB ring

tools/auractl/dcp_pkt_decode.py decodes the CPKT records of an auractl read dump: one line per packet (time, auractl mark, DCP, call/callback/output, tag, sizes, hex) plus a per-packet .bin and packets.tsv. tests/python/test_dcp_pkt_decode.py round-trips a synthetic call and reply.
3. J473 (T8112): every lookup missed. dcp-pkt dva 0x80003c000 not found (walkable sids 0x20): dart-dcp's vm-base is 0x800000000 and that DVA already fits the walk's 36-bit IOVA, but the vm-base was subtracted, so 0x3c000 was walked. The vm-base is now subtracted only for a DVA past the walk's width (T6050 0x100000xx000, J613 0x1000003c000).

Rows: K114s (T6050) macOS 27.2.1 guest: sid 23, 3-level, 48 of 49 pages, thousands of packets decoded. J473 (T8112) macOS 27.2 guest: sid 5, 48 of 49 pages, packets decoded. Both are in the PR comments.

Tested: K114s (T6050) macOS 27.2.1 guest under aura: sid 23, 3-level walk, 48 of 49 pages, thousands of IOMFB packets decoded. J473 (T8112) macOS 27.2 guest: sid 5, 48 of 49 pages, packets decoded. tests/python/test_dcp_pkt_decode.py passes. Rows were run on lab branches carrying this PR's first 5 commits; 1615ca4 only moves the code to .rodata.xtext and guards the third level, and the later merge of main adds main's commits.
Risk: two-way · debug-only. s2r_dcp_pkt.o is built only in SPTM_VIRT=1 images, its functions are AURA_XTEXT (out of Stage 1 text), and the packet copies only run when the host sets the AURA_S2R_DCP_PKT knobs. Default images are unchanged on every Mac.

AURA_S2R_DCP_PKT copies 128 input and 56 output bytes per packet, too
few for the swap and EDR calls (the swap record runs past 0x6e0).
Add host knobs: AURA_S2R_DCP_PKT_MAX (head bytes per packet),
AURA_S2R_DCP_PKT_FULL (up to 4 tags copied whole, input and output),
AURA_S2R_DCP_PKT_FULLMAX (bytes each way for those, default 4096) and
AURA_S2R_DCP_PKT_EVERY (one in N of each such tag, so a 120 Hz swap
does not fill the ring). Defaults keep the old behaviour.

tools/auractl/dcp_pkt_decode.py turns the CPKT records of an auractl
dump into one line per packet plus per-packet .bin files.
T6050's DCP DARTs have sid-count 32 and the DCP's stream is sid 23
(K114s ADT dart-dcp: sid = 23, pt-region-23). The walk only tried
sids 0-15, so every shared-memory lookup failed ('dcp-pkt dva ...
not found (walkable sids 0x0)' in every K114s guest session) and no
packet was ever copied there. Read sid-count (up to 32) and sid from
the DART node; walk the DCP's own sid first. Others keep 16.
On J473 (T8112) every IOMFB shared-memory lookup failed: 'dcp-pkt dva
0x80003c000 not found (walkable sids 0x20)'. dart-dcp's vm-base there
is 0x800000000 and the DVA already fits the walk's 36-bit IOVA, but
the vm-base was subtracted and 0x3c000 walked. Subtract it only for a
DVA past the walk's width (T6050 0x100000xx000, J613 0x1000003c000).
K114s (T6050) guest 11-29: sids 23 and 24 walk, yet no IOMFB DVA
(0x1000004c000, ...) is found. Print each walkable sid's mapped page
count and IOVA range against the IOVA looked for, so the next session
shows where the shared memory really sits.
K114s (T6050) guest dh2: sid 23's top table holds a single entry at
index 16 and the two-level walk read it as IOVA 0x20000000; the
shared memory is at DVA 0x1000007c000, whose bits 46:36 are 16. So
T6050's dart-dcp (vm-size 3 TB) is a three-level table: 64 GiB top
entries, then 32 MiB and 16 KiB. For a DVA at or past 2^36 look each
page up through the three levels first, the DCP's own sid first;
the two-level walk stays for everything else.
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

K114s (M5 Pro) row, macOS 27.2.1 guest under the HV, lab branch lab/dcp-hvtrace 32635c2 (= this PR's 5 commits on #543), chainloaded over the enrolled HV Stage 1:

  • before: every session logged dcp-pkt dva 0x100000xx000 not found; 0 packets copied.
  • with commit 2 (sid-count/sid): sids 32 (first 23), sids 23/24 walk, still not found; commit 4's diagnostic showed sid 23's top table has one entry at index 16 = DVA bits 46:36.
  • with commit 5 (three-level lookup): dcp-pkt dva 0x10000054000: sid 23, 3-level, 48 of 49 pages for every buffer; 224 / 3406 / 43956 packets decoded with tools/auractl/dcp_pkt_decode.py (idle SDR / EDR fills / brightness steps), A457 copied whole (7472 B) with AURA_S2R_DCP_PKT_FULL=A457,D594 AURA_S2R_DCP_PKT_FULLMAX=8192 AURA_S2R_DCP_PKT_EVERY=20.
    Still draft: the J473 half (commit 3) has no row yet.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J473 (M2 mini, T8112) row, macOS 27.2 guest under the HV, lab branch lab/dcp-hvtrace-j473 d330270 (this PR's 5 commits + debug AFK tracer): commit 3 resolves the IOMFB shared memory, dcp-pkt dva 0x80003c000: sid 5, 48 of 49 pages (before: not found (walkable sids 0x20)). 8 s idle = 1866 packets decoded; four MSI mode sets traced (144/240/280/280-VRR) with whole A457 copies. Rows now on both SoCs (K114s T6050 earlier, J473 T8112 here).

@RyanTheTide
RyanTheTide marked this pull request as ready for review November 28, 2026 20:19
@RyanTheTide
RyanTheTide requested review from a team as code owners November 28, 2026 20:19

@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 fcec3c9e

Blockers:

  • Stage 1 size / link failures (gcc, fedora, nix all FAILURE): src/s2r_dcp_pkt.o is linked into Stage 1 builds (Makefile:310). The new lookup, whole-packet copy, and diagnostic formatting push stage1 .text headroom below the 4096 B guard across all three toolchains (gcc: 3664 B, fedora: 4008 B, nix: 3152 B) and break stage1-dev-audit linking (ld.lld: error: Code and data reach the DCP log buffer after stage 1!). Keep this debug-only tracer out of stage1/RELEASE builds (or trim/gate it) so Stage 1 room passes on gcc, fedora, and nix.
  • Unsafe 3-level table walk on 2-level DARTs (src/s2r_dcp_pkt.c:114-181): s2r_dcp_resolve() runs s2r_dcp_lookup3() before the 2-level walk for any d->lo >= BIT(36) without checking DART_T8110_TCR_OFF + 4 * sid (translate enabled, not bypassed, multi-level) or checking that table addresses stay within DRAM (ram .. ram + mem_size_actual). On a 2-level DART whose DVA sits above BIT(36) (such as J613's 0x1000003c000, cited in the comment right above), s2r_dcp_lookup3() treats L1 as L0, indexes L1[16], treats an L2 leaf PTE as a table pointer, and dereferences an arbitrary DCP buffer page as L2 PTEs — returning bogus d->pa[] pages and skipping the 2-level walk if bit 0 happens to be set. Gate s2r_dcp_lookup3() on the stream's TCR (TRANSLATE_ENABLE, !BYPASS_DART, !REMAP_EN) and a real 3-level indicator (or run the validated 2-level walk first when d->have_vm_base fits within 36 bits), and bounds-check intermediate table PAs against DRAM.

Checked:

  • Audited all 5 touched files (src/s2r_dcp_pkt.c, src/s2r_dcp_pkt.h, proxyclient/tools/run_guest_sptm.py, tools/auractl/dcp_pkt_decode.py, tests/python/test_dcp_pkt_decode.py) and CI failure logs (gcc, fedora, nix).
  • Verified the whole-packet copy logic (S2R_PKT_FULL bit 63 in open[], s2r_dcp_full() tag/every throttling, 24-bit word cap w < BIT(24), o + 8 <= S2R_DCP_RPC bounds), ADT sid-count/sid parsing (bounded to 1..32), and tools/auractl/dcp_pkt_decode.py + tests/python/test_dcp_pkt_decode.py round-trip decoding are otherwise clean (Pytest suites and format-check pass).
  • Verified both K114s (T6050) and J473 (T8112) guest capture rows posted in PR comments.
Evidence
  • CI gcc (141060551611): gcc stage1: headroom 3664 B is below 4096 B, gcc stage1-dev-audit: does not link.
  • CI fedora (141060551864): fedora stage1: headroom 4008 B is below 4096 B, fedora stage1-dev-audit: ld.lld: error: Code and data reach the DCP log buffer after stage 1!.
  • CI nix (141060551840): nix stage1: headroom 3152 B is below 4096 B, nix stage1-dev-audit: ld.lld: error: Code and data reach the DCP log buffer after stage 1!.
  • src/s2r_dcp_pkt.c:114-139: s2r_dcp_lookup3() reads TTBR (0x1400 + 4 * sid) directly without checking DART_T8110_TCR_OFF (0x1000 + 4 * sid) or DRAM bounds on l0 / intermediate t, and is called ahead of dart_walk_locked_t8110() for every d->lo >= BIT(36).
  • Non-blocking nit: once the blockers above are fixed, updating the PR description to drop the stale "Draft until rows show..." line and summarize both K114s and J473 rows at the new head will keep the top summary in sync.

Review on #560:
- The three-level lookup ran before the validated two-level walk for
  any DVA past 2^36, without the stream's TCR check or table bounds: on
  a two-level DART with such a DVA (J613) it could read a buffer page
  as PTEs. Now it runs only after the two-level walk found nothing,
  only for a translating stream (TCR translate on, no bypass, no
  remap, TTBR valid), and every table and the final page must lie in
  DRAM.
- Everything in this debug-only file is AURA_XTEXT (.rodata.xtext), so
  it no longer counts against Stage 1 text: gcc 14 RELEASE stage1 room
  text is 13120 B on both main 99b6dd1 and this branch.
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review fixes in 1615ca4 (normal push):

  1. Stage 1 size: every function in src/s2r_dcp_pkt.c (debug-only) is now AURA_XTEXT (.rodata.xtext), so none of it counts against Stage 1 text. With the CI's own tools/stage1_size.sh gcc ... -Os locally (gcc 14), stage1 room text is 13120 B on both main 99b6dd1 and this branch. The previous head was about 32 B under main on the CI gcc. The stage1-dev-audit link failure also happens on plain main locally and in main's own runs (the DCP log buffer limit, 3696 B on main as K114S-EXTDISP2 measured in kboot: T6050: hybrid HDMI pipeline: fixed output before ADT routes, DP PHY tunables #559), so it is pre-existing. This PR now adds 0 B of Stage 1 text.
  2. 3-level walk: s2r_dcp_lookup3() now runs only after the validated two-level walk found nothing. It requires a translating stream: TCR translate on, not bypass, not remap, and TTBR valid. Every table PA and the final page must lie in DRAM (ram .. ram + mem_size_actual). So on a two-level DART with a DVA past 2^36 (J613), the two-level walk still decides, and nothing outside DRAM is ever read.
  3. Description updated: both rows (K114s T6050, J473 T8112) are posted above; the stale draft line is gone.

@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 1615ca4d

Blockers: None (wait for queued CI jobs to finish; pre-existing stage1-dev-audit DCP log buffer headroom on main is tracked separately, and this branch now adds 0 B to Stage 1 .text).

Checked:

  • Audited commit 1615ca4d (src/s2r_dcp_pkt.c): both blockers from fcec3c9e are cleanly resolved.
  • Verified every function in src/s2r_dcp_pkt.c now carries AURA_XTEXT (.rodata.xtext), adding 0 B to Stage 1 .text (13120 B room text on both main 99b6dd13 and 1615ca4d under tools/stage1_size.sh gcc).
  • Verified s2r_dcp_lookup3() now runs only after the validated 2-level dart_walk_locked_t8110() walk finds nothing, checks DART_T8110_TCR_OFF + 4 * sid (TRANSLATE_ENABLE, !BYPASS_DART, !REMAP_EN) plus TTBR valid before walking, and bounds-checks every intermediate table and the final leaf page against ram .. ram + mem_size_actual - 0x4000.
  • Verified updated PR description (stale draft line removed, both K114s T6050 and J473 T8112 capture rows summarized) and previously audited dcp_pkt_decode.py + test_dcp_pkt_decode.py + run_guest_sptm.py.
Evidence
  • src/s2r_dcp_pkt.c:96-123: s2r_dcp_lookup3() guards d->dart_size < 0x1400 + 4 * ((u64)sid + 1), reads tcr (+0x1000 + 4 * sid) and ttbr (+0x1400 + 4 * sid), rejects non-translating/bypass/remap streams, and checks t >= ram && t <= ram_end - 0x4000 before every sptm_virt_peek64() and before storing d->pa[i].
  • src/s2r_dcp_pkt.c:178-192: 3-level fallback is placed strictly after the 2-level dart_walk_locked_t8110() loop, so 2-level DARTs with d->lo >= BIT(36) (e.g. J613) resolve via the 2-level walk without entering s2r_dcp_lookup3().

@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) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks required sections (bot) labels Nov 28, 2026
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Merge readiness at d436986f: not ready yet

Check Detail
CI at head running running: policy, policy, pr-text / pr-text, Pytest (macos-26 + llvm-brew), selftest, clang-macos
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 d436986f, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · debug-only. s2rdcppkt.o is built only in SPTMVIRT=1 images, its functions are AURAXTEXT (out of Stage 1 text), and the packet copies only run when the host sets the AURAS2RDCPPKT knobs. Default images are unchanged on every Mac.

Areas: none matched in CODEOWNERS

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

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

CI at 1615ca4: everything passes except the three Stage 1 room jobs (gcc 3664 B, fedora 4008 B, nix 3152 B, plus stage1-dev-audit not linking). Those three fail on main too: main's own stage1-size run at a0504b2 fails gcc. Locally, with tools/stage1_size.sh gcc (gcc 14), this branch and main 99b6dd1 have identical stage1 room text (13120 B), because the whole tracer file is in .rodata.xtext. The CI numbers are unchanged from the previous head, so the remaining gap is in main's own Stage 1 size, not in this PR. Merge is the maintainers' call on that main-wide failure.

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
@github-actions github-actions Bot added blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) and removed needs-hw-row No hardware row at the PR head (bot) needs-template PR body lacks required sections (bot) labels Nov 29, 2026
Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>

@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 after validation at c00f504.

Checked: Recreated the main merge and the subsequent #570 merge. Both have empty remerge diffs. The packet changes retain the previous review, including the debug scope and the Stage 1 size requirement. Keep hosted CI.

@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) ci-failing A check failed at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 29, 2026
@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Nov 29, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merging at d436986f (merge) under the 6-point rule. (1) The review App's verdict at this head: APPROVED. (2) CI is green at this head (readiness excluded). (3/4) Rows: debug-only DCP packet trace, off by default; CI is the row. (5) No blocking review is open. (6) Dj was pinged with no objection. Revert: git revert -m 1 <commit>.

@RyanTheTide
RyanTheTide merged commit 079fdd7 into main Nov 29, 2026
29 checks passed
@RyanTheTide
RyanTheTide deleted the fix/s2r-dcp-pkt-t6050-whole branch November 29, 2026 13:24
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at d436986f. App approved (NEON-PR-REVIEW2), hosted CI green, rows in the body. Merges under the 6-point rule 1 h from now unless you object.

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

Labels

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.

1 participant