On Thu, 2024-01-04 at 10:30 +0200, Imre Deak wrote: > Glitches deasserting the connector HPD line can lead to incorrectly > detecting a disconnect event (a glitch asserting the line will only > cause a redundant connect->disconnect transition). The source of such > a > glitch can be noise on the line or a 0.5ms-1ms MST IRQ_HPD pulse. > TypeC > ports in the DP-alt or TBT-alt mode filter out these glitches > inernally, > but for others the driver has to do this. Make it so by polling the > HPD > line on these connectors for 4 ms. > > Signed-off-by: Imre Deak <imre.deak@xxxxxxxxx> Reviewed-by: Jouni Högander <jouni.hogander@xxxxxxxxx> > --- > drivers/gpu/drm/i915/display/intel_dp.c | 13 +++++++++++-- > drivers/gpu/drm/i915/display/intel_tc.c | 9 +++++++++ > drivers/gpu/drm/i915/display/intel_tc.h | 1 + > 3 files changed, 21 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/i915/display/intel_dp.c > b/drivers/gpu/drm/i915/display/intel_dp.c > index f04926d4aa80d..77ba6de6ba087 100644 > --- a/drivers/gpu/drm/i915/display/intel_dp.c > +++ b/drivers/gpu/drm/i915/display/intel_dp.c > @@ -5460,11 +5460,20 @@ bool > intel_digital_port_connected_locked(struct intel_encoder *encoder) > { > struct drm_i915_private *dev_priv = to_i915(encoder- > >base.dev); > struct intel_digital_port *dig_port = > enc_to_dig_port(encoder); > + bool is_glitch_free = > intel_tc_port_handles_hpd_glitches(dig_port); > bool is_connected = false; > intel_wakeref_t wakeref; > > - with_intel_display_power(dev_priv, POWER_DOMAIN_DISPLAY_CORE, > wakeref) > - is_connected = dig_port->connected(encoder); > + with_intel_display_power(dev_priv, POWER_DOMAIN_DISPLAY_CORE, > wakeref) { > + unsigned long wait_expires = jiffies + > msecs_to_jiffies_timeout(4); > + > + do { > + is_connected = dig_port->connected(encoder); > + if (is_connected || is_glitch_free) > + break; > + usleep_range(10, 30); > + } while (time_before(jiffies, wait_expires)); > + } > > return is_connected; > } > diff --git a/drivers/gpu/drm/i915/display/intel_tc.c > b/drivers/gpu/drm/i915/display/intel_tc.c > index 80aed9e87927a..f34743e6eeed2 100644 > --- a/drivers/gpu/drm/i915/display/intel_tc.c > +++ b/drivers/gpu/drm/i915/display/intel_tc.c > @@ -122,6 +122,15 @@ bool intel_tc_port_in_legacy_mode(struct > intel_digital_port *dig_port) > return intel_tc_port_in_mode(dig_port, TC_PORT_LEGACY); > } > > +bool intel_tc_port_handles_hpd_glitches(struct intel_digital_port > *dig_port) > +{ > + struct drm_i915_private *i915 = to_i915(dig_port- > >base.base.dev); > + enum phy phy = intel_port_to_phy(i915, dig_port->base.port); > + struct intel_tc_port *tc = to_tc_port(dig_port); > + > + return intel_phy_is_tc(i915, phy) && !tc->legacy_port; > +} > + > /* > * The display power domains used for TC ports depending on the > * platform and TC mode (legacy, DP-alt, TBT): > diff --git a/drivers/gpu/drm/i915/display/intel_tc.h > b/drivers/gpu/drm/i915/display/intel_tc.h > index 936fa2daaa74a..26c4265368c1a 100644 > --- a/drivers/gpu/drm/i915/display/intel_tc.h > +++ b/drivers/gpu/drm/i915/display/intel_tc.h > @@ -15,6 +15,7 @@ struct intel_encoder; > bool intel_tc_port_in_tbt_alt_mode(struct intel_digital_port > *dig_port); > bool intel_tc_port_in_dp_alt_mode(struct intel_digital_port > *dig_port); > bool intel_tc_port_in_legacy_mode(struct intel_digital_port > *dig_port); > +bool intel_tc_port_handles_hpd_glitches(struct intel_digital_port > *dig_port); > > bool intel_tc_port_connected(struct intel_encoder *encoder); >