All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 03/12] drm/i915: Apply lockdep annotations to i915_gem_context.c
Date: Mon, 23 May 2016 10:11:46 +0100	[thread overview]
Message-ID: <5742C952.2050206@linux.intel.com> (raw)
In-Reply-To: <1463922152-2709-3-git-send-email-chris@chris-wilson.co.uk>


On 22/05/16 14:02, Chris Wilson wrote:
> Markup the functions that require the caller to hold struct_mutex with
> lockdep_assert_held(). In the hopefully not-too-distant future we will
> split the struct_mutex up, and in doing so we need to be sure that we
> know what it protects - here the lockdep annotations are invaluable.
>
> 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>
> ---
>   drivers/gpu/drm/i915/i915_drv.h         |  1 +
>   drivers/gpu/drm/i915/i915_gem_context.c | 16 ++++++++++++++--
>   2 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 8380102bbdd8..48a222ddd8b3 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -3429,6 +3429,7 @@ static inline void i915_gem_context_reference(struct i915_gem_context *ctx)
>
>   static inline void i915_gem_context_unreference(struct i915_gem_context *ctx)
>   {
> +	lockdep_assert_held(&ctx->i915->dev->struct_mutex);
>   	kref_put(&ctx->ref, i915_gem_context_free);
>   }
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
> index 8484da26b5d4..af747f14522e 100644
> --- a/drivers/gpu/drm/i915/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/i915_gem_context.c
> @@ -153,6 +153,7 @@ void i915_gem_context_free(struct kref *ctx_ref)
>   {
>   	struct i915_gem_context *ctx = container_of(ctx_ref, typeof(*ctx), ref);
>
> +	lockdep_assert_held(&ctx->i915->dev->struct_mutex);
>   	trace_i915_context_free(ctx);
>
>   	if (i915.enable_execlists)
> @@ -181,6 +182,8 @@ i915_gem_alloc_context_obj(struct drm_device *dev, size_t size)
>   	struct drm_i915_gem_object *obj;
>   	int ret;
>
> +	lockdep_assert_held(&dev->struct_mutex);
> +
>   	obj = i915_gem_object_create(dev, size);
>   	if (IS_ERR(obj))
>   		return obj;
> @@ -368,6 +371,8 @@ void i915_gem_context_reset(struct drm_device *dev)
>   {
>   	struct drm_i915_private *dev_priv = dev->dev_private;
>
> +	lockdep_assert_held(&dev->struct_mutex);
> +
>   	if (i915.enable_execlists) {
>   		struct i915_gem_context *ctx;
>
> @@ -433,6 +438,8 @@ void i915_gem_context_lost(struct drm_i915_private *dev_priv)
>   {
>   	struct intel_engine_cs *engine;
>
> +	lockdep_assert_held(&dev_priv->dev->struct_mutex);
> +
>   	for_each_engine(engine, dev_priv) {
>   		if (engine->last_context == NULL)
>   			continue;
> @@ -451,6 +458,8 @@ void i915_gem_context_fini(struct drm_device *dev)
>   	struct drm_i915_private *dev_priv = dev->dev_private;
>   	struct i915_gem_context *dctx = dev_priv->kernel_context;
>
> +	lockdep_assert_held(&dev->struct_mutex);
> +
>   	if (dctx->legacy_hw_ctx.rcs_state)
>   		i915_gem_object_ggtt_unpin(dctx->legacy_hw_ctx.rcs_state);
>
> @@ -491,6 +500,8 @@ void i915_gem_context_close(struct drm_device *dev, struct drm_file *file)
>   {
>   	struct drm_i915_file_private *file_priv = file->driver_priv;
>
> +	lockdep_assert_held(&dev->struct_mutex);
> +
>   	idr_for_each(&file_priv->context_idr, context_idr_cleanup, NULL);
>   	idr_destroy(&file_priv->context_idr);
>   }
> @@ -500,6 +511,8 @@ 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);
> @@ -852,10 +865,9 @@ unpin_out:
>   int i915_switch_context(struct drm_i915_gem_request *req)
>   {
>   	struct intel_engine_cs *engine = req->engine;
> -	struct drm_i915_private *dev_priv = req->i915;
>
>   	WARN_ON(i915.enable_execlists);
> -	WARN_ON(!mutex_is_locked(&dev_priv->dev->struct_mutex));
> +	lockdep_assert_held(&req->i915->dev->struct_mutex);
>
>   	if (engine->id != RCS ||
>   	    req->ctx->legacy_hw_ctx.rcs_state == NULL) {
>

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

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

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

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-22 13:02 [PATCH 01/12] drm/i915/fbdev: Limit the global async-domain synchronization Chris Wilson
2016-05-22 13:02 ` [PATCH 02/12] drm/i915: Rename struct intel_context Chris Wilson
2016-05-23  9:09   ` Tvrtko Ursulin
2016-05-22 13:02 ` [PATCH 03/12] drm/i915: Apply lockdep annotations to i915_gem_context.c Chris Wilson
2016-05-23  9:11   ` Tvrtko Ursulin [this message]
2016-05-22 13:02 ` [PATCH 04/12] drm/i915: Rename and inline i915_gem_context_get() Chris Wilson
2016-05-23  9:15   ` Tvrtko Ursulin
2016-05-22 13:02 ` [PATCH 05/12] drm/i915: Rename i915_gem_context_reference/unreference() Chris Wilson
2016-05-23  9:17   ` Tvrtko Ursulin
2016-05-23  9:25     ` Chris Wilson
2016-05-24  8:10     ` Daniel Vetter
2016-05-22 13:02 ` [PATCH 06/12] drm/i915: Name the inner most per-engine intel_context struct Chris Wilson
2016-05-23  9:26   ` Tvrtko Ursulin
2016-05-23 10:17     ` Chris Wilson
2016-05-23 10:55       ` Tvrtko Ursulin
2016-05-23 11:08         ` Chris Wilson
2016-05-22 13:02 ` [PATCH 07/12] drm/i915: Move pinning of dev_priv->kernel_context into its creator Chris Wilson
2016-05-23  9:33   ` Tvrtko Ursulin
2016-05-23  9:45     ` Chris Wilson
2016-05-22 13:02 ` [PATCH 08/12] drm/i915: Show i915_gem_context owner in debugfs Chris Wilson
2016-05-23  9:42   ` Tvrtko Ursulin
2016-05-23  9:52     ` Chris Wilson
2016-05-22 13:02 ` [PATCH 09/12] drm/i915: Put the kernel_context in drm_i915_private next to its friends Chris Wilson
2016-05-23  9:45   ` Tvrtko Ursulin
2016-05-22 13:02 ` [PATCH 10/12] drm/i915: Merge legacy+execlists context structs Chris Wilson
2016-05-23 10:26   ` Tvrtko Ursulin
2016-05-23 10:40     ` Chris Wilson
2016-05-22 13:02 ` [PATCH 11/12] drm/i915: Rearrange i915_gem_context Chris Wilson
2016-05-23 10:27   ` Tvrtko Ursulin
2016-05-22 13:02 ` [PATCH 12/12] drm/i915: Show context objects in debugfs/i915_gem_objects Chris Wilson
2016-05-24  8:13   ` Daniel Vetter
2016-05-24  8:21     ` Chris Wilson
2016-05-22 13:33 ` ✗ Ro.CI.BAT: failure for series starting with [01/12] drm/i915/fbdev: Limit the global async-domain synchronization 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=5742C952.2050206@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=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.