Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: check flush fence context instead of same ring v2

Otherwise we can run into the following situation:

1. Process A grabs ID 1 for ring 0.
2. Process B grabs ID 1 for ring 0.
3. Process A grabs ID 1 for ring 1.
4. Process A tries to reuse ID1 for ring 0 but things he doesn't need to flush.

v2: check the context of the flush fence instead of messing with the owner field.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Christian König and committed by
Alex Deucher
090b767e d3200be6

+6 -3
+6 -3
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
··· 195 195 struct amdgpu_job *job) 196 196 { 197 197 struct amdgpu_device *adev = ring->adev; 198 + uint64_t fence_context = adev->fence_context + ring->idx; 198 199 struct fence *updates = sync->last_vm_update; 199 200 struct amdgpu_vm_id *id, *idle; 200 201 struct fence **fences; ··· 255 254 i = ring->idx; 256 255 do { 257 256 struct fence *flushed; 258 - bool same_ring = ring->idx == i; 259 257 260 258 id = vm->ids[i++]; 261 259 if (i == AMDGPU_MAX_RINGS) ··· 272 272 if (job->vm_pd_addr != id->pd_gpu_addr) 273 273 continue; 274 274 275 - if (!same_ring && 276 - (!id->last_flush || !fence_is_signaled(id->last_flush))) 275 + if (!id->last_flush) 276 + continue; 277 + 278 + if (id->last_flush->context != fence_context && 279 + !fence_is_signaled(id->last_flush)) 277 280 continue; 278 281 279 282 flushed = id->flushed_updates;