Skip to contentSkip to conversation

drm/amdgpu: add experimental resets debug flag

PATCH In review Alex Deucher 4 participants 5 messages Aug 20, 2024 – Aug 26, 2024

Subsystems (3)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/2 drm/amdgpu: add experimental resets debug flag

Add this flag to enable experimental resets for testing before they are fully validated.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h     | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 6 ++++++
 2 files changed, 7 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index e8c284aea1f25..6e6580ab7e04a 100644
@@ -1164,6 +1164,7 @@ struct amdgpu_device {
 	bool                            debug_disable_soft_recovery;
 	bool                            debug_use_vram_fw_buf;
 	bool                            debug_enable_ras_aca;
+	bool                            debug_exp_resets;
 
 	bool				enforce_isolation[MAX_XCP];
 	/* Added this mutex for cleaner shader isolation between GFX and compute processes */
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +6 -0
index b9529948f2b20..82bde5132dc68 100644
@@ -132,6 +132,7 @@ enum AMDGPU_DEBUG_MASK {
 	AMDGPU_DEBUG_DISABLE_GPU_SOFT_RECOVERY = BIT(2),
 	AMDGPU_DEBUG_USE_VRAM_FW_BUF = BIT(3),
 	AMDGPU_DEBUG_ENABLE_RAS_ACA = BIT(4),
+	AMDGPU_DEBUG_ENABLE_EXP_RESETS = BIT(5),
 };
 
 unsigned int amdgpu_vram_limit = UINT_MAX;
@@ -2200,6 +2201,11 @@ static void amdgpu_init_debug_options(struct amdgpu_device *adev)
 		pr_info("debug: enable RAS ACA\n");
 		adev->debug_enable_ras_aca = true;
 	}
+
+	if (amdgpu_debug_mask & AMDGPU_DEBUG_ENABLE_EXP_RESETS) {
+		pr_info("debug: enable experimental reset features\n");
+		adev->debug_exp_resets = true;
+	}
 }
 
 static unsigned long amdgpu_fix_asic_type(struct pci_dev *pdev, unsigned long flags)
Signature · 1 line
2.46.0
author maintainer
#1 lore raw

PATCH 2/2 drm/amdgpu/gfx9: put queue resets behind a debug option

Pending extended validation.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c | 4 ++++
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c             | 4 ++++
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c           | 6 ++++++
 3 files changed, 14 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +4 -0
