lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Wed, 23 Dec 2020 16:03:54 +0800 From: Yejune Deng <yejune.deng@...il.com> To: alexander.deucher@....com, christian.koenig@....com, airlied@...ux.ie, daniel@...ll.ch, nirmoy.das@....com, luben.tuikov@....com, Hawking.Zhang@....com, le.ma@....com, yejune.deng@...il.com Cc: amd-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org Subject: [PATCH] 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 <yejune.deng@...il.com> --- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c index 0350205..af26ec2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c @@ -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) -- 1.9.1
Powered by blists - more mailing lists