All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 08/13] drm/i915: Use proper locking for intel_dp_check_link_status.
Date: Thu, 16 Jul 2015 10:59:21 +0200	[thread overview]
Message-ID: <1437037166-9339-9-git-send-email-maarten.lankhorst@linux.intel.com> (raw)
In-Reply-To: <1437037166-9339-1-git-send-email-maarten.lankhorst@linux.intel.com>

To look at encoder->crtc->state the crtc mutex is required.
Get rid of connectors_active, and only check crtc state.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_dp.c | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index cea7d1785d13..4b16023fffd0 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -4235,19 +4235,17 @@ 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;
+	struct drm_crtc *crtc;
 	u8 sink_irq_vector;
 	u8 link_status[DP_LINK_STATUS_SIZE];
 
-	WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex));
-
-	if (!intel_encoder->connectors_active)
-		return;
 
-	if (WARN_ON(!intel_encoder->base.crtc))
+	crtc = intel_encoder->base.crtc;
+	if (!crtc || !crtc->state->active)
 		return;
 
-	if (!to_intel_crtc(intel_encoder->base.crtc)->active)
-		return;
+	WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex));
+	WARN_ON(!drm_modeset_is_locked(&crtc->mutex));
 
 	/* Try to read receiver status if the link appears to be up */
 	if (!intel_dp_get_link_status(intel_dp, link_status)) {
@@ -4906,13 +4904,31 @@ intel_dp_hpd_pulse(struct intel_digital_port *intel_dig_port, bool long_hpd)
 		}
 
 		if (!intel_dp->is_mst) {
+			struct drm_modeset_acquire_ctx ctx;
+
+			drm_modeset_acquire_init(&ctx, 0);
+
+			while (1) {
+				int ret;
+
+				ret = drm_modeset_lock(&dev->mode_config.connection_mutex, &ctx);
+				if (!ret && intel_encoder->base.crtc)
+					ret = drm_modeset_lock(&intel_encoder->base.crtc->mutex, &ctx);
+
+				if (!ret || WARN_ON(ret != -EDEADLK))
+					break;
+
+				drm_modeset_backoff(&ctx);
+			}
+
 			/*
 			 * 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);
+
+			drm_modeset_drop_locks(&ctx);
+			drm_modeset_acquire_fini(&ctx);
 		}
 	}
 
-- 
2.1.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2015-07-16  9:01 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-16  8:59 [PATCH 00/13] Make i915 dpms atomic Maarten Lankhorst
2015-07-16  8:59 ` [PATCH 01/13] drm/atomic: Only update crtc->x/y if it's part of the state Maarten Lankhorst
2015-07-16  9:19   ` Daniel Vetter
2015-07-16  9:17     ` Maarten Lankhorst
2015-07-16  9:29       ` Daniel Vetter
2015-07-16  9:38         ` Maarten Lankhorst
2015-07-16 12:34           ` Daniel Vetter
2015-07-16 13:44             ` Maarten Lankhorst
2015-07-16 13:51   ` [PATCH v1.1 01/13] drm/atomic: Only update crtc->x/y if it's part of the state, v2 Maarten Lankhorst
2015-07-16 14:58     ` Daniel Vetter
2015-07-16  8:59 ` [PATCH 02/13] drm/atomic: Update legacy DPMS state during modesets Maarten Lankhorst
2015-07-16  9:19   ` Daniel Vetter
2015-07-16  9:24     ` Maarten Lankhorst
2015-07-16  9:31       ` Daniel Vetter
2015-07-27 11:04         ` [PATCH v1.1 02/13] drm/atomic: Update legacy DPMS state during modesets, v2 Maarten Lankhorst
2015-07-27 11:16           ` Daniel Vetter
2015-07-27 11:15             ` Maarten Lankhorst
2015-07-27 11:24             ` [PATCH v1.2 02/13] drm/atomic: Update legacy DPMS state during modesets, v3 Maarten Lankhorst
2015-07-27 13:56               ` Daniel Vetter
2015-07-16  8:59 ` [PATCH 03/13] drm/i915: Make the force_thru workaround atomic Maarten Lankhorst
2015-07-16  8:59 ` [PATCH 04/13] drm/i915: Remove special dpms handling from intel_crt.c Maarten Lankhorst
2015-07-16  8:59 ` [PATCH 05/13] drm/i915: Remove special dpms handling from intel_crtc.c Maarten Lankhorst
2015-07-16  8:59 ` [PATCH 06/13] drm/i915: Remove special dpms handling from intel_sdvo.c Maarten Lankhorst
2015-07-16  8:59 ` [PATCH 07/13] drm/i915: Get rid of dpms handling Maarten Lankhorst
2015-07-16  8:59 ` Maarten Lankhorst [this message]
2015-07-16  8:59 ` [PATCH 09/13] drm/i915: Remove some unneeded checks from check_crtc_state Maarten Lankhorst
2015-07-16  9:24   ` Daniel Vetter
2015-07-16  9:38     ` Maarten Lankhorst
2015-07-16 15:01       ` Daniel Vetter
2015-07-16 14:59         ` Maarten Lankhorst
2015-07-16  8:59 ` [PATCH 10/13] drm/i915: Remove connectors_active from state checking Maarten Lankhorst
2015-07-16  8:59 ` [PATCH 11/13] drm/i915: Remove connectors_active from sanitization Maarten Lankhorst
2015-07-16  8:59 ` [PATCH 12/13] drm/i915: Remove connectors_active from intel_dp.c Maarten Lankhorst
2015-07-16  8:59 ` [PATCH 13/13] drm/i915: Remove connectors_active Maarten Lankhorst
2015-07-16  9:52 ` [PATCH 14/13] drm/i915: Only update mode related state if a modeset happened Maarten Lankhorst

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1437037166-9339-9-git-send-email-maarten.lankhorst@linux.intel.com \
    --to=maarten.lankhorst@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.