drm/i915: lock around link status and link training.
authorDave Airlie <airlied@redhat.com>
Tue, 5 Aug 2014 00:40:20 +0000 (10:40 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 6 Aug 2014 00:11:53 +0000 (10:11 +1000)
We need to take the connection mutex around the link status
check for non-MST case, but also around the MST link training
on short HPDs.

I suspect we actually should have a dpcd lock in the future as
well, that just lock the local copies of dpcd and flags stored
from that.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/i915/intel_dp.c

index ea6ff71b291067f45165cc85849831bc91f00727..eb52ecfe14cf9539f64d81a98994f28d0d2a8049 100644 (file)
@@ -3535,11 +3535,13 @@ go_again:
 void
 intel_dp_check_link_status(struct intel_dp *intel_dp)
 {
+       struct drm_device *dev = intel_dp_to_dev(intel_dp);
        struct intel_encoder *intel_encoder = &dp_to_dig_port(intel_dp)->base;
        u8 sink_irq_vector;
        u8 link_status[DP_LINK_STATUS_SIZE];
 
-       /* FIXME: This access isn't protected by any locks. */
+       WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex));
+
        if (!intel_encoder->connectors_active)
                return;
 
@@ -4058,7 +4060,9 @@ intel_dp_hpd_pulse(struct intel_digital_port *intel_dig_port, bool long_hpd)
                         * we'll check the link status via the normal hot plug path later -
                         * but for short hpds we should check it now
                         */
+                       drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
                        intel_dp_check_link_status(intel_dp);
+                       drm_modeset_unlock(&dev->mode_config.connection_mutex);
                }
        }
        return false;