Skip to contentSkip to conversation

drm/amdgpu/gmc: Use amdgpu_gmc_handle_retry_fault() for GMC v12.1

PATCH Applied Timur Kristóf 4 participants 4 messages Sep 16 – Sep 21

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

PATCH 1/1 drm/amdgpu/gmc: Use amdgpu_gmc_handle_retry_fault() for GMC v12.1

Use the same helper for GMC v12.1 that is used by other GMC IP block versions.

No functional changes intended. Just code cleanup.

---
 drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c | 45 ++++----------------------
 1 file changed, 7 insertions(+), 38 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c +7 -38
index 3349e8bc1c20..cfc46f912d47 100644
@@ -131,7 +131,7 @@ static int gmc_v12_1_process_interrupt(struct amdgpu_device *adev,
 	struct amdgpu_vmhub *hub;
 	uint32_t cam_index = 0;
 	const char *hub_name;
-	int ret, xcc_id = 0;
+	int xcc_id = 0;
 	uint32_t status = 0, status_hi = 0;
 	const char *die_name;
 	char die_name_buf[32];
@@ -164,44 +164,13 @@ static int gmc_v12_1_process_interrupt(struct amdgpu_device *adev,
 	hub = &adev->vmhub[vmhub];
 
 	if (retry_fault) {
-		if (adev->irq.retry_cam_enabled) {
-			/* Delegate it to a different ring if the hardware hasn't
-			 * already done it.
-			 */
-			if (entry->ih == &adev->irq.ih) {
-				amdgpu_irq_delegate(adev, entry, 8);
-				return 1;
-			}
-
-			cam_index = entry->src_data[3] & 0x3ff;
-
-			ret = amdgpu_vm_handle_fault(adev, entry->pasid, entry->vmid, node_id,
-							addr, entry->timestamp, write_fault);
-			WDOORBELL32(adev->irq.retry_cam_doorbell_index, cam_index);
-			if (ret)
-				return 1;
-		} else {
-			/* Process it onyl if it's the first fault for this address */
-			if (entry->ih != &adev->irq.ih_soft &&
-				amdgpu_gmc_filter_faults(adev, entry->ih, addr, entry->pasid,
-							 entry->timestamp))
-				return 1;
-
-			/* Delegate it to a different ring if the hardware hasn't
-			 * already done it.
-			 */
-			if (entry->ih == &adev->irq.ih) {
-				amdgpu_irq_delegate(adev, entry, 8);
-				return 1;
-			}
+		cam_index = entry->src_data[3] & 0x3ff;
 
-			/* Try to handle the recoverable page faults by filling page
-			 * tables
-			 */
-			if (amdgpu_vm_handle_fault(adev, entry->pasid, entry->vmid, node_id,
-						   addr, entry->timestamp, write_fault))
-				return 1;
-		}
+		int ret = amdgpu_gmc_handle_retry_fault(adev, entry, addr, cam_index, node_id,
+							write_fault);
+		/* Returning 1 here also prevents sending the IV to the KFD */
+		if (ret == 1)
+			return 1;
 	}
 
 	if (kgd2kfd_vmfault_fast_path(adev, entry, retry_fault))
Signature · 1 line
2.55.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 64 lines · Timur Kristóf

Use the same helper for GMC v12.1 that is used by other GMC IP block versions.

No functional changes intended. Just code cleanup.

---
  drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c | 45 ++++----------------------
  1 file changed, 7 insertions(+), 38 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c +2 -36
index 3349e8bc1c20..cfc46f912d47 100644
@@ -131,7 +131,7 @@ static int gmc_v12_1_process_interrupt(struct amdgpu_device *adev,
  	struct amdgpu_vmhub *hub;
  	uint32_t cam_index = 0;
  	const char *hub_name;
-	int ret, xcc_id = 0;
+	int xcc_id = 0;
  	uint32_t status = 0, status_hi = 0;
  	const char *die_name;
  	char die_name_buf[32];
@@ -164,44 +164,13 @@ static int gmc_v12_1_process_interrupt(struct amdgpu_device *adev,
  	hub = &adev->vmhub[vmhub];
 
  	if (retry_fault) {
-		if (adev->irq.retry_cam_enabled) {
-			/* Delegate it to a different ring if the hardware hasn't
-			 * already done it.
-			 */
-			if (entry->ih == &adev->irq.ih) {
-				amdgpu_irq_delegate(adev, entry, 8);
-				return 1;
-			}
-
-			cam_index = entry->src_data[3] & 0x3ff;
-
-			ret = amdgpu_vm_handle_fault(adev, entry->pasid, entry->vmid, node_id,
-							addr, entry->timestamp, write_fault);
-			WDOORBELL32(adev->irq.retry_cam_doorbell_index, cam_index);
-			if (ret)
-				return 1;
-		} else {
-			/* Process it onyl if it's the first fault for this address */
-			if (entry->ih != &adev->irq.ih_soft &&
-				amdgpu_gmc_filter_faults(adev, entry->ih, addr, entry->pasid,
-							 entry->timestamp))
-				return 1;
-
-			/* Delegate it to a different ring if the hardware hasn't
-			 * already done it.
-			 */
-			if (entry->ih == &adev->irq.ih) {
-				amdgpu_irq_delegate(adev, entry, 8);
-				return 1;
-			}
+		cam_index = entry->src_data[3] & 0x3ff;
 
-			/* Try to handle the recoverable page faults by filling page
-			 * tables
-			 */
-			if (amdgpu_vm_handle_fault(adev, entry->pasid, entry->vmid, node_id,
-						   addr, entry->timestamp, write_fault))

drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c static int gmc_v12_1_process_interrupt(struct amdgpu_device *adev, · line 176

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c +5 -2
-				return 1;
-		}
+		int ret = amdgpu_gmc_handle_retry_fault(adev, entry, addr, cam_index, node_id,
+							write_fault);
+		/* Returning 1 here also prevents sending the IV to the KFD */
+		if (ret == 1)
+			return 1;
  	}
 
  	if (kgd2kfd_vmfault_fast_path(adev, entry, retry_fault))

Regards,

Tvrtko

Applied
#2 lore raw

Applied. Thanks!

Quoted 84 lines · Tvrtko Ursulin
Quoted 64 lines · Timur Kristóf

Use the same helper for GMC v12.1 that is used by other GMC IP block versions.

No functional changes intended. Just code cleanup.

---
  drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c | 45 ++++----------------------
  1 file changed, 7 insertions(+), 38 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c +2 -36
index 3349e8bc1c20..cfc46f912d47 100644
@@ -131,7 +131,7 @@ static int gmc_v12_1_process_interrupt(struct amdgpu_device *adev,
      struct amdgpu_vmhub *hub;
      uint32_t cam_index = 0;
      const char *hub_name;
-     int ret, xcc_id = 0;
+     int xcc_id = 0;
      uint32_t status = 0, status_hi = 0;
      const char *die_name;
      char die_name_buf[32];
@@ -164,44 +164,13 @@ static int gmc_v12_1_process_interrupt(struct amdgpu_device *adev,
      hub = &adev->vmhub[vmhub];
 
      if (retry_fault) {
-             if (adev->irq.retry_cam_enabled) {
-                     /* Delegate it to a different ring if the hardware hasn't
-                      * already done it.
-                      */
-                     if (entry->ih == &adev->irq.ih) {
-                             amdgpu_irq_delegate(adev, entry, 8);
-                             return 1;
-                     }
-
-                     cam_index = entry->src_data[3] & 0x3ff;
-
-                     ret = amdgpu_vm_handle_fault(adev, entry->pasid, entry->vmid, node_id,
-                                                     addr, entry->timestamp, write_fault);
-                     WDOORBELL32(adev->irq.retry_cam_doorbell_index, cam_index);
-                     if (ret)
-                             return 1;
-             } else {
-                     /* Process it onyl if it's the first fault for this address */
-                     if (entry->ih != &adev->irq.ih_soft &&
-                             amdgpu_gmc_filter_faults(adev, entry->ih, addr, entry->pasid,
-                                                      entry->timestamp))
-                             return 1;
-
-                     /* Delegate it to a different ring if the hardware hasn't
-                      * already done it.
-                      */
-                     if (entry->ih == &adev->irq.ih) {
-                             amdgpu_irq_delegate(adev, entry, 8);
-                             return 1;
-                     }
+             cam_index = entry->src_data[3] & 0x3ff;
 
-                     /* Try to handle the recoverable page faults by filling page
-                      * tables
-                      */
-                     if (amdgpu_vm_handle_fault(adev, entry->pasid, entry->vmid, node_id,
-                                                addr, entry->timestamp, write_fault))

drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c static int gmc_v12_1_process_interrupt(struct amdgpu_device *adev, · line 176

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c +5 -2
-                             return 1;
-             }
+             int ret = amdgpu_gmc_handle_retry_fault(adev, entry, addr, cam_index, node_id,
+                                                     write_fault);
+             /* Returning 1 here also prevents sending the IV to the KFD */
+             if (ret == 1)
+                     return 1;
      }
 
      if (kgd2kfd_vmfault_fast_path(adev, entry, retry_fault))

Regards,

Tvrtko

maintainer Acked-by on v1 1/1
#3 lore raw
In reply to Timur Kristóf
Quoted 6 lines · Timur Kristóf

Use the same helper for GMC v12.1 that is used by other GMC IP block versions.

No functional changes intended. Just code cleanup.

Quoted 68 lines
---
 drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c | 45 ++++----------------------
 1 file changed, 7 insertions(+), 38 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c +7 -38
index 3349e8bc1c20..cfc46f912d47 100644
@@ -131,7 +131,7 @@ static int gmc_v12_1_process_interrupt(struct amdgpu_device *adev,
 	struct amdgpu_vmhub *hub;
 	uint32_t cam_index = 0;
 	const char *hub_name;
-	int ret, xcc_id = 0;
+	int xcc_id = 0;
 	uint32_t status = 0, status_hi = 0;
 	const char *die_name;
 	char die_name_buf[32];
@@ -164,44 +164,13 @@ static int gmc_v12_1_process_interrupt(struct amdgpu_device *adev,
 	hub = &adev->vmhub[vmhub];
 
 	if (retry_fault) {
-		if (adev->irq.retry_cam_enabled) {
-			/* Delegate it to a different ring if the hardware hasn't
-			 * already done it.
-			 */
-			if (entry->ih == &adev->irq.ih) {
-				amdgpu_irq_delegate(adev, entry, 8);
-				return 1;
-			}
-
-			cam_index = entry->src_data[3] & 0x3ff;
-
-			ret = amdgpu_vm_handle_fault(adev, entry->pasid, entry->vmid, node_id,
-							addr, entry->timestamp, write_fault);
-			WDOORBELL32(adev->irq.retry_cam_doorbell_index, cam_index);
-			if (ret)
-				return 1;
-		} else {
-			/* Process it onyl if it's the first fault for this address */
-			if (entry->ih != &adev->irq.ih_soft &&
-				amdgpu_gmc_filter_faults(adev, entry->ih, addr, entry->pasid,
-							 entry->timestamp))
-				return 1;
-
-			/* Delegate it to a different ring if the hardware hasn't
-			 * already done it.
-			 */
-			if (entry->ih == &adev->irq.ih) {
-				amdgpu_irq_delegate(adev, entry, 8);
-				return 1;
-			}
+		cam_index = entry->src_data[3] & 0x3ff;
 
-			/* Try to handle the recoverable page faults by filling page
-			 * tables
-			 */
-			if (amdgpu_vm_handle_fault(adev, entry->pasid, entry->vmid, node_id,
-						   addr, entry->timestamp, write_fault))
-				return 1;
-		}
+		int ret = amdgpu_gmc_handle_retry_fault(adev, entry, addr, cam_index, node_id,
+							write_fault);
+		/* Returning 1 here also prevents sending the IV to the KFD */
+		if (ret == 1)
+			return 1;
 	}
 
 	if (kgd2kfd_vmfault_fast_path(adev, entry, retry_fault))