All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel.vetter@ffwll.ch>
To: DRI Development <dri-devel@lists.freedesktop.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	Daniel Vetter <daniel.vetter@intel.com>
Subject: [PATCH 14/19] drm: Remove drm_modeset_(un)lock_crtc
Date: Wed, 22 Mar 2017 22:50:53 +0100	[thread overview]
Message-ID: <20170322215058.8671-15-daniel.vetter@ffwll.ch> (raw)
In-Reply-To: <20170322215058.8671-1-daniel.vetter@ffwll.ch>

The last user, the cursor ioctl, can just open-code this too. We
simply have to move the acquire ctx dance from the universal function
up into the top-level ioctl handler.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/drm_crtc_internal.h |  3 --
 drivers/gpu/drm/drm_modeset_lock.c  | 67 -------------------------------------
 drivers/gpu/drm/drm_plane.c         | 49 +++++++++++++--------------
 include/drm/drm_modeset_lock.h      |  1 -
 4 files changed, 24 insertions(+), 96 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h
index de1047530e07..8c04275cf226 100644
--- a/drivers/gpu/drm/drm_crtc_internal.h
+++ b/drivers/gpu/drm/drm_crtc_internal.h
@@ -61,9 +61,6 @@ int drm_mode_getresources(struct drm_device *dev,
 			  void *data, struct drm_file *file_priv);
 
 
-/* drm_modeset_lock.c */
-void drm_modeset_lock_crtc(struct drm_crtc *crtc,
-			   struct drm_plane *plane);
 /* drm_dumb_buffers.c */
 /* IOCTLs */
 int drm_mode_create_dumb_ioctl(struct drm_device *dev,
diff --git a/drivers/gpu/drm/drm_modeset_lock.c b/drivers/gpu/drm/drm_modeset_lock.c
index c94eff9d7544..c3ca6b859236 100644
--- a/drivers/gpu/drm/drm_modeset_lock.c
+++ b/drivers/gpu/drm/drm_modeset_lock.c
@@ -148,51 +148,6 @@ void drm_modeset_unlock_all(struct drm_device *dev)
 }
 EXPORT_SYMBOL(drm_modeset_unlock_all);
 
-void drm_modeset_lock_crtc(struct drm_crtc *crtc,
-			   struct drm_plane *plane)
-{
-	struct drm_modeset_acquire_ctx *ctx;
-	int ret;
-
-	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
-	if (WARN_ON(!ctx))
-		return;
-
-	drm_modeset_acquire_init(ctx, 0);
-
-retry:
-	ret = drm_modeset_lock(&crtc->mutex, ctx);
-	if (ret)
-		goto fail;
-
-	if (plane) {
-		ret = drm_modeset_lock(&plane->mutex, ctx);
-		if (ret)
-			goto fail;
-
-		if (plane->crtc) {
-			ret = drm_modeset_lock(&plane->crtc->mutex, ctx);
-			if (ret)
-				goto fail;
-		}
-	}
-
-	WARN_ON(crtc->acquire_ctx);
-
-	/* now we hold the locks, so now that it is safe, stash the
-	 * ctx for drm_modeset_unlock_crtc():
-	 */
-	crtc->acquire_ctx = ctx;
-
-	return;
-
-fail:
-	if (ret == -EDEADLK) {
-		drm_modeset_backoff(ctx);
-		goto retry;
-	}
-}
-
 /**
  * drm_modeset_legacy_acquire_ctx - find acquire ctx for legacy ioctls
  * @crtc: drm crtc
@@ -215,28 +170,6 @@ drm_modeset_legacy_acquire_ctx(struct drm_crtc *crtc)
 EXPORT_SYMBOL(drm_modeset_legacy_acquire_ctx);
 
 /**
- * drm_modeset_unlock_crtc - drop crtc lock
- * @crtc: drm crtc
- *
- * This drops the crtc lock acquire with drm_modeset_lock_crtc() and all other
- * locks acquired through the hidden context.
- */
-void drm_modeset_unlock_crtc(struct drm_crtc *crtc)
-{
-	struct drm_modeset_acquire_ctx *ctx = crtc->acquire_ctx;
-
-	if (WARN_ON(!ctx))
-		return;
-
-	crtc->acquire_ctx = NULL;
-	drm_modeset_drop_locks(ctx);
-	drm_modeset_acquire_fini(ctx);
-
-	kfree(ctx);
-}
-EXPORT_SYMBOL(drm_modeset_unlock_crtc);
-
-/**
  * drm_warn_on_modeset_not_all_locked - check that all modeset locks are locked
  * @dev: device
  *
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index ec3e2e757800..ec62221d64a9 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -620,7 +620,8 @@ int drm_mode_setplane(struct drm_device *dev, void *data,
 
 static int drm_mode_cursor_universal(struct drm_crtc *crtc,
 				     struct drm_mode_cursor2 *req,
-				     struct drm_file *file_priv)
+				     struct drm_file *file_priv,
+				     struct drm_modeset_acquire_ctx *ctx)
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_framebuffer *fb = NULL;
@@ -634,21 +635,11 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc,
 	int32_t crtc_x, crtc_y;
 	uint32_t crtc_w = 0, crtc_h = 0;
 	uint32_t src_w = 0, src_h = 0;
-	struct drm_modeset_acquire_ctx ctx;
 	int ret = 0;
 
 	BUG_ON(!crtc->cursor);
 	WARN_ON(crtc->cursor->crtc != crtc && crtc->cursor->crtc != NULL);
 
-	drm_modeset_acquire_init(&ctx, 0);
-retry:
-	ret = drm_modeset_lock(&crtc->mutex, &ctx);
-	if (ret)
-		goto fail;
-	ret = drm_modeset_lock(&crtc->cursor->mutex, &ctx);
-	if (ret)
-		goto fail;
-
 	/*
 	 * Obtain fb we'll be using (either new or existing) and take an extra
 	 * reference to it if fb != null.  setplane will take care of dropping
@@ -693,7 +684,7 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc,
 	 */
 	ret = __setplane_internal(crtc->cursor, crtc, fb,
 				crtc_x, crtc_y, crtc_w, crtc_h,
-				0, 0, src_w, src_h, &ctx);
+				0, 0, src_w, src_h, ctx);
 
 	/* Update successful; save new cursor position, if necessary */
 	if (ret == 0 && req->flags & DRM_MODE_CURSOR_MOVE) {
@@ -701,15 +692,6 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc,
 		crtc->cursor_y = req->y;
 	}
 
