Skip to content

Commit 99194e6

Browse files
ChristianKoenigAMDalexdeucher
authored andcommitted
drm/amdgpu: reject gang submit on reserved VMIDs
A gang submit won't work if the VMID is reserved and we can't flush out VM changes from multiple engines at the same time. Signed-off-by: Christian König <[email protected]> Reviewed-by: Alex Deucher <[email protected]> Signed-off-by: Alex Deucher <[email protected]> (cherry picked from commit 320debc)
1 parent 256abd8 commit 99194e6

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,21 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p)
10931093
unsigned int i;
10941094
int r;
10951095

1096+
/*
1097+
* We can't use gang submit on with reserved VMIDs when the VM changes
1098+
* can't be invalidated by more than one engine at the same time.
1099+
*/
1100+
if (p->gang_size > 1 && !p->adev->vm_manager.concurrent_flush) {
1101+
for (i = 0; i < p->gang_size; ++i) {
1102+
struct drm_sched_entity *entity = p->entities[i];
1103+
struct drm_gpu_scheduler *sched = entity->rq->sched;
1104+
struct amdgpu_ring *ring = to_amdgpu_ring(sched);
1105+
1106+
if (amdgpu_vmid_uses_reserved(vm, ring->vm_hub))
1107+
return -EINVAL;
1108+
}
1109+
}
1110+
10961111
r = amdgpu_vm_clear_freed(adev, vm, NULL);
10971112
if (r)
10981113
return r;

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ int amdgpu_vmid_grab(struct amdgpu_vm *vm, struct amdgpu_ring *ring,
406406
if (r || !idle)
407407
goto error;
408408

409-
if (vm->reserved_vmid[vmhub] || (enforce_isolation && (vmhub == AMDGPU_GFXHUB(0)))) {
409+
if (amdgpu_vmid_uses_reserved(vm, vmhub)) {
410410
r = amdgpu_vmid_grab_reserved(vm, ring, job, &id, fence);
411411
if (r || !id)
412412
goto error;
@@ -456,6 +456,19 @@ int amdgpu_vmid_grab(struct amdgpu_vm *vm, struct amdgpu_ring *ring,
456456
return r;
457457
}
458458

459+
/*
460+
* amdgpu_vmid_uses_reserved - check if a VM will use a reserved VMID
461+
* @vm: the VM to check
462+
* @vmhub: the VMHUB which will be used
463+
*
464+
* Returns: True if the VM will use a reserved VMID.
465+
*/
466+
bool amdgpu_vmid_uses_reserved(struct amdgpu_vm *vm, unsigned int vmhub)
467+
{
468+
return vm->reserved_vmid[vmhub] ||
469+
(enforce_isolation && (vmhub == AMDGPU_GFXHUB(0)));
470+
}
471+
459472
int amdgpu_vmid_alloc_reserved(struct amdgpu_device *adev,
460473
unsigned vmhub)
461474
{

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ void amdgpu_pasid_free_delayed(struct dma_resv *resv,
7878

7979
bool amdgpu_vmid_had_gpu_reset(struct amdgpu_device *adev,
8080
struct amdgpu_vmid *id);
81+
bool amdgpu_vmid_uses_reserved(struct amdgpu_vm *vm, unsigned int vmhub);
8182
int amdgpu_vmid_alloc_reserved(struct amdgpu_device *adev,
8283
unsigned vmhub);
8384
void amdgpu_vmid_free_reserved(struct amdgpu_device *adev,

0 commit comments

Comments
 (0)