Skip to content

Commit 20a5f5a

Browse files
ChristianKoenigAMDalexdeucher
authored andcommitted
drm/amdgpu: fix concurrent VM flushes on Vega/Navi v2
Starting with Vega the hardware supports concurrent flushes of VMID which can be used to implement per process VMID allocation. But concurrent flushes are mutual exclusive with back to back VMID allocations, fix this to avoid a VMID used in two ways at the same time. v2: don't set ring to NULL Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: James Zhu <James.Zhu@amd.com> Tested-by: James Zhu <James.Zhu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org
1 parent d89f604 commit 20a5f5a

3 files changed

Lines changed: 18 additions & 8 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,11 @@ static int amdgpu_vmid_grab_idle(struct amdgpu_vm *vm,
215215
/* Check if we have an idle VMID */
216216
i = 0;
217217
list_for_each_entry((*idle), &id_mgr->ids_lru, list) {
218-
fences[i] = amdgpu_sync_peek_fence(&(*idle)->active, ring);
218+
/* Don't use per engine and per process VMID at the same time */
219+
struct amdgpu_ring *r = adev->vm_manager.concurrent_flush ?
220+
NULL : ring;
221+
222+
fences[i] = amdgpu_sync_peek_fence(&(*idle)->active, r);
219223
if (!fences[i])
220224
break;
221225
++i;
@@ -281,7 +285,7 @@ static int amdgpu_vmid_grab_reserved(struct amdgpu_vm *vm,
281285
if (updates && (*id)->flushed_updates &&
282286
updates->context == (*id)->flushed_updates->context &&
283287
!dma_fence_is_later(updates, (*id)->flushed_updates))
284-
updates = NULL;
288+
updates = NULL;
285289

286290
if ((*id)->owner != vm->immediate.fence_context ||
287291
job->vm_pd_addr != (*id)->pd_gpu_addr ||
@@ -290,6 +294,10 @@ static int amdgpu_vmid_grab_reserved(struct amdgpu_vm *vm,
290294
!dma_fence_is_signaled((*id)->last_flush))) {
291295
struct dma_fence *tmp;
292296

297+
/* Don't use per engine and per process VMID at the same time */
298+
if (adev->vm_manager.concurrent_flush)
299+
ring = NULL;
300+
293301
/* to prevent one context starved by another context */
294302
(*id)->pd_gpu_addr = 0;
295303
tmp = amdgpu_sync_peek_fence(&(*id)->active, ring);
@@ -365,12 +373,7 @@ static int amdgpu_vmid_grab_used(struct amdgpu_vm *vm,
365373
if (updates && (!flushed || dma_fence_is_later(updates, flushed)))
366374
needs_flush = true;
367375

368-
/* Concurrent flushes are only possible starting with Vega10 and
369-
* are broken on Navi10 and Navi14.
370-
*/
371-
if (needs_flush && (adev->asic_type < CHIP_VEGA10 ||
372-
adev->asic_type == CHIP_NAVI10 ||
373-
adev->asic_type == CHIP_NAVI14))
376+
if (needs_flush && !adev->vm_manager.concurrent_flush)
374377
continue;
375378

376379
/* Good, we can use this VMID. Remember this submission as

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3148,6 +3148,12 @@ void amdgpu_vm_manager_init(struct amdgpu_device *adev)
31483148
{
31493149
unsigned i;
31503150

3151+
/* Concurrent flushes are only possible starting with Vega10 and
3152+
* are broken on Navi10 and Navi14.
3153+
*/
3154+
adev->vm_manager.concurrent_flush = !(adev->asic_type < CHIP_VEGA10 ||
3155+
adev->asic_type == CHIP_NAVI10 ||
3156+
adev->asic_type == CHIP_NAVI14);
31513157
amdgpu_vmid_mgr_init(adev);
31523158

31533159
adev->vm_manager.fence_context =

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ struct amdgpu_vm_manager {
331331
/* Handling of VMIDs */
332332
struct amdgpu_vmid_mgr id_mgr[AMDGPU_MAX_VMHUBS];
333333
unsigned int first_kfd_vmid;
334+
bool concurrent_flush;
334335

335336
/* Handling of VM fences */
336337
u64 fence_context;

0 commit comments

Comments
 (0)