Skip to contentSkip to conversation

drm/amdgpu: Update invalid PTE flag setting

PATCH Superseded Mukul Joshi 3 participants 5 messages Apr 4, 2023 – Apr 6, 2023

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Update invalid PTE flag setting

Update the invalid PTE flag setting to ensure, in addition to transitioning the retry fault to a no-retry fault, it also causes the wavefront to enter the trap handler. With the current setting, it only transitions to a no-retry fault.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
index af6f26a97fc5..5df4f7bb241f 100644
@@ -2488,7 +2488,7 @@ bool amdgpu_vm_handle_fault(struct amdgpu_device *adev, u32 pasid,
 		/* Intentionally setting invalid PTE flag
 		 * combination to force a no-retry-fault
 		 */
-		flags = AMDGPU_PTE_SNOOPED | AMDGPU_PTE_PRT;
+		flags = AMDGPU_PTE_VALID | AMDGPU_PTE_SYSTEM | AMDGPU_PTE_PRT;
 		value = 0;
 	} else if (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_NEVER) {
 		/* Redirect the access to the dummy page */
Signature · 1 line
2.35.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Mukul Joshi

Update the invalid PTE flag setting to ensure, in addition to transitioning the retry fault to a no-retry fault, it also causes the wavefront to enter the trap handler. With the current setting, it only transitions to a no-retry fault.

Quoted 17 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
index af6f26a97fc5..5df4f7bb241f 100644
@@ -2488,7 +2488,7 @@ bool amdgpu_vm_handle_fault(struct amdgpu_device *adev, u32 pasid,
  		/* Intentionally setting invalid PTE flag
  		 * combination to force a no-retry-fault
  		 */
-		flags = AMDGPU_PTE_SNOOPED | AMDGPU_PTE_PRT;
+		flags = AMDGPU_PTE_VALID | AMDGPU_PTE_SYSTEM | AMDGPU_PTE_PRT;
  		value = 0;
  	} else if (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_NEVER) {
  		/* Redirect the access to the dummy page */
maintainer
#2 lore raw
In reply to Mukul Joshi

Am 04.04.23 um 23:59 schrieb Mukul Joshi:

Quoted 4 lines

Update the invalid PTE flag setting to ensure, in addition to transitioning the retry fault to a no-retry fault, it also causes the wavefront to enter the trap handler. With the current setting, it only transitions to a no-retry fault.

Well that was actually the intended result. Why should it enter the trap handler here?

Quoted 11 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
index af6f26a97fc5..5df4f7bb241f 100644

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

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
@@ -2488,7 +2488,7 @@ bool amdgpu_vm_handle_fault(struct amdgpu_device *adev, u32 pasid,
  		/* Intentionally setting invalid PTE flag
  		 * combination to force a no-retry-fault
  		 */
-		flags = AMDGPU_PTE_SNOOPED | AMDGPU_PTE_PRT;
+		flags = AMDGPU_PTE_VALID | AMDGPU_PTE_SYSTEM | AMDGPU_PTE_PRT;

As far as I can see this is actually a valid combination and would not have the desired result.

Regards,
Christian.

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
  		value = 0;
  	} else if (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_NEVER) {
  		/* Redirect the access to the dummy page */
#3 lore raw

Am 2023-04-06 um 10:36 schrieb Christian König:

Quoted 7 lines

Am 04.04.23 um 23:59 schrieb Mukul Joshi:

Quoted 4 lines

Update the invalid PTE flag setting to ensure, in addition to transitioning the retry fault to a no-retry fault, it also causes the wavefront to enter the trap handler. With the current setting, it only transitions to a no-retry fault.

Well that was actually the intended result. Why should it enter the trap handler here?

We need the trap handler for reporting the fault to the debugger. The VM fault interrupt itself doesn't provide sufficient information to find the wave and the program counter that triggered the fault. It also doesn't work well when several waves are faulting on the same address.

Regards,
  Felix

Quoted 28 lines
Quoted 12 lines

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
index af6f26a97fc5..5df4f7bb241f 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c bool amdgpu_vm_handle_fault(struct · line 2492

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
@@ -2488,7 +2488,7 @@ bool amdgpu_vm_handle_fault(struct 
 amdgpu_device *adev, u32 pasid,
           /* Intentionally setting invalid PTE flag
            * combination to force a no-retry-fault
            */
-        flags = AMDGPU_PTE_SNOOPED | AMDGPU_PTE_PRT;
+        flags = AMDGPU_PTE_VALID | AMDGPU_PTE_SYSTEM | AMDGPU_PTE_PRT;

As far as I can see this is actually a valid combination and would not have the desired result.

Regards,
Christian.

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
           value = 0;
       } else if (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_NEVER) {

          /* Redirect the access to the dummy page */

maintainer
#4 lore raw

Am 06.04.23 um 17:01 schrieb Felix Kuehling:

Quoted 10 lines

Am 2023-04-06 um 10:36 schrieb Christian König:

Quoted 7 lines

Am 04.04.23 um 23:59 schrieb Mukul Joshi:

Quoted 4 lines

Update the invalid PTE flag setting to ensure, in addition to transitioning the retry fault to a no-retry fault, it also causes the wavefront to enter the trap handler. With the current setting, it only transitions to a no-retry fault.

Well that was actually the intended result. Why should it enter the trap handler here?

We need the trap handler for reporting the fault to the debugger. The VM fault interrupt itself doesn't provide sufficient information to find the wave and the program counter that triggered the fault. It also doesn't work well when several waves are faulting on the same address.

Interesting. But then we still have the problem that VSP set is actually a valid combination when this is applied to a non PTB.

So that really doesn't look like a good idea to me.

Regards,
Christian.

Quoted 33 lines

Regards,
  Felix

Quoted 28 lines
Quoted 12 lines

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
index af6f26a97fc5..5df4f7bb241f 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c bool amdgpu_vm_handle_fault(struct · line 2492

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
@@ -2488,7 +2488,7 @@ bool amdgpu_vm_handle_fault(struct 
 amdgpu_device *adev, u32 pasid,
           /* Intentionally setting invalid PTE flag
            * combination to force a no-retry-fault
            */
-        flags = AMDGPU_PTE_SNOOPED | AMDGPU_PTE_PRT;
+        flags = AMDGPU_PTE_VALID | AMDGPU_PTE_SYSTEM | AMDGPU_PTE_PRT;

As far as I can see this is actually a valid combination and would not have the desired result.

Regards,
Christian.

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
           value = 0;
       } else if (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_NEVER) {

          /* Redirect the access to the dummy page */