]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
drm/i915: Fix race condition in intel_dp_destroy_mst_connector()
authorLyude <cpaul@redhat.com>
Wed, 16 Mar 2016 19:18:04 +0000 (15:18 -0400)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 26 May 2016 22:46:46 +0000 (15:46 -0700)
Orabug: 23331170

[ Upstream commit 9e60290dbafdf577766e5fc5f2fdb3be450cf9a6 ]

After unplugging a DP MST display from the system, we have to go through
and destroy all of the DRM connectors associated with it since none of
them are valid anymore. Unfortunately, intel_dp_destroy_mst_connector()
doesn't do a good enough job of ensuring that throughout the destruction
process that no modesettings can be done with the connectors. As it is
right now, intel_dp_destroy_mst_connector() works like this:

* Take all modeset locks
* Clear the configuration of the crtc on the connector, if there is one
* Drop all modeset locks, this is required because of circular
  dependency issues that arise with trying to remove the connector from
  sysfs with modeset locks held
* Unregister the connector
* Take all modeset locks, again
* Do the rest of the required cleaning for destroying the connector
* Finally drop all modeset locks for good

This only works sometimes. During the destruction process, it's very
possible that a userspace application will attempt to do a modesetting
using the connector. When we drop the modeset locks, an ioctl handler
such as drm_mode_setcrtc has the oppurtunity to take all of the modeset
locks from us. When this happens, one thing leads to another and
eventually we end up committing a mode with the non-existent connector:

[drm:intel_dp_link_training_clock_recovery [i915]] *ERROR* failed to enable link training
[drm:intel_dp_aux_ch] dp_aux_ch timeout status 0x7cf0001f
[drm:intel_dp_start_link_train [i915]] *ERROR* failed to start channel equalization
[drm:intel_dp_aux_ch] dp_aux_ch timeout status 0x7cf0001f
[drm:intel_mst_pre_enable_dp [i915]] *ERROR* failed to allocate vcpi

And in some cases, such as with the T460s using an MST dock, this
results in breaking modesetting and/or panicking the system.

To work around this, we now unregister the connector at the very
beginning of intel_dp_destroy_mst_connector(), grab all the modesetting
locks, and then hold them until we finish the rest of the function.

CC: stable@vger.kernel.org
Signed-off-by: Lyude <cpaul@redhat.com>
Signed-off-by: Rob Clark <rclark@redhat.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1458155884-13877-1-git-send-email-cpaul@redhat.com
(cherry picked from commit 1f7717552ef1306be3b7ed28c66c6eff550e3a23)
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Dan Duval <dan.duval@oracle.com>
(cherry picked from commit e4ad83b41115d3e57318874474cb655f3d6f6378)

Conflict:

drivers/gpu/drm/i915/intel_dp_mst.c

drivers/gpu/drm/i915/intel_dp_mst.c

index 5cb47482d29fb7f70ddeb540f5d41579152c66f1..2cbfb951d02536dc19852342481b76dcf13057f0 100644 (file)
@@ -451,14 +451,23 @@ static void intel_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr,
 {
        struct intel_connector *intel_connector = to_intel_connector(connector);
        struct drm_device *dev = connector->dev;
-       /* need to nuke the connector */
-       mutex_lock(&dev->mode_config.mutex);
-       intel_connector_dpms(connector, DRM_MODE_DPMS_OFF);
-       mutex_unlock(&dev->mode_config.mutex);
 
        intel_connector->unregister(intel_connector);
 
-       mutex_lock(&dev->mode_config.mutex);
+       /* need to nuke the connector */
+       drm_modeset_lock_all(dev);
+       if (connector->state->crtc) {
+               struct drm_mode_set set;
+               int ret;
+
+               memset(&set, 0, sizeof(set));
+               set.crtc = connector->state->crtc,
+
+               ret = drm_atomic_helper_set_config(&set);
+
+               WARN(ret, "Disabling mst crtc failed with %i\n", ret);
+       }
+
        intel_connector_remove_from_fbdev(intel_connector);
        drm_connector_cleanup(connector);
        mutex_unlock(&dev->mode_config.mutex);