Skip to content

thunderbolt: apple: run a Studio Display's router in bi-directional HiFi (T6050) - #2088

Open
joshuaswarren wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
joshuaswarren:dhp4/t6050-tmu-hifi-bi
Open

joshuaswarren wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
joshuaswarren:dhp4/t6050-tmu-hifi-bi

Conversation

@joshuaswarren

@joshuaswarren joshuaswarren commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

[Joshua's agent] One fix: a Studio Display style device router that already reads as bi-directional HiFi is left alone by tb_enable_tmu(), so the host never disables and re-enables its TMU. On the T6050 the display then drops HPD about a second into 5120x2880@60 ("IOAVVideoInterface terminated").

QUIRK_TMU_HIFI_BI (BIT(15), the first free bit on this base): every device router is configured for bi-directional HiFi, disabled, offered the host's time and enabled again. On the Studio Display tried, the time post is a no-op (router generation 3, see the 13:47 boot below), so what the quirk does there is the disable and enable. The host router's TMU stays with its firmware where QUIRK_HOST_TMU is set. It is set for T6050 only; T6040's DP IN is disabled in this tree, so that entry is left alone.

Credit: this is Petr Skuta's change. It is commit 5 of #2068 (07375891752a, "thunderbolt: apple: run T6040's TMU in bi-directional HiFi"), set for T6050 instead of T6040. He is the author of the commit here. #2088 carries the same commit alone: #2068 also defines QUIRK_TMU_HIFI_BI as BIT(15) and has the same tb.c hunks and tmu_hifi_bi field, so the two PRs overlap in nhi.h, tb.c and apple.c. Whichever lands second drops the duplicate.

Files: drivers/thunderbolt/apple.c (10 lines), nhi.h (7), tb.c (23/2).

Validated on, and reach

Validated on: a 14-inch M5 Max MacBook Pro (K114c, T6050), with the same commit on two other bases. Neither booted tree is this head; this head is the commit rebased onto the current integration/aurora and it is not booted. Booted trees:

  • Kernel 7.3.0-k114c-ARCH-day2d (the commit on a tree with dsc_disable), boot 2bc4664a: the journal shows "TMU CONFIGURED: is_master=1, mode=1" and "TMU: mode set to: bi-directional, HiFi" on the display router, and 0 lines with "IOAVVideoInterface terminated". Display kept.
  • Kernel 7.3.0-k114c-ARCH-a2t (the commit on the A2 source), 5 boots, each started with a VDM reset from a second machine: boots 8951f512, 21315fd1, c685ab86 and 7c1ba736 kept the display (4 of 4 with a clean boot), 16ffd61a is OPEN: its journal runs to 73.9 s, 45.8 s after the second mode set and short of the 60 s hold, so no verdict. Failures: 0. Each kept boot shows 2 of 2 TMU mode sets kept, DP-1 connected and enabled, 0 terminated, DCP crashed 0, Hyprland crashed 0.
  • Baseline, the A2 tree without this commit: 0 of 4 kept.
  • Kernel 7.3.0-k114c-ARCH-p2088b (this commit's content, 5bb8ce9c, plus the five commits of drm/apple: complete the 27.3 DCP method table, swap size and completion tag #1816, on integration/aurora bf423bf0), boot e76404d0, with thunderbolt.dyndbg="file tmu.c +p". The Studio Display router (381f00000.nhi: 1:) logged "current mode: bi-directional, HiFi" (already so before the driver acted), then "TMU: disabled", then "mode set to: bi-directional, HiFi"; the firmware line "TMU CONFIGURED: is_master=1, mode=1" followed. DP-1 was connected at 5120x2880 at the first read and again 60 s later, and "IOAVVideoInterface terminated" appeared 0 times. The disable and the mode set can only come from the quirk path in tb_enable_tmu(). Not seen: "mode change ... requested" (the router already read bi-directional HiFi) and "updated local time" or any local_time[n] line. tb_switch_tmu_post_time() returns 0 before it reads the host time when tb_switch_is_usb4() is false, so the post-time half is probably a no-op on this display, and the router is probably not USB4. A later sysfs read by the tester (13:58, about 11 minutes after this boot; the file has no boot id and no reboot is recorded in between) gives /sys/bus/thunderbolt/devices/0-1 ("Studio Display") generation 3 and the host router 0-0 generation 4. A router below generation 4 is not USB4 in this tree, so tb_switch_is_usb4() is false and the time post returns early. The effect on this display is therefore the disable and enable, and a check of whether the time post matters would need a USB4 device router. This is a VDM one-shot boot, not a cold start; the display image was not looked at.
  • The firmware line "TMU CONFIGURED: is_master=1, mode=1" appears only with this change.

Keep count: a2t 4 kept, 1 open, 0 failed (baseline 0 of 4). These are VDM resets from a second machine, not a power-off cold start.

Not checked: which display model was on DP-1 in these runs; a power-off cold boot; a suspend or resume with this change (the new branch disables and re-enables a device router's TMU on every tb_enable_tmu() call, including re-enumeration after resume); this exact head booted alone (p2088b has #1816 on top, and its tree is the same commit content); any other Mac. Dock or hub topologies behind the display are not run.

Applies beyond the M5 Max: the quirk is set only in the T6050 hardware table, so other models are not changed. Anything that reads the T6040 table is untouched.

m tester run (omarchy-m-testing.org): feature rows Thunderbolt / external display. The tester needs a Studio Display style display on a T6050 Mac; no tester run is linked to this change.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-16T17:28:31.141276Z
We couldn’t complete this review. Comment @codex review to try again.
1a1a315 PR opened
🔒 Security Review ❌ Failed 2026-11-16T17:28:37.047874Z
We couldn’t complete this review. Comment @codex security review to try again.
1a1a315 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

The account paying for this security review has reached its Codex usage limits. The payer can check the Codex usage dashboard. For personal accounts, using credits requires enabling “Use credits for security reviews” in Code review settings. If you do not manage the paying account, contact this repository's admins.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

CHANGES on 1a1a315
Model: anthropic/claude-sonnet-5-5

Read the full diff against the base and against commit 0737589 of #2068. The code is right. Three statements in the body do not match the evidence; please correct them before merge.

Code (no finding):

  • QUIRK_TMU_HIFI_BI = BIT(15) is the first free bit on this base: the base's highest quirk is QUIRK_CIO_MACOS_FRAMES = BIT(14) (QUIRK_CIO_NO_ROUTER_STATE is BIT(12), QUIRK_CIO_WAKE_GIVES_UP BIT(13)).
  • The tb.c hunks are identical to J614s/T6040: Thunderbolt displays (Studio Display up to 5120x2880@60) #2068 commit 5: tb_enable_tmu() takes the new branch for (quirks & QUIRK_TMU_HIFI_BI) && tb_route(sw), so only device routers are configured for bi-directional HiFi, disabled, given the host time and enabled. The host router (tb_route() == 0) falls through to the existing tb_switch_tmu_host_managed() early return, which T6050 hits through .host_tmu = true. In tb_start() the HiFi-BI branch is dead on T6050 for the same reason.
  • tb_switch_tmu_configure/disable/post_time/enable and TB_SWITCH_TMU_MODE_HIFI_BI all exist on the base.
  • "T6040's DP IN is disabled in this tree" is true: apple_cio_t6040_hw has .dp = &apple_dpin_disabled. The quirk is set only in apple_cio_t6050_hw.
  • Behavior to know, not a defect: the new branch skips the "already enabled in the right mode, don't touch it" check, so every tb_enable_tmu() call on a device router disables and re-enables its TMU, including on re-enumeration after resume. No resume run with this change is in the body.

Evidence (matches):

  • day2d boot 2bc4664a: the journal has TMU CONFIGURED: is_master=1, mode=1 at 5.158 s and TMU: mode set to: bi-directional, HiFi on router 1 at 5.158 s, and 0 IOAVVideoInterface terminated lines.
  • a2t boots 8951f512, 21315fd1, c685ab86 and 7c1ba736: each has 2 of 2 mode sets kept, 0 terminates, DP-1 connected. Each of the five a2t journals has the firmware line; the 54 earlier A2-line journals I could check do not.

Needs correcting in the body:

  1. The J614s/T6040: Thunderbolt displays (Studio Display up to 5120x2880@60) #2068 quirk-bit statement is wrong. The body says J614s/T6040: Thunderbolt displays (Studio Display up to 5120x2880@60) #2068 uses BIT(12) and that "the two do not conflict except for the quirk bit number". J614s/T6040: Thunderbolt displays (Studio Display up to 5120x2880@60) #2068 commit 5 (07375891752a, J614s/T6040: Thunderbolt displays (Studio Display up to 5120x2880@60) #2068 head d64847a3) defines QUIRK_TMU_HIFI_BI as BIT(15), right after QUIRK_CIO_MACOS_FRAMES, and carries the same tb.c hunks and the same tmu_hifi_bi field. So the two PRs conflict in nhi.h, tb.c and the apple_cio_hw field. Whichever lands second should drop the duplicated parts: after J614s/T6040: Thunderbolt displays (Studio Display up to 5120x2880@60) #2068 lands, this PR reduces to the T6050 table entry in apple.c.
  2. "5 plain reboots" is not what ran. The five a2t boots were hard resets over the USB-C vendor-defined-message path from a second machine (the keep script logs "plain reboot" but calls the VDM reset tool). On this machine a plain Linux restart does not come back, so "plain reboot" misleads a reader. Say "5 resets by VDM from a second machine". The sentence "These are reboots, not a power-off cold start" should be removed or rewritten to say what was done.
  3. "16ffd61a ... its journal was cut at 45.8 s" is wrong. The journal runs to 73.9 s of uptime. The second mode set arrived at 28.08 s, so the log ends 45.8 s after it: the keep script wants 60 s after the mode set for KEPT, so it reports OPEN (0 terminates, DP-1 connected, no HPD drop in the 45.8 s that were recorded). Say that instead: it is not a verdict, and it is also not a truncated journal.

After those edits I will re-read the body and move to GREEN. No code change is needed.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

GREEN on 1a1a315
Model: anthropic/claude-sonnet-5-5

Re-read the body at the same head. The three corrections from my earlier comment are in:

  • The overlap with J614s/T6040: Thunderbolt displays (Studio Display up to 5120x2880@60) #2068 is now stated correctly: both define QUIRK_TMU_HIFI_BI as BIT(15) with the same hunks, so they overlap in nhi.h, tb.c and apple.c, and whichever lands second drops the duplicate.
  • The five a2t boots are described as starting with a VDM reset from a second machine, not as plain reboots, and the closing sentence says they are not a power-off cold start.
  • Boot 16ffd61a is described as a journal that runs to 73.9 s, 45.8 s after the second mode set and short of the 60 s hold, so no verdict.

The body now also lists "no suspend or resume run with this change" under "Not checked", which covers the disable and re-enable on every tb_enable_tmu() call.

The code is unchanged from the version I read: BIT(15) is the first free bit on the base, the router condition matches #2068 commit 5, and the T6050 table is the only place the quirk is set. I did not build or boot it. The host-tests check was still running when I looked; this review does not cover it.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

CHANGES on 1a1a315
Model: zai/glm-5.3

The code is right. One body statement is false against the tree it cites, and it matters to whoever lands second. Everything else checks out.

Finding (body and commit message): #2068 does not use BIT(12).
The body says "#2068 uses BIT(12), which is taken on this base, so whichever lands second takes the next free bit", and that the two PRs "do not conflict except for the quirk bit number". The commit the body cites, 0737589 ("thunderbolt: apple: run T6040's TMU in bi-directional HiFi"), defines QUIRK_TMU_HIFI_BI as BIT(15), the same name on the same line as this PR. The current head of #2068 (d64847a) still has #define QUIRK_TMU_HIFI_BI BIT(15) at nhi.h:264, and BIT(12) there is QUIRK_CIO_NO_ROUTER_STATE. So there is no bit-number difference to resolve. The two PRs define the same macro with the same value, and the tb.c hunk is byte-identical (blob d04c86e07a2 in both). I merged them with git merge-tree: the second one to land conflicts in drivers/thunderbolt/nhi.h (the comment text differs); apple.c merges clean. Following the body's "next free bit" rule would not be needed; the right resolution is to keep a single definition. Please correct the sentence, and say which PR carries the shared nhi.h and tb.c hunks (or drop them from one and stack it on the other) so the second lander resolves one known conflict by keeping one definition. The commit message has the same implication ("BIT(15) here, the first free bit" next to a reference to a different bit).

Smaller: sign-off. Petr's original commit carries his Signed-off-by (and a Co-Authored-By line). This commit keeps him as author but has neither. Half of recent integration/aurora commits carry a sign-off, so this is not a rule I can cite, but his work is being re-submitted under his name and the trailer should travel with it.

Checked and correct

  • Applies as described: parent of the single commit is bf423bf, which is the current integration/aurora head. Three files, +10 apple.c, +7 nhi.h, +23/-2 tb.c; the stat matches the body's "10 / 7 / 23/2".
  • BIT(15) free: integration/aurora's nhi.h uses BIT(0) to BIT(14) (QUIRK_CIO_MACOS_FRAMES is 14), and quirks is unsigned long. I read nhi.h's defines; I did not search the tree for other places that hand-build quirk masks.
  • Host router left to firmware where QUIRK_HOST_TMU is set: the new tb_enable_tmu branch is guarded by tb_route(sw), so the root switch falls through to the existing !tb_route(sw) && tb_switch_tmu_host_managed(sw) return 0. In tb_start the root's configure/enable is inside !tb_switch_tmu_host_managed(...), so it is skipped on T6050 (.host_tmu = true is in the same table). The tb_start LOWRES-or-HIFI_BI change is dead code on T6050.
  • T6050 only: apple_cio_t6050_hw gets .tmu_hifi_bi = true; no other table does. T6040's table on this base has .dp = &apple_dpin_disabled, so "T6040's DP IN is disabled in this tree" is true.
  • The new tb_enable_tmu branch is the existing tail sequence (configure, disable, post_time, enable) without the "already enabled in the right mode, do not touch it" early return, which is the point. tb_increase_switch_tmu_accuracy only acts on routers configured LOWRES, so it does not undo this.

Not verified by me

  • The runs: boots 2bc4664a, 8951f512, 21315fd1, c685ab86, 7c1ba736, 16ffd61a, the "TMU CONFIGURED: is_master=1, mode=1" line, "0 terminated", the 4 of 4 and 0 of 4 counts. Those journals are not on this host, so they are the author's evidence. The body is careful to say neither booted tree is this head, to call 16ffd61a OPEN, and to list what was not checked; I found no claim past that other than the sentence above. "Appears only with this change" is a statement about the baseline runs I could not see.
  • Not compiled: I started an arm64 build of drivers/thunderbolt for this head and did not finish it (no USB4 config in the sandbox's asahi.config; the Rust bindgen check also stops a full prepare). A syntax error is unlikely given the diff is a byte-for-byte reuse of the reviewed J614s/T6040: Thunderbolt displays (Studio Display up to 5120x2880@60) #2068 commit for tb.c, but it is not shown.
  • The head is not booted, as the body says. Resume and hotplug paths (tb_restore_children also calls tb_enable_tmu) are not claimed and not tested.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

GREEN on 5bb8ce9
Model: zai/glm-5.3

Re-review of the new head. Only the commit message changed.

  • Tree identical to the previous head: git rev-parse 5bb8ce9c^{tree} equals 1a1a315's tree, and git diff 1a1a315d 5bb8ce9c --stat is empty. Parent is bf423bf, which is still the current integration/aurora head (re-fetched just now), one commit ahead of base. So my earlier checks on the three files carry over unchanged: applies as described (+10 apple.c, +7 nhi.h, +23/-2 tb.c), BIT(15) free (0-14 used), host router left to firmware under QUIRK_HOST_TMU (new branch guarded by tb_route(sw); tb_start's root configure stays inside !tb_switch_tmu_host_managed), T6050 only, T6040's DP IN disabled on this base.
  • Message: Petr Skuta stays author, carries his Signed-off-by (same address as in 0737589), then the note line [joshuaswarren: set for T6050, BIT(15)], then Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>. The sign-off is byte-identical to the six already on integration/aurora, and the bracketed note follows the form already in use there ([thomas: ...], [niteria: ...]).
  • The earlier finding is closed: the PR body no longer says J614s/T6040: Thunderbolt displays (Studio Display up to 5120x2880@60) #2068 uses BIT(12). It now says J614s/T6040: Thunderbolt displays (Studio Display up to 5120x2880@60) #2068 defines QUIRK_TMU_HIFI_BI as BIT(15) too and that the two PRs overlap in nhi.h, tb.c and apple.c and the second to land drops the duplicate. That matches what I found: the tb.c hunk is byte-identical to the one in J614s/T6040: Thunderbolt displays (Studio Display up to 5120x2880@60) #2068's commit 0737589, and a merge of the two conflicts only in nhi.h (comment text); apple.c merges clean.

Not verified, unchanged from my previous review: the boot logs and counts are the author's (not on this host); the head is not booted and, as the body says, neither booted tree is this head; I did not finish an arm64 compile of drivers/thunderbolt, so a build is not shown (the tb.c hunk is the same one #2068 carries).

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

GREEN on 5bb8ce9
Model: anthropic/claude-sonnet-5-5

Claude review, exact head. Message-only change, checked:

  • Tree is 7bc0dab02c1f010618ee1db1d58b913235dad842 on both this head and the previous head 1a1a315d. Parent is bf423bf0e42c on both. The diff is unchanged: apple.c +10, nhi.h +7, tb.c +23 -2.
  • The message now carries Petr Skuta's Signed-off-by (same name and address as 07375891752a), the note line [joshuaswarren: set for T6050, BIT(15)], and our Signed-off-by. The Co-Authored-By line is gone.
  • The message agrees with the code. QUIRK_TMU_HIFI_BI is BIT(15) in nhi.h. Only apple_cio_t6050_hw sets .tmu_hifi_bi. apple_cio_t6040_hw has .dp = &apple_dpin_disabled, so "T6040's DP IN is disabled in this tree, so its entry is left alone" is true. The host router stays with firmware where QUIRK_HOST_TMU is set (T6050 has it).

Not covered: the host-tests check was still pending when I looked.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

Model correction (wAQ), not a new review.

My review comment(s) on this PR (comments 6924297226, 6924367104) carried the line 'Model: zai/glm-5.3'. That was wrong. The reviewing session ran anthropic/claude-sonnet-5-5 (per the pane header and the session log's model_change at 2026-11-16T17:18:43Z). The correct model line is: Model: anthropic/claude-sonnet-5-5.

Verdicts, heads, findings and checks in those comments are unchanged.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

Same-model flag (wAQ), not a new review.

My review of this PR ran anthropic/claude-sonnet-5-5. The implementing lane (wAP (dhp4), branch dhp4/t6050-tmu-hifi-bi) also runs Sonnet 5.5 (pane headers, Main, 2026-11-16 13:31 CST). This was not a cross-model review. wAW is being assigned a second-model review. My verdict stands as a Sonnet 5.5 review only.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

Review by SWE-2 Flash (Devin), head 5bb8ce9. Not booted.

The mechanism is right: the old tail of tb_enable_tmu() returned early on tb_switch_tmu_is_enabled(), so a device router already reading bi-directional HiFi never got tb_switch_tmu_post_time() — matching the ~1 s HPD drop. The new branch always runs configure → disable → post_time → enable, so the time is posted even when the mode was already correct.

Verified:

  • QUIRK_TMU_HIFI_BI = BIT(15) is free (0-14 used).
  • Host router is untouched on T6050: tb_route(root) is NULL so the new branch skips it, and QUIRK_HOST_TMU makes tb_switch_tmu_host_managed() true so the old early-return still applies.
  • tb_switch_tmu_post_time() no-ops safely for non-USB4 routers and a missing root tmu.cap; tb_switch_tmu_disable() no-ops when already OFF.
  • Failure is warn-only at both tb_enable_tmu call sites (switch activation ~1464, tb_restore_children ~4106) — no enumeration break.

Findings:

  1. The new branch drops the -EOPNOTSUPP fallback chain. The old path tried MEDRES_ENHANCED_UNI, then HIFI_UNI or LOWRES when CL1 was enabled, then HIFI_BI. The new code returns on the first configure error, so a downstream router that cannot do bi-directional HiFi now fails TMU enable outright (warn) where it previously landed on a uni-directional mode. If HIFI_BI is universal on USB4 routers this is moot, but a TB3-era router behind the T6050's ACIO is the case to think about — worth either a fallback or a comment saying why none is needed.

  2. Unconditional TMU cycle. Skipping the is_enabled early-out is the point at enumeration, but tb_enable_tmu also runs from tb_restore_children() on resume — every device router gets disabled → time-posted → re-enabled again on each resume. Bounded (post_time retries ~1 ms worst case) and probably harmless, but it is new resume work per router.

  3. Dead code today: the tb_start hunk can't execute on T6050 — QUIRK_HOST_TMU makes tb_switch_tmu_host_managed() true, so the configure block is skipped before the new ternary is reached. It only becomes live for a future chip with TMU_HIFI_BI and no HOST_TMU, which is fine, but then the comment in tb_enable_tmu ("host router set in tb_start()") is inaccurate for the only quirk user.

  4. Note, not a finding: "as macOS runs it" is the load-bearing claim and is asserted here, consistent with aurora#2068 — this patch doesn't re-verify it.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

[Joshua's agent] New head b29c51c: a commit-message and body change only, the tree is unchanged (7bc0dab0). It follows w88's reading of the M5 boot. The message no longer says the host's time is posted to the router. On the Studio Display tried, the logs show the quirk path ran (TMU disabled, then mode set to bi-directional, HiFi, on router 1, only possible from tb_enable_tmu()) and no local_time line, which fits tb_switch_tmu_post_time() returning early for a router that tb_switch_is_usb4() rejects. So the post-time half is probably a no-op here and the effect is the disable and enable. That is an inference; the router's generation was not read (w7C can read /sys/bus/thunderbolt/devices/0-1/generation on the next boot). Evidence added to the body: boot e76404d0 (kernel p2088b: this commit's content plus #1816 on bf423bf, dyndbg for tmu.c): DP-1 5120x2880 held at the first read and 60 s later, IOAVVideoInterface terminated 0. VDM one-shot, not a cold start; the display image was not looked at. Earlier GREENs were on 5bb8ce9; same tree.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

GREEN on b29c51c
Model: cursor/claude-sonnet-5-5

Re-review of the reworded commit. Not built or booted by me.

Same code. The tree is 7bc0dab02c1f010618ee1db1d58b913235dad842, the tree my earlier GREEN on 5bb8ce9c covered. The parent is still bf423bf0. The diff is apple.c +10, nhi.h +7, tb.c +23 -2. integration/aurora has moved two commits since (5fddb3f4, merge 677be395). A trial merge of this head onto the current tip has no conflicts, and git diff --check is clean.

Does the message match the logs? I read the one-shot boot logs for the p2088b-dd boot (e76404d0, thunderbolt.dyndbg="file tmu.c +p"), as saved by the tester.

  • "The router logs the disable and the mode set": yes. For the Studio Display router (381f00000.nhi: 1:), 13:47:34, in order: "current mode: bi-directional, HiFi", "TMU: disabled", "TMU: mode set to: bi-directional, HiFi".
  • "No local_time line": yes. The capture has no TMU: local_time[n]= line from the host router and no "TMU: updated local time" line. tb_switch_tmu_post_time() logs the first before it writes, so if it had gone past its early returns they would be there.
  • "What tb_switch_tmu_post_time() returning early for a router that tb_switch_is_usb4() rejects would give": correct against the source. The function returns 0 when !tb_switch_is_usb4(sw), and the new tb_enable_tmu() branch calls it unconditionally, so a skipped post is the only way to get that log.
  • "Set for T6050 only; T6040's DP IN is disabled in this tree": agrees with the hardware table.
  • The sentence "That is an inference" is accurate wording. The body's "probably a no-op (see the 13:47 boot below)" agrees with it.

One sentence is stale (should fix, does not block). "the router's generation was not read" is no longer true. A sysfs read at 13:58 (/sys/bus/thunderbolt/devices/0-1, name "Studio Display") gives gen=3. In this tree tb_switch_get_generation() returns 4 exactly when tb_switch_is_usb4() is true, so gen 3 means the router is not USB4 and the early return in tb_switch_tmu_post_time() applies. That turns the inference into an observation, as long as the read was on the same boot. I could not confirm which boot the 13:58 read came from. Suggested wording: "the router reads as generation 3 in sysfs, so tb_switch_is_usb4() is false and the time post returns early." I left this as a note, not a block, because the stale sentence understates the evidence and the body already labels the point as unproven.

Source of the first paragraph. "Min Required TMU Mode 3" and "macOS runs the link that way" are not in the M5 logs I read. The wording comes from the original #2068 commit message (07375891752a, T6040), where they are stated for that hardware. That is fine for Petr's commit; for this one, saying "per #2068, on T6040" would keep the M5 evidence and the borrowed facts apart.

The earlier open point from the other review (no fallback when a router cannot do bi-directional HiFi) is unchanged by this head. The Studio Display router here is generation 3 and took bi-directional HiFi, which is some evidence for this display only. The host-tests check was still pending when I looked.

Per Petr Skuta's T6040 work (aurora-silicon#2068), a Studio Display's router and DP OUT
adapter report "Min Required TMU Mode" 3, bi-directional HiFi, and macOS runs
the link that way. A device router
that already reads as bi-directional HiFi is left alone by tb_enable_tmu(),
so the host never disables and re-enables its TMU, and the display drops HPD
about a second into 5120x2880@60 ("IOAVVideoInterface terminated").

Add QUIRK_TMU_HIFI_BI: every device router is configured for
bi-directional HiFi, disabled, offered the host's time and enabled again.
On the Studio Display tried (14-inch M5 Max) the router logs the disable and
the mode set and no local_time line, and sysfs reads it as generation 3, so
tb_switch_is_usb4() is false and tb_switch_tmu_post_time() returns early: the
time post is a no-op there and the effect is the disable and enable. Whether
posting the time matters on a USB4 device router is not shown.
The host router's TMU stays with its firmware where QUIRK_HOST_TMU is set.
Set for T6050 only: T6040's DP IN is disabled in this tree, so its entry is
left alone.

Signed-off-by: Petr Škuta <20834920+petrskuta@users.noreply.github.com>
[joshuaswarren: set for T6050, BIT(15); commit message reworded to say what the logs show of the time post]
Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
@joshuaswarren

Copy link
Copy Markdown
Contributor Author

[Joshua's agent] New head 20608c5, message and body only; the tree is unchanged (7bc0dab0). Done per the GREEN's two notes: the router generation is now stated as read (sysfs 0-1 Studio Display gen=3, host 0-0 gen=4, so tb_switch_is_usb4() is false and the time post returns early), with the limit that the read was at 13:58 and the file has no boot id; no reboot is recorded between it and the 13:47 dyndbg boot. 'Min Required TMU Mode 3' and the macOS line are now attributed to Petr's T6040 work (#2068), not to the M5 logs.

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

GREEN on 20608c5
Model: cognition/swe-2-flash-medium

All three files read at head. QUIRK_TMU_HIFI_BI = BIT(15) is the first free quirk bit (0-14 used; TB_HOST_DP_NOTIFY is a separate policy namespace). Scope is T6050-only via apple_cio_t6050_hw.tmu_hifi_bi -> apple_nhi_probe; T6040 and other entries untouched.

tb_enable_tmu(): the new branch is gated on tb_route(sw), which is non-NULL only for non-root switches, so the host router can never enter it; the host path below still honors tb_switch_tmu_host_managed. Sequence configure(HIFI_BI) -> disable -> post_time -> enable matches the stated macOS order; tb_switch_tmu_post_time returns early on non-USB4 routers (gen3 Studio Display), so the effective action there is the disable/enable cycle, consistent with the boot log evidence.

tb_start(): the QUIRK_TMU_HIFI_BI ternary sits inside !tb_switch_tmu_host_managed(root), which is false on T6050 (host_tmu set), so host firmware ownership is preserved; the branch only matters for a hypothetical host with hifi_bi but no host_tmu.

Connector/CRTC teardown check (as tasked): this diff adds no connector, CRTC or HPD teardown path - it only adds TMU configure/disable/enable calls, so it cannot introduce a CRTC leak. The pre-existing HPD drop it fixes is upstream of any teardown.

Disclosed and accepted: disable+enable runs on every tb_enable_tmu() call including resume re-enumeration (untested), dock/hub topologies unrun, and this exact head is not the booted tree - the booted content is identical per the body. Hardware evidence is strong: 4 kept / 1 open / 0 failed vs 0 of 4 baseline.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for this, and for keeping Petr as author with the clear overlap note.

The reason given in drivers/thunderbolt/apple.c:239-244 is how macOS runs the device router and what the Studio Display's DP OUT adapter requires. That holds for any Apple USB4 host, but the flag is set only in apple_cio_t6050_hw (and #2068 sets the same flag only for T6040). We usually apply a fix like this to every chip with the hardware and select it by a hardware property, not by the list of machines it was tested on.

Could QUIRK_TMU_HIFI_BI be set for every apple_cio_hw (or simply be the Apple CIO host's behaviour), with an exclusion only where a chip is known to break and a comment saying why? The T6040 entry could then go from #2068, leaving one definition.

If you make it the default, we can run Thunderbolt display rows on our M1 Pro, M2, M4 Pro and A18 Pro.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

[Joshua's agent] Replying to @RyanTheTide.

Authorship / overlap: Noted—Petr Skuta remains author of the tb.c / quirk commit; #2088 is the T6050 table variant of his #2068 T6040 work. Whichever merges first, the second drops the duplicate nhi.h / tb.c hunks.

Scope (TMU HiFi bi on device routers): Agree with the direction: macOS-style disable/re-enable of a device router that already reads bi-directional HiFi is not T6050-specific in reason—it matches what the Studio Display DP OUT path needs on an Apple CIO host.

What we measured (T6050 / K114c, not this exact rebased head): With the quirk, a2t kernel boots after VDM reset: 4/4 kept (0 IOAVVideoInterface terminated, DP-1 connected, 2/2 mode sets kept); baseline without the change 0/4. day2d boot 2bc4664a: TMU configured on the display router, 0 terminates. p2088b boot e76404d0: journal shows router already "bi-directional, HiFi", then driver "TMU: disabled" and mode set again—only the quirk path does that; DP-1 held 5120x2880 for 60s.

What we did not measure: Other Mac hosts (M1/M2/M4 Pro rows), cold power-off, suspend/resume with the re-enable on every tb_enable_tmu(), or T6040 with DP IN enabled.

On defaulting the quirk: We are happy to set QUIRK_TMU_HIFI_BI for all apple_cio_hw entries that use Apple CIO, and exclude only where hardware or DT says otherwise—e.g. T6040 with DP IN disabled in this tree (as in #2068), plus any part your display matrix shows breaks. This PR stays T6050-only so merge order with #2068 stays clear; a follow-up (or your rows landing first) can widen default + shrink the exception list with measured notes.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for the clear account of what was and was not measured, and for agreeing on the direction. Merge order with #2068 is not a hardware reason, though, so we would rather make QUIRK_TMU_HIFI_BI the Apple CIO host default in this PR than add a T6050-only flag now and widen later. Whichever of the two lands first can carry the default; the other drops its flag. An exclusion such as T6040 with DP IN disabled is fine if it is keyed on what the DT describes and has a comment saying why. We will run Studio Display / Thunderbolt display rows on our M1 Pro, M2, M4 Pro and A18 Pro and post them here.

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.

3 participants