Lines Matching refs:ctx

29 		    struct amdgpu_ctx *ctx)  in amdgpu_ctx_init()  argument
34 memset(ctx, 0, sizeof(*ctx)); in amdgpu_ctx_init()
35 ctx->adev = adev; in amdgpu_ctx_init()
36 kref_init(&ctx->refcount); in amdgpu_ctx_init()
37 spin_lock_init(&ctx->ring_lock); in amdgpu_ctx_init()
39 ctx->rings[i].sequence = 1; in amdgpu_ctx_init()
50 &ctx->rings[i].entity, in amdgpu_ctx_init()
59 &ctx->rings[j].entity); in amdgpu_ctx_init()
60 kfree(ctx); in amdgpu_ctx_init()
67 void amdgpu_ctx_fini(struct amdgpu_ctx *ctx) in amdgpu_ctx_fini() argument
69 struct amdgpu_device *adev = ctx->adev; in amdgpu_ctx_fini()
77 fence_put(ctx->rings[i].fences[j]); in amdgpu_ctx_fini()
82 &ctx->rings[i].entity); in amdgpu_ctx_fini()
91 struct amdgpu_ctx *ctx; in amdgpu_ctx_alloc() local
94 ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); in amdgpu_ctx_alloc()
95 if (!ctx) in amdgpu_ctx_alloc()
99 r = idr_alloc(&mgr->ctx_handles, ctx, 1, 0, GFP_KERNEL); in amdgpu_ctx_alloc()
102 kfree(ctx); in amdgpu_ctx_alloc()
106 r = amdgpu_ctx_init(adev, false, ctx); in amdgpu_ctx_alloc()
114 struct amdgpu_ctx *ctx; in amdgpu_ctx_do_release() local
116 ctx = container_of(ref, struct amdgpu_ctx, refcount); in amdgpu_ctx_do_release()
118 amdgpu_ctx_fini(ctx); in amdgpu_ctx_do_release()
120 kfree(ctx); in amdgpu_ctx_do_release()
126 struct amdgpu_ctx *ctx; in amdgpu_ctx_free() local
129 ctx = idr_find(&mgr->ctx_handles, id); in amdgpu_ctx_free()
130 if (ctx) { in amdgpu_ctx_free()
132 kref_put(&ctx->refcount, amdgpu_ctx_do_release); in amdgpu_ctx_free()
144 struct amdgpu_ctx *ctx; in amdgpu_ctx_query() local
153 ctx = idr_find(&mgr->ctx_handles, id); in amdgpu_ctx_query()
154 if (!ctx) { in amdgpu_ctx_query()
166 if (ctx->reset_counter == reset_counter) in amdgpu_ctx_query()
170 ctx->reset_counter = reset_counter; in amdgpu_ctx_query()
209 struct amdgpu_ctx *ctx; in amdgpu_ctx_get() local
218 ctx = idr_find(&mgr->ctx_handles, id); in amdgpu_ctx_get()
219 if (ctx) in amdgpu_ctx_get()
220 kref_get(&ctx->refcount); in amdgpu_ctx_get()
222 return ctx; in amdgpu_ctx_get()
225 int amdgpu_ctx_put(struct amdgpu_ctx *ctx) in amdgpu_ctx_put() argument
227 if (ctx == NULL) in amdgpu_ctx_put()
230 kref_put(&ctx->refcount, amdgpu_ctx_do_release); in amdgpu_ctx_put()
234 uint64_t amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, struct amdgpu_ring *ring, in amdgpu_ctx_add_fence() argument
237 struct amdgpu_ctx_ring *cring = & ctx->rings[ring->idx]; in amdgpu_ctx_add_fence()
253 spin_lock(&ctx->ring_lock); in amdgpu_ctx_add_fence()
256 spin_unlock(&ctx->ring_lock); in amdgpu_ctx_add_fence()
263 struct fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx, in amdgpu_ctx_get_fence() argument
266 struct amdgpu_ctx_ring *cring = & ctx->rings[ring->idx]; in amdgpu_ctx_get_fence()
269 spin_lock(&ctx->ring_lock); in amdgpu_ctx_get_fence()
272 spin_unlock(&ctx->ring_lock); in amdgpu_ctx_get_fence()
278 spin_unlock(&ctx->ring_lock); in amdgpu_ctx_get_fence()
283 spin_unlock(&ctx->ring_lock); in amdgpu_ctx_get_fence()
296 struct amdgpu_ctx *ctx; in amdgpu_ctx_mgr_fini() local
302 idr_for_each_entry(idp, ctx, id) { in amdgpu_ctx_mgr_fini()
303 if (kref_put(&ctx->refcount, amdgpu_ctx_do_release) != 1) in amdgpu_ctx_mgr_fini()
304 DRM_ERROR("ctx %p is still alive\n", ctx); in amdgpu_ctx_mgr_fini()