index c63528a4e8941..1254a43ec96b6 100644
@@ -1151,6 +1151,10 @@ uint64_t kgd_gfx_v9_hqd_get_pq_addr(struct amdgpu_device *adev,
 	uint32_t low, high;
 	uint64_t queue_addr = 0;
 
+	if (!adev->debug_exp_resets &&
+	    !adev->gfx.num_gfx_rings)
+		return 0;
+
 	kgd_gfx_v9_acquire_queue(adev, pipe_id, queue_id, inst);
 	amdgpu_gfx_rlc_enter_safe_mode(adev, inst);
 
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +4 -0
index 21089aadbb7b4..8cf5d7925b51c 100644
@@ -7233,6 +7233,10 @@ static int gfx_v9_0_reset_kcq(struct amdgpu_ring *ring,
 	unsigned long flags;
 	int i, r;
 
+	if (!adev->debug_exp_resets &&
+	    !adev->gfx.num_gfx_rings)
+		return -EINVAL;
+
 	if (amdgpu_sriov_vf(adev))
 		return -EINVAL;
 
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +6 -0
index 2067f26d3a9d8..f8649546b9c4c 100644
@@ -3052,6 +3052,9 @@ static void gfx_v9_4_3_ring_soft_recovery(struct amdgpu_ring *ring,
 	struct amdgpu_device *adev = ring->adev;
 	uint32_t value = 0;
 
+	if (!adev->debug_exp_resets)
+		return;
+
 	value = REG_SET_FIELD(value, SQ_CMD, CMD, 0x03);
 	value = REG_SET_FIELD(value, SQ_CMD, MODE, 0x01);
 	value = REG_SET_FIELD(value, SQ_CMD, CHECK_VMID, 1);
@@ -3475,6 +3478,9 @@ static int gfx_v9_4_3_reset_kcq(struct amdgpu_ring *ring,
 	unsigned long flags;
 	int r, i;
 
+	if (!adev->debug_exp_resets)
+		return -EINVAL;
+
 	if (amdgpu_sriov_vf(adev))
 		return -EINVAL;
 
Signature · 1 line
2.46.0
maintainer Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drm/amdgpu/gfx9: put queue resets behind a debug option

Quoted 14 lines · Alex Deucher

Pending extended validation.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c | 4 ++++
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c             | 4 ++++
  drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c           | 6 ++++++
  3 files changed, 14 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +0 -0
index c63528a4e8941..1254a43ec96b6 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c uint64_t kgd_gfx_v9_hqd_get_pq_addr(struct amdgpu_device *adev, · line 1157

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +4 -0
@@ -1151,6 +1151,10 @@ uint64_t kgd_gfx_v9_hqd_get_pq_addr(struct amdgpu_device *adev,
  	uint32_t low, high;
  	uint64_t queue_addr = 0;
 
+	if (!adev->debug_exp_resets &&
+	    !adev->gfx.num_gfx_rings)
+		return 0;
+

Did you put this in the HW-specific code path intentionally? If you want this check to apply to all ASICs, you should put it into detect_queue_hang in kfd_device_queue_manager.c. But maybe the extended validation is HW-specific.

Either way, the patch is

Quoted 42 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +0 -0
  	kgd_gfx_v9_acquire_queue(adev, pipe_id, queue_id, inst);
  	amdgpu_gfx_rlc_enter_safe_mode(adev, inst);
 
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +4 -0
index 21089aadbb7b4..8cf5d7925b51c 100644
@@ -7233,6 +7233,10 @@ static int gfx_v9_0_reset_kcq(struct amdgpu_ring *ring,
  	unsigned long flags;
  	int i, r;
 
+	if (!adev->debug_exp_resets &&
+	    !adev->gfx.num_gfx_rings)
+		return -EINVAL;
+
  	if (amdgpu_sriov_vf(adev))
  		return -EINVAL;
 
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +6 -0
index 2067f26d3a9d8..f8649546b9c4c 100644
@@ -3052,6 +3052,9 @@ static void gfx_v9_4_3_ring_soft_recovery(struct amdgpu_ring *ring,
  	struct amdgpu_device *adev = ring->adev;
  	uint32_t value = 0;
 
+	if (!adev->debug_exp_resets)
+		return;
+
  	value = REG_SET_FIELD(value, SQ_CMD, CMD, 0x03);
  	value = REG_SET_FIELD(value, SQ_CMD, MODE, 0x01);
  	value = REG_SET_FIELD(value, SQ_CMD, CHECK_VMID, 1);
@@ -3475,6 +3478,9 @@ static int gfx_v9_4_3_reset_kcq(struct amdgpu_ring *ring,
  	unsigned long flags;
  	int r, i;
 
+	if (!adev->debug_exp_resets)
+		return -EINVAL;
+
  	if (amdgpu_sriov_vf(adev))
  		return -EINVAL;
 
#3 lore raw

Re: [PATCH 2/2] drm/amdgpu/gfx9: put queue resets behind a debug option

Quoted 20 lines · Felix Kuehling
Quoted 17 lines · Alex Deucher

Pending extended validation.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c | 4 ++++
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c             | 4 ++++
  drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c           | 6 ++++++
  3 files changed, 14 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +0 -0
index c63528a4e8941..1254a43ec96b6 100644
@@ -1151,6 +1151,10 @@ uint64_t kgd_gfx_v9_hqd_get_pq_addr(struct amdgpu_device *adev,
      uint32_t low, high;
      uint64_t queue_addr = 0;
 
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c uint64_t kgd_gfx_v9_hqd_get_pq_addr(struct amdgpu_device *adev, · line 1157

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +4 -0
+     if (!adev->debug_exp_resets &&
+         !adev->gfx.num_gfx_rings)
+             return 0;
+

Did you put this in the HW-specific code path intentionally? If you want this check to apply to all ASICs, you should put it into detect_queue_hang in kfd_device_queue_manager.c. But maybe the extended validation is HW-specific.

I only want to apply it to MI parts at this point. We will likely have a different default on other parts.

Alex

Quoted 48 lines

Either way, the patch is

Quoted 42 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +0 -0
      kgd_gfx_v9_acquire_queue(adev, pipe_id, queue_id, inst);
      amdgpu_gfx_rlc_enter_safe_mode(adev, inst);
 
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +4 -0
index 21089aadbb7b4..8cf5d7925b51c 100644
@@ -7233,6 +7233,10 @@ static int gfx_v9_0_reset_kcq(struct amdgpu_ring *ring,
      unsigned long flags;
      int i, r;
 
+     if (!adev->debug_exp_resets &&
+         !adev->gfx.num_gfx_rings)
+             return -EINVAL;
+
      if (amdgpu_sriov_vf(adev))
              return -EINVAL;
 
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +6 -0
index 2067f26d3a9d8..f8649546b9c4c 100644
@@ -3052,6 +3052,9 @@ static void gfx_v9_4_3_ring_soft_recovery(struct amdgpu_ring *ring,
      struct amdgpu_device *adev = ring->adev;
      uint32_t value = 0;
 
+     if (!adev->debug_exp_resets)
+             return;
+
      value = REG_SET_FIELD(value, SQ_CMD, CMD, 0x03);
      value = REG_SET_FIELD(value, SQ_CMD, MODE, 0x01);
      value = REG_SET_FIELD(value, SQ_CMD, CHECK_VMID, 1);
@@ -3475,6 +3478,9 @@ static int gfx_v9_4_3_reset_kcq(struct amdgpu_ring *ring,
      unsigned long flags;
      int r, i;
 
+     if (!adev->debug_exp_resets)
+             return -EINVAL;
+
      if (amdgpu_sriov_vf(adev))
              return -EINVAL;
 
#4 lore raw

RE: [PATCH 2/2] drm/amdgpu/gfx9: put queue resets behind a debug option

In reply to Alex Deucher

[AMD Official Use Only - AMD Internal Distribution Only]

The series is Reviewed-and-tested-by: Jiadong Zhu <[email protected]>

Quoted 81 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Wednesday, August 21, 2024 4:25 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu/gfx9: put queue resets behind a debug option

Pending extended validation.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c | 4 ++++
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c             | 4 ++++
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c           | 6 ++++++
 3 files changed, 14 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +4 -0
index c63528a4e8941..1254a43ec96b6 100644
@@ -1151,6 +1151,10 @@ uint64_t kgd_gfx_v9_hqd_get_pq_addr(struct
 amdgpu_device *adev,
      uint32_t low, high;
      uint64_t queue_addr = 0;
 
+     if (!adev->debug_exp_resets &&
+         !adev->gfx.num_gfx_rings)
+             return 0;
+
      kgd_gfx_v9_acquire_queue(adev, pipe_id, queue_id, inst);
      amdgpu_gfx_rlc_enter_safe_mode(adev, inst);
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +4 -0
index 21089aadbb7b4..8cf5d7925b51c 100644
@@ -7233,6 +7233,10 @@ static int gfx_v9_0_reset_kcq(struct amdgpu_ring
 *ring,
      unsigned long flags;
      int i, r;
 
+     if (!adev->debug_exp_resets &&
+         !adev->gfx.num_gfx_rings)
+             return -EINVAL;
+
      if (amdgpu_sriov_vf(adev))
              return -EINVAL;
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +3 -0
index 2067f26d3a9d8..f8649546b9c4c 100644
@@ -3052,6 +3052,9 @@ static void gfx_v9_4_3_ring_soft_recovery(struct
 amdgpu_ring *ring,
      struct amdgpu_device *adev = ring->adev;
      uint32_t value = 0;
 
+     if (!adev->debug_exp_resets)
+             return;
+
      value = REG_SET_FIELD(value, SQ_CMD, CMD, 0x03);
      value = REG_SET_FIELD(value, SQ_CMD, MODE, 0x01);
      value = REG_SET_FIELD(value, SQ_CMD, CHECK_VMID, 1); @@ -
3475,6 +3478,9 @@ static int gfx_v9_4_3_reset_kcq(struct amdgpu_ring
*ring,
      unsigned long flags;
      int r, i;
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +3 -1
+     if (!adev->debug_exp_resets)
+             return -EINVAL;
+
      if (amdgpu_sriov_vf(adev))
              return -EINVAL;
 
--

2.46.0