[PATCH] drm/amdgpu:fix race condition
Monk Liu
Monk.Liu at amd.com
Mon Apr 10 07:18:01 UTC 2017
sequence is protected by spinlock so don't access sequence
in paramter seq when invoking this function.
~0 means to get the latest sequence number and 0 means none to
get.
Change-Id: Ib7a03f3cf5594deeb4ad333cc59b47a6bddfd1ad
Signed-off-by: Monk Liu <Monk.Liu at amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
index 6d86eae..71d5f25 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
@@ -277,6 +277,13 @@ struct fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx,
spin_lock(&ctx->ring_lock);
+ if (seq == ~0) {
+ seq = ctx->rings[ring->idx].sequence - 1;
+ } else if(seq == 0) {
+ spin_unlock(&ctx->ring_lock);
+ return NULL;
+ }
+
if (seq >= cring->sequence) {
spin_unlock(&ctx->ring_lock);
return ERR_PTR(-EINVAL);
--
2.7.4
More information about the amd-gfx
mailing list