Skip to contentSkip to conversation

drm/amdgpu: reject errored peers in UALink local vPod integrity check

PATCH In review Mukul Joshi 4 participants 8 messages Nov 30 – Dec 1

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

PATCH v3 1/1 drm/amdgpu: reject errored peers in UALink local vPod integrity check

AMDGPU_UALINK_ACCEL_STATE_ERROR sorts above every configured state, so a local peer in the error state passes both the "pPod configured" and "vPod configured" checks in __check_local_vpod_integrity() and is treated as a healthy vPod member. The local vPod is then activated around an accelerator that cannot participate.

The error state is also entered when __check_ppod_info() fails on a configuration that already includes vPod information. Such a peer never reaches PPOD_CONFIGURED, and its accel_id is unvalidated firmware data that is used to index vpod.active_accel_bits without a bounds check.

Check for the error state first, before any other state check. Fail the integrity check if the errored peer is a member of this vPod, and skip it otherwise. If its accel_id is out of range, its membership cannot be determined, so treat it as a member and fail the check rather than risk activating the vPod without it.

Fixes 448a35158bee ("drm/amdgpu: Assign accel state based on ASP config")

---
v1->v2:
- Ensure invalid accel_id peer fail VPOD activation.

v2->v3:
- Check error state before PPOD_CONFIGURED check.

 drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +16 -3
index 0982d8455b0c..6d675c318952 100644
@@ -1169,17 +1169,30 @@ static int __check_local_vpod_integrity(struct amdgpu_device *adev)
 			continue;
 
 		peer_info = peer_adev->ualink.info;
+		accel_id = peer_info->ppod.accel_id;
+		/* An errored peer's accel_id may have failed validation, in
+		 * which case its vPod membership is unknown: treat it as a
+		 * member.
+		 */
+		if (peer_info->accel_state == AMDGPU_UALINK_ACCEL_STATE_ERROR) {
+			if (accel_id >= AMDGPU_UALINK_ACCEL_MAX ||
+			    test_bit(accel_id, info->vpod.active_accel_bits)) {
+				dev_warn(adev->dev,
+					 "UALINK: integrity fail: errored peer accel_id=%u is or may be a vpod member\n",
+					 accel_id);
+				return -EINVAL;
+			}
+			continue;
+		}
 		/* peer device ppod not configured */
 		if (peer_info->accel_state <
 		    AMDGPU_UALINK_ACCEL_STATE_PPOD_CONFIGURED) {
 			dev_info(adev->dev,
 				 "UALINK: integrity EAGAIN: peer accel_id=%u not ppod-configured (accel_state=%d)\n",
-				 peer_info->ppod.accel_id,
-				 peer_info->accel_state);
+				 accel_id, peer_info->accel_state);
 			return -EAGAIN;
 		}
 
-		accel_id = peer_info->ppod.accel_id;
 		if (!test_bit(accel_id, info->vpod.active_accel_bits))
 			continue;
 		/* peer device vpod not configured */
Signature · 1 line
2.56.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] drm/amdgpu: incomplete errored peer check in __check_local_vpod_integrity() --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] drm/amdgpu: incomplete errored peer check in __check_local_vpod_integrity()
--

commit afa1dfd6bced3e7e4c6a0f3810602234d791cc37
Author: Mukul Joshi <[email protected]>

drm/amdgpu: reject errored peers in UALink local vPod integrity check

This commit updates __check_local_vpod_integrity() to check whether a peer accelerator is in AMDGPU_UALINK_ACCEL_STATE_ERROR before testing its pPod or vPod configuration states, failing the integrity check if the errored peer has an out-of-range accel_id or is marked in vpod.active_accel_bits.

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +5 -0
index fa4c3d27d2720..2966e501ac120 100644
@@ -1168,17 +1168,30 @@ static int __check_local_vpod_integrity(struct amdgpu_device *adev)
 			continue;
 
 		peer_info = peer_adev->ualink.info;
+		accel_id = peer_info->ppod.accel_id;
+		/* An errored peer's accel_id may have failed validation, in
+		 * which case its vPod membership is unknown: treat it as a
+		 * member.
+		 */

drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c static int __check_local_vpod_integrity(struct amdgpu_device *adev) · line 1185

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +10 -0
+		if (peer_info->accel_state == AMDGPU_UALINK_ACCEL_STATE_ERROR) {
+			if (accel_id >= AMDGPU_UALINK_ACCEL_MAX ||
+			    test_bit(accel_id, info->vpod.active_accel_bits)) {
+				dev_warn(adev->dev,
+					 "UALINK: integrity fail: errored peer accel_id=%u is or may be a vpod member\n",
+					 accel_id);
+				return -EINVAL;
+			}
+			continue;
+		}

[Severity: Medium]
Can an errored peer whose pPod failed __check_ppod_info() still be skipped here when accel_id < AMDGPU_UALINK_ACCEL_MAX?

In amdgpu_ualink_info_set_accel_state(), a peer enters AMDGPU_UALINK_ACCEL_STATE_ERROR when __check_ppod_info() fails because ppod.size is 0 or ppod.accel_id >= ppod.size. When info->ppod.size is smaller than AMDGPU_UALINK_ACCEL_MAX (for example 8) and the errored peer has an unvalidated accel_id in [info->ppod.size, AMDGPU_UALINK_ACCEL_MAX - 1] (or ppod.size == 0 and accel_id == 0 when bit 0 is not in this vPod), accel_id >= AMDGPU_UALINK_ACCEL_MAX and test_bit() are both false. The loop then skips the peer and activates the vPod even though the peer's accel_id failed validation and its vPod membership is unknown.

Checking !__check_ppod_info(peer_adev, peer_info) instead of accel_id >= AMDGPU_UALINK_ACCEL_MAX would catch any unvalidated pPod on an errored peer before consulting active_accel_bits.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to Mukul Joshi
Quoted 36 lines · Mukul Joshi

AMDGPU_UALINK_ACCEL_STATE_ERROR sorts above every configured state, so a local peer in the error state passes both the "pPod configured" and "vPod configured" checks in __check_local_vpod_integrity() and is treated as a healthy vPod member. The local vPod is then activated around an accelerator that cannot participate.

The error state is also entered when __check_ppod_info() fails on a configuration that already includes vPod information. Such a peer never reaches PPOD_CONFIGURED, and its accel_id is unvalidated firmware data that is used to index vpod.active_accel_bits without a bounds check.

Check for the error state first, before any other state check. Fail the integrity check if the errored peer is a member of this vPod, and skip it otherwise. If its accel_id is out of range, its membership cannot be determined, so treat it as a member and fail the check rather than risk activating the vPod without it.

Fixes 448a35158bee ("drm/amdgpu: Assign accel state based on ASP config")

---
v1->v2:
- Ensure invalid accel_id peer fail VPOD activation.

v2->v3:
- Check error state before PPOD_CONFIGURED check.

  drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 19 ++++++++++++++++---
  1 file changed, 16 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +0 -0
index 0982d8455b0c..6d675c318952 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c static int __check_local_vpod_integrity(struct amdgpu_device *adev) · line 1177

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +6 -0
@@ -1169,17 +1169,30 @@ static int __check_local_vpod_integrity(struct amdgpu_device *adev)
  			continue;
 
  		peer_info = peer_adev->ualink.info;
+		accel_id = peer_info->ppod.accel_id;
+		/* An errored peer's accel_id may have failed validation, in
+		 * which case its vPod membership is unknown: treat it as a
+		 * member.
+		 */
+		if (peer_info->accel_state == AMDGPU_UALINK_ACCEL_STATE_ERROR) {

I don't think anything can be inferred from an accel id in error state. It could be part of a different vpod altogether. It's better to just skip it.

Thanks,
Lijo

Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +10 -3
+			if (accel_id >= AMDGPU_UALINK_ACCEL_MAX ||
+			    test_bit(accel_id, info->vpod.active_accel_bits)) {
+				dev_warn(adev->dev,
+					 "UALINK: integrity fail: errored peer accel_id=%u is or may be a vpod member\n",
+					 accel_id);
+				return -EINVAL;
+			}
+			continue;
+		}
  		/* peer device ppod not configured */
  		if (peer_info->accel_state <
  		    AMDGPU_UALINK_ACCEL_STATE_PPOD_CONFIGURED) {
  			dev_info(adev->dev,
  				 "UALINK: integrity EAGAIN: peer accel_id=%u not ppod-configured (accel_state=%d)\n",
-				 peer_info->ppod.accel_id,
-				 peer_info->accel_state);
+				 accel_id, peer_info->accel_state);
  			return -EAGAIN;
  		}
 
