Skip to contentSkip to conversation

drm/amdgpu: Workaround to skip kiq ring test during ras gpu recovery

PATCH In review Stanley.Yang 4 participants 5 messages Oct 17, 2023 – Oct 20, 2023

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

PATCH 1/1 drm/amdgpu: Workaround to skip kiq ring test during ras gpu recovery

This is workaround, kiq ring test failed in suspend stage when do ras recovery for gfx v9_4_3.

Change-Id I8de9900aa76706f59bc029d4e9e8438c6e1db8e0
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +21 -0
index 9a158018ae16..902e60203809 100644
@@ -29,6 +29,7 @@
 #include "amdgpu_rlc.h"
 #include "amdgpu_ras.h"
 #include "amdgpu_xcp.h"
+#include "amdgpu_xgmi.h"
 
 /* delay 0.1 second to enable gfx off feature */
 #define GFX_OFF_DELAY_ENABLE         msecs_to_jiffies(100)
@@ -501,6 +502,9 @@ int amdgpu_gfx_disable_kcq(struct amdgpu_device *adev, int xcc_id)
 {
 	struct amdgpu_kiq *kiq = &adev->gfx.kiq[xcc_id];
 	struct amdgpu_ring *kiq_ring = &kiq->ring;
+	struct amdgpu_hive_info *hive;
+	struct amdgpu_ras *ras;
+	int hive_ras_recovery;
 	int i, r = 0;
 	int j;
 
@@ -521,6 +525,23 @@ int amdgpu_gfx_disable_kcq(struct amdgpu_device *adev, int xcc_id)
 					   RESET_QUEUES, 0, 0);
 	}
 
+	/**
+	 * This is workaround: only skip kiq_ring test
+	 * during ras recovery in suspend stage for gfx v9_4_3
+	 */
+	hive = amdgpu_get_xgmi_hive(adev);
+	if (hive) {
+		hive_ras_recovery = atomic_read(&hive->ras_recovery);
+		amdgpu_put_xgmi_hive(hive);
+	}
+
+	ras = amdgpu_ras_get_context(adev);
+	if ((amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 3)) &&
+		ras && (atomic_read(&ras->in_recovery) || hive_ras_recovery)) {
+		spin_unlock(&kiq->ring_lock);
+		return 0;
+	}
+
 	if (kiq_ring->sched.ready && !adev->job_hang)
 		r = amdgpu_ring_test_helper(kiq_ring);
 	spin_unlock(&kiq->ring_lock);
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw

[AMD Official Use Only - General]

Regards,
Hawking
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Stanley.Yang
Sent: Tuesday, October 17, 2023 22:37
To: [email protected]
Cc: Yang, Stanley <[email protected]>
Subject: [PATCH Review 1/1] drm/amdgpu: Workaround to skip kiq ring test during ras gpu recovery

This is workaround, kiq ring test failed in suspend stage when do ras recovery for gfx v9_4_3.

Change-Id I8de9900aa76706f59bc029d4e9e8438c6e1db8e0
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +21 -0
index 9a158018ae16..902e60203809 100644
@@ -29,6 +29,7 @@
 #include "amdgpu_rlc.h"
 #include "amdgpu_ras.h"
 #include "amdgpu_xcp.h"
+#include "amdgpu_xgmi.h"
 
 /* delay 0.1 second to enable gfx off feature */
 #define GFX_OFF_DELAY_ENABLE         msecs_to_jiffies(100)
@@ -501,6 +502,9 @@ int amdgpu_gfx_disable_kcq(struct amdgpu_device *adev, int xcc_id)  {
        struct amdgpu_kiq *kiq = &adev->gfx.kiq[xcc_id];
        struct amdgpu_ring *kiq_ring = &kiq->ring;
+       struct amdgpu_hive_info *hive;
+       struct amdgpu_ras *ras;
+       int hive_ras_recovery;
        int i, r = 0;
        int j;
 
@@ -521,6 +525,23 @@ int amdgpu_gfx_disable_kcq(struct amdgpu_device *adev, int xcc_id)
                                           RESET_QUEUES, 0, 0);
        }
 
+       /**
+        * This is workaround: only skip kiq_ring test
+        * during ras recovery in suspend stage for gfx v9_4_3
+        */
+       hive = amdgpu_get_xgmi_hive(adev);
+       if (hive) {
+               hive_ras_recovery = atomic_read(&hive->ras_recovery);
+               amdgpu_put_xgmi_hive(hive);
+       }
+
+       ras = amdgpu_ras_get_context(adev);
+       if ((amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 3)) &&
+               ras && (atomic_read(&ras->in_recovery) || hive_ras_recovery)) {
+               spin_unlock(&kiq->ring_lock);
+               return 0;
+       }
+
        if (kiq_ring->sched.ready && !adev->job_hang)
                r = amdgpu_ring_test_helper(kiq_ring);
        spin_unlock(&kiq->ring_lock);

