UPSTREAM: drm/i915: Fix race condition in intel_dp_destroy_m... [chromiumos/third_party/kernel : chromeos-4.4]

57 views
Skip to first unread message

Tarun Vyas (Gerrit)

unread,
May 17, 2016, 2:15:37 AM5/17/16
to Olof Johansson
Tarun Vyas has uploaded a new change for review.

https://chromium-review.googlesource.com/345046

Change subject: UPSTREAM: drm/i915: Fix race condition in
intel_dp_destroy_mst_connector()
......................................................................

UPSTREAM: drm/i915: Fix race condition in intel_dp_destroy_mst_connector()

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: sta...@vger.kernel.org
Signed-off-by: Lyude <cp...@redhat.com>
Signed-off-by: Rob Clark <rcl...@redhat.com>
Reviewed-by: Ville Syrjälä <ville....@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel...@ffwll.ch>
Link:
http://patchwork.freedesktop.org/patch/msgid/1458155884-13877-1-...@redhat.com
(cherry picked from commit 1f7717552ef1306be3b7ed28c66c6eff550e3a23
from drm-intel-next-2016-03-30)
Signed-off-by: Tarun Vyas <tarun...@intel.com>

BUG=chrome-os-partner:52640
TEST=Image builds, boots and is browse-able

Change-Id: I216edacd1e655075d6b1c5ee9af48e1ce9185c30
---
M drivers/gpu/drm/i915/intel_dp_mst.c
1 file changed, 2 insertions(+), 4 deletions(-)



diff --git a/drivers/gpu/drm/i915/intel_dp_mst.c
b/drivers/gpu/drm/i915/intel_dp_mst.c
index 8d1b703..94b4e83 100644
--- a/drivers/gpu/drm/i915/intel_dp_mst.c
+++ b/drivers/gpu/drm/i915/intel_dp_mst.c
@@ -502,6 +502,8 @@
struct intel_connector *intel_connector = to_intel_connector(connector);
struct drm_device *dev = connector->dev;

+ intel_connector->unregister(intel_connector);
+
/* need to nuke the connector */
drm_modeset_lock_all(dev);
if (connector->state->crtc) {
@@ -515,11 +517,7 @@

WARN(ret, "Disabling mst crtc failed with %i\n", ret);
}
- drm_modeset_unlock_all(dev);

- intel_connector->unregister(intel_connector);
-
- drm_modeset_lock_all(dev);
intel_connector_remove_from_fbdev(intel_connector);
drm_connector_cleanup(connector);
drm_modeset_unlock_all(dev);

--
To view, visit https://chromium-review.googlesource.com/345046
To unsubscribe, visit https://chromium-review.googlesource.com/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I216edacd1e655075d6b1c5ee9af48e1ce9185c30
Gerrit-PatchSet: 1
Gerrit-Project: chromiumos/third_party/kernel
Gerrit-Branch: chromeos-4.4
Gerrit-Owner: Tarun Vyas <tarun...@intel.com>

Benson Leung (Gerrit)

unread,
May 25, 2016, 4:01:01 AM5/25/16
to Tarun Vyas
Benson Leung has posted comments on this change.

Change subject: UPSTREAM: drm/i915: Fix race condition in
intel_dp_destroy_mst_connector()
......................................................................


Patch Set 1: Code-Review+2
Gerrit-MessageType: comment
Gerrit-Change-Id: I216edacd1e655075d6b1c5ee9af48e1ce9185c30
Gerrit-PatchSet: 1
Gerrit-Project: chromiumos/third_party/kernel
Gerrit-Branch: chromeos-4.4
Gerrit-Owner: Tarun Vyas <tarun...@intel.com>
Gerrit-Reviewer: Benson Leung <ble...@google.com>
Gerrit-HasComments: No

Russ Sage (Gerrit)

unread,
Jun 7, 2016, 8:57:04 PM6/7/16
to Tarun Vyas, Benson Leung
Russ Sage has posted comments on this change.

Change subject: UPSTREAM: drm/i915: Fix race condition in
intel_dp_destroy_mst_connector()
......................................................................


Patch Set 1: Verified+1
Gerrit-MessageType: comment
Gerrit-Change-Id: I216edacd1e655075d6b1c5ee9af48e1ce9185c30
Gerrit-PatchSet: 1
Gerrit-Project: chromiumos/third_party/kernel
Gerrit-Branch: chromeos-4.4
Gerrit-Owner: Tarun Vyas <tarun...@intel.com>
Gerrit-Reviewer: Benson Leung <ble...@google.com>
Gerrit-Reviewer: Russ Sage <russ...@intel.com>
Gerrit-HasComments: No

Tarun Vyas (Gerrit)

unread,
Jun 7, 2016, 9:41:56 PM6/7/16
to Benson Leung, Russ Sage
Tarun Vyas has posted comments on this change.

