Skip to contentSkip to conversation

Possible regression in 3.17-rc2 in i915 driver

PATCH Superseded Tibor Billes 4 participants 16 messages Aug 31, 2014 – Sep 2, 2014

Subsystems (3)
lore
Share & tools
lore

Tibor Billes

author Reviewed-by Daniel Vetter
#0 lore raw

Hi!

I tried to upgrade my kernel from 3.16 to 3.17-rc2 and I found that my laptop was unable to boot. The boot process hangs after 2-3 seconds (according to timestamps of log messages). The last kernel log line I usually see is the discovery of my touchpad: "input: SynPS/2 Synaptics TouchPad as /devices/platform/i8042/serio2/input/input11".

I did a git bisect and it pointed me to the following commit:
commit 208bf9fdcd3575aa4a5d48b3e0295f7cdaf6fc44
Author: Ville Syrjälä <[email protected]>
Date:   Mon Aug 11 13:15:35 2014 +0300

    drm/i915: Fix locking for intel_enable_pipe_a()

    intel_enable_pipe_a() gets called with all the modeset locks already held (by drm_modeset_lock_all()), so trying to grab the same locks using another drm_modeset_acquire_ctx is going to fail miserably.
    Move most of the drm_modeset_acquire_ctx handling (init/drop/fini) out from intel_{get,release}_load_detect_pipe() into the callers (intel_{crt,tv}_detect()). Only the actual locking and backoff handling is left in intel_get_load_detect_pipe(). And in intel_enable_pipe_a() we just share the mode_config.acquire_ctx from drm_modeset_lock_all() which is already holding all the relevant locks.
    It's perfectly legal to lock the same ww_mutex multiple times using the same ww_acquire_ctx. drm_modeset_lock() will convert the returned -EALREADY into 0, so the caller doesn't need to do antyhing special.
    Fixes a hang on resume on my 830.


I tried booting with the above commit reverted on top of 3.17-rc2 and it booted successfully.

I also did a MagicSyrq-W (Display list of blocked (D state) tasks) after the boot process stopped (using plain 3.17-rc2, without reverting the above commit) and it showed that plymouthd was blocked with the following call trace (hand copied):
irq_exit
common_interrupt
schedule_preemt_disabled
__mutex_lock_slowpath
mutex_lock
drm_modeset_lock
drm_getconnector
drm_mode_getcrttc
drm_ioctl
...

This may have something to do with the hang or it may not, I don't know but is related to drm locking so I thought it was a good idea to mention it.
My laptop is an old Fujitsu-Siemens Amilo M1450g, running Linux Mint 16.
Let me know if I can help further debug this issue.

Tibor Billes

maintainer
#1 lore raw

+intel-gfx

Ville, Daniel, any thoughts before we queue a revert?

BR,
Jani.

Quoted 63 lines · Tibor Billes

Hi!

I tried to upgrade my kernel from 3.16 to 3.17-rc2 and I found that my laptop was unable to boot. The boot process hangs after 2-3 seconds (according to timestamps of log messages). The last kernel log line I usually see is the discovery of my touchpad: "input: SynPS/2 Synaptics TouchPad as /devices/platform/i8042/serio2/input/input11".

I did a git bisect and it pointed me to the following commit:
commit 208bf9fdcd3575aa4a5d48b3e0295f7cdaf6fc44
Author: Ville Syrjälä <[email protected]>
Date:   Mon Aug 11 13:15:35 2014 +0300

    drm/i915: Fix locking for intel_enable_pipe_a()

    intel_enable_pipe_a() gets called with all the modeset locks already held (by drm_modeset_lock_all()), so trying to grab the same locks using another drm_modeset_acquire_ctx is going to fail miserably.
    Move most of the drm_modeset_acquire_ctx handling (init/drop/fini) out from intel_{get,release}_load_detect_pipe() into the callers (intel_{crt,tv}_detect()). Only the actual locking and backoff handling is left in intel_get_load_detect_pipe(). And in intel_enable_pipe_a() we just share the mode_config.acquire_ctx from drm_modeset_lock_all() which is already holding all the relevant locks.
    It's perfectly legal to lock the same ww_mutex multiple times using the same ww_acquire_ctx. drm_modeset_lock() will convert the returned -EALREADY into 0, so the caller doesn't need to do antyhing special.
    Fixes a hang on resume on my 830.


I tried booting with the above commit reverted on top of 3.17-rc2 and it booted successfully.

I also did a MagicSyrq-W (Display list of blocked (D state) tasks) after the boot process stopped (using plain 3.17-rc2, without reverting the above commit) and it showed that plymouthd was blocked with the following call trace (hand copied):
irq_exit
common_interrupt
schedule_preemt_disabled
__mutex_lock_slowpath
mutex_lock
drm_modeset_lock
drm_getconnector
drm_mode_getcrttc
drm_ioctl
...