--
2.25.1

Reviewed-by on v1 1/1
#2 lore raw
In reply to Stanley.Yang

[AMD Official Use Only - General]

Quoted 42 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Stanley.Yang
Sent: Tuesday, October 17, 2023 10:37 PM
To: [email protected]
Cc: Yang, Stanley <[email protected]>
Subject: [PATCH Review 1/1] drm/amdgpu: Workaround to skip kiq ring test during ras gpu recovery

This is workaround, kiq ring test failed in suspend stage when do ras recovery for gfx v9_4_3.

Change-Id I8de9900aa76706f59bc029d4e9e8438c6e1db8e0
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +4 -0
index 9a158018ae16..902e60203809 100644
@@ -29,6 +29,7 @@
 #include "amdgpu_rlc.h"
 #include "amdgpu_ras.h"
 #include "amdgpu_xcp.h"
+#include "amdgpu_xgmi.h"
 
 /* delay 0.1 second to enable gfx off feature */
 #define GFX_OFF_DELAY_ENABLE         msecs_to_jiffies(100)
@@ -501,6 +502,9 @@ int amdgpu_gfx_disable_kcq(struct amdgpu_device
 *adev, int xcc_id)  {
      struct amdgpu_kiq *kiq = &adev->gfx.kiq[xcc_id];
      struct amdgpu_ring *kiq_ring = &kiq->ring;
+     struct amdgpu_hive_info *hive;
+     struct amdgpu_ras *ras;
+     int hive_ras_recovery;
      int i, r = 0;
      int j;
 

drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c int amdgpu_gfx_disable_kcq(struct amdgpu_device · line 534

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +6 -0
@@ -521,6 +525,23 @@ int amdgpu_gfx_disable_kcq(struct amdgpu_device
 *adev, int xcc_id)
                                         RESET_QUEUES, 0, 0);
      }
 
+     /**
+      * This is workaround: only skip kiq_ring test
+      * during ras recovery in suspend stage for gfx v9_4_3
+      */
+     hive = amdgpu_get_xgmi_hive(adev);
+     if (hive) {

[Tao] the hive_ras_recovery should has default value if !hive. With that fixed, the patch is:

Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +11 -0
+             hive_ras_recovery = atomic_read(&hive->ras_recovery);
+             amdgpu_put_xgmi_hive(hive);
+     }
+
+     ras = amdgpu_ras_get_context(adev);
+     if ((amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 3)) &&
+             ras && (atomic_read(&ras->in_recovery) || hive_ras_recovery))
 {
+             spin_unlock(&kiq->ring_lock);
+             return 0;
+     }
+
      if (kiq_ring->sched.ready && !adev->job_hang)
              r = amdgpu_ring_test_helper(kiq_ring);
      spin_unlock(&kiq->ring_lock);

--
2.25.1

#3 lore raw

[AMD Official Use Only - General]

Thanks, will update.

Regards,
Stanley

Quoted 88 lines

-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Wednesday, October 18, 2023 11:00 AM
To: Yang, Stanley <[email protected]>; [email protected]
Cc: Yang, Stanley <[email protected]>
Subject: RE: [PATCH Review 1/1] drm/amdgpu: Workaround to skip kiq ring test during ras gpu recovery

[AMD Official Use Only - General]

Quoted 9 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Stanley.Yang
Sent: Tuesday, October 17, 2023 10:37 PM
To: [email protected]
Cc: Yang, Stanley <[email protected]>
Subject: [PATCH Review 1/1] drm/amdgpu: Workaround to skip kiq ring test during ras gpu recovery

Quoted 7 lines

This is workaround, kiq ring test failed in suspend stage when do ras recovery for gfx v9_4_3.

Change-Id I8de9900aa76706f59bc029d4e9e8438c6e1db8e0
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 21

+++++++++++++++++++++

drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c int amdgpu_gfx_disable_kcq(struct

Quoted 26 lines
 1 file changed, 21 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +4 -0
index 9a158018ae16..902e60203809 100644
@@ -29,6 +29,7 @@
 #include "amdgpu_rlc.h"
 #include "amdgpu_ras.h"
 #include "amdgpu_xcp.h"
+#include "amdgpu_xgmi.h"
 
 /* delay 0.1 second to enable gfx off feature */
 #define GFX_OFF_DELAY_ENABLE         msecs_to_jiffies(100)
@@ -501,6 +502,9 @@ int amdgpu_gfx_disable_kcq(struct amdgpu_device
 *adev, int xcc_id)  {
      struct amdgpu_kiq *kiq = &adev->gfx.kiq[xcc_id];
      struct amdgpu_ring *kiq_ring = &kiq->ring;
+     struct amdgpu_hive_info *hive;
+     struct amdgpu_ras *ras;
+     int hive_ras_recovery;
      int i, r = 0;
      int j;
 
@@ -521,6 +525,23 @@ int amdgpu_gfx_disable_kcq(struct

amdgpu_device

drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c int amdgpu_gfx_disable_kcq(struct amdgpu_device *adev, int xcc_id) · line 533

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +6 -0
 *adev, int xcc_id)
                                         RESET_QUEUES, 0, 0);
      }
 
+     /**
+      * This is workaround: only skip kiq_ring test
+      * during ras recovery in suspend stage for gfx v9_4_3
+      */
+     hive = amdgpu_get_xgmi_hive(adev);
+     if (hive) {

[Tao] the hive_ras_recovery should has default value if !hive. With that fixed, the patch is:

Quoted 18 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +12 -1
+             hive_ras_recovery = atomic_read(&hive->ras_recovery);
+             amdgpu_put_xgmi_hive(hive);
+     }
+
+     ras = amdgpu_ras_get_context(adev);
+     if ((amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 3)) &&
+             ras && (atomic_read(&ras->in_recovery) ||
+ hive_ras_recovery))
 {
+             spin_unlock(&kiq->ring_lock);
+             return 0;
+     }
+
      if (kiq_ring->sched.ready && !adev->job_hang)
              r = amdgpu_ring_test_helper(kiq_ring);
      spin_unlock(&kiq->ring_lock);
--

2.25.1

#4 lore raw
In reply to Stanley.Yang

Am 17.10.23 um 16:36 schrieb Stanley.Yang:

Quoted 2 lines

This is workaround, kiq ring test failed in suspend stage when do ras recovery for gfx v9_4_3.

Any idea why that failed? Problems like this usually point to an incorrect init or in this case re-init procedure and are actually what the ring test should uncover.

Christian.

Quoted 53 lines
Change-Id I8de9900aa76706f59bc029d4e9e8438c6e1db8e0
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 21 +++++++++++++++++++++
  1 file changed, 21 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +21 -0
index 9a158018ae16..902e60203809 100644
@@ -29,6 +29,7 @@
  #include "amdgpu_rlc.h"
  #include "amdgpu_ras.h"
  #include "amdgpu_xcp.h"
+#include "amdgpu_xgmi.h"
 
  /* delay 0.1 second to enable gfx off feature */
  #define GFX_OFF_DELAY_ENABLE         msecs_to_jiffies(100)
@@ -501,6 +502,9 @@ int amdgpu_gfx_disable_kcq(struct amdgpu_device *adev, int xcc_id)
  {
  	struct amdgpu_kiq *kiq = &adev->gfx.kiq[xcc_id];
  	struct amdgpu_ring *kiq_ring = &kiq->ring;
+	struct amdgpu_hive_info *hive;
+	struct amdgpu_ras *ras;
+	int hive_ras_recovery;
  	int i, r = 0;
  	int j;
 
@@ -521,6 +525,23 @@ int amdgpu_gfx_disable_kcq(struct amdgpu_device *adev, int xcc_id)
  					   RESET_QUEUES, 0, 0);
  	}
 
+	/**
+	 * This is workaround: only skip kiq_ring test
+	 * during ras recovery in suspend stage for gfx v9_4_3
+	 */
+	hive = amdgpu_get_xgmi_hive(adev);
+	if (hive) {
+		hive_ras_recovery = atomic_read(&hive->ras_recovery);
+		amdgpu_put_xgmi_hive(hive);
+	}
+
+	ras = amdgpu_ras_get_context(adev);
+	if ((amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 3)) &&
+		ras && (atomic_read(&ras->in_recovery) || hive_ras_recovery)) {
+		spin_unlock(&kiq->ring_lock);
+		return 0;
+	}
+
  	if (kiq_ring->sched.ready && !adev->job_hang)
  		r = amdgpu_ring_test_helper(kiq_ring);
  	spin_unlock(&kiq->ring_lock);