Skip to contentSkip to conversation

drm/amdgpu: Add a filter condition to restrict the SW ras function to be registered only by asics whose hardware supports the ras function

PATCH In review yipechai 4 participants 9 messages Jan 12, 2022 – Jan 13, 2022

Subsystems (2)
lore
Share & tools
lore

yipechai

author
#0 lore raw

PATCH 1/2 drm/amdgpu: Add a filter condition to restrict the SW ras function to be registered only by asics whose hardware supports the ras function

Add a filter condition to restrict the SW ras function to be registered only by asics whose hardware supports the ras function.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -1
index b1bedfd4febc..62be0b4909b3 100644
@@ -2754,7 +2754,7 @@ int amdgpu_ras_reset_gpu(struct amdgpu_device *adev)
 int amdgpu_ras_register_ras_block(struct amdgpu_device *adev,
 		struct amdgpu_ras_block_object* ras_block_obj)
 {
-	if (!adev || !ras_block_obj)
+	if (!adev || !amdgpu_ras_asic_supported(adev) || !ras_block_obj)
 		return -EINVAL;
 
 	INIT_LIST_HEAD(&ras_block_obj->node);
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 2/2 drm/amdgpu: No longer insert ras blocks into ras_list if it already exists in ras_list

No longer insert ras blocks into ras_list if it already exists in ras_list.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +8 -0
index 62be0b4909b3..e6d3bb4b56e4 100644
@@ -2754,9 +2754,17 @@ int amdgpu_ras_reset_gpu(struct amdgpu_device *adev)
 int amdgpu_ras_register_ras_block(struct amdgpu_device *adev,
 		struct amdgpu_ras_block_object* ras_block_obj)
 {
+	struct amdgpu_ras_block_object *obj, *tmp;
 	if (!adev || !amdgpu_ras_asic_supported(adev) || !ras_block_obj)
 		return -EINVAL;
 
+	/* If the ras object had been in ras_list, doesn't add it to ras_list again */
+	list_for_each_entry_safe(obj, tmp, &adev->ras_list, node) {
+		if (obj == ras_block_obj) {
+			return 0;
+		}
+	}
+
 	INIT_LIST_HEAD(&ras_block_obj->node);
 	list_add_tail(&ras_block_obj->node, &adev->ras_list);
 
Signature · 1 line
2.25.1
#2 lore raw

RE: [PATCH 2/2] drm/amdgpu: No longer insert ras blocks into ras_list if it already exists in ras_list

[AMD Official Use Only]

Quoted 23 lines

-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Wednesday, January 12, 2022 3:48 PM
To: [email protected]
Cc: Chai, Thomas <[email protected]>; Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; Clements, John <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: No longer insert ras blocks into ras_list if it already exists in ras_list

No longer insert ras blocks into ras_list if it already exists in ras_list.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -0
index 62be0b4909b3..e6d3bb4b56e4 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c int amdgpu_ras_reset_gpu(struct amdgpu_device · line 2760

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2 -0
@@ -2754,9 +2754,17 @@ int amdgpu_ras_reset_gpu(struct amdgpu_device
 *adev)  int amdgpu_ras_register_ras_block(struct amdgpu_device *adev,
 		struct amdgpu_ras_block_object* ras_block_obj)  {
+	struct amdgpu_ras_block_object *obj, *tmp;
 	if (!adev || !amdgpu_ras_asic_supported(adev) || !ras_block_obj)
 		return -EINVAL;
 
+	/* If the ras object had been in ras_list, doesn't add it to ras_list again */

[Tao] How about "If the ras object is in ras_list, don't add it again"

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c int amdgpu_ras_reset_gpu(struct amdgpu_device *adev) · line 2766

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +5 -0
+	list_for_each_entry_safe(obj, tmp, &adev->ras_list, node) {
+		if (obj == ras_block_obj) {
+			return 0;
+		}
+	}

[Tao] The patch is OK for me currently, but I think the root cause is we initialize adev->gmc.xgmi.ras in gmc_ras_late_init, the initialization should be called only in modprobe stage and we can create a general gmc_early_init for it.

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -1
+
 	INIT_LIST_HEAD(&ras_block_obj->node);
 	list_add_tail(&ras_block_obj->node, &adev->ras_list);
 
--

2.25.1

#3 lore raw

RE: [PATCH 2/2] drm/amdgpu: No longer insert ras blocks into ras_list if it already exists in ras_list

-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Wednesday, January 12, 2022 4:37 PM
To: Chai, Thomas <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Clements, John <[email protected]>
Subject: RE: [PATCH 2/2] drm/amdgpu: No longer insert ras blocks into ras_list if it already exists in ras_list

[AMD Official Use Only]

Quoted 31 lines

-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Wednesday, January 12, 2022 3:48 PM
To: [email protected]
Cc: Chai, Thomas <[email protected]>; Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; Clements, John <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: No longer insert ras blocks into ras_list if it already exists in ras_list

No longer insert ras blocks into ras_list if it already exists in ras_list.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +3 -0
index 62be0b4909b3..e6d3bb4b56e4 100644
@@ -2754,9 +2754,17 @@ int amdgpu_ras_reset_gpu(struct amdgpu_device
 *adev)  int amdgpu_ras_register_ras_block(struct amdgpu_device *adev,
 		struct amdgpu_ras_block_object* ras_block_obj)  {
+	struct amdgpu_ras_block_object *obj, *tmp;
 	if (!adev || !amdgpu_ras_asic_supported(adev) || !ras_block_obj)
 		return -EINVAL;
 
+	/* If the ras object had been in ras_list, doesn't add it to 
+ras_list again */
Quoted 1 line

[Tao] How about "If the ras object is in ras_list, don't add it again"

[Thomas] OK

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +5 -0
+	list_for_each_entry_safe(obj, tmp, &adev->ras_list, node) {
+		if (obj == ras_block_obj) {
+			return 0;
+		}
+	}

[Tao] The patch is OK for me currently, but I think the root cause is we initialize adev->gmc.xgmi.ras in gmc_ras_late_init, the initialization should be called only in modprobe stage and we can create a general gmc_early_init for it.

[Thomas] This can create a new task to do it.

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -1
+
 	INIT_LIST_HEAD(&ras_block_obj->node);
 	list_add_tail(&ras_block_obj->node, &adev->ras_list);
 
--

2.25.1

#4 lore raw

Re: [PATCH 2/2] drm/amdgpu: No longer insert ras blocks into ras_list if it already exists in ras_list

In reply to Zhou1, Tao
Quoted 37 lines · Tao

[AMD Official Use Only]

Quoted 23 lines

-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Wednesday, January 12, 2022 3:48 PM
To: [email protected]
Cc: Chai, Thomas <[email protected]>; Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; Clements, John <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: No longer insert ras blocks into ras_list if it already exists in ras_list

No longer insert ras blocks into ras_list if it already exists in ras_list.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -0
index 62be0b4909b3..e6d3bb4b56e4 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c int amdgpu_ras_reset_gpu(struct amdgpu_device · line 2760

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2 -0
@@ -2754,9 +2754,17 @@ int amdgpu_ras_reset_gpu(struct amdgpu_device
 *adev)  int amdgpu_ras_register_ras_block(struct amdgpu_device *adev,
              struct amdgpu_ras_block_object* ras_block_obj)  {
+     struct amdgpu_ras_block_object *obj, *tmp;
      if (!adev || !amdgpu_ras_asic_supported(adev) || !ras_block_obj)
              return -EINVAL;
 
+     /* If the ras object had been in ras_list, doesn't add it to ras_list again */

[Tao] How about "If the ras object is in ras_list, don't add it again"

Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c int amdgpu_ras_reset_gpu(struct amdgpu_device *adev) · line 2766

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +5 -0
+     list_for_each_entry_safe(obj, tmp, &adev->ras_list, node) {
+             if (obj == ras_block_obj) {
+                     return 0;
+             }
+     }

[Tao] The patch is OK for me currently, but I think the root cause is we initialize adev->gmc.xgmi.ras in gmc_ras_late_init, the initialization should be called only in modprobe stage and we can create a general gmc_early_init for it.

Yes, please fix the root cause. We should only be adding the blocks once. This is just papering over the actual problem.

Alex

Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -1
+
      INIT_LIST_HEAD(&ras_block_obj->node);
      list_add_tail(&ras_block_obj->node, &adev->ras_list);
 
--

2.25.1

#5 lore raw

Re: [PATCH 2/2] drm/amdgpu: No longer insert ras blocks into ras_list if it already exists in ras_list

In reply to yipechai

Am 2022-01-12 um 2:48 a.m. schrieb yipechai:

Quoted 12 lines

No longer insert ras blocks into ras_list if it already exists in ras_list.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -0
index 62be0b4909b3..e6d3bb4b56e4 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c int amdgpu_ras_reset_gpu(struct amdgpu_device *adev) · line 2763

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +4 -0
@@ -2754,9 +2754,17 @@ int amdgpu_ras_reset_gpu(struct amdgpu_device *adev)
 int amdgpu_ras_register_ras_block(struct amdgpu_device *adev,
 		struct amdgpu_ras_block_object* ras_block_obj)
 {
+	struct amdgpu_ras_block_object *obj, *tmp;
 	if (!adev || !amdgpu_ras_asic_supported(adev) || !ras_block_obj)
 		return -EINVAL;
 
+	/* If the ras object had been in ras_list, doesn't add it to ras_list again */
+	list_for_each_entry_safe(obj, tmp, &adev->ras_list, node) {
+		if (obj == ras_block_obj) {

Instead of a loop, can't this be done more efficiently with "if (!list_empty(&ras_block_obj->node))"?

Of course this would require that you move the INIT_LIST_HEAD to some earlier stage so that list_empty is reliable.

Regards,
  Felix

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +4 -0
+			return 0;
+		}
+	}
+
 	INIT_LIST_HEAD(&ras_block_obj->node);
 	list_add_tail(&ras_block_obj->node, &adev->ras_list);
 
#6 lore raw

RE: [PATCH 2/2] drm/amdgpu: No longer insert ras blocks into ras_list if it already exists in ras_list

Hi Felix:
amdgpu_ras_register_ras_block was called by all IP ras blocks, and every ip also has different ras versions. We do common work together, which can reduce the chance of the ras function going wrong.

-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Thursday, January 13, 2022 12:39 AM
To: Chai, Thomas <[email protected]>; [email protected]
Cc: Zhou1, Tao <[email protected]>; Zhang, Hawking <[email protected]>; Clements, John <[email protected]>; Chai, Thomas <[email protected]>
Subject: Re: [PATCH 2/2] drm/amdgpu: No longer insert ras blocks into ras_list if it already exists in ras_list

Am 2022-01-12 um 2:48 a.m. schrieb yipechai:

Quoted 13 lines

No longer insert ras blocks into ras_list if it already exists in ras_list.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -0
index 62be0b4909b3..e6d3bb4b56e4 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c int amdgpu_ras_reset_gpu(struct amdgpu_device · line 2762

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +4 -0
@@ -2754,9 +2754,17 @@ int amdgpu_ras_reset_gpu(struct amdgpu_device 
 *adev)  int amdgpu_ras_register_ras_block(struct amdgpu_device *adev,
 		struct amdgpu_ras_block_object* ras_block_obj)  {
+	struct amdgpu_ras_block_object *obj, *tmp;
 	if (!adev || !amdgpu_ras_asic_supported(adev) || !ras_block_obj)
 		return -EINVAL;
 
+	/* If the ras object had been in ras_list, doesn't add it to ras_list again */
+	list_for_each_entry_safe(obj, tmp, &adev->ras_list, node) {
+		if (obj == ras_block_obj) {

Instead of a loop, can't this be done more efficiently with "if (!list_empty(&ras_block_obj->node))"?

Of course this would require that you move the INIT_LIST_HEAD to some earlier stage so that list_empty is reliable.

Regards,
  Felix

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +4 -0
+			return 0;
+		}
+	}
+
 	INIT_LIST_HEAD(&ras_block_obj->node);
 	list_add_tail(&ras_block_obj->node, &adev->ras_list);
 
#7 lore raw
In reply to yipechai

[AMD Official Use Only]

Quoted 9 lines

-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Wednesday, January 12, 2022 3:48 PM
To: [email protected]
Cc: Chai, Thomas <[email protected]>; Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; Clements, John <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: Add a filter condition to restrict the SW ras function to be registered only by asics whose hardware supports the ras function

[Tao] The subject is too long, I think "add ras supported check for register_ras_block" is enough.

Quoted 15 lines

Add a filter condition to restrict the SW ras function to be registered only by asics whose hardware supports the ras function.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -0
index b1bedfd4febc..62be0b4909b3 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c int amdgpu_ras_reset_gpu(struct amdgpu_device · line 2757

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -1
@@ -2754,7 +2754,7 @@ int amdgpu_ras_reset_gpu(struct amdgpu_device
 *adev)  int amdgpu_ras_register_ras_block(struct amdgpu_device *adev,
 		struct amdgpu_ras_block_object* ras_block_obj)  {
-	if (!adev || !ras_block_obj)
+	if (!adev || !amdgpu_ras_asic_supported(adev) || !ras_block_obj)
 		return -EINVAL;

[Tao] Can we return 0 if !amdgpu_ras_asic_supported(adev)? It's not an error.

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -1
 	INIT_LIST_HEAD(&ras_block_obj->node);
--

2.25.1

#8 lore raw

-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Wednesday, January 12, 2022 4:28 PM
To: Chai, Thomas <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Clements, John <[email protected]>
Subject: RE: [PATCH 1/2] drm/amdgpu: Add a filter condition to restrict the SW ras function to be registered only by asics whose hardware supports the ras function

[AMD Official Use Only]

Quoted 11 lines

-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Wednesday, January 12, 2022 3:48 PM
To: [email protected]
Cc: Chai, Thomas <[email protected]>; Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; Clements, John <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: Add a filter condition to restrict the SW ras function to be registered only by asics whose hardware supports the ras function

Quoted 1 line

[Tao] The subject is too long, I think "add ras supported check for register_ras_block" is enough.

[Thomas] Ok.

Quoted 21 lines

Add a filter condition to restrict the SW ras function to be registered only by asics whose hardware supports the ras function.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -1
index b1bedfd4febc..62be0b4909b3 100644
@@ -2754,7 +2754,7 @@ int amdgpu_ras_reset_gpu(struct amdgpu_device
 *adev)  int amdgpu_ras_register_ras_block(struct amdgpu_device *adev,
 		struct amdgpu_ras_block_object* ras_block_obj)  {
-	if (!adev || !ras_block_obj)
+	if (!adev || !amdgpu_ras_asic_supported(adev) || !ras_block_obj)
 		return -EINVAL;
 
Quoted 1 line

[Tao] Can we return 0 if !amdgpu_ras_asic_supported(adev)? It's not an error.

[Thomas] OK.

Quoted 4 lines

INIT_LIST_HEAD(&ras_block_obj->node);
--
2.25.1