All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH v2 03/11] drm/i915: Rename and inline i915_gem_context_get()
Date: Mon, 23 May 2016 12:34:10 +0100	[thread overview]
Message-ID: <1464003258-23669-4-git-send-email-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <1464003258-23669-1-git-send-email-chris@chris-wilson.co.uk>

i915_gem_context_get() is a very simple wrapper around idr_find(), so
simple that it would be smaller to do the lookup inline. Also we use the
verb 'lookup' to return a pointer from a handle, freeing 'get' to imply
obtaining a reference to the context.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h            | 17 +++++++++++++++--
 drivers/gpu/drm/i915/i915_gem_context.c    | 22 ++++------------------
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |  2 +-
 3 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index a0f5f00f552f..d162bf86db7e 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3417,11 +3417,24 @@ void i915_gem_context_reset(struct drm_device *dev);
 int i915_gem_context_open(struct drm_device *dev, struct drm_file *file);
 void i915_gem_context_close(struct drm_device *dev, struct drm_file *file);
 int i915_switch_context(struct drm_i915_gem_request *req);
-struct i915_gem_context *
-i915_gem_context_get(struct drm_i915_file_private *file_priv, u32 id);
 void i915_gem_context_free(struct kref *ctx_ref);
 struct drm_i915_gem_object *
 i915_gem_alloc_context_obj(struct drm_device *dev, size_t size);
+
+static inline struct i915_gem_context *
+i915_gem_context_lookup(struct drm_i915_file_private *file_priv, u32 id)
+{
+	struct i915_gem_context *ctx;
+
+	lockdep_assert_held(&file_priv->dev_priv->dev->struct_mutex);
+
+	ctx = idr_find(&file_priv->context_idr, id);
+	if (!ctx)
+		return ERR_PTR(-ENOENT);
+
+	return ctx;
+}
+
 static inline void i915_gem_context_reference(struct i915_gem_context *ctx)
 {
 	kref_get(&ctx->ref);
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index af747f14522e..aa329175f73a 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -506,20 +506,6 @@ void i915_gem_context_close(struct drm_device *dev, struct drm_file *file)
 	idr_destroy(&file_priv->context_idr);
 }
 
