* [PATCH] drm/amdgpu: kref_put() may not require a lock.
@ 2020-12-23 8:03 Yejune Deng
0 siblings, 0 replies; only message in thread
From: Yejune Deng @ 2020-12-23 8:03 UTC (permalink / raw)
To: alexander.deucher, christian.koenig, airlied, daniel, nirmoy.das,
luben.tuikov, Hawking.Zhang, le.ma, yejune.deng
Cc: amd-gfx, dri-devel, linux-kernel
kref_put() can be outside of mutex_lock(),and use amdgpu_ctx_put()
instead of kref_put().
Signed-off-by: Yejune Deng <yejune.deng@gmail.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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-12-23 8:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-23 8:03 [PATCH] drm/amdgpu: kref_put() may not require a lock Yejune Deng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®