Skip to contentSkip to conversation

drm/amdgpu: allow sparse UALink accelerator IDs in pPod validation

PATCH New Mukul Joshi 2 participants 3 messages Nov 30

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

PATCH v2 1/1 drm/amdgpu: allow sparse UALink accelerator IDs in pPod validation

The pPod size reported by PSP is the number of GPUs in the physical pod, not an upper bound on accelerator IDs. Accelerator IDs can be sparse, e.g. a 1-plane/2-GPU-per-node AFM config reports a pPod size of 4 for accelerator IDs 0, 1, 4 and 5.

Both __check_ppod_info() and check_ppod_state() rejected any accelerator ID >= pPod size, leaving accelerators 4 and 5 stuck in the unconfigured state. Bound the accelerator ID by AMDGPU_UALINK_ACCEL_MAX instead, which matches the size of the per-accelerator bitmaps.

Fixes af9a280325b5 ("drm/amdgpu: Add sysfs API for UALink physical pod setup")
Fixes 448a35158bee ("drm/amdgpu: Assign accel state based on ASP config")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +7 -6
index 2d4a17e11a1f..0982d8455b0c 100644
@@ -112,10 +112,11 @@ static bool __check_ppod_info(struct amdgpu_device *adev,
 			ppod->size, AMDGPU_UALINK_ACCEL_MAX);
 		return false;
 	}
-	if (ppod->accel_id >= ppod->size) {
+	/* pPod size is a GPU count; accelerator IDs may be sparse. */
+	if (ppod->accel_id >= AMDGPU_UALINK_ACCEL_MAX) {
 		dev_dbg(adev->dev,
-			"Accelerator ID %u greater or equal pPod size %u\n",
-			ppod->accel_id, ppod->size);
+			"Accelerator ID %u out of range [0..%u)\n",
+			ppod->accel_id, AMDGPU_UALINK_ACCEL_MAX);
 		return false;
 	}
 
@@ -928,9 +929,9 @@ check_ppod_state(struct amdgpu_device *adev,
 			setup->ppod.size, AMDGPU_UALINK_ACCEL_MAX);
 		return AMDGPU_UALINK_ACCEL_STATE_UNCONFIGURED;
 	}
-	if (setup->ppod.accel_id >= setup->ppod.size) {
-		dev_dbg(adev->dev, "Accelerator ID %u greater or equal pPod size %u\n",
-			setup->ppod.accel_id, setup->ppod.size);
+	if (setup->ppod.accel_id >= AMDGPU_UALINK_ACCEL_MAX) {
+		dev_dbg(adev->dev, "Accelerator ID %u out of range [0..%u)\n",
+			setup->ppod.accel_id, AMDGPU_UALINK_ACCEL_MAX);
 		return AMDGPU_UALINK_ACCEL_STATE_UNCONFIGURED;
 	}
 	return AMDGPU_UALINK_ACCEL_STATE_PPOD_CONFIGURED;
Signature · 1 line
2.56.0
#1 lore raw

PATCH 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 pPod validation fails, in which case the peer's accel_id is unvalidated firmware data and is used to index vpod.active_accel_bits without a bounds check.

Handle errored peers explicitly: range-check the accel_id before use, fail the integrity check if the peer is a member of this vPod, and skip it otherwise.

Fixes 448a35158bee ("drm/amdgpu: Assign accel state based on ASP config")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +11 -0
index 0982d8455b0c..1a169884bd40 100644
@@ -1180,6 +1180,17 @@ static int __check_local_vpod_integrity(struct amdgpu_device *adev)
 		}
 
 		accel_id = peer_info->ppod.accel_id;
+		/* An errored peer's accel_id may have failed validation. */
+		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: vpod peer accel_id=%u is in error state\n",
+					 accel_id);
+				return -EINVAL;
+			}
+			continue;
+		}
 		if (!test_bit(accel_id, info->vpod.active_accel_bits))
 			continue;
 		/* peer device vpod not configured */
Signature · 1 line
2.56.0
#2 lore raw

Re: [PATCH] drm/amdgpu: reject errored peers in UALink local vPod integrity check

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] drm/amdgpu: errored vPod peers with invalid accel_id are skipped --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] drm/amdgpu: errored vPod peers with invalid accel_id are skipped
--

commit 51531015613e09183d21d8b32b3616673d7a007c
Author: Mukul Joshi <[email protected]>

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

This commit updates __check_local_vpod_integrity() to explicitly handle peers in AMDGPU_UALINK_ACCEL_STATE_ERROR by bounds-checking their accel_id and failing the integrity check if they belong to the local vPod.

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +4 -0
index fa4c3d27d2720..8a1069feb27b9 100644
@@ -1179,6 +1179,17 @@ static int __check_local_vpod_integrity(struct amdgpu_device *adev)
 		}
 
 		accel_id = peer_info->ppod.accel_id;
+		/* An errored peer's accel_id may have failed validation. */
+		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)) {

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

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +7 -0
+				dev_warn(adev->dev,
+					 "UALINK: integrity fail: vpod peer accel_id=%u is in error state\n",
+					 accel_id);
+				return -EINVAL;
+			}
+			continue;
+		}
 		if (!test_bit(accel_id, info->vpod.active_accel_bits))
 			continue;
 		/* peer device vpod not configured */

[Severity: Medium]
Can an errored peer in the same vPod still be skipped here when its peer_info->ppod.accel_id is invalid?

When a peer enters AMDGPU_UALINK_ACCEL_STATE_ERROR because __check_ppod_info() failed in amdgpu_ualink_info_set_accel_state() (for example, accel_id >= AMDGPU_UALINK_ACCEL_MAX or >= ppod.size) or because __check_vpod_info() rejected a missing self-bit in active_accel_bits, this condition is false and hits continue. Because info->vpod.active_accel_bits includes both local and remote accelerators, membership of a local GPU cannot be determined from an unvalidated accel_id.

__check_local_vpod_integrity() then succeeds and activates the local vPod despite the broken local peer, and the second loop still matches that errored peer via __is_vpod_peer() (which only compares vpod.id and ppod.id) and overwrites its n_local_accels and local_accels.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1