intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 15/62] drm/i915: Rename i915_gem_context_reference/unreference()
Date: Mon, 06 Jun 2016 15:12:11 +0300	[thread overview]
Message-ID: <1465215131.7623.0.camel@linux.intel.com> (raw)
In-Reply-To: <1464971847-15809-16-git-send-email-chris@chris-wilson.co.uk>

On pe, 2016-06-03 at 17:36 +0100, Chris Wilson wrote:
> As these are wrappers around kref_get/kref_put() it is preferable to
> follow the naming convention and use the same verb get/put in our
> wrapper names for manipulating 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: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

> ---
>  drivers/gpu/drm/i915/i915_drv.h            |  6 ++++--
>  drivers/gpu/drm/i915/i915_gem_context.c    | 22 ++++++++++------------
>  drivers/gpu/drm/i915/i915_gem_execbuffer.c |  6 +++---
>  drivers/gpu/drm/i915/i915_gem_request.c    |  7 +++----
>  drivers/gpu/drm/i915/intel_lrc.c           |  4 ++--
>  drivers/gpu/drm/i915/intel_ringbuffer.c    |  4 ++--
>  6 files changed, 24 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 939cd45043c7..48d89b181246 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -3247,12 +3247,14 @@ i915_gem_context_lookup(struct drm_i915_file_private *file_priv, u32 id)
>  	return ctx;
>  }
>  
> -static inline void i915_gem_context_reference(struct i915_gem_context *ctx)
> +static inline struct i915_gem_context *
> +i915_gem_context_get(struct i915_gem_context *ctx)
>  {
>  	kref_get(&ctx->ref);
> +	return ctx;
>  }
>  
> -static inline void i915_gem_context_unreference(struct i915_gem_context *ctx)
> +static inline void i915_gem_context_put(struct i915_gem_context *ctx)
>  {
>  	lockdep_assert_held(&ctx->i915->drm.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 d01b3893eac0..b62862e31642 100644
> --- a/drivers/gpu/drm/i915/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/i915_gem_context.c
> @@ -301,7 +301,7 @@ __create_hw_context(struct drm_device *dev,
>  	return ctx;
>  
>  err_out:
> -	i915_gem_context_unreference(ctx);
> +	i915_gem_context_put(ctx);
>  	return ERR_PTR(ret);
>  }
>  
> @@ -329,7 +329,7 @@ i915_gem_create_context(struct drm_device *dev,
>  			DRM_DEBUG_DRIVER("PPGTT setup failed (%ld)\n",
>  					 PTR_ERR(ppgtt));
>  			idr_remove(&file_priv->context_idr, ctx->user_handle);
> -			i915_gem_context_unreference(ctx);
> +			i915_gem_context_put(ctx);
>  			return ERR_CAST(ppgtt);
>  		}
>  
> @@ -352,7 +352,7 @@ static void i915_gem_context_unpin(struct i915_gem_context *ctx,
>  		if (ce->state)
>  			i915_gem_object_ggtt_unpin(ce->state);
>  
> -		i915_gem_context_unreference(ctx);
> +		i915_gem_context_put(ctx);
>  	}
>  }
>  
> @@ -466,7 +466,7 @@ void i915_gem_context_fini(struct drm_device *dev)
>  
>  	lockdep_assert_held(&dev->struct_mutex);
>  
> -	i915_gem_context_unreference(dctx);
> +	i915_gem_context_put(dctx);
>  	dev_priv->kernel_context = NULL;
>  
>  	ida_destroy(&dev_priv->context_hw_ida);
> @@ -477,7 +477,7 @@ static int context_idr_cleanup(int id, void *p, void *data)
>  	struct i915_gem_context *ctx = p;
>  
>  	ctx->file_priv = ERR_PTR(-EBADF);
> -	i915_gem_context_unreference(ctx);
> +	i915_gem_context_put(ctx);
>  	return 0;
>  }
>  
> @@ -789,10 +789,9 @@ static int do_rcs_switch(struct drm_i915_gem_request *req)
>  
>  		/* obj is kept alive until the next request by its active ref */
>  		i915_gem_object_ggtt_unpin(from->engine[RCS].state);
> -		i915_gem_context_unreference(from);
> +		i915_gem_context_put(from);
>  	}
> -	i915_gem_context_reference(to);
> -	engine->last_context = to;
> +	engine->last_context = i915_gem_context_get(to);
>  
>  	/* GEN8 does *not* require an explicit reload if the PDPs have been
>  	 * setup, and we do not wish to move them.
> @@ -876,10 +875,9 @@ int i915_switch_context(struct drm_i915_gem_request *req)
>  		}
>  
>  		if (to != engine->last_context) {
> -			i915_gem_context_reference(to);
>  			if (engine->last_context)
> -				i915_gem_context_unreference(engine->last_context);
> -			engine->last_context = to;
> +				i915_gem_context_put(engine->last_context);
> +			engine->last_context = i915_gem_context_get(to);
>  		}
>  
>  		return 0;
> @@ -947,7 +945,7 @@ int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data,
>  	}
>  
>  	idr_remove(&file_priv->context_idr, ctx->user_handle);
> -	i915_gem_context_unreference(ctx);
> +	i915_gem_context_put(ctx);
>  	mutex_unlock(&dev->struct_mutex);
>  
>  	DRM_DEBUG_DRIVER("HW context %d destroyed\n", args->ctx_id);
> diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> index d3297dab0298..7f441e74c903 100644
> --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> @@ -1496,7 +1496,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
>  		goto pre_mutex_err;
>  	}
>  
> -	i915_gem_context_reference(ctx);
> +	i915_gem_context_get(ctx);
>  
>  	if (ctx->ppgtt)
>  		vm = &ctx->ppgtt->base;
> @@ -1507,7 +1507,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
>  
>  	eb = eb_create(args);
>  	if (eb == NULL) {
> -		i915_gem_context_unreference(ctx);
> +		i915_gem_context_put(ctx);
>  		mutex_unlock(&dev->struct_mutex);
>  		ret = -ENOMEM;
>  		goto pre_mutex_err;
> @@ -1651,7 +1651,7 @@ err_batch_unpin:
>  
>  err:
>  	/* the request owns the ref now */
> -	i915_gem_context_unreference(ctx);
> +	i915_gem_context_put(ctx);
>  	eb_destroy(eb);
>  
>  	mutex_unlock(&dev->struct_mutex);
> diff --git a/drivers/gpu/drm/i915/i915_gem_request.c b/drivers/gpu/drm/i915/i915_gem_request.c
> index 2ecaf9fa936a..987a43f1aac8 100644
> --- a/drivers/gpu/drm/i915/i915_gem_request.c
> +++ b/drivers/gpu/drm/i915/i915_gem_request.c
> @@ -243,8 +243,7 @@ __i915_gem_request_alloc(struct intel_engine_cs *engine,
>  	req->i915 = dev_priv;
>  	req->engine = engine;
>  	req->reset_counter = reset_counter;
> -	req->ctx = ctx;
> -	i915_gem_context_reference(ctx);
> +	req->ctx = i915_gem_context_get(ctx);
>  
>  	/*
>  	 * Reserve space in the ring buffer for all the commands required to
> @@ -266,7 +265,7 @@ __i915_gem_request_alloc(struct intel_engine_cs *engine,
>  	return 0;
>  
>  err_ctx:
> -	i915_gem_context_unreference(ctx);
> +	i915_gem_context_put(ctx);
>  err:
>  	kmem_cache_free(dev_priv->requests, req);
>  	return ret;
> @@ -364,7 +363,7 @@ static void i915_gem_request_retire(struct drm_i915_gem_request *request)
>  					       request->engine);
>  	}
>  
> -	i915_gem_context_unreference(request->ctx);
> +	i915_gem_context_put(request->ctx);
>  	i915_gem_request_put(request);
>  }
>  
> diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
> index a25177016fb3..d55aa9ca2877 100644
> --- a/drivers/gpu/drm/i915/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/intel_lrc.c
> @@ -961,7 +961,6 @@ static int intel_lr_context_pin(struct i915_gem_context *ctx,
>  	if (ret)
>  		goto unpin_map;
>  
> -	i915_gem_context_reference(ctx);
>  	ce->lrc_vma = i915_gem_obj_to_ggtt(ce->state);
>  	intel_lr_context_descriptor_update(ctx, engine);
>  
> @@ -973,6 +972,7 @@ static int intel_lr_context_pin(struct i915_gem_context *ctx,
>  	if (i915.enable_guc_submission)
>  		I915_WRITE(GEN8_GTCR, GEN8_GTCR_INVALIDATE);
>  
> +	i915_gem_context_get(ctx);
>  	return 0;
>  
>  unpin_map:
> @@ -1004,7 +1004,7 @@ void intel_lr_context_unpin(struct i915_gem_context *ctx,
>  	ce->lrc_desc = 0;
>  	ce->lrc_reg_state = NULL;
>  
> -	i915_gem_context_unreference(ctx);
> +	i915_gem_context_put(ctx);
>  }
>  
>  static int intel_logical_ring_workarounds_emit(struct drm_i915_gem_request *req)
> diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
> index c3d6345aa2c1..e6a2e4973a01 100644
> --- a/drivers/gpu/drm/i915/intel_ringbuffer.c
> +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
> @@ -2058,7 +2058,7 @@ static int intel_ring_context_pin(struct i915_gem_context *ctx,
>  	if (ctx == ctx->i915->kernel_context)
>  		ce->initialised = true;
>  
> -	i915_gem_context_reference(ctx);
> +	i915_gem_context_get(ctx);
>  	return 0;
>  
>  error:
> @@ -2079,7 +2079,7 @@ static void intel_ring_context_unpin(struct i915_gem_context *ctx,
>  	if (ce->state)
>  		i915_gem_object_ggtt_unpin(ce->state);
>  
> -	i915_gem_context_unreference(ctx);
> +	i915_gem_context_put(ctx);
>  }
>  
>  static int intel_init_ring_buffer(struct drm_device *dev,
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2016-06-06 12:12 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-03 16:36 The vma leak fix from yonder Chris Wilson
2016-06-03 16:36 ` [PATCH 01/62] drm/i915: Only start retire worker when idle Chris Wilson
2016-06-07 11:31   ` Joonas Lahtinen
2016-06-08 10:53     ` Chris Wilson
2016-06-08 11:06       ` Chris Wilson
2016-06-08 12:07         ` Joonas Lahtinen
2016-06-03 16:36 ` [PATCH 02/62] drm/i915: Do not keep postponing the idle-work Chris Wilson
2016-06-07 11:34   ` Joonas Lahtinen
2016-06-03 16:36 ` [PATCH 03/62] drm/i915: Remove redundant queue_delayed_work() from throttle ioctl Chris Wilson
2016-06-07 11:39   ` Joonas Lahtinen
2016-06-03 16:36 ` [PATCH 04/62] drm/i915: Restore waitboost credit to the synchronous waiter Chris Wilson
2016-06-08  9:04   ` Daniel Vetter
2016-06-08 10:38     ` Chris Wilson
2016-06-03 16:36 ` [PATCH 05/62] drm/i915: Add background commentary to "waitboosting" Chris Wilson
2016-06-03 16:36 ` [PATCH 06/62] drm/i915: Flush the RPS bottom-half when the GPU idles Chris Wilson
2016-06-16  8:49   ` Michał Winiarski
2016-06-16 11:09     ` Chris Wilson
2016-06-03 16:36 ` [PATCH 07/62] drm/i915: Remove temporary RPM wakeref assert disables Chris Wilson
2016-06-03 16:36 ` [PATCH 08/62] drm/i915: Remove stop-rings debugfs interface Chris Wilson
2016-06-08 11:50   ` Arun Siluvery
2016-06-03 16:36 ` [PATCH 09/62] drm/i915: Record the ringbuffer associated with the request Chris Wilson
2016-06-03 16:36 ` [PATCH 10/62] drm/i915: Allow userspace to request no-error-capture upon GPU hangs Chris Wilson
2016-06-03 16:36 ` [PATCH 11/62] drm/i915: Clean up GPU hang message Chris Wilson
2016-06-14  8:13   ` Mika Kuoppala
2016-06-03 16:36 ` [PATCH 12/62] drm/i915: Skip capturing an error state if we already have one Chris Wilson
2016-06-08 11:14   ` Arun Siluvery
2016-06-08 12:06     ` Chris Wilson
2016-06-03 16:36 ` [PATCH 13/62] drm/i915: Derive GEM requests from dma-fence Chris Wilson
2016-06-08  9:14   ` Daniel Vetter
2016-06-08 10:33     ` Chris Wilson
2016-06-03 16:36 ` [PATCH 14/62] drm/i915: Rename request reference/unreference to get/put Chris Wilson
2016-06-08  9:15   ` Daniel Vetter
2016-06-03 16:36 ` [PATCH 15/62] drm/i915: Rename i915_gem_context_reference/unreference() Chris Wilson
2016-06-06 12:12   ` Joonas Lahtinen [this message]
2016-06-03 16:36 ` [PATCH 16/62] drm/i915: Wrap drm_gem_object_lookup in i915_gem_object_lookup Chris Wilson
2016-06-03 16:36 ` [PATCH 17/62] drm/i915: Wrap drm_gem_object_reference in i915_gem_object_get Chris Wilson
2016-06-03 16:36 ` [PATCH 18/62] drm/i915: Rename drm_gem_object_unreference in preparation for lockless free Chris Wilson
2016-06-03 16:36 ` [PATCH 19/62] drm/i915: Rename drm_gem_object_unreference_unlocked " Chris Wilson
2016-06-03 16:36 ` [PATCH 20/62] drm/i915: Disable waitboosting for fence_wait() Chris Wilson
2016-06-03 16:36 ` [PATCH 21/62] drm/i915: Disable waitboosting for mmioflips/semaphores Chris Wilson
2016-06-03 16:36 ` [PATCH 22/62] drm/i915: Treat ringbuffer writes as write to normal memory Chris Wilson
2016-06-03 16:36 ` [PATCH 23/62] drm/i915: Rename ring->virtual_start as ring->vaddr Chris Wilson
2016-06-03 16:36 ` [PATCH 24/62] drm/i915: Convert i915_semaphores_is_enabled over to early sanitize Chris Wilson
2016-06-03 16:36 ` [PATCH 25/62] drm/i915: Unify intel_logical_ring_emit and intel_ring_emit Chris Wilson
2016-06-03 16:36 ` [PATCH 26/62] drm/i915: Rename request->ring to request->engine Chris Wilson
2016-06-06 13:42   ` Tvrtko Ursulin
2016-06-03 16:36 ` [PATCH 27/62] drm/i915: Rename request->ringbuf to request->ring Chris Wilson
2016-06-06 13:44   ` Tvrtko Ursulin
2016-06-08  9:18     ` Daniel Vetter
2016-06-03 16:36 ` [PATCH 28/62] drm/i915: Rename backpointer from intel_ringbuffer to intel_engine_cs Chris Wilson
2016-06-06 13:45   ` Tvrtko Ursulin
2016-06-03 16:36 ` [PATCH 29/62] drm/i915: Rename intel_context[engine].ringbuf Chris Wilson
2016-06-03 16:36 ` [PATCH 30/62] drm/i915: Rename struct intel_ringbuffer to struct intel_ring Chris Wilson
2016-06-03 16:36 ` [PATCH 31/62] drm/i915: Rename residual ringbuf parameters Chris Wilson
2016-06-03 16:36 ` [PATCH 32/62] drm/i915: Rename intel_pin_and_map_ring() Chris Wilson
2016-06-03 16:36 ` [PATCH 33/62] drm/i915: Remove obsolete engine->gpu_caches_dirty Chris Wilson
2016-06-03 16:36 ` [PATCH 34/62] drm/i915: Simplify request_alloc by returning the allocated request Chris Wilson
2016-06-03 16:37 ` [PATCH 35/62] drm/i915: Unify legacy/execlists emission of MI_BATCHBUFFER_START Chris Wilson
2016-06-03 16:37 ` [PATCH 36/62] drm/i915: Convert engine->write_tail to operate on a request Chris Wilson
2016-06-03 16:37 ` [PATCH 37/62] drm/i915: Unify request submission Chris Wilson
2016-06-03 16:37 ` [PATCH 38/62] drm/i915: Stop passing caller's num_dwords to engine->semaphore.signal() Chris Wilson
2016-06-03 16:37 ` [PATCH 39/62] drm/i915: Reuse legacy breadcrumbs + tail emission Chris Wilson
2016-06-03 16:37 ` [PATCH 40/62] drm/i915: Remove duplicate golden render state init from execlists Chris Wilson
2016-06-03 16:37 ` [PATCH 41/62] drm/i915: Unify legacy/execlists submit_execbuf callbacks Chris Wilson
2016-06-03 16:37 ` [PATCH 42/62] drm/i915: Simplify calling engine->sync_to Chris Wilson
2016-06-03 16:37 ` [PATCH 43/62] drm/i915: Introduce i915_gem_active for request tracking Chris Wilson
2016-06-03 16:37 ` [PATCH 44/62] drm/i915: Prepare i915_gem_active for annotations Chris Wilson
2016-06-03 16:37 ` [PATCH 45/62] drm/i915: Mark up i915_gem_active for locking annotation Chris Wilson
2016-06-03 16:37 ` [PATCH 46/62] drm/i915: Refactor blocking waits Chris Wilson
2016-06-03 16:37 ` [PATCH 47/62] drm/i915: Rename request->list to link for consistency Chris Wilson
2016-06-03 16:37 ` [PATCH 48/62] drm/i915: Remove obsolete i915_gem_object_flush_active() Chris Wilson
2016-06-03 16:37 ` [PATCH 49/62] drm/i915: Refactor activity tracking for requests Chris Wilson
2016-06-03 16:37 ` [PATCH 50/62] drm/i915: Double check activity before relocations Chris Wilson
2016-06-03 16:37 ` [PATCH 51/62] drm/i915: Move request list retirement to i915_gem_request.c Chris Wilson
2016-06-03 16:37 ` [PATCH 52/62] drm/i915: Amalgamate GGTT/ppGTT vma debug list walkers Chris Wilson
2016-06-03 16:37 ` [PATCH 53/62] drm/i915: Split early global GTT initialisation Chris Wilson
2016-06-03 16:37 ` [PATCH 54/62] drm/i915: Store owning file on the i915_address_space Chris Wilson
2016-06-03 16:37 ` [PATCH 55/62] drm/i915: i915_vma_move_to_active prep patch Chris Wilson
2016-06-03 16:37 ` [PATCH 56/62] drm/i915: Count how many VMA are bound for an object Chris Wilson
2016-06-03 16:37 ` [PATCH 57/62] drm/i915: Be more careful when unbinding vma Chris Wilson
2016-06-03 16:37 ` [PATCH 58/62] drm/i915: Kill drop_pages() Chris Wilson
2016-06-03 16:37 ` [PATCH 59/62] drm/i915: Track active vma requests Chris Wilson
2016-06-03 16:37 ` [PATCH 60/62] drm/i915: Release vma when the handle is closed Chris Wilson
2016-06-03 16:37 ` [PATCH 61/62] drm/i915: Mark the context and address space as closed Chris Wilson
2016-06-03 16:37 ` [PATCH 62/62] Revert "drm/i915: Clean up associated VMAs on context destruction" Chris Wilson
2016-06-05  5:24 ` ✗ Ro.CI.BAT: failure for series starting with [01/62] drm/i915: Only start retire worker when idle Patchwork
2016-06-08  9:30 ` The vma leak fix from yonder 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=1465215131.7623.0.camel@linux.intel.com \
    --to=joonas.lahtinen@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).