diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-07-20 08:31:50 -0400 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-07-20 08:40:10 -0400 |
commit | 9a6feaf0d74f91eeef23d0ee72c5ce69a559b31b (patch) | |
tree | 9ab77d8e41a502b179a7679706b0183399e56513 | |
parent | e8a261ea639998d79dee78220098b25f38801bcb (diff) |
drm/i915: Rename i915_gem_context_reference/unreference()
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.
s/i915_gem_context_reference/i915_gem_context_get/
s/i915_gem_context_unreference/i915_gem_context_put/
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>
Link: http://patchwork.freedesktop.org/patch/msgid/1469005202-9659-3-git-send-email-chris@chris-wilson.co.uk
Link: http://patchwork.freedesktop.org/patch/msgid/1469017917-15134-2-git-send-email-chris@chris-wilson.co.uk
-rw-r--r-- | drivers/gpu/drm/i915/i915_drv.h | 6 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem_context.c | 22 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem_execbuffer.c | 6 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem_request.c | 7 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_lrc.c | 4 | ||||
-rw-r--r-- | 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 e163a9487750..2131e7f1e57a 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
@@ -3338,12 +3338,14 @@ i915_gem_context_lookup(struct drm_i915_file_private *file_priv, u32 id) | |||
3338 | return ctx; | 3338 | return ctx; |
3339 | } | 3339 | } |
3340 | 3340 | ||
3341 | static inline void i915_gem_context_reference(struct i915_gem_context *ctx) | 3341 | static inline struct i915_gem_context * |
3342 | i915_gem_context_get(struct i915_gem_context *ctx) | ||
3342 | { | 3343 | { |
3343 | kref_get(&ctx->ref); | 3344 | kref_get(&ctx->ref); |
3345 | return ctx; | ||
3344 | } | 3346 | } |
3345 | 3347 | ||
3346 | static inline void i915_gem_context_unreference(struct i915_gem_context *ctx) | 3348 | static inline void i915_gem_context_put(struct i915_gem_context *ctx) |
3347 | { | 3349 | { |
3348 | lockdep_assert_held(&ctx->i915->drm.struct_mutex); | 3350 | lockdep_assert_held(&ctx->i915->drm.struct_mutex); |
3349 | kref_put(&ctx->ref, i915_gem_context_free); | 3351 | 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 3b636161256c..71517918853a 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c | |||
@@ -305,7 +305,7 @@ __create_hw_context(struct drm_device *dev, | |||
305 | return ctx; | 305 | return ctx; |
306 | 306 | ||
307 | err_out: | 307 | err_out: |
308 | i915_gem_context_unreference(ctx); | 308 | i915_gem_context_put(ctx); |
309 | return ERR_PTR(ret); | 309 | return ERR_PTR(ret); |
310 | } | 310 | } |
311 | 311 | ||
@@ -333,7 +333,7 @@ i915_gem_create_context(struct drm_device *dev, | |||
333 | DRM_DEBUG_DRIVER("PPGTT setup failed (%ld)\n", | 333 | DRM_DEBUG_DRIVER("PPGTT setup failed (%ld)\n", |
334 | PTR_ERR(ppgtt)); | 334 | PTR_ERR(ppgtt)); |
335 | idr_remove(&file_priv->context_idr, ctx->user_handle); | 335 | idr_remove(&file_priv->context_idr, ctx->user_handle); |
336 | i915_gem_context_unreference(ctx); | 336 | i915_gem_context_put(ctx); |
337 | return ERR_CAST(ppgtt); | 337 | return ERR_CAST(ppgtt); |
338 | } | 338 | } |
339 | 339 | ||
@@ -390,7 +390,7 @@ static void i915_gem_context_unpin(struct i915_gem_context *ctx, | |||
390 | if (ce->state) | 390 | if (ce->state) |
391 | i915_gem_object_ggtt_unpin(ce->state); | 391 | i915_gem_object_ggtt_unpin(ce->state); |
392 | 392 | ||
393 | i915_gem_context_unreference(ctx); | 393 | i915_gem_context_put(ctx); |
394 | } | 394 | } |
395 | } | 395 | } |
396 | 396 | ||
@@ -504,7 +504,7 @@ void i915_gem_context_fini(struct drm_device *dev) | |||
504 | 504 | ||
505 | lockdep_assert_held(&dev->struct_mutex); | 505 | lockdep_assert_held(&dev->struct_mutex); |
506 | 506 | ||
507 | i915_gem_context_unreference(dctx); | 507 | i915_gem_context_put(dctx); |
508 | dev_priv->kernel_context = NULL; | 508 | dev_priv->kernel_context = NULL; |
509 | 509 | ||
510 | ida_destroy(&dev_priv->context_hw_ida); | 510 | ida_destroy(&dev_priv->context_hw_ida); |
@@ -515,7 +515,7 @@ static int context_idr_cleanup(int id, void *p, void *data) | |||
515 | struct i915_gem_context *ctx = p; | 515 | struct i915_gem_context *ctx = p; |
516 | 516 | ||
517 | ctx->file_priv = ERR_PTR(-EBADF); | 517 | ctx->file_priv = ERR_PTR(-EBADF); |
518 | i915_gem_context_unreference(ctx); | 518 | i915_gem_context_put(ctx); |
519 | return 0; | 519 | return 0; |
520 | } | 520 | } |
521 | 521 | ||
@@ -827,10 +827,9 @@ static int do_rcs_switch(struct drm_i915_gem_request *req) | |||
827 | 827 | ||
828 | /* obj is kept alive until the next request by its active ref */ | 828 | /* obj is kept alive until the next request by its active ref */ |
829 | i915_gem_object_ggtt_unpin(from->engine[RCS].state); | 829 | i915_gem_object_ggtt_unpin(from->engine[RCS].state); |
830 | i915_gem_context_unreference(from); | 830 | i915_gem_context_put(from); |
831 | } | 831 | } |
832 | i915_gem_context_reference(to); | 832 | engine->last_context = i915_gem_context_get(to); |
833 | engine->last_context = to; | ||
834 | 833 | ||
835 | /* GEN8 does *not* require an explicit reload if the PDPs have been | 834 | /* GEN8 does *not* require an explicit reload if the PDPs have been |
836 | * setup, and we do not wish to move them. | 835 | * setup, and we do not wish to move them. |
@@ -914,10 +913,9 @@ int i915_switch_context(struct drm_i915_gem_request *req) | |||
914 | } | 913 | } |
915 | 914 | ||
916 | if (to != engine->last_context) { | 915 | if (to != engine->last_context) { |
917 | i915_gem_context_reference(to); | ||
918 | if (engine->last_context) | 916 | if (engine->last_context) |
919 | i915_gem_context_unreference(engine->last_context); | 917 | i915_gem_context_put(engine->last_context); |
920 | engine->last_context = to; | 918 | engine->last_context = i915_gem_context_get(to); |
921 | } | 919 | } |
922 | 920 | ||
923 | return 0; | 921 | return 0; |
@@ -1014,7 +1012,7 @@ int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data, | |||
1014 | } | 1012 | } |
1015 | 1013 | ||
1016 | idr_remove(&file_priv->context_idr, ctx->user_handle); | 1014 | idr_remove(&file_priv->context_idr, ctx->user_handle); |
1017 | i915_gem_context_unreference(ctx); | 1015 | i915_gem_context_put(ctx); |
1018 | mutex_unlock(&dev->struct_mutex); | 1016 | mutex_unlock(&dev->struct_mutex); |
1019 | 1017 | ||
1020 | DRM_DEBUG_DRIVER("HW context %d destroyed\n", args->ctx_id); | 1018 | 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 f6724ae210b3..551dd4f549fa 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c | |||
@@ -1509,7 +1509,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, | |||
1509 | goto pre_mutex_err; | 1509 | goto pre_mutex_err; |
1510 | } | 1510 | } |
1511 | 1511 | ||
1512 | i915_gem_context_reference(ctx); | 1512 | i915_gem_context_get(ctx); |
1513 | 1513 | ||
1514 | if (ctx->ppgtt) | 1514 | if (ctx->ppgtt) |
1515 | vm = &ctx->ppgtt->base; | 1515 | vm = &ctx->ppgtt->base; |
@@ -1520,7 +1520,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, | |||
1520 | 1520 | ||
1521 | eb = eb_create(args); | 1521 | eb = eb_create(args); |
1522 | if (eb == NULL) { | 1522 | if (eb == NULL) { |
1523 | i915_gem_context_unreference(ctx); | 1523 | i915_gem_context_put(ctx); |
1524 | mutex_unlock(&dev->struct_mutex); | 1524 | mutex_unlock(&dev->struct_mutex); |
1525 | ret = -ENOMEM; | 1525 | ret = -ENOMEM; |
1526 | goto pre_mutex_err; | 1526 | goto pre_mutex_err; |
@@ -1664,7 +1664,7 @@ err_batch_unpin: | |||
1664 | 1664 | ||
1665 | err: | 1665 | err: |
1666 | /* the request owns the ref now */ | 1666 | /* the request owns the ref now */ |
1667 | i915_gem_context_unreference(ctx); | 1667 | i915_gem_context_put(ctx); |
1668 | eb_destroy(eb); | 1668 | eb_destroy(eb); |
1669 | 1669 | ||
1670 | mutex_unlock(&dev->struct_mutex); | 1670 | 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 04ff97b10c08..60a3a343b3a8 100644 --- a/drivers/gpu/drm/i915/i915_gem_request.c +++ b/drivers/gpu/drm/i915/i915_gem_request.c | |||
@@ -180,7 +180,7 @@ static void i915_gem_request_retire(struct drm_i915_gem_request *request) | |||
180 | request->engine); | 180 | request->engine); |
181 | } | 181 | } |
182 | 182 | ||
183 | i915_gem_context_unreference(request->ctx); | 183 | i915_gem_context_put(request->ctx); |
184 | i915_gem_request_put(request); | 184 | i915_gem_request_put(request); |
185 | } | 185 | } |
186 | 186 | ||
@@ -341,8 +341,7 @@ __i915_gem_request_alloc(struct intel_engine_cs *engine, | |||
341 | 341 | ||
342 | req->i915 = dev_priv; | 342 | req->i915 = dev_priv; |
343 | req->engine = engine; | 343 | req->engine = engine; |
344 | req->ctx = ctx; | 344 | req->ctx = i915_gem_context_get(ctx); |
345 | i915_gem_context_reference(ctx); | ||
346 | 345 | ||
347 | /* | 346 | /* |
348 | * Reserve space in the ring buffer for all the commands required to | 347 | * Reserve space in the ring buffer for all the commands required to |
@@ -364,7 +363,7 @@ __i915_gem_request_alloc(struct intel_engine_cs *engine, | |||
364 | return 0; | 363 | return 0; |
365 | 364 | ||
366 | err_ctx: | 365 | err_ctx: |
367 | i915_gem_context_unreference(ctx); | 366 | i915_gem_context_put(ctx); |
368 | err: | 367 | err: |
369 | kmem_cache_free(dev_priv->requests, req); | 368 | kmem_cache_free(dev_priv->requests, req); |
370 | return ret; | 369 | return ret; |
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c index b23d4cc94cd5..6282fca6229c 100644 --- a/drivers/gpu/drm/i915/intel_lrc.c +++ b/drivers/gpu/drm/i915/intel_lrc.c | |||
@@ -980,7 +980,6 @@ static int intel_lr_context_pin(struct i915_gem_context *ctx, | |||
980 | if (ret) | 980 | if (ret) |
981 | goto unpin_map; | 981 | goto unpin_map; |
982 | 982 | ||
983 | i915_gem_context_reference(ctx); | ||
984 | ce->lrc_vma = i915_gem_obj_to_ggtt(ce->state); | 983 | ce->lrc_vma = i915_gem_obj_to_ggtt(ce->state); |
985 | intel_lr_context_descriptor_update(ctx, engine); | 984 | intel_lr_context_descriptor_update(ctx, engine); |
986 | 985 | ||
@@ -992,6 +991,7 @@ static int intel_lr_context_pin(struct i915_gem_context *ctx, | |||
992 | if (i915.enable_guc_submission) | 991 | if (i915.enable_guc_submission) |
993 | I915_WRITE(GEN8_GTCR, GEN8_GTCR_INVALIDATE); | 992 | I915_WRITE(GEN8_GTCR, GEN8_GTCR_INVALIDATE); |
994 | 993 | ||
994 | i915_gem_context_get(ctx); | ||
995 | return 0; | 995 | return 0; |
996 | 996 | ||
997 | unpin_map: | 997 | unpin_map: |
@@ -1023,7 +1023,7 @@ void intel_lr_context_unpin(struct i915_gem_context *ctx, | |||
1023 | ce->lrc_desc = 0; | 1023 | ce->lrc_desc = 0; |
1024 | ce->lrc_reg_state = NULL; | 1024 | ce->lrc_reg_state = NULL; |
1025 | 1025 | ||
1026 | i915_gem_context_unreference(ctx); | 1026 | i915_gem_context_put(ctx); |
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | static int intel_logical_ring_workarounds_emit(struct drm_i915_gem_request *req) | 1029 | 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 af0bd71e3a36..3a7135d00033 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.c +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c | |||
@@ -2139,7 +2139,7 @@ static int intel_ring_context_pin(struct i915_gem_context *ctx, | |||
2139 | if (ctx == ctx->i915->kernel_context) | 2139 | if (ctx == ctx->i915->kernel_context) |
2140 | ce->initialised = true; | 2140 | ce->initialised = true; |
2141 | 2141 | ||
2142 | i915_gem_context_reference(ctx); | 2142 | i915_gem_context_get(ctx); |
2143 | return 0; | 2143 | return 0; |
2144 | 2144 | ||
2145 | error: | 2145 | error: |
@@ -2160,7 +2160,7 @@ static void intel_ring_context_unpin(struct i915_gem_context *ctx, | |||
2160 | if (ce->state) | 2160 | if (ce->state) |
2161 | i915_gem_object_ggtt_unpin(ce->state); | 2161 | i915_gem_object_ggtt_unpin(ce->state); |
2162 | 2162 | ||
2163 | i915_gem_context_unreference(ctx); | 2163 | i915_gem_context_put(ctx); |
2164 | } | 2164 | } |
2165 | 2165 | ||
2166 | static int intel_init_ring_buffer(struct intel_engine_cs *engine) | 2166 | static int intel_init_ring_buffer(struct intel_engine_cs *engine) |