drm/amdgpu: kref_put() may not require a lock.
Subsystems (2)
PATCH 1/1 drm/amdgpu: kref_put() may not require a lock.
kref_put() can be outside of mutex_lock(),and use amdgpu_ctx_put() instead of kref_put().
Signed-off-by Yejune Deng <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +11 -12
@@ -282,6 +282,15 @@ static void amdgpu_ctx_do_release(struct kref *ref)amdgpu_ctx_fini (ref); } +int amdgpu_ctx_put (struct amdgpu_ctx *ctx) +{ +if (ctx ==NULL ) +return -EINVAL ; + +kref_put (&ctx->refcount, amdgpu_ctx_do_release); +return 0 ; +} +static int amdgpu_ctx_free (struct amdgpu_fpriv *fpriv,uint32_t id) {struct amdgpu_ctx_mgr *mgr = &fpriv->ctx_mgr;
@@ -289,10 +298,9 @@ static int amdgpu_ctx_free(struct amdgpu_fpriv *fpriv, uint32_t id)mutex_lock (&mgr->lock); ctx =idr_remove (&mgr->ctx_handles, id); -if (ctx) -kref_put (&ctx->refcount, amdgpu_ctx_do_release);mutex_unlock (&mgr->lock); -return ctx ?0 : -EINVAL ; + +return amdgpu_ctx_put (ctx); } static int amdgpu_ctx_query(struct amdgpu_device *adev,
@@ -439,15 +447,6 @@ struct amdgpu_ctx *amdgpu_ctx_get(struct amdgpu_fpriv *fpriv, uint32_t id)return ctx; } -int amdgpu_ctx_put (struct amdgpu_ctx *ctx) -{ -if (ctx ==NULL ) -return -EINVAL ; - -kref_put (&ctx->refcount, amdgpu_ctx_do_release); -return 0 ; -} -void amdgpu_ctx_add_fence (struct amdgpu_ctx *ctx,struct drm_sched_entity *entity,struct dma_fence *fence,uint64_t *handle)
Signature · 1 line
1.9.1