diff options
author | Andrey Grodzovsky <andrey.grodzovsky@amd.com> | 2017-10-10 16:50:17 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-10-19 15:26:59 -0400 |
commit | 0ae94444c08a0adf2fab4aab26be0646ee445a19 (patch) | |
tree | d5bc47553183dfe5ec29a23fe3e7d78f1906fc2d /drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |
parent | ad864d243826cedc53404a1c0db7d1e38ddceb84 (diff) |
drm/amdgpu: Move old fence waiting before reservation lock is aquired v2
Helps avoiding deadlock during GPU reset.
Added mutex to amdgpu_ctx to preserve order of fences on a ring.
v2:
Put waiting logic in a function in a seperate function in amdgpu_ctx.c
Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 9166d5e1e557..5de092eab0fa 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |||
@@ -90,6 +90,8 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data) | |||
90 | goto free_chunk; | 90 | goto free_chunk; |
91 | } | 91 | } |
92 | 92 | ||
93 | mutex_lock(&p->ctx->lock); | ||
94 | |||
93 | /* get chunks */ | 95 | /* get chunks */ |
94 | chunk_array_user = u64_to_user_ptr(cs->in.chunks); | 96 | chunk_array_user = u64_to_user_ptr(cs->in.chunks); |
95 | if (copy_from_user(chunk_array, chunk_array_user, | 97 | if (copy_from_user(chunk_array, chunk_array_user, |
@@ -737,8 +739,10 @@ static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser, int error, | |||
737 | 739 | ||
738 | dma_fence_put(parser->fence); | 740 | dma_fence_put(parser->fence); |
739 | 741 | ||
740 | if (parser->ctx) | 742 | if (parser->ctx) { |
743 | mutex_unlock(&parser->ctx->lock); | ||
741 | amdgpu_ctx_put(parser->ctx); | 744 | amdgpu_ctx_put(parser->ctx); |
745 | } | ||
742 | if (parser->bo_list) | 746 | if (parser->bo_list) |
743 | amdgpu_bo_list_put(parser->bo_list); | 747 | amdgpu_bo_list_put(parser->bo_list); |
744 | 748 | ||
@@ -895,9 +899,7 @@ static int amdgpu_cs_ib_vm_chunk(struct amdgpu_device *adev, | |||
895 | r = amdgpu_ring_parse_cs(ring, p, j); | 899 | r = amdgpu_ring_parse_cs(ring, p, j); |
896 | if (r) | 900 | if (r) |
897 | return r; | 901 | return r; |
898 | |||
899 | } | 902 | } |
900 | |||
901 | j++; | 903 | j++; |
902 | } | 904 | } |
903 | 905 | ||
@@ -985,7 +987,7 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev, | |||
985 | parser->job->ring->funcs->type == AMDGPU_RING_TYPE_VCE)) | 987 | parser->job->ring->funcs->type == AMDGPU_RING_TYPE_VCE)) |
986 | return -EINVAL; | 988 | return -EINVAL; |
987 | 989 | ||
988 | return 0; | 990 | return amdgpu_ctx_wait_prev_fence(parser->ctx, parser->job->ring->idx); |
989 | } | 991 | } |
990 | 992 | ||
991 | static int amdgpu_cs_process_fence_dep(struct amdgpu_cs_parser *p, | 993 | static int amdgpu_cs_process_fence_dep(struct amdgpu_cs_parser *p, |