Skip to content

thunderbolt: apple: DisplayPort tunnels to external displays on the M4 (T8132) - #955

Merged
RyanTheTide merged 3 commits into
aurora-silicon:integration/aurorafrom
erikwb:j713/extdisp-tb
Nov 5, 2026
Merged

RyanTheTide merged 3 commits into
aurora-silicon:integration/aurorafrom
erikwb:j713/extdisp-tb

Conversation

@erikwb

@erikwb erikwb commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

DP tunnelling was left disabled on the M4's USB4 host routers, so a monitor behind a dock never got a DP tunnel.

  • DP IN policy. T8132 gets its own policy: the M3 flow (tunnel-changed notifications, capacity retry, deferred bring-up) with the t8103 handshake, which writes only DPTX_INACTIVE and polls its ACK, gated on HPD. A new lazy_idle flag tears down a tunnel whose DP IN the DCP never activated without touching the block.

  • One link rate per PHY. Both DP IN adapters of a T8132 host router feed one ATC PHY, and the second stream only shows when both run at one rate (HBR3 next to HBR stays dark). A new host DP policy, TB_HOST_DP_HBR2_MAX, handles this where the connection manager decides the rate:

    • the tunnels from such a host offer HBR2 at most, in the capability exchange and in bandwidth allocation mode (two 4K60 streams fit at HBR2);
    • when bandwidth is short, the rate is kept and lanes go first (HBR2 x4, x2, x1); only a tunnel with no other DP tunnel up on that host router falls to a lower rate;
    • a second tunnel takes the first one's rate, or isn't set up.

    The DPTX still trains the link itself, so the PHY driver (PR 2) refuses a mismatched stream as the backstop. This is policy, not a module parameter.

  • Suspend-to-idle. With a DP tunnel from the host up, the tunnels are kept across s2idle (the routers stay awake): releasing one in the noirq phase would have the DCP release its display with the DCP already suspended. If a PCIe-C tunnel exists whose link isn't kept, it would be rebuilt at resume and take the others down, so the sleep is refused instead. With router_sleep set the routers sleep and all tunnels go, so the sleep is refused while such a DP tunnel is up.

KUnit: the T8132 qualification rows and apple_dpin_m4_policy (the M4 policy's fields and hooks, and the HBR2 cap set on M4 only) in apple-dpin-lifecycle, and tb_test_dp_reduce_bandwidth_shared (the rate is kept and lanes drop; a second tunnel takes the first one's rate or is refused) in the thunderbolt suite.

Part of the J713 external display series (six PRs, see #957). It doesn't depend on the others. Docked s2idle with the displays lit also needs the PCI: apple PR, which keeps the PCIe-C link through the sleep; without it the sleep is refused while a monitor is attached.

Tested on a J713 (M4 MacBook Air) with a CalDigit TS5 dock and two 4K monitors, with the six PRs together: two DP tunnels at HBR2 x4 with 3840x2160@60 each, dock and monitor replug, s2idle with the dock attached and the monitors lit.

Known gaps (follow-ups): HBR2 is also the cap for a single monitor; it could use HBR3 when it is alone on the PHY.

This was developed and tested by Claude (Anthropic), working with me on the J713.

… most

On the M4 (T8132) both DP IN adapters of a host router feed one ATC PHY,
and the second DP IN stream only shows when both streams run at one link
rate: HBR3 next to HBR stays dark, while HBR next to HBR and HBR2 next to
HBR2 both show. Two 4K60 streams fit at HBR2.

Add a host DP policy, TB_HOST_DP_HBR2_MAX, for such a host:

- a DP tunnel from the host router's DP IN adapters offers HBR2 at most:
  both DP_LOCAL_CAPs are capped (UHBR rates cleared) before they go to the
  other side's DP_REMOTE_CAP, so that the DP OUT and the DPTX both see the
  capped rate; in bandwidth allocation mode the non-reduced rate, the
  granularity base and the maximum bandwidth a request is checked against
  use the capped rate, and the estimated bandwidth is at most what the
  capped rate takes at the non-reduced lanes;
- when the bandwidth has to be reduced, the rate is kept and the lanes go
  first (x4, x2, x1); only a tunnel with no other DP tunnel up on the host
  router falls to a lower rate after that;
- a second DP tunnel takes the link rate of the one already up, with fewer
  lanes if need be, or is not set up at all.

This narrows the cases where the two streams could differ; the DPTX still
trains the link itself, so the PHY driver checks the rates too.

No host sets the policy yet.

Signed-off-by: Erik Bourget <[email protected]>
Give T8132 a DP IN policy of its own, apple_dpin_m4: the M3 flow (tunnel
changed notifications, capacity retry, deferred bring-up) with the t8103
handshake, which writes only DPTX_INACTIVE (+0x0c bit 0) and polls its ACK
(+0x10 bit 0), gated on HPD. The DP IN interrupts are not set up. Its
tunnels take TB_HOST_DP_HBR2_MAX, which keeps the DP IN streams of a PHY at
one link rate where the connection manager decides it.

A new policy flag, lazy_idle: a tunnel whose DP IN block the DCP never
activated is torn down without touching the block, neither the inactive
handshake nor the interrupt mask.

Qualify apple,t8132.

Signed-off-by: Erik Bourget <[email protected]>
…nd-to-idle

With the routers awake through suspend-to-idle, the tunnels are kept only
if the PCIe-C tunnel's link was kept; otherwise tb_suspend_noirq() releases
the DP tunnels. Releasing a DP tunnel from an Apple host DP IN adapter has
its DCP release the display route (its locks, firmware calls and waits) in
the noirq phase, with the DCP already suspended.

With a DP tunnel from an Apple host DP IN adapter up, keep the tunnels
across the sleep: the routers stay awake. If a PCIe-C tunnel exists whose
link is not kept, it is rebuilt at resume, which would tear down the others
too: refuse the sleep (-EBUSY, logged) instead. With router_sleep set the
routers sleep and every tunnel goes, so the sleep is refused while such a
DP tunnel is up.

Signed-off-by: Erik Bourget <[email protected]>

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

Reviewed and tested here with the whole series on top of integration/aurora, thanks Erik.

  • Fedora-base universal config build is clean, W=1 adds no warnings, dtbs_check adds none and only the t8132 DTBs change
  • KUnit passes (atc 49/49, apple-dpin 94 + 1 skip, drm/apple 112 + 1 skip, the arm64 gate set 74 + 1 skip)
  • one-shot boots on the M4 Pro (J616s, dock and external display attached) and the M2, both with zero err lines, no new warnings, 0 AVCs with SELinux enforcing, a freezer pm_test pass and the external display still up on the J616s
  • the host selftests needed fixture updates for the renamed and new helpers, those come in with the #957 merge, all groups pass with them

Merging.
One thing to follow up on after this lands. The suspend_noirq change in "keep DP tunnels to external displays across suspend-to-idle" isn't T8132 only, it runs on every SoC in apple_dpin_qualified_soc (M1, M2, M3 Pro too). On those, with a dock and a display up and a PCIe-C link that isn't kept, s2idle now gets refused with -EBUSY where before the DP tunnels were released. Could you either put it behind a flag in the M4 dpin policy like lazy_idle, or let us know it's been tried on an M1/M2/M3 with a dock? We can run it on the M2 here with the dock if you want.

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