-		accel_id = peer_info->ppod.accel_id;
  		if (!test_bit(accel_id, info->vpod.active_accel_bits))
  			continue;
  		/* peer device vpod not configured */
#3 lore raw

AMD General

Quoted 63 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, November 30, 2026 10:23 PM
To: Joshi, Mukul <[email protected]>; [email protected]
Cc: Kuehling, Felix <[email protected]>; Kasiviswanathan, Harish <[email protected]>; Yang, Philip <[email protected]>; Sashiko-bot <[email protected]>
Subject: Re: [PATCHv3] drm/amdgpu: reject errored peers in UALink local vPod integrity check

Quoted 1 line · Mukul Joshi

AMDGPU_UALINK_ACCEL_STATE_ERROR sorts above every configured state,

so

Quoted 21 lines

a local peer in the error state passes both the "pPod configured" and "vPod configured" checks in __check_local_vpod_integrity() and is treated as a healthy vPod member. The local vPod is then activated around an accelerator that cannot participate.

The error state is also entered when __check_ppod_info() fails on a configuration that already includes vPod information. Such a peer never reaches PPOD_CONFIGURED, and its accel_id is unvalidated firmware data that is used to index vpod.active_accel_bits without a bounds check.

Check for the error state first, before any other state check. Fail the integrity check if the errored peer is a member of this vPod, and skip it otherwise. If its accel_id is out of range, its membership cannot be determined, so treat it as a member and fail the check rather than risk activating the vPod without it.

