Skip to contentSkip to conversation

drm/amdgpu/gmc11: add amdgpu_vm_handle_fault() handling

PATCH In review Alex Deucher 5 participants 8 messages Nov 18, 2025 – Nov 28, 2025

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/3 drm/amdgpu/gmc11: add amdgpu_vm_handle_fault() handling

We need to call amdgpu_vm_handle_fault() on page fault on all gfx9 and newer parts to properly update the page tables, not just for recoverable page faults.

---
 drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 27 ++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +27 -0
index 7bc389d9f5c48..25cdcb850416c 100644
@@ -103,12 +103,39 @@ static int gmc_v11_0_process_interrupt(struct amdgpu_device *adev,
 	uint32_t vmhub_index = entry->client_id == SOC21_IH_CLIENTID_VMC ?
 			       AMDGPU_MMHUB0(0) : AMDGPU_GFXHUB(0);
 	struct amdgpu_vmhub *hub = &adev->vmhub[vmhub_index];
+	bool retry_fault = !!(entry->src_data[1] & 0x80);
+	bool write_fault = !!(entry->src_data[1] & 0x20);
 	uint32_t status = 0;
 	u64 addr;
 
 	addr = (u64)entry->src_data[0] << 12;
 	addr |= ((u64)entry->src_data[1] & 0xf) << 44;
 
+	if (retry_fault) {
+		/* Returning 1 here also prevents sending the IV to the KFD */
+
+		/* 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;
+		}
+
+		/* Try to handle the recoverable page faults by filling page
+		 * tables
+		 */
+		if (amdgpu_vm_handle_fault(adev, entry->pasid, 0, 0, addr,
+					   entry->timestamp, write_fault))
+			return 1;
+	}
+
 	if (!amdgpu_sriov_vf(adev)) {
 		/*
 		 * Issue a dummy read to wait for the status register to
Signature · 1 line
2.51.1
author maintainer
#1 lore raw

PATCH 2/3 drm/amdgpu/gmc12: add amdgpu_vm_handle_fault() handling

We need to call amdgpu_vm_handle_fault() on page fault on all gfx9 and newer parts to properly update the page tables, not just for recoverable page faults.

---
 drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c | 27 ++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +27 -0
index cad2d19105c4c..43f8e96d3fe53 100644
@@ -91,6 +91,8 @@ static int gmc_v12_0_process_interrupt(struct amdgpu_device *adev,
 				       struct amdgpu_iv_entry *entry)
 {
 	struct amdgpu_vmhub *hub;
+	bool retry_fault = !!(entry->src_data[1] & 0x80);
+	bool write_fault = !!(entry->src_data[1] & 0x20);
 	uint32_t status = 0;
 	u64 addr;
 
@@ -102,6 +104,31 @@ static int gmc_v12_0_process_interrupt(struct amdgpu_device *adev,
 	else
 		hub = &adev->vmhub[AMDGPU_GFXHUB(0)];
 
+	if (retry_fault) {
+		/* Returning 1 here also prevents sending the IV to the KFD */
+
+		/* 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;
+		}
+
+		/* Try to handle the recoverable page faults by filling page
+		 * tables
+		 */
+		if (amdgpu_vm_handle_fault(adev, entry->pasid, 0, 0, addr,
+					   entry->timestamp, write_fault))
+			return 1;
+	}
+
 	if (!amdgpu_sriov_vf(adev)) {
 		/*
 		 * Issue a dummy read to wait for the status register to
Signature · 1 line
2.51.1
author maintainer
#2 lore raw

PATCH 3/3 drm/amdgpu: use common defines for HUB faults

In reply to Alex Deucher

Use common definitions for the fault bits in the IH sourc data for the gmc9-12 memory hub faults

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 5 +++++
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c  | 6 ++++--
 drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c  | 6 ++++--
 drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c  | 6 ++++--
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   | 6 ++++--
 5 files changed, 21 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +5 -0
index 55097ca107382..727342689d4ba 100644
@@ -86,6 +86,11 @@ enum amdgpu_memory_partition {
 
 #define AMDGPU_MAX_MEM_RANGES 8
 
+#define AMDGPU_GMC9_FAULT_SOURCE_DATA_RETRY 0x80
+#define AMDGPU_GMC9_FAULT_SOURCE_DATA_READ  0x40
+#define AMDGPU_GMC9_FAULT_SOURCE_DATA_WRITE 0x20
+#define AMDGPU_GMC9_FAULT_SOURCE_DATA_EXE   0x10
+
 /*
  * GMC page fault information
  */
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +4 -2
index d7499be8c4bfc..ce6e04242c522 100644
@@ -103,8 +103,10 @@ static int gmc_v10_0_process_interrupt(struct amdgpu_device *adev,
 	uint32_t vmhub_index = entry->client_id == SOC15_IH_CLIENTID_VMC ?
 			       AMDGPU_MMHUB0(0) : AMDGPU_GFXHUB(0);
 	struct amdgpu_vmhub *hub = &adev->vmhub[vmhub_index];
-	bool retry_fault = !!(entry->src_data[1] & 0x80);
-	bool write_fault = !!(entry->src_data[1] & 0x20);
+	bool retry_fault = !!(entry->src_data[1] &
+			      AMDGPU_GMC9_FAULT_SOURCE_DATA_RETRY);
+	bool write_fault = !!(entry->src_data[1] &
+			      AMDGPU_GMC9_FAULT_SOURCE_DATA_WRITE);
 	struct amdgpu_task_info *task_info;
 	uint32_t status = 0;
 	u64 addr;
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +4 -2
index 25cdcb850416c..b36abb3f664d2 100644
@@ -103,8 +103,10 @@ static int gmc_v11_0_process_interrupt(struct amdgpu_device *adev,
 	uint32_t vmhub_index = entry->client_id == SOC21_IH_CLIENTID_VMC ?
 			       AMDGPU_MMHUB0(0) : AMDGPU_GFXHUB(0);
 	struct amdgpu_vmhub *hub = &adev->vmhub[vmhub_index];
-	bool retry_fault = !!(entry->src_data[1] & 0x80);
-	bool write_fault = !!(entry->src_data[1] & 0x20);
+	bool retry_fault = !!(entry->src_data[1] &
+			      AMDGPU_GMC9_FAULT_SOURCE_DATA_RETRY);
+	bool write_fault = !!(entry->src_data[1] &
+			      AMDGPU_GMC9_FAULT_SOURCE_DATA_WRITE);
 	uint32_t status = 0;
 	u64 addr;
 
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +4 -2
index 43f8e96d3fe53..c2947415359ad 100644
@@ -91,8 +91,10 @@ static int gmc_v12_0_process_interrupt(struct amdgpu_device *adev,
 				       struct amdgpu_iv_entry *entry)
 {
 	struct amdgpu_vmhub *hub;
-	bool retry_fault = !!(entry->src_data[1] & 0x80);
-	bool write_fault = !!(entry->src_data[1] & 0x20);
+	bool retry_fault = !!(entry->src_data[1] &
+			      AMDGPU_GMC9_FAULT_SOURCE_DATA_RETRY);
+	bool write_fault = !!(entry->src_data[1] &
+			      AMDGPU_GMC9_FAULT_SOURCE_DATA_WRITE);
 	uint32_t status = 0;
 	u64 addr;
 
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +4 -2
index e716097dfde48..8ad7519f7b581 100644
@@ -544,8 +544,10 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev,
 				      struct amdgpu_irq_src *source,
 				      struct amdgpu_iv_entry *entry)
 {
-	bool retry_fault = !!(entry->src_data[1] & 0x80);
-	bool write_fault = !!(entry->src_data[1] & 0x20);
+	bool retry_fault = !!(entry->src_data[1] &
+			      AMDGPU_GMC9_FAULT_SOURCE_DATA_RETRY);
+	bool write_fault = !!(entry->src_data[1] &
+			      AMDGPU_GMC9_FAULT_SOURCE_DATA_WRITE);
 	uint32_t status = 0, cid = 0, rw = 0, fed = 0;
 	struct amdgpu_task_info *task_info;
 	struct amdgpu_vmhub *hub;
Signature · 1 line
2.51.1
#3 lore raw
In reply to Alex Deucher

Le 18/11/2025 à 23:06, Alex Deucher a écrit :

Quoted 19 lines

We need to call amdgpu_vm_handle_fault() on page fault on all gfx9 and newer parts to properly update the page tables, not just for recoverable page faults.

---
  drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 27 ++++++++++++++++++++++++++
  1 file changed, 27 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +2 -0
index 7bc389d9f5c48..25cdcb850416c 100644
@@ -103,12 +103,39 @@ static int gmc_v11_0_process_interrupt(struct amdgpu_device *adev,
  	uint32_t vmhub_index = entry->client_id == SOC21_IH_CLIENTID_VMC ?
  			       AMDGPU_MMHUB0(0) : AMDGPU_GFXHUB(0);
  	struct amdgpu_vmhub *hub = &adev->vmhub[vmhub_index];
+	bool retry_fault = !!(entry->src_data[1] & 0x80);
+	bool write_fault = !!(entry->src_data[1] & 0x20);

drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c static int gmc_v11_0_process_interrupt(struct amdgpu_device *adev, · line 117

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +4 -0
  	uint32_t status = 0;
  	u64 addr;
 
  	addr = (u64)entry->src_data[0] << 12;
  	addr |= ((u64)entry->src_data[1] & 0xf) << 44;
 
+	if (retry_fault) {
+		/* Returning 1 here also prevents sending the IV to the KFD */
+
+		/* Process it onyl if it's the first fault for this address */

typo: onyl -> only (same for patch 2/3)

Pierre-Eric

Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +21 -0
+		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;
+		}
+
+		/* Try to handle the recoverable page faults by filling page
+		 * tables
+		 */
+		if (amdgpu_vm_handle_fault(adev, entry->pasid, 0, 0, addr,
+					   entry->timestamp, write_fault))
+			return 1;
+	}
+
  	if (!amdgpu_sriov_vf(adev)) {
  		/*
  		 * Issue a dummy read to wait for the status register to
#4 lore raw
Quoted 29 lines · Pierre-Eric Pelloux-Prayer
Quoted 25 lines · Alex Deucher

We need to call amdgpu_vm_handle_fault() on page fault on all gfx9 and newer parts to properly update the page tables, not just for recoverable page faults.

---
  drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 27 ++++++++++++++++++++++++++
  1 file changed, 27 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +2 -0
index 7bc389d9f5c48..25cdcb850416c 100644
@@ -103,12 +103,39 @@ static int gmc_v11_0_process_interrupt(struct amdgpu_device *adev,
      uint32_t vmhub_index = entry->client_id == SOC21_IH_CLIENTID_VMC ?
                             AMDGPU_MMHUB0(0) : AMDGPU_GFXHUB(0);
      struct amdgpu_vmhub *hub = &adev->vmhub[vmhub_index];
+     bool retry_fault = !!(entry->src_data[1] & 0x80);
+     bool write_fault = !!(entry->src_data[1] & 0x20);
      uint32_t status = 0;
      u64 addr;
 
      addr = (u64)entry->src_data[0] << 12;
      addr |= ((u64)entry->src_data[1] & 0xf) << 44;
 
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c static int gmc_v11_0_process_interrupt(struct amdgpu_device *adev, · line 117

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +4 -0
+     if (retry_fault) {
+             /* Returning 1 here also prevents sending the IV to the KFD */
+
+             /* Process it onyl if it's the first fault for this address */

typo: onyl -> only (same for patch 2/3)

Fixed locally. thanks!

Alex

Quoted 29 lines

Pierre-Eric

Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +21 -0
+             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;
+             }
+
+             /* Try to handle the recoverable page faults by filling page
+              * tables
+              */
+             if (amdgpu_vm_handle_fault(adev, entry->pasid, 0, 0, addr,
+                                        entry->timestamp, write_fault))
+                     return 1;
+     }
+
      if (!amdgpu_sriov_vf(adev)) {
              /*
               * Issue a dummy read to wait for the status register to
#5 lore raw

Ping on this series?

Quoted 72 lines · Alex Deucher
Quoted 29 lines · Pierre-Eric Pelloux-Prayer
Quoted 25 lines · Alex Deucher

We need to call amdgpu_vm_handle_fault() on page fault on all gfx9 and newer parts to properly update the page tables, not just for recoverable page faults.

---
  drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 27 ++++++++++++++++++++++++++
  1 file changed, 27 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +2 -0
index 7bc389d9f5c48..25cdcb850416c 100644
@@ -103,12 +103,39 @@ static int gmc_v11_0_process_interrupt(struct amdgpu_device *adev,
      uint32_t vmhub_index = entry->client_id == SOC21_IH_CLIENTID_VMC ?
                             AMDGPU_MMHUB0(0) : AMDGPU_GFXHUB(0);
      struct amdgpu_vmhub *hub = &adev->vmhub[vmhub_index];
+     bool retry_fault = !!(entry->src_data[1] & 0x80);
+     bool write_fault = !!(entry->src_data[1] & 0x20);
      uint32_t status = 0;
      u64 addr;
 
      addr = (u64)entry->src_data[0] << 12;
      addr |= ((u64)entry->src_data[1] & 0xf) << 44;
 
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c static int gmc_v11_0_process_interrupt(struct amdgpu_device *adev, · line 117

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +4 -0
+     if (retry_fault) {
+             /* Returning 1 here also prevents sending the IV to the KFD */
+
+             /* Process it onyl if it's the first fault for this address */

typo: onyl -> only (same for patch 2/3)

Fixed locally. thanks!

Alex

Quoted 29 lines

Pierre-Eric

Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +21 -0
+             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;
+             }
+
+             /* Try to handle the recoverable page faults by filling page
+              * tables
+              */
+             if (amdgpu_vm_handle_fault(adev, entry->pasid, 0, 0, addr,
+                                        entry->timestamp, write_fault))
+                     return 1;
+     }
+
      if (!amdgpu_sriov_vf(adev)) {
              /*
               * Issue a dummy read to wait for the status register to
Reviewed-by
#6 lore raw
Quoted 1 line · Alex Deucher

Ping on this series?

My apologies, I've missed this.

The series makes good sense to me.

Though, haven't yet tested personally.
Also added Christian to CC.

Quoted 88 lines
Quoted 85 lines · Alex Deucher
Quoted 34 lines · Pierre-Eric Pelloux-Prayer
Quoted 30 lines · Alex Deucher

We need to call amdgpu_vm_handle_fault() on page fault on all gfx9 and newer parts to properly update the page tables, not just for recoverable page faults.

---
  drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 27
++++++++++++++++++++++++++

  1 file changed, 27 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +0 -0
index 7bc389d9f5c48..25cdcb850416c 100644
@@ -103,12 +103,39 @@ static int
 gmc_v11_0_process_interrupt(struct amdgpu_device *adev,

      uint32_t vmhub_index = entry->client_id == SOC21_IH_CLIENTID_VMC ?
                             AMDGPU_MMHUB0(0) :
AMDGPU_GFXHUB(0);
      struct amdgpu_vmhub *hub = &adev->vmhub[vmhub_index]; +     bool retry_fault = !!(entry->src_data[1] & 0x80); +     bool write_fault = !!(entry->src_data[1] & 0x20); uint32_t status = 0;
      u64 addr;

      addr = (u64)entry->src_data[0] << 12; addr |= ((u64)entry->src_data[1] & 0xf) << 44;

Quoted 8 lines
Quoted 6 lines

+     if (retry_fault) {
+             /* Returning 1 here also prevents sending the IV to the KFD */
+
+             /* Process it onyl if it's the first fault for this address */

typo: onyl -> only (same for patch 2/3)

Fixed locally.  thanks!

Alex

Quoted 35 lines

Pierre-Eric

Quoted 30 lines

+             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;
+             }
+
+             /* Try to handle the recoverable page faults by filling page
+              * tables
+              */
+             if (amdgpu_vm_handle_fault(adev, entry->pasid, 0, 0, addr,
+                                        entry->timestamp, write_fault))
+                     return 1;
+     }
+
      if (!amdgpu_sriov_vf(adev)) {
              /*
               * Issue a dummy read to wait for the status register to

#7 lore raw
In reply to Alex Deucher
Quoted 2 lines · Alex Deucher

Ping on this series?

It looks like the same generic logic in different IP versions. Would it make sense to have amdgpu_gmc_handle_retry_fault() and call it.

Thanks,
Lijo

Quoted 73 lines · Alex Deucher
Quoted 72 lines
Quoted 29 lines · Pierre-Eric Pelloux-Prayer
Quoted 25 lines · Alex Deucher

We need to call amdgpu_vm_handle_fault() on page fault on all gfx9 and newer parts to properly update the page tables, not just for recoverable page faults.

---
   drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 27 ++++++++++++++++++++++++++
   1 file changed, 27 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +2 -0
index 7bc389d9f5c48..25cdcb850416c 100644
@@ -103,12 +103,39 @@ static int gmc_v11_0_process_interrupt(struct amdgpu_device *adev,
       uint32_t vmhub_index = entry->client_id == SOC21_IH_CLIENTID_VMC ?
                              AMDGPU_MMHUB0(0) : AMDGPU_GFXHUB(0);
       struct amdgpu_vmhub *hub = &adev->vmhub[vmhub_index];
+     bool retry_fault = !!(entry->src_data[1] & 0x80);
+     bool write_fault = !!(entry->src_data[1] & 0x20);
       uint32_t status = 0;
       u64 addr;
 
       addr = (u64)entry->src_data[0] << 12;
       addr |= ((u64)entry->src_data[1] & 0xf) << 44;
 
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c static int gmc_v11_0_process_interrupt(struct amdgpu_device *adev, · line 117

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +4 -0
+     if (retry_fault) {
+             /* Returning 1 here also prevents sending the IV to the KFD */
+
+             /* Process it onyl if it's the first fault for this address */

typo: onyl -> only (same for patch 2/3)

Fixed locally. thanks!

Alex

Quoted 29 lines

Pierre-Eric

Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +21 -0
+             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;
+             }
+
+             /* Try to handle the recoverable page faults by filling page
+              * tables
+              */
+             if (amdgpu_vm_handle_fault(adev, entry->pasid, 0, 0, addr,
+                                        entry->timestamp, write_fault))
+                     return 1;
+     }
+
       if (!amdgpu_sriov_vf(adev)) {
               /*
                * Issue a dummy read to wait for the status register to