Change subject: UPSTREAM: drm/i915: Fix race condition in
intel_dp_destroy_mst_connector()
......................................................................


Patch Set 1: Commit-Queue+1
Gerrit-MessageType: comment
Gerrit-Change-Id: I216edacd1e655075d6b1c5ee9af48e1ce9185c30
Gerrit-PatchSet: 1
Gerrit-Project: chromiumos/third_party/kernel
Gerrit-Branch: chromeos-4.4
Gerrit-Owner: Tarun Vyas <tarun...@intel.com>
Gerrit-Reviewer: Benson Leung <ble...@google.com>
Gerrit-Reviewer: Russ Sage <russ...@intel.com>
Gerrit-Reviewer: Tarun Vyas <tarun...@intel.com>
Gerrit-HasComments: No

Tarun Vyas (Gerrit)

unread,
Jun 8, 2016, 8:52:56 PM6/8/16
to Benson Leung, Russ Sage, ChromeOS Commit Bot
Tarun Vyas has posted comments on this change.

Change subject: UPSTREAM: drm/i915: Fix race condition in
intel_dp_destroy_mst_connector()
......................................................................


Patch Set 1: Commit-Queue+1
Gerrit-MessageType: comment
Gerrit-Change-Id: I216edacd1e655075d6b1c5ee9af48e1ce9185c30
Gerrit-PatchSet: 1
Gerrit-Project: chromiumos/third_party/kernel
Gerrit-Branch: chromeos-4.4
Gerrit-Owner: Tarun Vyas <tarun...@intel.com>
Gerrit-Reviewer: Benson Leung <ble...@google.com>
Gerrit-Reviewer: ChromeOS Commit Bot <chromeos-...@chromium.org>

ChromeOS Commit Bot (Gerrit)

unread,
Jun 9, 2016, 8:21:50 AM6/9/16
to Tarun Vyas, Benson Leung, Russ Sage
Hello Benson Leung, Tarun Vyas, Russ Sage,

I'd like you to reexamine a change. Please visit

https://chromium-review.googlesource.com/345046

to look at the new patch set (#2).
Reviewed-by: Ville Syrjl <ville....@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel...@ffwll.ch>
Link:
http://patchwork.freedesktop.org/patch/msgid/1458155884-13877-1-...@redhat.com
(cherry picked from commit 1f7717552ef1306be3b7ed28c66c6eff550e3a23
from drm-intel-next-2016-03-30)
Signed-off-by: Tarun Vyas <tarun...@intel.com>

BUG=chrome-os-partner:52640
TEST=Image builds, boots and is browse-able

Change-Id: I216edacd1e655075d6b1c5ee9af48e1ce9185c30
Reviewed-on: https://chromium-review.googlesource.com/345046
Commit-Ready: Tarun Vyas <tarun...@intel.com>
Tested-by: Russ Sage <russ...@intel.com>
Reviewed-by: Benson Leung <ble...@google.com>
---
M drivers/gpu/drm/i915/intel_dp_mst.c
1 file changed, 2 insertions(+), 4 deletions(-)


Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I216edacd1e655075d6b1c5ee9af48e1ce9185c30
Gerrit-PatchSet: 2
Gerrit-Project: chromiumos/third_party/kernel
Gerrit-Branch: chromeos-4.4
Gerrit-Owner: Tarun Vyas <tarun...@intel.com>

ChromeOS Commit Bot (Gerrit)

unread,
Jun 9, 2016, 8:22:37 AM6/9/16
to Tarun Vyas, Benson Leung, Russ Sage
ChromeOS Commit Bot has submitted this change and it was merged.
Reviewed-by: Ville Syrjl <ville....@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel...@ffwll.ch>
Link:
http://patchwork.freedesktop.org/patch/msgid/1458155884-13877-1-...@redhat.com
(cherry picked from commit 1f7717552ef1306be3b7ed28c66c6eff550e3a23
from drm-intel-next-2016-03-30)
Signed-off-by: Tarun Vyas <tarun...@intel.com>

BUG=chrome-os-partner:52640
TEST=Image builds, boots and is browse-able

Change-Id: I216edacd1e655075d6b1c5ee9af48e1ce9185c30
Reviewed-on: https://chromium-review.googlesource.com/345046
Commit-Ready: Tarun Vyas <tarun...@intel.com>
Tested-by: Russ Sage <russ...@intel.com>
Reviewed-by: Benson Leung <ble...@google.com>
Gerrit-MessageType: merged
Gerrit-Change-Id: I216edacd1e655075d6b1c5ee9af48e1ce9185c30
Gerrit-PatchSet: 2
Gerrit-Project: chromiumos/third_party/kernel
Gerrit-Branch: chromeos-4.4
Gerrit-Owner: Tarun Vyas <tarun...@intel.com>
Reply all
Reply to author
Forward
0 new messages