[PATCH] drm/i915: Handle error paths during watermark sanitization properly (v3)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



sanitize_watermarks() does not properly handle errors returned by
drm_atomic_helper_duplicate_state().  Make failures drop locks before
returning.  We also change the lock of connection_mutex to a
drm_modeset_lock_all_ctx() to make sure any EDEADLK's are handled
earlier.

v2: Change call to lock connetion_mutex with a call to
    drm_modeset_lock_all_ctx().  This ensures that any lock contention
    is handled earlier and drm_atomic_helper_duplicate_state() won't
    return EDEADLK. (Maarten)

v3: Drop locks properly in more error paths. (Maarten)

Cc: Daniel Vetter <daniel@xxxxxxxx>
Cc: Maarten Lankhorst <maarten.lankhorst@xxxxxxxxxxxxxxx>
Signed-off-by: Matt Roper <matthew.d.roper@xxxxxxxxx>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@xxxxxxxxxxxxxxx>
---
 drivers/gpu/drm/i915/intel_display.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index abfb5ba..07ca19b 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -15353,17 +15353,17 @@ static void sanitize_watermarks(struct drm_device *dev)
 	 */
 	drm_modeset_acquire_init(&ctx, 0);
 retry:
-	ret = drm_modeset_lock(&dev->mode_config.connection_mutex, &ctx);
+	ret = drm_modeset_lock_all_ctx(dev, &ctx);
 	if (ret == -EDEADLK) {
 		drm_modeset_backoff(&ctx);
 		goto retry;
 	} else if (WARN_ON(ret)) {
-		return;
+		goto fail;
 	}
 
 	state = drm_atomic_helper_duplicate_state(dev, &ctx);
 	if (WARN_ON(IS_ERR(state)))
-		return;
+		goto fail;
 
 	/*
 	 * Hardware readout is the only time we don't want to calculate
@@ -15386,7 +15386,7 @@ retry:
 		 * BIOS-programmed watermarks untouched and hope for the best.
 		 */
 		WARN(true, "Could not determine valid watermarks for inherited state\n");
-		return;
+		goto fail;
 	}
 
 	/* Write calculated watermark values back */
@@ -15399,6 +15399,7 @@ retry:
 	}
 
 	drm_atomic_state_free(state);
+fail:
 	drm_modeset_drop_locks(&ctx);
 	drm_modeset_acquire_fini(&ctx);
 }
-- 
2.1.4

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




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux