drm: Remove drm_modeset_(un)lock_crtc
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 3 Apr 2017 08:32:51 +0000 (10:32 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 5 Apr 2017 07:26:07 +0000 (09:26 +0200)
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.

Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170403083304.9083-3-daniel.vetter@ffwll.ch
drivers/gpu/drm/drm_crtc_internal.h
drivers/gpu/drm/drm_modeset_lock.c
drivers/gpu/drm/drm_plane.c
include/drm/drm_modeset_lock.h

index de1047530e07a829def0d239da6d527dd7aaef60..8c04275cf226811a024c51cfd303e7537c7a1aac 100644 (file)
@@ -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,
index c94eff9d75448dbf4272aa0b403ff1f8610a18d3..c3ca6b859236832ae28ce74de65b75d64c439e97 100644 (file)
@@ -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
@@ -214,28 +169,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
index bc71aa2b78728d1c241682ce9eee852faafade13..838ca742a28b8da731d021857e9dd2db992e9d08 100644 (file)
@@ -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 @@ retry:
         */
        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 @@ retry:
                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;
 
index 88d35bfc9cd8ae7f0611ff03d1b36af0662f18d6..2bb065bf05932c79cbd0c4e5e8706ee052d2fb4d 100644 (file)
@@ -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);