drm/i915: Init DRM connector polled field early
authorImre Deak <imre.deak@intel.com>
Thu, 4 Jan 2024 08:29:57 +0000 (10:29 +0200)
committerImre Deak <imre.deak@intel.com>
Mon, 8 Jan 2024 16:51:31 +0000 (18:51 +0200)
After an HPD IRQ storm on a connector intel_hpd_irq_storm_detect() will
set the connector's HPD pin state to HPD_MARK_DISABLED and the IRQ gets
disabled. Subsequently intel_hpd_irq_storm_switch_to_polling() will
enable polling for these connectors, setting the pin state to
HPD_DISABLED, but only if the connector's base.polled field is set to
DRM_CONNECTOR_POLL_HPD. intel_hpd_irq_storm_reenable_work() will
reenable the IRQ - after 2 minutes -  if the pin state is HPD_DISABLED.

The connectors will be created with their base.polled field set to 0,
which gets initialized only later in i915_hpd_poll_init_work() (using
intel_connector::polled). If a storm is detected on a connector after
it's created and IRQs are enabled on it - by intel_hpd_init() - and
before its bease.polled field is initialized in the above work, the
connector's HPD pin will stay in the HPD_MARK_DISABLED state - leaving
the IRQ disabled indefinitely - and polling will not get enabled on it as
intended.

I can't see a reason for initializing base.polled in a delayed manner,
so do this already when creating the connector, to prevent the above
race condition.

Link: https://patchwork.freedesktop.org/patch/msgid/20240104083008.2715733-2-imre.deak@intel.com
Reviewed-by: Jouni Högander <jouni.hogander@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
drivers/gpu/drm/i915/display/intel_crt.c
drivers/gpu/drm/i915/display/intel_dp.c
drivers/gpu/drm/i915/display/intel_dvo.c
drivers/gpu/drm/i915/display/intel_hdmi.c
drivers/gpu/drm/i915/display/intel_sdvo.c
drivers/gpu/drm/i915/display/intel_tv.c

index abaacea..b330337 100644 (file)
@@ -1069,6 +1069,7 @@ void intel_crt_init(struct drm_i915_private *dev_priv)
        } else {
                intel_connector->polled = DRM_CONNECTOR_POLL_CONNECT;
        }
+       intel_connector->base.polled = intel_connector->polled;
 
        if (HAS_DDI(dev_priv)) {
                assert_port_valid(dev_priv, PORT_E);
index f4a22d4..8803a93 100644 (file)
@@ -6462,6 +6462,7 @@ intel_dp_init_connector(struct intel_digital_port *dig_port,
                connector->interlace_allowed = true;
 
        intel_connector->polled = DRM_CONNECTOR_POLL_HPD;
+       intel_connector->base.polled = intel_connector->polled;
 
        intel_connector_attach_encoder(intel_connector, intel_encoder);
 
index 9111e9d..83898ba 100644 (file)
@@ -536,6 +536,7 @@ void intel_dvo_init(struct drm_i915_private *i915)
        if (intel_dvo->dev.type == INTEL_DVO_CHIP_TMDS)
                connector->polled = DRM_CONNECTOR_POLL_CONNECT |
                        DRM_CONNECTOR_POLL_DISCONNECT;
+       connector->base.polled = connector->polled;
 
        drm_connector_init_with_ddc(&i915->drm, &connector->base,
                                    &intel_dvo_connector_funcs,
index eedef81..55048c5 100644 (file)
@@ -3017,6 +3017,7 @@ void intel_hdmi_init_connector(struct intel_digital_port *dig_port,
                connector->ycbcr_420_allowed = true;
 
        intel_connector->polled = DRM_CONNECTOR_POLL_HPD;
+       intel_connector->base.polled = intel_connector->polled;
 
        if (HAS_DDI(dev_priv))
                intel_connector->get_hw_state = intel_ddi_connector_get_hw_state;
index 0362d02..c660dd8 100644 (file)
@@ -2804,6 +2804,7 @@ intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, u16 type)
        } else {
                intel_connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT;
        }
+       intel_connector->base.polled = intel_connector->polled;
        encoder->encoder_type = DRM_MODE_ENCODER_TMDS;
        connector->connector_type = DRM_MODE_CONNECTOR_DVID;
 
@@ -2879,6 +2880,7 @@ intel_sdvo_analog_init(struct intel_sdvo *intel_sdvo, u16 type)
        intel_connector = &intel_sdvo_connector->base;
        connector = &intel_connector->base;
        intel_connector->polled = DRM_CONNECTOR_POLL_CONNECT;
+       intel_connector->base.polled = intel_connector->polled;
        encoder->encoder_type = DRM_MODE_ENCODER_DAC;
        connector->connector_type = DRM_MODE_CONNECTOR_VGA;
 
index 9a21780..1b19443 100644 (file)
@@ -1990,6 +1990,7 @@ intel_tv_init(struct drm_i915_private *dev_priv)
         * More recent chipsets favour HDMI rather than integrated S-Video.
         */
        intel_connector->polled = DRM_CONNECTOR_POLL_CONNECT;
+       intel_connector->base.polled = intel_connector->polled;
 
        drm_connector_init(&dev_priv->drm, connector, &intel_tv_connector_funcs,
                           DRM_MODE_CONNECTOR_SVIDEO);