-struct i915_gem_context *
-i915_gem_context_get(struct drm_i915_file_private *file_priv, u32 id)
-{
-	struct i915_gem_context *ctx;
-
-	lockdep_assert_held(&file_priv->dev_priv->dev->struct_mutex);
-
-	ctx = idr_find(&file_priv->context_idr, id);
-	if (!ctx)
-		return ERR_PTR(-ENOENT);
-
-	return ctx;
-}
-
 static inline int
 mi_set_context(struct drm_i915_gem_request *req, u32 hw_flags)
 {
@@ -951,7 +937,7 @@ int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data,
 	if (ret)
 		return ret;
 
-	ctx = i915_gem_context_get(file_priv, args->ctx_id);
+	ctx = i915_gem_context_lookup(file_priv, args->ctx_id);
 	if (IS_ERR(ctx)) {
 		mutex_unlock(&dev->struct_mutex);
 		return PTR_ERR(ctx);
@@ -977,7 +963,7 @@ int i915_gem_context_getparam_ioctl(struct drm_device *dev, void *data,
 	if (ret)
 		return ret;
 
-	ctx = i915_gem_context_get(file_priv, args->ctx_id);
+	ctx = i915_gem_context_lookup(file_priv, args->ctx_id);
 	if (IS_ERR(ctx)) {
 		mutex_unlock(&dev->struct_mutex);
 		return PTR_ERR(ctx);
@@ -1020,7 +1006,7 @@ int i915_gem_context_setparam_ioctl(struct drm_device *dev, void *data,
 	if (ret)
 		return ret;
 
-	ctx = i915_gem_context_get(file_priv, args->ctx_id);
+	ctx = i915_gem_context_lookup(file_priv, args->ctx_id);
 	if (IS_ERR(ctx)) {
 		mutex_unlock(&dev->struct_mutex);
 		return PTR_ERR(ctx);
@@ -1072,7 +1058,7 @@ int i915_gem_context_reset_stats_ioctl(struct drm_device *dev,
 	if (ret)
 		return ret;
 
-	ctx = i915_gem_context_get(file->driver_priv, args->ctx_id);
+	ctx = i915_gem_context_lookup(file->driver_priv, args->ctx_id);
 	if (IS_ERR(ctx)) {
 		mutex_unlock(&dev->struct_mutex);
 		return PTR_ERR(ctx);
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index e61b92d7b0bc..84d990331abd 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -1075,7 +1075,7 @@ i915_gem_validate_context(struct drm_device *dev, struct drm_file *file,
 	if (engine->id != RCS && ctx_id != DEFAULT_CONTEXT_HANDLE)
 		return ERR_PTR(-EINVAL);
 
-	ctx = i915_gem_context_get(file->driver_priv, ctx_id);
+	ctx = i915_gem_context_lookup(file->driver_priv, ctx_id);
 	if (IS_ERR(ctx))
 		return ctx;
 
-- 
2.8.1

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

  parent reply	other threads:[~2016-05-23 11:34 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-23 11:34 Context churn Chris Wilson
2016-05-23 11:34 ` [PATCH v2 01/11] drm/i915: Rename struct intel_context Chris Wilson
2016-05-23 11:34 ` [PATCH v2 02/11] drm/i915: Apply lockdep annotations to i915_gem_context.c Chris Wilson
2016-05-23 11:34 ` Chris Wilson [this message]
2016-05-23 11:34 ` [PATCH v2 04/11] drm/i915: Rename i915_gem_context_reference/unreference() Chris Wilson
2016-05-24 11:21   ` Chris Wilson
2016-05-23 11:34 ` [PATCH v2 05/11] drm/i915: Name the inner most per-engine intel_context struct Chris Wilson
2016-05-23 11:34 ` [PATCH v2 06/11] drm/i915: Move pinning of dev_priv->kernel_context into its creator Chris Wilson
2016-05-23 12:09   ` Tvrtko Ursulin
2016-05-23 12:16     ` Chris Wilson
2016-05-23 12:23       ` Tvrtko Ursulin
2016-05-25  9:25   ` Joonas Lahtinen
2016-05-23 11:34 ` [PATCH v2 07/11] drm/i915: Show i915_gem_context owner in debugfs Chris Wilson
2016-05-23 12:18   ` Tvrtko Ursulin
2016-05-25  9:18   ` Joonas Lahtinen
2016-05-23 11:34 ` [PATCH v2 08/11] drm/i915: Put the kernel_context in drm_i915_private next to its friends Chris Wilson
2016-05-23 11:34 ` [PATCH v2 09/11] drm/i915: Merge legacy+execlists context structs Chris Wilson
2016-05-23 11:34 ` [PATCH v2 10/11] drm/i915: Rearrange i915_gem_context Chris Wilson
2016-05-25  9:15   ` Joonas Lahtinen
2016-05-23 11:34 ` [PATCH v2 11/11] drm/i915: Show context objects in debugfs/i915_gem_objects Chris Wilson
2016-05-23 12:31   ` Tvrtko Ursulin
2016-05-23 12:40     ` Chris Wilson
2016-05-23 13:01     ` [PATCH v3] drm/i915/debugfs: Show context objects in i915_gem_objects Chris Wilson
2016-05-23 13:42       ` kbuild test robot
2016-05-23 13:50       ` kbuild test robot
2016-05-24 11:15       ` Tvrtko Ursulin
2016-05-25  9:55       ` Joonas Lahtinen
2016-05-25 10:00         ` Chris Wilson
2016-05-25  9:33   ` [PATCH v2 11/11] drm/i915: Show context objects in debugfs/i915_gem_objects Joonas Lahtinen
2016-05-23 12:01 ` ✓ Ro.CI.BAT: success for series starting with [v2,01/11] drm/i915: Rename struct intel_context Patchwork
2016-05-23 14:30 ` ✗ Ro.CI.BAT: failure for series starting with [v2,01/11] drm/i915: Rename struct intel_context (rev2) Patchwork
2016-05-24 13:53 ` [CI 01/10] drm/i915: Rename struct intel_context Chris Wilson
2016-05-24 13:53   ` [CI 02/10] drm/i915: Apply lockdep annotations to i915_gem_context.c Chris Wilson
2016-05-24 13:53   ` [CI 03/10] drm/i915: Rename and inline i915_gem_context_get() Chris Wilson
2016-05-24 13:53   ` [CI 04/10] drm/i915: Name the inner most per-engine intel_context struct Chris Wilson
2016-05-24 13:53   ` [CI 05/10] drm/i915: Move pinning of dev_priv->kernel_context into its creator Chris Wilson
2016-05-24 13:53   ` [CI 06/10] drm/i915: Show i915_gem_context owner in debugfs Chris Wilson
2016-05-24 13:53   ` [CI 07/10] drm/i915: Put the kernel_context in drm_i915_private next to its friends Chris Wilson
2016-05-24 13:53   ` [CI 08/10] drm/i915: Merge legacy+execlists context structs Chris Wilson
2016-05-24 13:53   ` [CI 09/10] drm/i915: Rearrange i915_gem_context Chris Wilson
2016-05-24 13:53   ` [CI 10/10] drm/i915/debugfs: Show context objects in i915_gem_objects Chris Wilson
2016-05-24 14:19 ` ✗ Ro.CI.BAT: warning for series starting with [v2,01/11] drm/i915: Rename struct intel_context (rev10) 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=1464003258-23669-4-git-send-email-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --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.