From 68c8317cc5fb6935d2bb20e6f86c8307eb89d064 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Sat, 28 Nov 2026 00:26:46 +0100 Subject: [PATCH 1/2] usb: typec: tipd: only set connector_fwnode when displayport property exists Commit d769aaf5b389 ("usb: typec: tipd: reconcile firmware-entered J616s DP mode") added a fallback in cd321x_register_port() that sets cd321x->connector_fwnode to the USB-C connector fwnode itself whenever no "displayport" reference property is present in the device tree. On Apple Silicon systems using dcp-fabric, no DRM connector registers with the USB-C connector fwnode (apple_connector_create() only attaches dcp->dev.fwnode for non-fabric external pipelines). Consequently, drm_connector_oob_hotplug_event() with the fallback fwnode silently matches no connector, while making cd321x->connector_fwnode unconditionally non-NULL breaks the !(IS_REACHABLE(CONFIG_DRM) && cd321x->connector_fwnode) guard in cd321x_typec_update_mode(). That disabled coalesced HPD pulse handling on every dcp-fabric port. Restore the original lookup so cd321x->connector_fwnode is only set when a "displayport" reference actually exists, and remove the now-unused fwnode_property_present()/fwnode_handle_get() stubs from the apple-dcp host selftest. Also move tps->h17_display initialization from tipd_resume() into tipd_init() so T8140/T8142 have h17_display set from boot rather than staying false until the first suspend/resume once the connector_fwnode fallback no longer masks it. Fixes: d769aaf5b389 ("usb: typec: tipd: reconcile firmware-entered J616s DP mode") Signed-off-by: Thomas Glanzmann --- drivers/usb/typec/tipd/core.c | 15 +++++---------- .../testing/selftests/drivers/gpu/apple-dcp/pm.py | 2 -- .../drivers/gpu/apple-dcp/transaction.py | 2 +- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index d9ece372d36a4..e005e813d43c2 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -3004,7 +3004,6 @@ static bool cd321x_display_gate_pending(struct tps6598x *tps) static int cd321x_register_port(struct tps6598x *tps, struct fwnode_handle *fwnode) { - struct fwnode_handle *connector_fwnode; struct cd321x *cd321x = container_of(tps, struct cd321x, tps); bool tbt_late; int ret; @@ -3025,12 +3024,9 @@ cd321x_register_port(struct tps6598x *tps, struct fwnode_handle *fwnode) goto err_unregister_altmodes; } - if (fwnode_property_present(fwnode, "displayport")) - connector_fwnode = fwnode_find_reference(fwnode, "displayport", 0); - else - connector_fwnode = fwnode_handle_get(fwnode); - if (!IS_ERR_OR_NULL(connector_fwnode)) - cd321x->connector_fwnode = connector_fwnode; + cd321x->connector_fwnode = fwnode_find_reference(fwnode, "displayport", 0); + if (IS_ERR(cd321x->connector_fwnode)) + cd321x->connector_fwnode = NULL; cd321x->tbt_switch = cd321x_tbt_switch_get(tps->dev, fwnode, &tbt_late); if (IS_ERR(cd321x->tbt_switch)) { @@ -4047,6 +4043,8 @@ int tipd_init(struct tps6598x *tps) return -EPROBE_DEFER; dev_dbg(tps->dev, "Type-C probe start\n"); + tps->h17_display = of_machine_is_compatible("apple,t8140") || + of_machine_is_compatible("apple,t8142"); tps->reset = devm_gpiod_get_optional(tps->dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(tps->reset)) return dev_err_probe(tps->dev, PTR_ERR(tps->reset), @@ -4383,9 +4381,6 @@ int tipd_resume(struct tps6598x *tps) { int ret; - tps->h17_display = of_machine_is_compatible("apple,t8140") || - of_machine_is_compatible("apple,t8142"); - ret = tps6598x_check_mode(tps); if (ret < 0) return ret; diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/pm.py b/tools/testing/selftests/drivers/gpu/apple-dcp/pm.py index eacb1b3e40fca..f6b3d713b2b8b 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/pm.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/pm.py @@ -525,8 +525,6 @@ def function(text, name): static struct fwnode_handle *fwnode_find_reference(struct fwnode_handle *f,const char *s,int n) { (void)f;(void)s;(void)n;connector.refs++;return &connector; } -static bool fwnode_property_present(struct fwnode_handle *f,const char *s) { (void)f;(void)s;return true; } -static struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *f) { assert(!"connector is a displayport reference");return f; } static void __attribute__((unused)) fwnode_handle_put(struct fwnode_handle *f) { if(f){assert(f->refs>0);f->refs--;} } diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/transaction.py b/tools/testing/selftests/drivers/gpu/apple-dcp/transaction.py index 7e98084906081..644c96709a949 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/transaction.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/transaction.py @@ -373,7 +373,7 @@ def probe(root): unit = quiesce.make_unit(root) unit = unit.replace(block(unit, 'int main('), block(unit, 'int main(').replace('int main(', 'int __attribute__((unused)) prior_main(', 1), 1) unit = unit.replace('struct tipd_data {', 'struct fwnode_handle;\nstruct tipd_data { unsigned irq_mask1; int (*init)(struct tps6598x *); int (*switch_power_state)(struct tps6598x *, int); int (*register_port)(struct tps6598x *, struct fwnode_handle *); bool (*read_data_status)(struct tps6598x *); bool (*read_power_status)(struct tps6598x *); int (*connect)(struct tps6598x *,u32); void (*ready)(struct tps6598x *); void *irq_handler;') - unit = unit.replace('struct tps6598x {', 'struct tps6598x { bool dbma_at_probe,wakeup; u32 status; bool (*sleep_event)(struct tps6598x *);') + unit = unit.replace('struct tps6598x {', 'struct tps6598x { bool dbma_at_probe,wakeup,h17_display; u32 status; bool (*sleep_event)(struct tps6598x *);') helpers = r""" #undef dev_err #define dev_err(...) ((void)0) From a590df619dd74fa6a6f767ee07ff967e676fb4cb Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Sat, 28 Nov 2026 00:26:46 +0100 Subject: [PATCH 2/2] usb: typec: tipd: replay HPD low before high on coalesced HPD drops MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a DisplayPort sink drops HPD and raises it again within the 500 ms debounce window of cd321x_update_work() — for example an EIZO EV2780 waking from standby and dropping HPD for ~248 ms about 3 s after plug — cd321x_typec_update_mode() previously synthesized DP_STATUS_IRQ_HPD. On a dcp-fabric port, DP_STATUS_IRQ_HPD routes to dcp_retrain_oob(), which only requests a modeset for the active mode without toggling DPTX HPD. On DCP firmware 27.2.1 (M1 MacBook Air J313), the firmware still considers the link up for that timing/color ID and short-circuits the modeset as a no-op, skipping DisplayPort link training so the monitor reports "No Signal" and returns to standby. A >2 ms HPD drop is a hot-unplug/hot-plug event rather than an IRQ_HPD. Replay HPD low first and then HPD high to the Type-C mux on a coalesced HPD drop/rise, matching what cd321x_dp_sid_replay() already does on SN201202x and what an uncoalesced (>500 ms) HPD drop produces. Gate hpd_pulse on the port already being in DP altmode (state_valid && state.alt == port_altmode_dp) and clear dp_status/dp_conf after placing the mux in TYPEC_STATE_SAFE on disconnect so a fresh plug-in after unplug cannot trigger a spurious HPD=0 edge. Update cd321x_dp_send() and its KUnit test accordingly. Fixes: 836f05b1c151 ("usb: typec: tipd: report a coalesced sink HPD pulse as IRQ_HPD") Fixes: b9057513e354 ("usb: typec: tipd: send each IRQ_HPD request to the display route once") Signed-off-by: Thomas Glanzmann --- drivers/usb/typec/tipd/cd321x-pm-test.c | 4 ++-- drivers/usb/typec/tipd/cd321x-pm.h | 11 +++++------ drivers/usb/typec/tipd/core.c | 22 +++++++++++++--------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/drivers/usb/typec/tipd/cd321x-pm-test.c b/drivers/usb/typec/tipd/cd321x-pm-test.c index e66b48ca636e3..48cc1dafdb2d6 100644 --- a/drivers/usb/typec/tipd/cd321x-pm-test.c +++ b/drivers/usb/typec/tipd/cd321x-pm-test.c @@ -1060,8 +1060,8 @@ static void cd321x_dp_send_test(struct kunit *test) KUNIT_EXPECT_EQ(test, cd321x_dp_send(hpd, irq, false), CD321X_DP_SEND); KUNIT_EXPECT_EQ(test, cd321x_dp_send(irq, hpd, false), CD321X_DP_SEND); KUNIT_EXPECT_EQ(test, cd321x_dp_send(hpd, 0, false), CD321X_DP_SEND); - /* An HPD pulse is sent once, as an edge if the route holds IRQ_HPD. */ - KUNIT_EXPECT_EQ(test, cd321x_dp_send(hpd, irq, true), CD321X_DP_SEND); + /* A coalesced HPD drop/rise replays HPD low first, then high. */ + KUNIT_EXPECT_EQ(test, cd321x_dp_send(hpd, hpd, true), CD321X_DP_SEND_EDGE); KUNIT_EXPECT_EQ(test, cd321x_dp_send(irq, irq, true), CD321X_DP_SEND_EDGE); } diff --git a/drivers/usb/typec/tipd/cd321x-pm.h b/drivers/usb/typec/tipd/cd321x-pm.h index c91aaed83f8af..49ff301a81984 100644 --- a/drivers/usb/typec/tipd/cd321x-pm.h +++ b/drivers/usb/typec/tipd/cd321x-pm.h @@ -377,7 +377,7 @@ static inline bool cd321x_display_taken(int ret) enum cd321x_dp_send { CD321X_DP_SEND_NONE, /* the display route holds this status */ CD321X_DP_SEND, /* send the status */ - CD321X_DP_SEND_EDGE, /* send it without IRQ_HPD first, then with it */ + CD321X_DP_SEND_EDGE, /* send HPD low first, then the status */ }; /* @@ -385,16 +385,15 @@ enum cd321x_dp_send { * route, which holds @applied for the same pin assignment and configuration. * The route drops a status equal to the one it holds, and so does this: an * IRQ_HPD that the partner's last status still carries is not a new request. - * @pulse is a new request: the sink dropped HPD and raised it again since the - * last update (@status has IRQ_HPD set for it). When the route holds IRQ_HPD - * already, the request is sent as an edge, so that the route sees it. + * @pulse means the sink dropped HPD and raised it again since the last update: + * replay HPD low first so the display route tears down and retrains the link + * anew, matching an uncoalesced HPD drop. */ static inline enum cd321x_dp_send cd321x_dp_send(u32 applied, u32 status, bool pulse) { if (pulse) - return applied & DP_STATUS_IRQ_HPD ? CD321X_DP_SEND_EDGE : - CD321X_DP_SEND; + return CD321X_DP_SEND_EDGE; return applied == status ? CD321X_DP_SEND_NONE : CD321X_DP_SEND; } diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index e005e813d43c2..d6707be903939 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -916,25 +916,26 @@ static int cd321x_typec_update_mode(struct tps6598x *tps, /* * The sink dropped HPD and raised it again within the debounce - * window, as a monitor does after losing the link. The coalesced - * state looks unchanged, so the display side would never hear of - * it: report the pulse as IRQ_HPD. A port with a displayport - * reference reports the pulse out of band instead, as a - * disconnect and a connect (see cd321x_update_work()). + * window, as a monitor does after losing the link or waking + * from standby. Replay HPD low first so the display route + * disconnects and retrains the link anew, matching an + * uncoalesced HPD drop. A port with a displayport reference + * reports the pulse out of band instead, as a disconnect and + * a connect (see cd321x_update_work()). */ hpd_pulse = !tps->h17_display && !(IS_REACHABLE(CONFIG_DRM) && cd321x->connector_fwnode) && + cd321x->state_valid && + cd321x->state.alt == cd321x->port_altmode_dp && (st->data_status_changed & CD321X_DATA_STATUS_HPD_LEVEL) && (dp_data.status & DP_STATUS_HPD_STATE) && (cd321x->dp_status & DP_STATUS_HPD_STATE); - if (hpd_pulse) - dp_data.status |= DP_STATUS_IRQ_HPD; if (cd321x->state_valid && cd321x->state.alt == cd321x->port_altmode_dp && cd321x->state.mode == mode && cd321x->dp_conf == dp_data.conf) send = cd321x_dp_send(cd321x->dp_status, dp_data.status, hpd_pulse); else - send = CD321X_DP_SEND; + send = hpd_pulse ? CD321X_DP_SEND_EDGE : CD321X_DP_SEND; if (send == CD321X_DP_SEND_NONE) return 0; @@ -946,7 +947,8 @@ static int cd321x_typec_update_mode(struct tps6598x *tps, goto out; if (send == CD321X_DP_SEND_EDGE) { struct typec_displayport_data edge = { - .status = dp_data.status & ~DP_STATUS_IRQ_HPD, + .status = dp_data.status & + ~(DP_STATUS_HPD_STATE | DP_STATUS_IRQ_HPD), .conf = dp_data.conf, }; @@ -1358,6 +1360,8 @@ static void cd321x_update_work(struct work_struct *work) cd321x->state = old_state; goto retry; } + cd321x->dp_status = 0; + cd321x->dp_conf = 0; cd321x->display_route_active = false; }