aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
diff options
context:
space:
mode:
authorMonk Liu <[email protected]>2017-04-07 10:39:07 +0000
committerAlex Deucher <[email protected]>2017-04-28 20:38:00 +0000
commitd7b1eeb2ca039d04f1a1fcb241920cb112b4b52a (patch)
tree60d4a49eeb0baf5e3a3181cec53d5c4033af4c97 /drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
parentdrm/amd/amdgpu: Port gfx9 driver over to new read/write macros (diff)
downloadkernel-d7b1eeb2ca039d04f1a1fcb241920cb112b4b52a.tar.gz
kernel-d7b1eeb2ca039d04f1a1fcb241920cb112b4b52a.zip
drm/amdgpu:fix race condition
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 <[email protected]> Reviewed-by: Christian König <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
index cf0500671353..90d1ac8a80f8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
@@ -273,6 +273,9 @@ struct dma_fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx,
spin_lock(&ctx->ring_lock);
+ if (seq == ~0ull)
+ seq = ctx->rings[ring->idx].sequence - 1;
+
if (seq >= cring->sequence) {
spin_unlock(&ctx->ring_lock);
return ERR_PTR(-EINVAL);