| From 0b3f5fe37cfa2173f762258267158b0b6c440e5b Mon Sep 17 00:00:00 2001 |
| From: =?UTF-8?q?Christian=20K=C3=B6nig?= <christian.koenig@amd.com> |
| Date: Mon, 9 Sep 2019 13:57:32 +0200 |
| Subject: [PATCH] drm/amdgpu: grab the id mgr lock while accessing |
| passid_mapping |
| MIME-Version: 1.0 |
| Content-Type: text/plain; charset=UTF-8 |
| Content-Transfer-Encoding: 8bit |
| |
| commit 6817bf283b2b851095825ec7f0e9f10398e09125 upstream. |
| |
| Need to make sure that we actually dropping the right fence. |
| Could be done with RCU as well, but to complicated for a fix. |
| |
| Signed-off-by: Christian Kรถnig <christian.koenig@amd.com> |
| Reviewed-by: Chunming Zhou <david1.zhou@amd.com> |
| Signed-off-by: Alex Deucher <alexander.deucher@amd.com> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c |
| index 4f10f5aba00b..7ff2afec477e 100644 |
| --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c |
| +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c |
| @@ -1036,10 +1036,8 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, bool need_ |
| id->oa_base != job->oa_base || |
| id->oa_size != job->oa_size); |
| bool vm_flush_needed = job->vm_needs_flush; |
| - bool pasid_mapping_needed = id->pasid != job->pasid || |
| - !id->pasid_mapping || |
| - !dma_fence_is_signaled(id->pasid_mapping); |
| struct dma_fence *fence = NULL; |
| + bool pasid_mapping_needed; |
| unsigned patch_offset = 0; |
| int r; |
| |
| @@ -1049,6 +1047,12 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, bool need_ |
| pasid_mapping_needed = true; |
| } |
| |
| + mutex_lock(&id_mgr->lock); |
| + if (id->pasid != job->pasid || !id->pasid_mapping || |
| + !dma_fence_is_signaled(id->pasid_mapping)) |
| + pasid_mapping_needed = true; |
| + mutex_unlock(&id_mgr->lock); |
| + |
| gds_switch_needed &= !!ring->funcs->emit_gds_switch; |
| vm_flush_needed &= !!ring->funcs->emit_vm_flush && |
| job->vm_pd_addr != AMDGPU_BO_INVALID_OFFSET; |
| @@ -1088,9 +1092,11 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, bool need_ |
| } |
| |
| if (pasid_mapping_needed) { |
| + mutex_lock(&id_mgr->lock); |
| id->pasid = job->pasid; |
| dma_fence_put(id->pasid_mapping); |
| id->pasid_mapping = dma_fence_get(fence); |
| + mutex_unlock(&id_mgr->lock); |
| } |
| dma_fence_put(fence); |
| |
| -- |
| 2.7.4 |
| |