From 53397b77038e1f8bb1548a1cd52b3b8990495e0b Mon Sep 17 00:00:00 2001 From: Andreas Fernandez Date: Wed, 14 Oct 2026 21:37:44 +0200 Subject: [PATCH] drm/apple: dcp: let a Type-C port with HPD take over a pipeline held without it The PD controllers on the M1 Pro/Max laptops report a DP alt mode state at probe for ports that have no display behind them, for example an empty port or one with only a charger. With the crossbar driver in the initramfs appledrm binds about a second into boot, and whichever port is routed first gets the Type-C pipeline. If that is the wrong one, the port with the display finds every pipeline taken (-ENOSPC, which the CD321x driver does not retry) and stays dark for the whole boot, which puts the LUKS prompt on the internal panel of a closed laptop. When a port whose sink asserts HPD finds no free pipeline, release one held by a port whose sink never asserted HPD and take it. Tunnels, ports with a pending safe state and pipelines whose fixed output is in use are left alone. The released port drops its applied state so its next update is routed again once a pipeline is free. Link: https://github.com/omacom/omarchy-pkgs/issues/1037 Signed-off-by: Andreas Fernandez --- drivers/gpu/drm/apple/dcp.c | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index 8f601bbb91cbe..b17f1db002ddb 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -1043,6 +1043,36 @@ static void dcp_typec_route_commit(struct typec_mux_dev *mux, dcp_typec_pipeline_freed(); } +static struct apple_dcp_typec_route * +dcp_typec_take_over_without_hpd(struct apple_dcp_typec_port *port) +{ + struct apple_dcp_typec_route *candidate; + + list_for_each_entry(candidate, &port->routes, port_link) { + struct apple_dcp_typec_route *held = + candidate->dcp->active_typec_route; + int ret; + + if (!held || held->tunnel || held->port == port || + held->port->hpd || held->port->safe_pending || + dcp_typec_route_fixed_output_busy(candidate)) + continue; + + ret = dcp_typec_route_deactivate(held); + if (ret) + return ERR_PTR(ret); + held->port->owner = NULL; + /* let the port's next update try again */ + held->port->applied_valid = false; + dev_info(candidate->dcp->dev, + "released Type-C DPTX PHY %u held without HPD\n", + held->dptx_phy); + return candidate; + } + + return NULL; +} + static int dcp_typec_route_set(struct typec_mux_dev *mux, struct typec_mux_state *state) { @@ -1174,6 +1204,17 @@ static int dcp_typec_route_set(struct typec_mux_dev *mux, if (!best) best = dcp_typec_lowest_free(port); + /* + * PD controllers can report a DP state at probe for a port that + * has no display behind it, and whichever port is routed first + * wins the pipeline. A port whose sink asserts HPD takes it over + * from one whose sink never did. + */ + if (!best && hpd) + best = dcp_typec_take_over_without_hpd(port); + + if (IS_ERR(best)) + return PTR_ERR(best); /* Every pipeline is driving another port's display. */ if (!best) return -ENOSPC;