Skip to contentSkip to conversation

drm/amdgpu: add flag to indicate amdgpu vm context

PATCH In review Alex Sierra 2 participants 3 messages Nov 18, 2019 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/amdgpu: add flag to indicate amdgpu vm context

Flag added to indicate if the amdgpu vm context is used for compute or graphics.

Change-Id Ia813037fda2ec2947d73f5c7328388078fbeebe5
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 2 ++
 2 files changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3 -0
index 3c0bd6472a46..d51ac8771ae0 100644
@@ -2713,6 +2713,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 		goto error_free_direct;
 
 	vm->pte_support_ats = false;
+	vm->is_compute_context = false;
 
 	if (vm_context == AMDGPU_VM_CONTEXT_COMPUTE) {
 		vm->use_cpu_for_update = !!(adev->vm_manager.vm_update_mode &
@@ -2898,6 +2899,7 @@ int amdgpu_vm_make_compute(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 		vm->update_funcs = &amdgpu_vm_sdma_funcs;
 	dma_fence_put(vm->last_update);
 	vm->last_update = NULL;
+	vm->is_compute_context = true;
 
 	if (vm->pasid) {
 		unsigned long flags;
@@ -2952,6 +2954,7 @@ void amdgpu_vm_release_compute(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 		spin_unlock_irqrestore(&adev->vm_manager.pasid_lock, flags);
 	}
 	vm->pasid = 0;
+	vm->is_compute_context = false;
 }
 
 /**
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +2 -0
index 5cb25c1c54e0..76fcf853035c 100644
@@ -301,6 +301,8 @@ struct amdgpu_vm {
 	struct ttm_lru_bulk_move lru_bulk_move;
 	/* mark whether can do the bulk move */
 	bool			bulk_moveable;
+	/* Flag to indicate if VM is used for compute */
+	bool			is_compute_context;
 };
 
 struct amdgpu_vm_manager {
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

PATCH 2/2 amd/amdgpu: force to trigger a no-retry-fault after a retry-fault

Only for the debugger use case.

[why]
Avoid endless translation retries, after an invalid address access has been issued to the GPU. Instead, the trap handler is forced to enter by generating a no-retry-fault.
A s_trap instruction is inserted in the debugger case to let the wave to enter trap handler to save context.

[how]
Intentionally using an invalid flag combination (F and P set at the same time) to trigger a no-retry-fault, after a retry-fault happens. This is only valid under compute context.

Change-Id I4180c30e2631dc0401cbd6171f8a6776e4733c9a
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6 -0
index d51ac8771ae0..358a4f50fcfb 100644
@@ -3207,6 +3207,12 @@ bool amdgpu_vm_handle_fault(struct amdgpu_device *adev, unsigned int pasid,
 		value = adev->dummy_page_addr;
 		flags |= AMDGPU_PTE_EXECUTABLE | AMDGPU_PTE_READABLE |
 			AMDGPU_PTE_WRITEABLE;
+
+		if (vm->is_compute_context) {
+			/* Setting PTE flags to trigger a no-retry-fault  */
+			flags = AMDGPU_PTE_EXECUTABLE | AMDGPU_PDE_PTE |
+				AMDGPU_PTE_TF;
+		}
 	} else {
 		/* Let the hw retry silently on the PTE */
 		value = 0;
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

Re: [PATCH 2/2] amd/amdgpu: force to trigger a no-retry-fault after a retry-fault

Quoted 25 lines · Alex Sierra

Only for the debugger use case.

[why]
Avoid endless translation retries, after an invalid address access has been issued to the GPU. Instead, the trap handler is forced to enter by generating a no-retry-fault.
A s_trap instruction is inserted in the debugger case to let the wave to enter trap handler to save context.

[how]
Intentionally using an invalid flag combination (F and P set at the same time) to trigger a no-retry-fault, after a retry-fault happens. This is only valid under compute context.

Change-Id I4180c30e2631dc0401cbd6171f8a6776e4733c9a
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
index d51ac8771ae0..358a4f50fcfb 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c bool amdgpu_vm_handle_fault(struct amdgpu_device *adev, unsigned int pasid, · line 3214

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +5 -0
@@ -3207,6 +3207,12 @@ bool amdgpu_vm_handle_fault(struct amdgpu_device *adev, unsigned int pasid,
  		value = adev->dummy_page_addr;
  		flags |= AMDGPU_PTE_EXECUTABLE | AMDGPU_PTE_READABLE |
  			AMDGPU_PTE_WRITEABLE;
+
+		if (vm->is_compute_context) {
+			/* Setting PTE flags to trigger a no-retry-fault  */
+			flags = AMDGPU_PTE_EXECUTABLE | AMDGPU_PDE_PTE |
+				AMDGPU_PTE_TF;

Hmm, this looks like you're setting flags twice in the compute-case. I was also expecting something more like this:

if (vm->is_compute_context) {
    ...
} else if (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_NEVER) {
    ...
} else {
    ...
}

I.e. for compute contexts, we do our compute-specific thing, otherwise the behaviour depends on the amdgpu_vm_fault_stop setting.

Regards,
  Felix

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c bool amdgpu_vm_handle_fault(struct amdgpu_device *adev, unsigned int pasid, · line 3218

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -0
+		}
  	} else {
  		/* Let the hw retry silently on the PTE */
  		value = 0;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx