Skip to contentSkip to conversation

drm/amdgpu: Update PTE flags with TF enabled

PATCH In review Mukul Joshi 3 participants 3 messages Sep 13, 2022 – Sep 14, 2022

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

PATCH 1/1 drm/amdgpu: Update PTE flags with TF enabled

This patch updates the PTE flags when translate further (TF) is enabled:
- With translate_further enabled, invalid PTEs can be 0. Reading consecutive invalid PTEs as 0 is considered a fault. To prevent this, ensure invalid PTEs have at least 1 bit set.
- The current invalid PTE flags settings to translate a retry fault into a no-retry fault, doesn't work with TF enabled. As a result, update invalid PTE flags settings which works for both TF enabled and disabled case.

Fixes 2abf2573b1c69 ("drm/amdgpu: Enable translate_further to extend UTCL2 reach")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 +--
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c  | 7 +++++--
 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -2
index 59cac347baa3..690fd4f639f1 100644
@@ -2484,8 +2484,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_EXECUTABLE | AMDGPU_PDE_PTE |
-			AMDGPU_PTE_TF;
+		flags = AMDGPU_PTE_SNOOPED | AMDGPU_PTE_PRT;
 		value = 0;
 	} else if (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_NEVER) {
 		/* Redirect the access to the dummy page */
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +5 -2
index 4603653916f5..67ca16a8027c 100644
@@ -1103,10 +1103,13 @@ static void gmc_v9_0_get_vm_pde(struct amdgpu_device *adev, int level,
 			*flags |= AMDGPU_PDE_BFS(0x9);
 
 	} else if (level == AMDGPU_VM_PDB0) {
-		if (*flags & AMDGPU_PDE_PTE)
+		if (*flags & AMDGPU_PDE_PTE) {
 			*flags &= ~AMDGPU_PDE_PTE;
-		else
+			if (!(*flags & AMDGPU_PTE_VALID))
+				*addr |= 1 << PAGE_SHIFT;
+		} else {
 			*flags |= AMDGPU_PTE_TF;
+		}
 	}
 }
 
Signature · 1 line
2.35.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Am 14.09.22 um 00:16 schrieb Mukul Joshi:

Quoted 10 lines

This patch updates the PTE flags when translate further (TF) is enabled:
- With translate_further enabled, invalid PTEs can be 0. Reading consecutive invalid PTEs as 0 is considered a fault. To prevent this, ensure invalid PTEs have at least 1 bit set.
- The current invalid PTE flags settings to translate a retry fault into a no-retry fault, doesn't work with TF enabled. As a result, update invalid PTE flags settings which works for both TF enabled and disabled case.

Quoted 2 lines
Fixes 2abf2573b1c69 ("drm/amdgpu: Enable translate_further to extend UTCL2 reach")
Quoted 39 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 +--
  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c  | 7 +++++--
  2 files changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -2
index 59cac347baa3..690fd4f639f1 100644
@@ -2484,8 +2484,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_EXECUTABLE | AMDGPU_PDE_PTE |
-			AMDGPU_PTE_TF;
+		flags = AMDGPU_PTE_SNOOPED | AMDGPU_PTE_PRT;
  		value = 0;
  	} else if (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_NEVER) {
  		/* Redirect the access to the dummy page */
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +5 -2
index 4603653916f5..67ca16a8027c 100644
@@ -1103,10 +1103,13 @@ static void gmc_v9_0_get_vm_pde(struct amdgpu_device *adev, int level,
  			*flags |= AMDGPU_PDE_BFS(0x9);
 
  	} else if (level == AMDGPU_VM_PDB0) {
-		if (*flags & AMDGPU_PDE_PTE)
+		if (*flags & AMDGPU_PDE_PTE) {
  			*flags &= ~AMDGPU_PDE_PTE;
-		else
+			if (!(*flags & AMDGPU_PTE_VALID))
+				*addr |= 1 << PAGE_SHIFT;
+		} else {
  			*flags |= AMDGPU_PTE_TF;
+		}
  	}
  }
 
Reviewed-by on v1 1/1
#2 lore raw
In reply to Mukul Joshi

Am 2022-09-13 um 18:16 schrieb Mukul Joshi:

Quoted 10 lines

This patch updates the PTE flags when translate further (TF) is enabled:
- With translate_further enabled, invalid PTEs can be 0. Reading consecutive invalid PTEs as 0 is considered a fault. To prevent this, ensure invalid PTEs have at least 1 bit set.
- The current invalid PTE flags settings to translate a retry fault into a no-retry fault, doesn't work with TF enabled. As a result, update invalid PTE flags settings which works for both TF enabled and disabled case.

Quoted 2 lines
Fixes 2abf2573b1c69 ("drm/amdgpu: Enable translate_further to extend UTCL2 reach")
Quoted 39 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 +--
  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c  | 7 +++++--
  2 files changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -2
index 59cac347baa3..690fd4f639f1 100644
@@ -2484,8 +2484,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_EXECUTABLE | AMDGPU_PDE_PTE |
-			AMDGPU_PTE_TF;
+		flags = AMDGPU_PTE_SNOOPED | AMDGPU_PTE_PRT;
  		value = 0;
  	} else if (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_NEVER) {
  		/* Redirect the access to the dummy page */
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +5 -2
index 4603653916f5..67ca16a8027c 100644
@@ -1103,10 +1103,13 @@ static void gmc_v9_0_get_vm_pde(struct amdgpu_device *adev, int level,
  			*flags |= AMDGPU_PDE_BFS(0x9);
 
  	} else if (level == AMDGPU_VM_PDB0) {
-		if (*flags & AMDGPU_PDE_PTE)
+		if (*flags & AMDGPU_PDE_PTE) {
  			*flags &= ~AMDGPU_PDE_PTE;
-		else
+			if (!(*flags & AMDGPU_PTE_VALID))
+				*addr |= 1 << PAGE_SHIFT;
+		} else {
  			*flags |= AMDGPU_PTE_TF;
+		}
  	}
  }