Fixes 448a35158bee ("drm/amdgpu: Assign accel state based on ASP

config")

Quoted 8 lines

---
v1->v2:
- Ensure invalid accel_id peer fail VPOD activation.

v2->v3:
- Check error state before PPOD_CONFIGURED check.

  drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 19

++++++++++++++++---

drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c static int __check_local_vpod_integrity(struct

Quoted 8 lines
  1 file changed, 16 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +0 -0
index 0982d8455b0c..6d675c318952 100644
@@ -1169,17 +1169,30 @@ static int __check_local_vpod_integrity(struct

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c static int __check_local_vpod_integrity(struct amdgpu_device *adev)

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +6 -0
                    continue;
 
            peer_info = peer_adev->ualink.info;
+           accel_id = peer_info->ppod.accel_id;
+           /* An errored peer's accel_id may have failed validation, in
+            * which case its vPod membership is unknown: treat it as a
+            * member.
+            */
+           if (peer_info->accel_state ==
Quoted 5 lines

AMDGPU_UALINK_ACCEL_STATE_ERROR) {

I don't think anything can be inferred from an accel id in error state. It could be part of a different vpod altogether. It's better to just skip it.

I would prefer to let the administrators know that there is something wrong in your config rather than silently ignore/skip that Accelerator.
Unfortunately, failing the VPOD config with an errored accelerator is the cleanest way to let administrator know that something is wrong in the configuration.

I agree that if accel_id > = 256 would fail the VPOD config for another VPOD but I don't see how to avoid that.

Regards,
Mukul

Quoted 29 lines

Thanks,
Lijo

drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c static int __check_local_vpod_integrity(struct amdgpu_device *adev)

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +4 -0
+                   if (accel_id >= AMDGPU_UALINK_ACCEL_MAX ||
+                       test_bit(accel_id, info->vpod.active_accel_bits)) {
+                           dev_warn(adev->dev,
+                                    "UALINK: integrity fail: errored peer

accel_id=%u is or may be a vpod member\n",

drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c static int __check_local_vpod_integrity(struct amdgpu_device *adev)

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +5 -0
+                                    accel_id);
+                           return -EINVAL;
+                   }
+                   continue;
+           }
            /* peer device ppod not configured */
            if (peer_info->accel_state <
                AMDGPU_UALINK_ACCEL_STATE_PPOD_CONFIGURED) {
                    dev_info(adev->dev,
                             "UALINK: integrity EAGAIN: peer accel_id=%u

not ppod-configured (accel_state=%d)\n",

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +1 -3
-                            peer_info->ppod.accel_id,
-                            peer_info->accel_state);
+                            accel_id, peer_info->accel_state);
                    return -EAGAIN;
            }
 
-           accel_id = peer_info->ppod.accel_id;
            if (!test_bit(accel_id, info->vpod.active_accel_bits))
                    continue;
            /* peer device vpod not configured */
#4 lore raw
Quoted 70 lines · Mukul

AMD General

Quoted 63 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, November 30, 2026 10:23 PM
To: Joshi, Mukul <[email protected]>; [email protected]
Cc: Kuehling, Felix <[email protected]>; Kasiviswanathan, Harish <[email protected]>; Yang, Philip <[email protected]>; Sashiko-bot <[email protected]>
Subject: Re: [PATCHv3] drm/amdgpu: reject errored peers in UALink local vPod integrity check

Quoted 1 line · Mukul Joshi

AMDGPU_UALINK_ACCEL_STATE_ERROR sorts above every configured state,

so

Quoted 21 lines

a local peer in the error state passes both the "pPod configured" and "vPod configured" checks in __check_local_vpod_integrity() and is treated as a healthy vPod member. The local vPod is then activated around an accelerator that cannot participate.

The error state is also entered when __check_ppod_info() fails on a configuration that already includes vPod information. Such a peer never reaches PPOD_CONFIGURED, and its accel_id is unvalidated firmware data that is used to index vpod.active_accel_bits without a bounds check.

Check for the error state first, before any other state check. Fail the integrity check if the errored peer is a member of this vPod, and skip it otherwise. If its accel_id is out of range, its membership cannot be determined, so treat it as a member and fail the check rather than risk activating the vPod without it.

Fixes 448a35158bee ("drm/amdgpu: Assign accel state based on ASP

config")

Quoted 8 lines

---
v1->v2:
- Ensure invalid accel_id peer fail VPOD activation.

v2->v3:
- Check error state before PPOD_CONFIGURED check.

   drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 19

++++++++++++++++---

drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c static int __check_local_vpod_integrity(struct

Quoted 8 lines
   1 file changed, 16 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +0 -0
index 0982d8455b0c..6d675c318952 100644
@@ -1169,17 +1169,30 @@ static int __check_local_vpod_integrity(struct

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c static int __check_local_vpod_integrity(struct amdgpu_device *adev)

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +6 -0
                     continue;
 
             peer_info = peer_adev->ualink.info;
+           accel_id = peer_info->ppod.accel_id;
+           /* An errored peer's accel_id may have failed validation, in
+            * which case its vPod membership is unknown: treat it as a
+            * member.
+            */
+           if (peer_info->accel_state ==
Quoted 5 lines

AMDGPU_UALINK_ACCEL_STATE_ERROR) {

I don't think anything can be inferred from an accel id in error state. It could be part of a different vpod altogether. It's better to just skip it.

Quoted 7 lines

I would prefer to let the administrators know that there is something wrong in your config rather than silently ignore/skip that Accelerator.
Unfortunately, failing the VPOD config with an errored accelerator is the cleanest way to let administrator know that something is wrong in the configuration.

I agree that if accel_id > = 256 would fail the VPOD config for another VPOD but I don't see how to avoid that.

The notification is already there when an accelerator is put to error state.

Thanks,
Lijo

Quoted 34 lines

Regards,
Mukul

Quoted 29 lines

Thanks,
Lijo

drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c static int __check_local_vpod_integrity(struct amdgpu_device *adev)

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +4 -0
+                   if (accel_id >= AMDGPU_UALINK_ACCEL_MAX ||
+                       test_bit(accel_id, info->vpod.active_accel_bits)) {
+                           dev_warn(adev->dev,
+                                    "UALINK: integrity fail: errored peer

accel_id=%u is or may be a vpod member\n",

drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c static int __check_local_vpod_integrity(struct amdgpu_device *adev)

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +5 -0
+                                    accel_id);
+                           return -EINVAL;
+                   }
+                   continue;
+           }
             /* peer device ppod not configured */
             if (peer_info->accel_state <
                 AMDGPU_UALINK_ACCEL_STATE_PPOD_CONFIGURED) {
                     dev_info(adev->dev,
                              "UALINK: integrity EAGAIN: peer accel_id=%u

not ppod-configured (accel_state=%d)\n",

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +1 -3
-                            peer_info->ppod.accel_id,
-                            peer_info->accel_state);
+                            accel_id, peer_info->accel_state);
                     return -EAGAIN;
             }
 
-           accel_id = peer_info->ppod.accel_id;
             if (!test_bit(accel_id, info->vpod.active_accel_bits))
                     continue;
             /* peer device vpod not configured */
#5 lore raw

AMD General

Quoted 90 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, December 1, 2026 10:20 AM
To: Joshi, Mukul <[email protected]>; [email protected]
Cc: Kuehling, Felix <[email protected]>; Kasiviswanathan, Harish <[email protected]>; Yang, Philip <[email protected]>; Sashiko-bot <[email protected]>
Subject: Re: [PATCHv3] drm/amdgpu: reject errored peers in UALink local vPod integrity check

Quoted 8 lines · Mukul

AMD General

Quoted 6 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, November 30, 2026 10:23 PM
To: Joshi, Mukul <[email protected]>; [email protected]
Cc: Kuehling, Felix <[email protected]>; Kasiviswanathan, Harish <[email protected]>; Yang, Philip

<[email protected]>;

Quoted 8 lines
Quoted 8 lines

Sashiko-bot <[email protected]>
Subject: Re: [PATCHv3] drm/amdgpu: reject errored peers in UALink local vPod integrity check

Quoted 1 line · Mukul Joshi

AMDGPU_UALINK_ACCEL_STATE_ERROR sorts above every configured

state,

Quoted 52 lines
Quoted 52 lines

so

Quoted 21 lines

a local peer in the error state passes both the "pPod configured" and "vPod configured" checks in __check_local_vpod_integrity() and is treated as a healthy vPod member. The local vPod is then activated around an accelerator that cannot participate.

The error state is also entered when __check_ppod_info() fails on a configuration that already includes vPod information. Such a peer never reaches PPOD_CONFIGURED, and its accel_id is unvalidated firmware data that is used to index vpod.active_accel_bits without a bounds check.

Check for the error state first, before any other state check. Fail the integrity check if the errored peer is a member of this vPod, and skip it otherwise. If its accel_id is out of range, its membership cannot be determined, so treat it as a member and fail the check rather than risk activating the vPod without it.

Fixes 448a35158bee ("drm/amdgpu: Assign accel state based on ASP

config")

Quoted 8 lines

---
v1->v2:
- Ensure invalid accel_id peer fail VPOD activation.

v2->v3:
- Check error state before PPOD_CONFIGURED check.

   drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 19

++++++++++++++++---

Quoted 9 lines
   1 file changed, 16 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +0 -0
index 0982d8455b0c..6d675c318952 100644
@@ -1169,17 +1169,30 @@ static int

__check_local_vpod_integrity(struct

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c static int __check_local_vpod_integrity(struct amdgpu_device *adev)

Quoted 9 lines
                     continue;

             peer_info = peer_adev->ualink.info;
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +6 -0
+           accel_id = peer_info->ppod.accel_id;
+           /* An errored peer's accel_id may have failed validation, in
+            * which case its vPod membership is unknown: treat it as a
+            * member.
+            */
+           if (peer_info->accel_state ==

AMDGPU_UALINK_ACCEL_STATE_ERROR) {

Quoted 7 lines
Quoted 3 lines

I don't think anything can be inferred from an accel id in error state. It could be part of a different vpod altogether. It's better to just skip it.

I would prefer to let the administrators know that there is something wrong in your config rather than silently ignore/skip that Accelerator. Unfortunately, failing the VPOD config with an errored accelerator is the cleanest way to let administrator know that something is wrong in the

Quoted 8 lines

configuration.

Quoted 2 lines

I agree that if accel_id > = 256 would fail the VPOD config for another VPOD

but I don't see how to avoid that.

Quoted 1 line

The notification is already there when an accelerator is put to error state.

Its just a notification which can be missed. An accelerator state not in READY cannot be missed because it wouldn't let a workload run.
From an administrator point of view, silent ignore is not preferable.

Regards,
Mukul

Quoted 40 lines

Thanks,
Lijo

Quoted 36 lines

Regards,
Mukul

Quoted 31 lines

Thanks,
Lijo

drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c static int __check_local_vpod_integrity(struct amdgpu_device *adev)

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +5 -0
+                   if (accel_id >= AMDGPU_UALINK_ACCEL_MAX ||
+                       test_bit(accel_id, info->vpod.active_accel_bits)) {
+                           dev_warn(adev->dev,
+                                    "UALINK: integrity fail:
+ errored peer

accel_id=%u is or may be a vpod member\n",

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +5 -0
+                                    accel_id);
+                           return -EINVAL;
+                   }
+                   continue;
+           }
             /* peer device ppod not configured */
             if (peer_info->accel_state <
                 AMDGPU_UALINK_ACCEL_STATE_PPOD_CONFIGURED) {
                     dev_info(adev->dev,
                              "UALINK: integrity EAGAIN: peer

accel_id=%u

not ppod-configured (accel_state=%d)\n",

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +1 -3
-                            peer_info->ppod.accel_id,
-                            peer_info->accel_state);
+                            accel_id, peer_info->accel_state);
                     return -EAGAIN;
             }
 
-           accel_id = peer_info->ppod.accel_id;
             if (!test_bit(accel_id, info->vpod.active_accel_bits))
                     continue;
             /* peer device vpod not configured */
#6 lore raw
In reply to Lazar, Lijo
Quoted 43 lines · Lijo
Quoted 40 lines · Mukul Joshi

AMDGPU_UALINK_ACCEL_STATE_ERROR sorts above every configured state, so a local peer in the error state passes both the "pPod configured" and "vPod configured" checks in __check_local_vpod_integrity() and is treated as a healthy vPod member. The local vPod is then activated around an accelerator that cannot participate.

The error state is also entered when __check_ppod_info() fails on a configuration that already includes vPod information. Such a peer never reaches PPOD_CONFIGURED, and its accel_id is unvalidated firmware data that is used to index vpod.active_accel_bits without a bounds check.

Check for the error state first, before any other state check. Fail the integrity check if the errored peer is a member of this vPod, and skip it otherwise. If its accel_id is out of range, its membership cannot be determined, so treat it as a member and fail the check rather than risk activating the vPod without it.

Fixes 448a35158bee ("drm/amdgpu: Assign accel state based on ASP config")

---
v1->v2:
- Ensure invalid accel_id peer fail VPOD activation.

v2->v3:
- Check error state before PPOD_CONFIGURED check.

  drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 19 ++++++++++++++++---

  1 file changed, 16 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +1 -0
index 0982d8455b0c..6d675c318952 100644
@@ -1169,17 +1169,30 @@ static int 
 __check_local_vpod_integrity(struct amdgpu_device *adev)
               continue;
             peer_info = peer_adev->ualink.info;
+        accel_id = peer_info->ppod.accel_id;
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c static int __check_local_vpod_integrity(struct amdgpu_device *adev)

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +5 -0
+        /* An errored peer's accel_id may have failed validation, in
+         * which case its vPod membership is unknown: treat it as a
+         * member.
+         */
+        if (peer_info->accel_state == 
 AMDGPU_UALINK_ACCEL_STATE_ERROR) {

I don't think anything can be inferred from an accel id in error state. It could be part of a different vpod altogether. It's better to just skip it.

We also fail if any GPU is not at least in PPOD CONFIGURED state just below. Failing if any GPU is in an error state would be consistent with that. We require that the PPOD is correctly configured for all GPUs before we allow any VPOD to be enabled.

If we don't like that requirement, we can relax it. But that's outside the scope of this patch.

Regards,
  Felix

Quoted 29 lines

Thanks,
Lijo

Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +9 -0
+            if (accel_id >= AMDGPU_UALINK_ACCEL_MAX ||
+                test_bit(accel_id, info->vpod.active_accel_bits)) {
+                dev_warn(adev->dev,
+                     "UALINK: integrity fail: errored peer 
 accel_id=%u is or may be a vpod member\n",
+                     accel_id);
+                return -EINVAL;
+            }
+            continue;
+        }
           /* peer device ppod not configured */

          if (peer_info->accel_state <
              AMDGPU_UALINK_ACCEL_STATE_PPOD_CONFIGURED) {
              dev_info(adev->dev,
                   "UALINK: integrity EAGAIN: peer accel_id=%u not ppod-configured (accel_state=%d)\n", -                 peer_info->ppod.accel_id,
-                 peer_info->accel_state);
+                 accel_id, peer_info->accel_state);
              return -EAGAIN;
          }
  -        accel_id = peer_info->ppod.accel_id;
          if (!test_bit(accel_id, info->vpod.active_accel_bits))
              continue;
          /* peer device vpod not configured */

#7 lore raw
Quoted 54 lines · Felix
Quoted 43 lines · Lijo
Quoted 40 lines · Mukul Joshi

AMDGPU_UALINK_ACCEL_STATE_ERROR sorts above every configured state, so a local peer in the error state passes both the "pPod configured" and "vPod configured" checks in __check_local_vpod_integrity() and is treated as a healthy vPod member. The local vPod is then activated around an accelerator that cannot participate.

The error state is also entered when __check_ppod_info() fails on a configuration that already includes vPod information. Such a peer never reaches PPOD_CONFIGURED, and its accel_id is unvalidated firmware data that is used to index vpod.active_accel_bits without a bounds check.

Check for the error state first, before any other state check. Fail the integrity check if the errored peer is a member of this vPod, and skip it otherwise. If its accel_id is out of range, its membership cannot be determined, so treat it as a member and fail the check rather than risk activating the vPod without it.

Fixes 448a35158bee ("drm/amdgpu: Assign accel state based on ASP config")

---
v1->v2:
- Ensure invalid accel_id peer fail VPOD activation.

v2->v3:
- Check error state before PPOD_CONFIGURED check.

  drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 19 ++++++++++++++++---

  1 file changed, 16 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +1 -0
index 0982d8455b0c..6d675c318952 100644
@@ -1169,17 +1169,30 @@ static int 
 __check_local_vpod_integrity(struct amdgpu_device *adev)
               continue;
             peer_info = peer_adev->ualink.info;
+        accel_id = peer_info->ppod.accel_id;
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c static int __check_local_vpod_integrity(struct amdgpu_device *adev)

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +5 -0
+        /* An errored peer's accel_id may have failed validation, in
+         * which case its vPod membership is unknown: treat it as a
+         * member.
+         */
+        if (peer_info->accel_state == 
 AMDGPU_UALINK_ACCEL_STATE_ERROR) {

I don't think anything can be inferred from an accel id in error state. It could be part of a different vpod altogether. It's better to just skip it.

Quoted 2 lines

We also fail if any GPU is not at least in PPOD CONFIGURED state just below. Failing if any GPU is in an error state would be consistent with that. We require that the PPOD is correctly configured for all GPUs before we allow any VPOD to be enabled.

For any GPU not having PPOD configured is not considered a real error. It's tried again later.

The checked conditions in this code -
A device not having a valid accelerator id. This should be a PPOD admissibility check and not part of VPOD integrity check.

The second check - Trying to exclude a device in error state which is part of vpod and in error state.

The error could have happened while trying to remove that device (in update config handler). I think that also shouldn't be in vpod integrity check.

Thanks,
Lijo

Quoted 35 lines

If we don't like that requirement, we can relax it. But that's outside the scope of this patch.

Regards,
  Felix

Quoted 29 lines

Thanks,
Lijo

Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +9 -0
+            if (accel_id >= AMDGPU_UALINK_ACCEL_MAX ||
+                test_bit(accel_id, info->vpod.active_accel_bits)) {
+                dev_warn(adev->dev,
+                     "UALINK: integrity fail: errored peer 
 accel_id=%u is or may be a vpod member\n",
+                     accel_id);
+                return -EINVAL;
+            }
+            continue;
+        }
           /* peer device ppod not configured */

          if (peer_info->accel_state <
              AMDGPU_UALINK_ACCEL_STATE_PPOD_CONFIGURED) {
              dev_info(adev->dev,
                   "UALINK: integrity EAGAIN: peer accel_id=%u not ppod-configured (accel_state=%d)\n", -                 peer_info->ppod.accel_id,
-                 peer_info->accel_state);
+                 accel_id, peer_info->accel_state);
              return -EAGAIN;
          }
  -        accel_id = peer_info->ppod.accel_id;
          if (!test_bit(accel_id, info->vpod.active_accel_bits))
              continue;
          /* peer device vpod not configured */