aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_modeset_lock.c
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2014-11-11 04:12:00 -0500
committerDave Airlie <airlied@redhat.com>2014-11-12 02:56:12 -0500
commit4d02e2de0e80a786452e70d7f3a20a50641e6620 (patch)
tree4f3614925a25bab36ec2bb08c93ec836711ca928 /drivers/gpu/drm/drm_modeset_lock.c
parent5ee3229c87d396cab3c2dfc335b90320cc4a2f42 (diff)
drm: Per-plane locking
Turned out to be much simpler on top of my latest atomic stuff than what I've feared. Some details: - Drop the modeset_lock_all snakeoil in drm_plane_init. Same justification as for the equivalent change in drm_crtc_init done in commit d0fa1af40e784aaf7ebb7ba8a17b229bb3fa4c21 Author: Daniel Vetter <daniel.vetter@ffwll.ch> Date: Mon Sep 8 09:02:49 2014 +0200 drm: Drop modeset locking from crtc init function Without these the drm_modeset_lock_init would fall over the exact same way. - Since the atomic core code wraps the locking switching it to per-plane locks was a one-line change. - For the legacy ioctls add a plane argument to the locking helper so that we can grab the right plane lock (cursor or primary). Since the universal cursor plane might not be there, or someone really crazy might forgoe the primary plane even accept NULL. - Add some locking WARN_ON to the atomic helpers for good paranoid measure and to check that it all works out. Tested on my exynos atomic hackfest with full lockdep checks and ww backoff injection. v2: I've forgotten about the load-detect code in i915. v3: Thierry reported that in latest 3.18-rc vmwgfx doesn't compile any more due to commit 21e88620aa21b48d4f62d29275e3e2944a5ea2b5 Author: Rob Clark <robdclark@gmail.com> Date: Thu Oct 30 13:39:04 2014 -0400 drm/vmwgfx: fix lock breakage Rebased and fix this up. Cc: Thierry Reding <thierry.reding@gmail.com> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Reviewed-by: Sean Paul <seanpaul@chromium.org> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/drm_modeset_lock.c')
-rw-r--r--drivers/gpu/drm/drm_modeset_lock.c43
1 files changed, 33 insertions, 10 deletions
diff --git a/drivers/gpu/drm/drm_modeset_lock.c b/drivers/gpu/drm/drm_modeset_lock.c
index 474e4d12a2d8..51cc47d827d8 100644
--- a/drivers/gpu/drm/drm_modeset_lock.c
+++ b/drivers/gpu/drm/drm_modeset_lock.c
@@ -157,14 +157,20 @@ void drm_modeset_unlock_all(struct drm_device *dev)
157EXPORT_SYMBOL(drm_modeset_unlock_all); 157EXPORT_SYMBOL(drm_modeset_unlock_all);
158 158
159/** 159/**
160 * drm_modeset_lock_crtc - lock crtc with hidden acquire ctx 160 * drm_modeset_lock_crtc - lock crtc with hidden acquire ctx for a plane update
161 * @crtc: drm crtc 161 * @crtc: DRM CRTC
162 * @plane: DRM plane to be updated on @crtc
163 *
164 * This function locks the given crtc and plane (which should be either the
165 * primary or cursor plane) using a hidden acquire context. This is necessary so
166 * that drivers internally using the atomic interfaces can grab further locks
167 * with the lock acquire context.
162 * 168 *
163 * This function locks the given crtc using a hidden acquire context. This is 169 * Note that @plane can be NULL, e.g. when the cursor support hasn't yet been
164 * necessary so that drivers internally using the atomic interfaces can grab 170 * converted to universal planes yet.
165 * further locks with the lock acquire context.
166 */ 171 */
167void drm_modeset_lock_crtc(struct drm_crtc *crtc) 172void drm_modeset_lock_crtc(struct drm_crtc *crtc,
173 struct drm_plane *plane)
168{ 174{
169 struct drm_modeset_acquire_ctx *ctx; 175 struct drm_modeset_acquire_ctx *ctx;
170 int ret; 176 int ret;
@@ -180,6 +186,18 @@ retry:
180 if (ret) 186 if (ret)
181 goto fail; 187 goto fail;
182 188
189 if (plane) {
190 ret = drm_modeset_lock(&plane->mutex, ctx);
191 if (ret)
192 goto fail;
193
194 if (plane->crtc) {
195 ret = drm_modeset_lock(&plane->crtc->mutex, ctx);
196 if (ret)
197 goto fail;
198 }
199 }
200
183 WARN_ON(crtc->acquire_ctx); 201 WARN_ON(crtc->acquire_ctx);
184 202
185 /* now we hold the locks, so now that it is safe, stash the 203 /* now we hold the locks, so now that it is safe, stash the
@@ -437,15 +455,14 @@ void drm_modeset_unlock(struct drm_modeset_lock *lock)
437} 455}
438EXPORT_SYMBOL(drm_modeset_unlock); 456EXPORT_SYMBOL(drm_modeset_unlock);
439 457
440/* Temporary.. until we have sufficiently fine grained locking, there 458/* In some legacy codepaths it's convenient to just grab all the crtc and plane
441 * are a couple scenarios where it is convenient to grab all crtc locks. 459 * related locks. */
442 * It is planned to remove this:
443 */
444int drm_modeset_lock_all_crtcs(struct drm_device *dev, 460int drm_modeset_lock_all_crtcs(struct drm_device *dev,
445 struct drm_modeset_acquire_ctx *ctx) 461 struct drm_modeset_acquire_ctx *ctx)
446{ 462{
447 struct drm_mode_config *config = &dev->mode_config; 463 struct drm_mode_config *config = &dev->mode_config;
448 struct drm_crtc *crtc; 464 struct drm_crtc *crtc;
465 struct drm_plane *plane;
449 int ret = 0; 466 int ret = 0;
450 467
451 list_for_each_entry(crtc, &config->crtc_list, head) { 468 list_for_each_entry(crtc, &config->crtc_list, head) {
@@ -454,6 +471,12 @@ int drm_modeset_lock_all_crtcs(struct drm_device *dev,
454 return ret; 471 return ret;
455 } 472 }
456 473
474 list_for_each_entry(plane, &config->plane_list, head) {
475 ret = drm_modeset_lock(&plane->mutex, ctx);
476 if (ret)
477 return ret;
478 }
479
457 return 0; 480 return 0;
458} 481}
459EXPORT_SYMBOL(drm_modeset_lock_all_crtcs); 482EXPORT_SYMBOL(drm_modeset_lock_all_crtcs);