]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/amdgpu:fix race condition
authorMonk Liu <Monk.Liu@amd.com>
Fri, 7 Apr 2017 10:39:07 +0000 (18:39 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 28 Apr 2017 20:38:00 +0000 (16:38 -0400)
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@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
include/uapi/drm/amdgpu_drm.h

index cf05006713531ce920c62ca105929907b7457fcd..90d1ac8a80f8b872dfbb15ac1b00d6a4c2e7c24b 100644 (file)
@@ -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);
index 516a9f2857307fd672557e2761692fd1b9fbbbb2..92262d81d41e2b6ffa45cb7aff9cd187465ef368 100644 (file)
@@ -295,7 +295,10 @@ union drm_amdgpu_gem_wait_idle {
 };
 
 struct drm_amdgpu_wait_cs_in {
-       /** Command submission handle */
+       /* Command submission handle
+         * handle equals 0 means none to wait for
+         * handle equal ~0ull meanas wait for the latest sequence number
+         */
        __u64 handle;
        /** Absolute timeout to wait */
        __u64 timeout;