-fail:
-	if (ret == -EDEADLK) {
-		drm_modeset_backoff(&ctx);
-		goto retry;
-	}
-
-	drm_modeset_drop_locks(&ctx);
-	drm_modeset_acquire_fini(&ctx);
-
 	return ret;
 }
 
@@ -718,6 +700,7 @@ static int drm_mode_cursor_common(struct drm_device *dev,
 				  struct drm_file *file_priv)
 {
 	struct drm_crtc *crtc;
+	struct drm_modeset_acquire_ctx ctx;
 	int ret = 0;
 
 	if (!drm_core_check_feature(dev, DRIVER_MODESET))
@@ -732,14 +715,24 @@ static int drm_mode_cursor_common(struct drm_device *dev,
 		return -ENOENT;
 	}
 
+	drm_modeset_acquire_init(&ctx, 0);
+retry:
+	ret = drm_modeset_lock(&crtc->mutex, &ctx);
+	if (ret)
+		goto out;
+	ret = drm_modeset_lock(&crtc->cursor->mutex, &ctx);
+	if (ret)
+		goto out;
+
 	/*
 	 * If this crtc has a universal cursor plane, call that plane's update
 	 * handler rather than using legacy cursor handlers.
 	 */
-	if (crtc->cursor)
-		return drm_mode_cursor_universal(crtc, req, file_priv);
+	if (crtc->cursor) {
+		ret = drm_mode_cursor_universal(crtc, req, file_priv, &ctx);
+		goto out;
+	}
 
-	drm_modeset_lock_crtc(crtc, crtc->cursor);
 	if (req->flags & DRM_MODE_CURSOR_BO) {
 		if (!crtc->funcs->cursor_set && !crtc->funcs->cursor_set2) {
 			ret = -ENXIO;
@@ -763,7 +756,13 @@ static int drm_mode_cursor_common(struct drm_device *dev,
 		}
 	}
 out:
-	drm_modeset_unlock_crtc(crtc);
+	if (ret == -EDEADLK) {
+		drm_modeset_backoff(&ctx);
+		goto retry;
+	}
+
+	drm_modeset_drop_locks(&ctx);
+	drm_modeset_acquire_fini(&ctx);
 
 	return ret;
 
diff --git a/include/drm/drm_modeset_lock.h b/include/drm/drm_modeset_lock.h
index 88d35bfc9cd8..2bb065bf0593 100644
--- a/include/drm/drm_modeset_lock.h
+++ b/include/drm/drm_modeset_lock.h
@@ -121,7 +121,6 @@ struct drm_plane;
 
 void drm_modeset_lock_all(struct drm_device *dev);
 void drm_modeset_unlock_all(struct drm_device *dev);
-void drm_modeset_unlock_crtc(struct drm_crtc *crtc);
 void drm_warn_on_modeset_not_all_locked(struct drm_device *dev);
 struct drm_modeset_acquire_ctx *
 drm_modeset_legacy_acquire_ctx(struct drm_crtc *crtc);
-- 
2.11.0

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

  parent reply	other threads:[~2017-03-22 21:50 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-22 21:50 [PATCH 00/19] wire acquire ctx through legacy modeset paths Daniel Vetter
2017-03-22 21:50 ` [PATCH 01/19] drm: Wire up proper acquire ctx for plane functions Daniel Vetter
2017-03-27 20:12   ` Harry Wentland
2017-03-28  6:23     ` Daniel Vetter
2017-03-28  6:46       ` Daniel Vetter
2017-03-28  7:02       ` Daniel Vetter
2017-03-28 14:48         ` Harry Wentland
2017-03-22 21:50 ` [PATCH 02/19] drm: Add acquire ctx parameter to ->update_plane Daniel Vetter
2017-03-22 23:03   ` Russell King - ARM Linux
2017-03-24  7:07     ` Daniel Vetter
2017-03-22 21:50 ` [PATCH 03/19] drm: drm_plane_force_disable is not for atomic drivers Daniel Vetter
2017-03-22 21:50 ` [PATCH 04/19] drm: Add acquire ctx parameter to ->plane_disable Daniel Vetter
2017-03-22 21:50 ` [PATCH 05/19] drm/atomic-helper: remove backoff hack from disable/update_plane Daniel Vetter
2017-03-22 21:50 ` [PATCH 06/19] drm/vmwgfx: Drop the cursor locking hack Daniel Vetter
2017-03-23  6:22   ` Thomas Hellstrom
2017-03-23  7:28     ` Daniel Vetter
2017-03-23  7:31       ` Daniel Vetter
2017-03-23  8:35         ` Thomas Hellstrom
2017-03-23 10:10           ` Daniel Vetter
2017-03-23 10:32             ` Thomas Hellstrom
2017-03-23 12:56               ` Daniel Vetter
2017-03-27  3:01               ` Michel Dänzer
2017-03-27  6:28                 ` Daniel Vetter
2017-03-27  8:31                   ` Thomas Hellstrom
2017-03-29  8:00                     ` Daniel Vetter
2017-03-29  8:04                       ` Thomas Hellstrom
2017-03-22 21:50 ` [PATCH 07/19] drm/tegra: Don't use modeset_lock_crtc Daniel Vetter
2017-03-27 15:50   ` Daniel Vetter
2017-03-22 21:50 ` [PATCH 08/19] drm/tilcdc: Drop calls to modeset_lock_crtc Daniel Vetter
2017-03-24  9:46   ` Tomi Valkeinen
2017-03-25 21:19     ` Daniel Vetter
2017-03-24 13:34   ` Jyri Sarha
2017-03-22 21:50 ` [PATCH 09/19] drm: Make drm_modeset_lock_crtc internal Daniel Vetter
2017-03-22 21:50 ` [PATCH 10/19] drm: Roll out acquire context for the page_flip ioctl Daniel Vetter
2017-03-22 21:50 ` [PATCH 11/19] drm: Add acquire ctx parameter to ->page_flip(_target) Daniel Vetter
2017-03-22 21:50 ` [PATCH 12/19] drm/atomic-helper: remove backoff hack from page_flip Daniel Vetter
2017-03-22 21:50 ` [PATCH 13/19] drm: simplify the locking in the GETCRTC ioctl Daniel Vetter
2017-03-28  0:13   ` Harry Wentland
2017-03-28  6:27     ` Daniel Vetter
2017-03-28  7:01   ` [PATCH] " Daniel Vetter
2017-03-28 14:41     ` Harry Wentland
2017-03-30  7:36     ` [PATCH] Revert unrelated part of "drm: simplify the locking in the GETCRTC ioctl" Maarten Lankhorst
2017-03-30  7:48       ` Pandiyan, Dhinakaran
2017-03-30  7:56         ` [Intel-gfx] " Daniel Vetter
2017-03-22 21:50 ` Daniel Vetter [this message]
2017-03-22 21:50 ` [PATCH 15/19] drm: Remove drm_modeset_legacy_acquire_ctx and crtc->acquire_ctx Daniel Vetter
2017-03-22 21:50 ` [PATCH 16/19] drm: Restrict drm_mode_set_config_internal to non-atomic drivers Daniel Vetter
2017-03-22 21:50 ` [PATCH 17/19] drm: Add explicit acquire ctx handling around ->set_config Daniel Vetter
2017-03-22 21:50 ` [PATCH 18/19] drm: Add acquire ctx parameter to ->set_config Daniel Vetter
2017-04-04  0:06   ` Sinclair Yeh
2017-03-22 21:50 ` [PATCH 19/19] drm/atomic-helper: Remove the backoff hack from set_config Daniel Vetter
2017-03-23  9:37 ` ✗ Fi.CI.BAT: warning for wire acquire ctx through legacy modeset paths Patchwork
2017-03-28  0:31 ` [PATCH 00/19] " Harry Wentland
2017-03-28  7:20 ` ✓ Fi.CI.BAT: success for wire acquire ctx through legacy modeset paths (rev2) Patchwork

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=20170322215058.8671-15-daniel.vetter@ffwll.ch \
    --to=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --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.