AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: allow sparse UALink accelerator IDs in pPod validation
@ 2026-11-30 16:47 Mukul Joshi
  2026-11-30 16:57 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Mukul Joshi @ 2026-11-30 16:47 UTC (permalink / raw)
  To: amd-gfx; +Cc: Felix.Kuehling, Harish.Kasiviswanathan, philip.yang, Mukul Joshi

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.

Signed-off-by: Mukul Joshi <mukul.joshi@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c
index 941e482a6fcd..3d83dba3a408 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c
@@ -115,10 +115,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;
 	}
 
@@ -977,9 +978,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;
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/amdgpu: allow sparse UALink accelerator IDs in pPod validation
  2026-11-30 16:47 [PATCH] drm/amdgpu: allow sparse UALink accelerator IDs in pPod validation Mukul Joshi
@ 2026-11-30 16:57 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-30 16:57 UTC (permalink / raw)
  To: Mukul Joshi, amd-gfx

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] drm/amdgpu: missing Fixes: trailer for sparse UALink accel_id
  validation fix
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [High] drm/amdgpu: missing error-state check in
  __check_local_vpod_integrity() [1]
--

commit 96f45a4c14545b259b124ee1e846265658479441
Author: Mukul Joshi <mukul.joshi@amd.com>

> 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.
>
> Signed-off-by: Mukul Joshi <mukul.joshi@amd.com>

[Severity: Low]
This fixes a bug where sparse accelerator IDs remain stuck in the
unconfigured state.  Should it include Fixes: tags for the commits that
introduced the ppod.size bounds checks in __check_ppod_info() and
check_ppod_state()?

  Fixes: 0e8eb0dcea51 ("drm/amdgpu: Assign accel state based on ASP config")
  Fixes: 61273d11eee2 ("drm/amdgpu: Add sysfs API for UALink physical pod setup")

> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c
> index fa4c3d27d2720..46e93c4f6236b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c
> @@ -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;
>  	}

[Severity: High]
This problem wasn't introduced by this patch, but can
__check_local_vpod_integrity() [1] read out of bounds on
info->vpod.active_accel_bits when a peer is in
AMDGPU_UALINK_ACCEL_STATE_ERROR?

drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c:__check_local_vpod_integrity() {
    ...
		if (peer_info->accel_state <
		    AMDGPU_UALINK_ACCEL_STATE_PPOD_CONFIGURED) {
    ...
			return -EAGAIN;
		}

		accel_id = peer_info->ppod.accel_id;
		if (!test_bit(accel_id, info->vpod.active_accel_bits))
			continue;
    ...
}

In enum amdgpu_ualink_accel_state, AMDGPU_UALINK_ACCEL_STATE_ERROR (5) is
greater than AMDGPU_UALINK_ACCEL_STATE_PPOD_CONFIGURED (1).  If a peer
enters AMDGPU_UALINK_ACCEL_STATE_ERROR before its pPod configuration is
validated (for example, when psp_ual_query_info() fails in
amdgpu_ualink_config_update_handler()), peer_info->ppod.accel_id stays at
its initial value of 0xffffffff, which __check_local_vpod_integrity() then
passes to test_bit() on the 256-bit active_accel_bits bitmap.

[1] https://sashiko.dev/#/bug/linux-70b01f66-1fb6-4cfd-b1b5-9e69e35e868d

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261130164746.479120-1-mukul.joshi@amd.com?part=1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-30 16:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 16:47 [PATCH] drm/amdgpu: allow sparse UALink accelerator IDs in pPod validation Mukul Joshi
2026-11-30 16:57 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox