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 11/15] drm: Add explicit acquire ctx handling around ->gamma_set
Date: Mon,  3 Apr 2017 10:33:00 +0200	[thread overview]
Message-ID: <20170403083304.9083-12-daniel.vetter@ffwll.ch> (raw)
In-Reply-To: <20170403083304.9083-1-daniel.vetter@ffwll.ch>

Just the groundwork to prepare for adding the acquire cxt parameter to
the ->gamma_set hook. Again we need a temporary hack to fill out
mode_config.acquire_ctx until the atomic helpers are switched over.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/drm_color_mgmt.c | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
index a32be59a72d1..e1b4084c3d16 100644
--- a/drivers/gpu/drm/drm_color_mgmt.c
+++ b/drivers/gpu/drm/drm_color_mgmt.c
@@ -218,28 +218,29 @@ int drm_mode_gamma_set_ioctl(struct drm_device *dev,
 	struct drm_crtc *crtc;
 	void *r_base, *g_base, *b_base;
 	int size;
+	struct drm_modeset_acquire_ctx ctx;
 	int ret = 0;
 
 	if (!drm_core_check_feature(dev, DRIVER_MODESET))
 		return -EINVAL;
 
-	drm_modeset_lock_all(dev);
 	crtc = drm_crtc_find(dev, crtc_lut->crtc_id);
-	if (!crtc) {
-		ret = -ENOENT;
-		goto out;
-	}
+	if (!crtc)
+		return -ENOENT;
 
-	if (crtc->funcs->gamma_set == NULL) {
-		ret = -ENOSYS;
-		goto out;
-	}
+	if (crtc->funcs->gamma_set == NULL)
+		return -ENOSYS;
 
 	/* memcpy into gamma store */
-	if (crtc_lut->gamma_size != crtc->gamma_size) {
-		ret = -EINVAL;
+	if (crtc_lut->gamma_size != crtc->gamma_size)
+		return -EINVAL;
+
+	drm_modeset_acquire_init(&ctx, 0);
+	dev->mode_config.acquire_ctx = &ctx;
+retry:
+	ret = drm_modeset_lock_all_ctx(dev, &ctx);
+	if (ret)
 		goto out;
-	}
 
 	size = crtc_lut->gamma_size * (sizeof(uint16_t));
 	r_base = crtc->gamma_store;
@@ -263,7 +264,13 @@ int drm_mode_gamma_set_ioctl(struct drm_device *dev,
 	ret = crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, crtc->gamma_size);
 
 out:
-	drm_modeset_unlock_all(dev);
+	if (ret == -EDEADLK) {
+		drm_modeset_backoff(&ctx);
+		goto retry;
+	}
+	drm_modeset_drop_locks(&ctx);
+	drm_modeset_acquire_fini(&ctx);
+
 	return ret;
 
 }
-- 
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-04-03  8:33 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-03  8:32 [PATCH 00/15] acquire ctx wire-up, part 2 Daniel Vetter
2017-04-03  8:32 ` [PATCH 01/15] drm: Make drm_modeset_lock_crtc internal Daniel Vetter
2017-04-03 22:00   ` kbuild test robot
2017-04-03  8:32 ` [PATCH 02/15] drm: Remove drm_modeset_(un)lock_crtc Daniel Vetter
2017-04-03 22:13   ` kbuild test robot
2017-04-04  5:39     ` [Intel-gfx] " Daniel Vetter
2017-04-14 16:20       ` Mike Lothian
2017-04-18  6:32         ` [Intel-gfx] " Daniel Vetter
2017-04-03  8:32 ` [PATCH 03/15] drm: Remove drm_modeset_legacy_acquire_ctx and crtc->acquire_ctx Daniel Vetter
2017-04-03  8:32 ` [PATCH 04/15] drm/atomic-helper: remove modeset_lock_all from helper_resume Daniel Vetter
2017-04-05 19:31   ` Alex Deucher
2017-04-03  8:32 ` [PATCH 05/15] drm: drop modeset_lock_all from drm_state_info Daniel Vetter
2017-04-03  8:32 ` [PATCH 06/15] drm: Drop modeset_lock_all from the getproperty ioctl Daniel Vetter
2017-04-13 20:03   ` Alex Deucher
2017-04-13 20:18     ` [Intel-gfx] " Chris Wilson
2017-04-03  8:32 ` [PATCH 07/15] drm: Only take crtc lock in get_gamma ioctl Daniel Vetter
2017-04-03  8:32 ` [PATCH 08/15] drm/i915: Nuke intel_atomic_legacy_gamma_set Daniel Vetter
2017-04-04 10:44   ` Maarten Lankhorst
2017-04-05 11:16     ` Daniel Vetter
2017-04-03  8:32 ` [PATCH 09/15] drm/msm: Nerf zpos property Daniel Vetter
2017-04-05 13:24   ` Daniel Vetter
2017-04-03  8:32 ` [PATCH 10/15] drm/fb-helper: Give up on kgdb for atomic drivers Daniel Vetter
2017-04-03  8:33 ` Daniel Vetter [this message]
2017-04-03  8:33 ` [PATCH 12/15] drm: Add acquire ctx to ->gamma_set hook Daniel Vetter
2017-04-03 18:28   ` Sinclair Yeh
2017-04-06 16:51   ` Eric Anholt
2017-04-06 18:00     ` Daniel Vetter
2017-04-03  8:33 ` [PATCH 13/15] drm/atomic-helper: Remove legacy backoff hack from gamma_set Daniel Vetter
2017-04-03  8:33 ` [PATCH 14/15] drm: extract legacy framebuffer remove Daniel Vetter
2017-04-03  8:33 ` [PATCH 15/15] drm/fb-helper: Extract _legacy kms functions Daniel Vetter
2017-04-03  9:28 ` ✓ Fi.CI.BAT: success for acquire ctx wire-up, part 2 Patchwork
2017-04-05 19:45 ` [PATCH 00/15] " Alex Deucher
2017-04-06  8:23   ` Daniel Vetter

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=20170403083304.9083-12-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.