This may have something to do with the hang or it may not, I don't know but is related to drm locking so I thought it was a good idea to mention it.
My laptop is an old Fujitsu-Siemens Amilo M1450g, running Linux Mint 16.
Let me know if I can help further debug this issue.

Tibor Billes

Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH 1/1 drm/i915: Fix lock dropping in intel_tv_detect()

From: Ville Syrjälä <[email protected]>

When intel_tv_detect() fails to do load detection it would forget to drop the locks and clean up the acquire context. Fix it up.

This is a regression from:
commit 208bf9fdcd3575aa4a5d48b3e0295f7cdaf6fc44
Author: Ville Syrjälä <[email protected]>
Date: Mon Aug 11 13:15:35 2014 +0300

drm/i915: Fix locking for intel_enable_pipe_a()

---
 drivers/gpu/drm/i915/intel_tv.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_tv.c +9 -6
index 32186a6..abbf0ea 100644
@@ -1311,7 +1311,8 @@ intel_tv_detect(struct drm_connector *connector, bool force)
 {
 	struct drm_display_mode mode;
 	struct intel_tv *intel_tv = intel_attached_tv(connector);
-	int type;
+	enum drm_connector_status status = connector->status;
+	int type = -1;
 
 	DRM_DEBUG_KMS("[CONNECTOR:%d:%s] force=%d\n",
 		      connector->base.id, connector->name,
@@ -1328,21 +1329,23 @@ intel_tv_detect(struct drm_connector *connector, bool force)
 		if (intel_get_load_detect_pipe(connector, &mode, &tmp, &ctx)) {
 			type = intel_tv_detect_type(intel_tv, connector);
 			intel_release_load_detect_pipe(connector, &tmp);
+			status = type < 0 ?
+				connector_status_disconnected :
+				connector_status_connected;
 		} else
-			return connector_status_unknown;
+			status = connector_status_unknown;
 
 		drm_modeset_drop_locks(&ctx);
 		drm_modeset_acquire_fini(&ctx);
-	} else
-		return connector->status;
+	}
 
 	if (type < 0)
-		return connector_status_disconnected;
+		return status;
 
 	intel_tv->type = type;
 	intel_tv_find_better_format(connector);
 
-	return connector_status_connected;
+	return status;
 }
 
 static const struct input_res {
Signature · 6 lines
1.8.5.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

Re: [Intel-gfx] [PATCH] drm/i915: Fix lock dropping in intel_tv_detect()

Quoted 48 lines · On Mon, Sep 01, 2014 at 11:09:46AM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

When intel_tv_detect() fails to do load detection it would forget to drop the locks and clean up the acquire context. Fix it up.

This is a regression from:
commit 208bf9fdcd3575aa4a5d48b3e0295f7cdaf6fc44
Author: Ville Syrjälä <[email protected]>
Date: Mon Aug 11 13:15:35 2014 +0300

drm/i915: Fix locking for intel_enable_pipe_a()

---
 drivers/gpu/drm/i915/intel_tv.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_tv.c +7 -4
index 32186a6..abbf0ea 100644
@@ -1311,7 +1311,8 @@ intel_tv_detect(struct drm_connector *connector, bool force)
 {
 	struct drm_display_mode mode;
 	struct intel_tv *intel_tv = intel_attached_tv(connector);
-	int type;
+	enum drm_connector_status status = connector->status;
+	int type = -1;
 
 	DRM_DEBUG_KMS("[CONNECTOR:%d:%s] force=%d\n",
 		      connector->base.id, connector->name,
@@ -1328,21 +1329,23 @@ intel_tv_detect(struct drm_connector *connector, bool force)
 		if (intel_get_load_detect_pipe(connector, &mode, &tmp, &ctx)) {
 			type = intel_tv_detect_type(intel_tv, connector);
 			intel_release_load_detect_pipe(connector, &tmp);
+			status = type < 0 ?
+				connector_status_disconnected :
+				connector_status_connected;
 		} else
-			return connector_status_unknown;
+			status = connector_status_unknown;
 
 		drm_modeset_drop_locks(&ctx);
 		drm_modeset_acquire_fini(&ctx);
-	} else
-		return connector->status;
+	}

drivers/gpu/drm/i915/intel_tv.c intel_tv_detect(struct drm_connector *connector, bool force) · line 1348

Quoted 10 lines
drivers/gpu/drm/i915/intel_tv.c +2 -2
 
 	if (type < 0)
-		return connector_status_disconnected;
+		return status;
 
 	intel_tv->type = type;
 	intel_tv_find_better_format(connector);
 
-	return connector_status_connected;
+	return status;

Hmm, this makes the code unclear. if type != -1, status should always be connected.

I think:

if (status != connector_status_connected)
return status;

if (WARN_ON(type < 0))
return connector_status_disconnected;

intel_tv->type = type;
find_better_format();
return connector_status_connected;

And leave type unset to encourage gcc.

drivers/gpu/drm/i915/intel_tv.c +9 -5
index 32186a6..a109b7b 100644
@@ -1311,6 +1311,7 @@ intel_tv_detect(struct drm_connector *connector, bool force)
 {
        struct drm_display_mode mode;
        struct intel_tv *intel_tv = intel_attached_tv(connector);
+       enum drm_connector_status status = connector->status;
        int type;
 
        DRM_DEBUG_KMS("[CONNECTOR:%d:%s] force=%d\n",
@@ -1327,17 +1328,20 @@ intel_tv_detect(struct drm_connector *connector, bool force)
 
                if (intel_get_load_detect_pipe(connector, &mode, &tmp, &ctx)) {
                        type = intel_tv_detect_type(intel_tv, connector);
+                       status = type < 0 ?
+                               connector_status_disconnected :
+                               connector_status_connected;
+
                        intel_release_load_detect_pipe(connector, &tmp);
                } else
-                       return connector_status_unknown;
+                       status = connector_status_unknown;
 
                drm_modeset_drop_locks(&ctx);
                drm_modeset_acquire_fini(&ctx);
-       } else
-               return connector->status;
+       }
 
-       if (type < 0)
-               return connector_status_disconnected;
+       if (status != connector_status_connected)
+               return status;
 
        intel_tv->type = type;
        intel_tv_find_better_format(connector);
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#4 lore raw

Re: [Intel-gfx] [PATCH] drm/i915: Fix lock dropping in intel_tv_detect()

Quoted 107 lines · Chris Wilson
Quoted 48 lines · On Mon, Sep 01, 2014 at 11:09:46AM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

When intel_tv_detect() fails to do load detection it would forget to drop the locks and clean up the acquire context. Fix it up.

This is a regression from:
commit 208bf9fdcd3575aa4a5d48b3e0295f7cdaf6fc44
Author: Ville Syrjälä <[email protected]>
Date: Mon Aug 11 13:15:35 2014 +0300

drm/i915: Fix locking for intel_enable_pipe_a()

---
 drivers/gpu/drm/i915/intel_tv.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_tv.c +7 -4
index 32186a6..abbf0ea 100644
@@ -1311,7 +1311,8 @@ intel_tv_detect(struct drm_connector *connector, bool force)
 {
 	struct drm_display_mode mode;
 	struct intel_tv *intel_tv = intel_attached_tv(connector);
-	int type;
+	enum drm_connector_status status = connector->status;
+	int type = -1;
 
 	DRM_DEBUG_KMS("[CONNECTOR:%d:%s] force=%d\n",
 		      connector->base.id, connector->name,
@@ -1328,21 +1329,23 @@ intel_tv_detect(struct drm_connector *connector, bool force)
 		if (intel_get_load_detect_pipe(connector, &mode, &tmp, &ctx)) {
 			type = intel_tv_detect_type(intel_tv, connector);
 			intel_release_load_detect_pipe(connector, &tmp);
+			status = type < 0 ?
+				connector_status_disconnected :
+				connector_status_connected;
 		} else
-			return connector_status_unknown;
+			status = connector_status_unknown;
 
 		drm_modeset_drop_locks(&ctx);
 		drm_modeset_acquire_fini(&ctx);
-	} else
-		return connector->status;
+	}

drivers/gpu/drm/i915/intel_tv.c intel_tv_detect(struct drm_connector *connector, bool force) · line 1348

Quoted 10 lines
drivers/gpu/drm/i915/intel_tv.c +2 -2
 
 	if (type < 0)
-		return connector_status_disconnected;
+		return status;
 
 	intel_tv->type = type;
 	intel_tv_find_better_format(connector);
 
-	return connector_status_connected;
+	return status;

Hmm, this makes the code unclear. if type != -1, status should always be connected.

I think:

if (status != connector_status_connected)
return status;

if (WARN_ON(type < 0))
return connector_status_disconnected;

intel_tv->type = type;
find_better_format();
return connector_status_connected;

And leave type unset to encourage gcc.

drivers/gpu/drm/i915/intel_tv.c +6 -2
index 32186a6..a109b7b 100644
@@ -1311,6 +1311,7 @@ intel_tv_detect(struct drm_connector *connector, bool force)
 {
        struct drm_display_mode mode;
        struct intel_tv *intel_tv = intel_attached_tv(connector);
+       enum drm_connector_status status = connector->status;
        int type;
 
        DRM_DEBUG_KMS("[CONNECTOR:%d:%s] force=%d\n",
@@ -1327,17 +1328,20 @@ intel_tv_detect(struct drm_connector *connector, bool force)
 
                if (intel_get_load_detect_pipe(connector, &mode, &tmp, &ctx)) {
                        type = intel_tv_detect_type(intel_tv, connector);
+                       status = type < 0 ?
+                               connector_status_disconnected :
+                               connector_status_connected;
+
                        intel_release_load_detect_pipe(connector, &tmp);
                } else
-                       return connector_status_unknown;
+                       status = connector_status_unknown;
 
                drm_modeset_drop_locks(&ctx);
                drm_modeset_acquire_fini(&ctx);
-       } else

drivers/gpu/drm/i915/intel_tv.c intel_tv_detect(struct drm_connector *connector, bool force) · line 1347

Quoted 10 lines
drivers/gpu/drm/i915/intel_tv.c +3 -3
-               return connector->status;
+       }
 
-       if (type < 0)
-               return connector_status_disconnected;
+       if (status != connector_status_connected)
+               return status;
 
        intel_tv->type = type;
        intel_tv_find_better_format(connector);

With this approach we're going to have to keep the !force else branch to avoid populating intel_tv->type with stack garbage. But I suppose the resulting code might still be a bit clearer.

Signature · 2 lines
Ville Syrjälä
Intel OTC
#5 lore raw

Re: [Intel-gfx] [PATCH] drm/i915: Fix lock dropping in intel_tv_detect()

Quoted 37 lines · Ville Syrjälä
Quoted 36 lines · Chris Wilson
drivers/gpu/drm/i915/intel_tv.c +9 -5
index 32186a6..a109b7b 100644
@@ -1311,6 +1311,7 @@ intel_tv_detect(struct drm_connector *connector, bool force)
 {
        struct drm_display_mode mode;
        struct intel_tv *intel_tv = intel_attached_tv(connector);
+       enum drm_connector_status status = connector->status;
        int type;
 
        DRM_DEBUG_KMS("[CONNECTOR:%d:%s] force=%d\n",
@@ -1327,17 +1328,20 @@ intel_tv_detect(struct drm_connector *connector, bool force)
 
                if (intel_get_load_detect_pipe(connector, &mode, &tmp, &ctx)) {
                        type = intel_tv_detect_type(intel_tv, connector);
+                       status = type < 0 ?
+                               connector_status_disconnected :
+                               connector_status_connected;
+
                        intel_release_load_detect_pipe(connector, &tmp);
                } else
-                       return connector_status_unknown;
+                       status = connector_status_unknown;
 
                drm_modeset_drop_locks(&ctx);
                drm_modeset_acquire_fini(&ctx);
-       } else
-               return connector->status;
+       }
 
-       if (type < 0)
-               return connector_status_disconnected;
+       if (status != connector_status_connected)
+               return status;
 
Quoted 6 lines

drivers/gpu/drm/i915/intel_tv.c intel_tv_detect(struct drm_connector *connector, bool force) · line 1347

Quoted 2 lines
drivers/gpu/drm/i915/intel_tv.c +0 -0
        intel_tv->type = type;
        intel_tv_find_better_format(connector);

With this approach we're going to have to keep the !force else branch to avoid populating intel_tv->type with stack garbage. But I suppose the resulting code might still be a bit clearer.

Or just set intel_tv->type directly inside

status = intel_tv_detect_type() ?

Hmm. Indeed, we should not be touching them at all for !forced, as type is only set for forced, and so we can similarly ignore hpd of better formats.

drivers/gpu/drm/i915/intel_tv.c +24 -30
index 32186a656816..e80eac5e5239 100644
@@ -1169,7 +1169,7 @@ static const struct drm_display_mode reported_modes[] = {
  * \return true if TV is connected.
  * \return false if TV is disconnected.
  */
-static int
+static enum drm_connector_status
 intel_tv_detect_type(struct intel_tv *intel_tv,
                      struct drm_connector *connector)
 {
@@ -1178,10 +1178,10 @@ intel_tv_detect_type(struct intel_tv *intel_tv,
        struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
        struct drm_device *dev = encoder->dev;
        struct drm_i915_private *dev_priv = dev->dev_private;
+       enum drm_connector_status status;
        unsigned long irqflags;
        u32 tv_ctl, save_tv_ctl;
        u32 tv_dac, save_tv_dac;
-       int type;
 
        /* Disable TV interrupts around load detect or we'll recurse */
        if (connector->polled & DRM_CONNECTOR_POLL_HPD) {
@@ -1229,7 +1229,6 @@ intel_tv_detect_type(struct intel_tv *intel_tv,
        intel_wait_for_vblank(intel_tv->base.base.dev,
                              to_intel_crtc(intel_tv->base.base.crtc)->pipe);
 
-       type = -1;
        tv_dac = I915_READ(TV_DAC);
        DRM_DEBUG_KMS("TV detected: %x, %x\n", tv_ctl, tv_dac);
        /*
@@ -1238,18 +1237,19 @@ intel_tv_detect_type(struct intel_tv *intel_tv,
         *  1 0 X svideo
         *  0 0 0 Component
         */
+       status = connector_status_connected;
        if ((tv_dac & TVDAC_SENSE_MASK) == (TVDAC_B_SENSE | TVDAC_C_SENSE)) {
                DRM_DEBUG_KMS("Detected Composite TV connection\n");
-               type = DRM_MODE_CONNECTOR_Composite;
+               intel_tv->type = DRM_MODE_CONNECTOR_Composite;
        } else if ((tv_dac & (TVDAC_A_SENSE|TVDAC_B_SENSE)) == TVDAC_A_SENSE) {
                DRM_DEBUG_KMS("Detected S-Video TV connection\n");
-               type = DRM_MODE_CONNECTOR_SVIDEO;
+               intel_tv->type = DRM_MODE_CONNECTOR_SVIDEO;
        } else if ((tv_dac & TVDAC_SENSE_MASK) == 0) {
                DRM_DEBUG_KMS("Detected Component TV connection\n");
-               type = DRM_MODE_CONNECTOR_Component;
+               intel_tv->type = DRM_MODE_CONNECTOR_Component;
        } else {
                DRM_DEBUG_KMS("Unrecognised TV connection\n");
-               type = -1;
+               status = connector_status_disconnected;
        }
 
        I915_WRITE(TV_DAC, save_tv_dac & ~TVDAC_STATE_CHG_EN);
@@ -1269,7 +1269,7 @@ intel_tv_detect_type(struct intel_tv *intel_tv,
                spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
        }
 
-       return type;
+       return status;
 }
 
 /*
@@ -1309,39 +1309,33 @@ static void intel_tv_find_better_format(struct drm_connector *connector)
 static enum drm_connector_status
 intel_tv_detect(struct drm_connector *connector, bool force)
 {
-       struct drm_display_mode mode;
        struct intel_tv *intel_tv = intel_attached_tv(connector);
-       int type;
+       struct drm_display_mode mode = reported_modes[0];
+       struct intel_load_detect_pipe tmp;
+       struct drm_modeset_acquire_ctx ctx;
+       enum drm_connector_status status;
 
        DRM_DEBUG_KMS("[CONNECTOR:%d:%s] force=%d\n",
                      connector->base.id, connector->name,
                      force);
+       if (!force)
+               return connector->status;
 
-       mode = reported_modes[0];
-
-       if (force) {
-               struct intel_load_detect_pipe tmp;
-               struct drm_modeset_acquire_ctx ctx;
-
-               drm_modeset_acquire_init(&ctx, 0);
-
-               if (intel_get_load_detect_pipe(connector, &mode, &tmp, &ctx)) {
-                       type = intel_tv_detect_type(intel_tv, connector);
-                       intel_release_load_detect_pipe(connector, &tmp);
-               } else
-                       return connector_status_unknown;
+       drm_modeset_acquire_init(&ctx, 0);
 
-               drm_modeset_drop_locks(&ctx);
-               drm_modeset_acquire_fini(&ctx);
+       if (intel_get_load_detect_pipe(connector, &mode, &tmp, &ctx)) {
+               status = intel_tv_detect_type(intel_tv, connector);
+               intel_release_load_detect_pipe(connector, &tmp);
        } else
-               return connector->status;
+               status = connector_status_unknown;
 
-       if (type < 0)
-               return connector_status_disconnected;
+       drm_modeset_drop_locks(&ctx);
+       drm_modeset_acquire_fini(&ctx);
 
-       intel_tv->type = type;
-       intel_tv_find_better_format(connector);
+       if (status != connector
+               return status;
 
+       intel_tv_find_better_format(connector);
        return connector_status_connected;
 }
 
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#6 lore raw

PATCH v2 1/1 drm/i915: Fix lock dropping in intel_tv_detect()

In reply to Chris Wilson

From: Ville Syrjälä <[email protected]>

When intel_tv_detect() fails to do load detection it would forget to drop the locks and clean up the acquire context. Fix it up.

This is a regression from:
commit 208bf9fdcd3575aa4a5d48b3e0295f7cdaf6fc44
Author: Ville Syrjälä <[email protected]>
Date: Mon Aug 11 13:15:35 2014 +0300

drm/i915: Fix locking for intel_enable_pipe_a()

v2: Make the code more readable (Chris)

---
 drivers/gpu/drm/i915/intel_tv.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_tv.c +9 -2
index 32186a6..c6b00f20 100644
@@ -1311,6 +1311,7 @@ intel_tv_detect(struct drm_connector *connector, bool force)
 {
 	struct drm_display_mode mode;
 	struct intel_tv *intel_tv = intel_attached_tv(connector);
+	enum drm_connector_status status;
 	int type;
 
 	DRM_DEBUG_KMS("[CONNECTOR:%d:%s] force=%d\n",
@@ -1328,15 +1329,21 @@ intel_tv_detect(struct drm_connector *connector, bool force)
 		if (intel_get_load_detect_pipe(connector, &mode, &tmp, &ctx)) {
 			type = intel_tv_detect_type(intel_tv, connector);
 			intel_release_load_detect_pipe(connector, &tmp);
+			status = type < 0 ?
+				connector_status_disconnected :
+				connector_status_connected;
 		} else
-			return connector_status_unknown;
+			status = connector_status_unknown;
 
 		drm_modeset_drop_locks(&ctx);
 		drm_modeset_acquire_fini(&ctx);
 	} else
 		return connector->status;
 
-	if (type < 0)
+	if (status != connector_status_connected)
+		return status;
+
+	if (WARN_ON(type < 0))
 		return connector_status_disconnected;
 
 	intel_tv->type = type;
Signature · 6 lines
1.8.5.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v2 1/1
#7 lore raw

Re: [PATCH v2] drm/i915: Fix lock dropping in intel_tv_detect()

Quoted 10 lines · On Mon, Sep 01, 2014 at 01:07:40PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

When intel_tv_detect() fails to do load detection it would forget to drop the locks and clean up the acquire context. Fix it up.

This is a regression from:
commit 208bf9fdcd3575aa4a5d48b3e0295f7cdaf6fc44
Author: Ville Syrjälä <[email protected]>
Date: Mon Aug 11 13:15:35 2014 +0300

Quoted 6 lines

drm/i915: Fix locking for intel_enable_pipe_a()

v2: Make the code more readable (Chris)

Hmm, if we use WARN_ON() you should init type.

Otherwise,

-Chrsi

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#8 lore raw

Re: [PATCH v2] drm/i915: Fix lock dropping in intel_tv_detect()

Quoted 11 lines · Chris Wilson
Quoted 10 lines · On Mon, Sep 01, 2014 at 01:07:40PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

When intel_tv_detect() fails to do load detection it would forget to drop the locks and clean up the acquire context. Fix it up.

This is a regression from:
commit 208bf9fdcd3575aa4a5d48b3e0295f7cdaf6fc44
Author: Ville Syrjälä <[email protected]>
Date: Mon Aug 11 13:15:35 2014 +0300

Quoted 8 lines
Quoted 6 lines

drm/i915: Fix locking for intel_enable_pipe_a()

v2: Make the code more readable (Chris)

Hmm, if we use WARN_ON() you should init type.

type is always set in the branch that sets status=connected.

Quoted 7 lines

Otherwise,

-Chrsi

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Signature · 2 lines
Ville Syrjälä
Intel OTC
#9 lore raw

Re: [PATCH v2] drm/i915: Fix lock dropping in intel_tv_detect()

Quoted 14 lines · Ville Syrjälä
Quoted 13 lines · Chris Wilson
Quoted 12 lines · On Mon, Sep 01, 2014 at 01:07:40PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

When intel_tv_detect() fails to do load detection it would forget to drop the locks and clean up the acquire context. Fix it up.

This is a regression from:
commit 208bf9fdcd3575aa4a5d48b3e0295f7cdaf6fc44
Author: Ville Syrjälä <[email protected]>
Date: Mon Aug 11 13:15:35 2014 +0300

drm/i915: Fix locking for intel_enable_pipe_a()

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

v2: Make the code more readable (Chris)

Hmm, if we use WARN_ON() you should init type.

type is always set in the branch that sets status=connected.

Back to thinking about readability and making sure that the WARN_ON never happens with just a glance. Otherwise, the WARN_ON would be better as WARN_ON(unsigned)type >= last_tv_type); Or something. Anway, take your pick and slap my r-b on it. :)
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
maintainer
#10 lore raw

Re: [PATCH v2] drm/i915: Fix lock dropping in intel_tv_detect()

Quoted 20 lines · Chris Wilson
Quoted 19 lines · Ville Syrjälä
Quoted 18 lines · Chris Wilson
Quoted 16 lines · On Mon, Sep 01, 2014 at 01:07:40PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

When intel_tv_detect() fails to do load detection it would forget to drop the locks and clean up the acquire context. Fix it up.

This is a regression from:
commit 208bf9fdcd3575aa4a5d48b3e0295f7cdaf6fc44
Author: Ville Syrjälä <[email protected]>
Date: Mon Aug 11 13:15:35 2014 +0300

drm/i915: Fix locking for intel_enable_pipe_a()

v2: Make the code more readable (Chris)

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Hmm, if we use WARN_ON() you should init type.

type is always set in the branch that sets status=connected.

Back to thinking about readability and making sure that the WARN_ON never happens with just a glance. Otherwise, the WARN_ON would be better as WARN_ON(unsigned)type >= last_tv_type); Or something. Anway, take your pick and slap my r-b on it. :)

Ville?

J.

Quoted 4 lines

-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#11 lore raw

Re: [PATCH v2] drm/i915: Fix lock dropping in intel_tv_detect()

Quoted 23 lines · Jani Nikula
Quoted 22 lines · Chris Wilson
Quoted 21 lines · Ville Syrjälä
Quoted 19 lines · Chris Wilson
Quoted 10 lines · On Mon, Sep 01, 2014 at 01:07:40PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

When intel_tv_detect() fails to do load detection it would forget to drop the locks and clean up the acquire context. Fix it up.

This is a regression from:
commit 208bf9fdcd3575aa4a5d48b3e0295f7cdaf6fc44
Author: Ville Syrjälä <[email protected]>
Date: Mon Aug 11 13:15:35 2014 +0300

Quoted 6 lines

drm/i915: Fix locking for intel_enable_pipe_a()

v2: Make the code more readable (Chris)

Hmm, if we use WARN_ON() you should init type.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

type is always set in the branch that sets status=connected.

Back to thinking about readability and making sure that the WARN_ON never happens with just a glance. Otherwise, the WARN_ON would be better as WARN_ON(unsigned)type >= last_tv_type); Or something. Anway, take your pick and slap my r-b on it. :)

Ville?

I don't know anymore. Just kill the WARN_ON() if it makes things confusing?

Signature · 2 lines
Ville Syrjälä
Intel OTC
#12 lore raw

Re: [PATCH v2] drm/i915: Fix lock dropping in intel_tv_detect()

Quoted 31 lines · Ville Syrjälä
Quoted 30 lines · Jani Nikula
Quoted 28 lines · Chris Wilson
Quoted 14 lines · Ville Syrjälä
Quoted 13 lines · Chris Wilson
Quoted 12 lines · On Mon, Sep 01, 2014 at 01:07:40PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

When intel_tv_detect() fails to do load detection it would forget to drop the locks and clean up the acquire context. Fix it up.

This is a regression from:
commit 208bf9fdcd3575aa4a5d48b3e0295f7cdaf6fc44
Author: Ville Syrjälä <[email protected]>
Date: Mon Aug 11 13:15:35 2014 +0300

drm/i915: Fix locking for intel_enable_pipe_a()

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

v2: Make the code more readable (Chris)

Hmm, if we use WARN_ON() you should init type.

type is always set in the branch that sets status=connected.

Back to thinking about readability and making sure that the WARN_ON never happens with just a glance. Otherwise, the WARN_ON would be better as WARN_ON(unsigned)type >= last_tv_type); Or something. Anway, take your pick and slap my r-b on it. :)

Quoted 4 lines
Quoted 1 line

Ville?

I don't know anymore. Just kill the WARN_ON() if it makes things confusing?

Just drop the WARN_ON. I prefer the if() using the status rather than type, as that seems more idiomatic (when looking at our other detection routines).
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#13 lore raw

PATCH v3 1/1 drm/i915: Fix lock dropping in intel_tv_detect()

From: Ville Syrjälä <[email protected]>

When intel_tv_detect() fails to do load detection it would forget to drop the locks and clean up the acquire context. Fix it up.

This is a regression from:
commit 208bf9fdcd3575aa4a5d48b3e0295f7cdaf6fc44
Author: Ville Syrjälä <[email protected]>
Date: Mon Aug 11 13:15:35 2014 +0300

drm/i915: Fix locking for intel_enable_pipe_a()

v2: Make the code more readable (Chris)
v3: Drop WARN_ON(type < 0) (Chris)

---
 drivers/gpu/drm/i915/intel_tv.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_tv.c +7 -3
index 32186a6..c69d3ce 100644
@@ -1311,6 +1311,7 @@ intel_tv_detect(struct drm_connector *connector, bool force)
 {
 	struct drm_display_mode mode;
 	struct intel_tv *intel_tv = intel_attached_tv(connector);
+	enum drm_connector_status status;
 	int type;
 
 	DRM_DEBUG_KMS("[CONNECTOR:%d:%s] force=%d\n",
@@ -1328,16 +1329,19 @@ intel_tv_detect(struct drm_connector *connector, bool force)
 		if (intel_get_load_detect_pipe(connector, &mode, &tmp, &ctx)) {
 			type = intel_tv_detect_type(intel_tv, connector);
 			intel_release_load_detect_pipe(connector, &tmp);
+			status = type < 0 ?
+				connector_status_disconnected :
+				connector_status_connected;
 		} else
-			return connector_status_unknown;
+			status = connector_status_unknown;
 
 		drm_modeset_drop_locks(&ctx);
 		drm_modeset_acquire_fini(&ctx);
 	} else
 		return connector->status;
 
-	if (type < 0)
-		return connector_status_disconnected;
+	if (status != connector_status_connected)
+		return status;
 
 	intel_tv->type = type;
 	intel_tv_find_better_format(connector);
Signature · 1 line
1.8.5.5
maintainer
#14 lore raw

Re: [PATCH v3] drm/i915: Fix lock dropping in intel_tv_detect()

Quoted 15 lines · On Tue, 02 Sep 2014, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

When intel_tv_detect() fails to do load detection it would forget to drop the locks and clean up the acquire context. Fix it up.

This is a regression from:
commit 208bf9fdcd3575aa4a5d48b3e0295f7cdaf6fc44
Author: Ville Syrjälä <[email protected]>
Date: Mon Aug 11 13:15:35 2014 +0300

drm/i915: Fix locking for intel_enable_pipe_a()

v2: Make the code more readable (Chris)
v3: Drop WARN_ON(type < 0) (Chris)

Quoted 6 lines

Pushed to drm-intel-fixes, thanks for the patch, review, and testing.

BR,
Jani.

Quoted 42 lines
---
 drivers/gpu/drm/i915/intel_tv.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_tv.c +7 -3
index 32186a6..c69d3ce 100644
@@ -1311,6 +1311,7 @@ intel_tv_detect(struct drm_connector *connector, bool force)
 {
 	struct drm_display_mode mode;
 	struct intel_tv *intel_tv = intel_attached_tv(connector);
+	enum drm_connector_status status;
 	int type;
 
 	DRM_DEBUG_KMS("[CONNECTOR:%d:%s] force=%d\n",
@@ -1328,16 +1329,19 @@ intel_tv_detect(struct drm_connector *connector, bool force)
 		if (intel_get_load_detect_pipe(connector, &mode, &tmp, &ctx)) {
 			type = intel_tv_detect_type(intel_tv, connector);
 			intel_release_load_detect_pipe(connector, &tmp);
+			status = type < 0 ?
+				connector_status_disconnected :
+				connector_status_connected;
 		} else
-			return connector_status_unknown;
+			status = connector_status_unknown;
 
 		drm_modeset_drop_locks(&ctx);
 		drm_modeset_acquire_fini(&ctx);
 	} else
 		return connector->status;
 
-	if (type < 0)
-		return connector_status_disconnected;
+	if (status != connector_status_connected)
+		return status;
 
 	intel_tv->type = type;
 	intel_tv_find_better_format(connector);
Signature · 1 line
1.8.5.5
Signature · 1 line
Jani Nikula, Intel Open Source Technology Center
author Tested-by on v2 1/1
#15 lore raw

Re: [PATCH v2] drm/i915: Fix lock dropping in intel_tv_detect()

In reply to [email protected]

Hi!

From: [email protected] Sent: Monday, September 01, 2014 at 12:07 PM

Quoted 8 lines

When intel_tv_detect() fails to do load detection it would forget to drop the locks and clean up the acquire context. Fix it up.

This is a regression from:
commit 208bf9fdcd3575aa4a5d48b3e0295f7cdaf6fc44
Author: Ville Syrjälä <[email protected]>
Date: Mon Aug 11 13:15:35 2014 +0300

Quoted 6 lines

drm/i915: Fix locking for intel_enable_pipe_a()

v2: Make the code more readable (Chris)

I tested the posted patch, applying it on top of 3.17-rc2 did solve my boot problems. Just to make sure I also tried a clean 3.17-rc3, which was unable to boot. With this patch applied, it again booted successfully.

I'm not quite sure how tags work, but you may add my following tags:

Thank you all for the quick responses and the patch, nice work! :)

Tibor