Commit 16bb81d5 authored by Christian König's avatar Christian König Committed by Greg Kroah-Hartman

drm/amdgpu: grab the id mgr lock while accessing passid_mapping

[ Upstream commit 6817bf28 ]

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: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarChunming Zhou <david1.zhou@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent cfcf92d8
...@@ -700,10 +700,8 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, bool need_ ...@@ -700,10 +700,8 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, bool need_
id->oa_base != job->oa_base || id->oa_base != job->oa_base ||
id->oa_size != job->oa_size); id->oa_size != job->oa_size);
bool vm_flush_needed = job->vm_needs_flush; 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; struct dma_fence *fence = NULL;
bool pasid_mapping_needed;
unsigned patch_offset = 0; unsigned patch_offset = 0;
int r; int r;
...@@ -713,6 +711,12 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, bool need_ ...@@ -713,6 +711,12 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, bool need_
pasid_mapping_needed = true; 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; gds_switch_needed &= !!ring->funcs->emit_gds_switch;
vm_flush_needed &= !!ring->funcs->emit_vm_flush && vm_flush_needed &= !!ring->funcs->emit_vm_flush &&
job->vm_pd_addr != AMDGPU_BO_INVALID_OFFSET; job->vm_pd_addr != AMDGPU_BO_INVALID_OFFSET;
...@@ -752,9 +756,11 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, bool need_ ...@@ -752,9 +756,11 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, bool need_
} }
if (pasid_mapping_needed) { if (pasid_mapping_needed) {
mutex_lock(&id_mgr->lock);
id->pasid = job->pasid; id->pasid = job->pasid;
dma_fence_put(id->pasid_mapping); dma_fence_put(id->pasid_mapping);
id->pasid_mapping = dma_fence_get(fence); id->pasid_mapping = dma_fence_get(fence);
mutex_unlock(&id_mgr->lock);
} }
dma_fence_put(fence); dma_fence_put(fence);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment