Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Junhua Shen <Junhua.Shen@amd.com>
To: <igt-dev@lists.freedesktop.org>
Cc: Vitaly Prosyak <vitaly.prosyak@amd.com>,
	Jesse Zhang <Jesse.Zhang@amd.com>,
	Sunil Khatri <sunil.khatri@amd.com>,
	Honglei Huang <honglei1.huang@amd.com>,
	Huang Rui <ray.huang@amd.com>, Yiru Ma <yiru.ma@amd.com>,
	Junhua Shen <Junhua.Shen@amd.com>
Subject: [PATCH i-g-t v2 6/6] tests/amdgpu: query KFD aperture node count before filling array
Date: Wed, 9 Sep 2026 18:46:02 +0800	[thread overview]
Message-ID: <20260909104602.13807-7-Junhua.Shen@amd.com> (raw)
In-Reply-To: <20260909104602.13807-1-Junhua.Shen@amd.com>

kfd_get_gpuvm_base() passed num_of_nodes = NUM_OF_SUPPORTED_GPUS
unconditionally, which the kernel rejects with -EINVAL via
kfd_ioctl_get_process_apertures_new()'s
'num_of_nodes > kfd_topology_get_num_devices()' check.

Follow the documented two-step protocol instead: an initial call with
num_of_nodes == 0 returns the actual node count without touching the
array, then fill up to that count (capped at the array capacity).

Signed-off-by: Junhua Shen <Junhua.Shen@amd.com>
---
 tests/amdgpu/amd_kfd_dmabuf_unload.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tests/amdgpu/amd_kfd_dmabuf_unload.c b/tests/amdgpu/amd_kfd_dmabuf_unload.c
index 28caf8982..f0d076910 100644
--- a/tests/amdgpu/amd_kfd_dmabuf_unload.c
+++ b/tests/amdgpu/amd_kfd_dmabuf_unload.c
@@ -132,9 +132,15 @@ static int kfd_get_gpuvm_base(int fd, uint32_t gpu_id,
 	struct kfd_ioctl_get_process_apertures_new_args args = {};
 	uint32_t i;
 
+	if (ioctl(fd, AMDKFD_IOC_GET_PROCESS_APERTURES_NEW, &args))
+		return -errno;
+	if (args.num_of_nodes == 0)
+		return -ENODEV;
+	if (args.num_of_nodes > NUM_OF_SUPPORTED_GPUS)
+		args.num_of_nodes = NUM_OF_SUPPORTED_GPUS;
+
 	args.kfd_process_device_apertures_ptr =
 		(uint64_t)(uintptr_t)aps;
-	args.num_of_nodes = NUM_OF_SUPPORTED_GPUS;
 	if (ioctl(fd, AMDKFD_IOC_GET_PROCESS_APERTURES_NEW, &args))
 		return -errno;
 
-- 
2.34.1


  parent reply	other threads:[~2026-09-09 10:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-09 10:45 [PATCH i-g-t v2 0/6] lib/amdgpu: refactor cmd_context ownership and packet operands Junhua Shen
2026-09-09 10:45 ` [PATCH i-g-t v2 1/6] lib/amdgpu: document amdgpu_ring_context field contract Junhua Shen
2026-09-09 10:45 ` [PATCH i-g-t v2 2/6] lib/amdgpu: drop external BO from cmd_context Junhua Shen
2026-09-14  2:18   ` Zhang, Jesse(Jie)
2026-09-09 10:45 ` [PATCH i-g-t v2 3/6] lib/amdgpu: source packet operands from params and size the IB from pm4_size Junhua Shen
2026-09-09 10:46 ` [PATCH i-g-t v2 4/6] lib/amdgpu: add CONST_FILL packet type and pass caller fill value through Junhua Shen
2026-09-09 10:46 ` [PATCH i-g-t v2 5/6] tests/amdgpu: derive compute dispatch version from hw_ip_version_major Junhua Shen
2026-09-09 10:46 ` Junhua Shen [this message]
2026-09-09 18:19 ` ✓ i915.CI.BAT: success for lib/amdgpu: refactor cmd_context ownership and packet operands (rev2) Patchwork
2026-09-09 18:20 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-10  3:38 ` ✓ Xe.CI.FULL: " Patchwork
2026-09-10 11:49 ` ✗ i915.CI.Full: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260909104602.13807-7-Junhua.Shen@amd.com \
    --to=junhua.shen@amd.com \
    --cc=Jesse.Zhang@amd.com \
    --cc=honglei1.huang@amd.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=ray.huang@amd.com \
    --cc=sunil.khatri@amd.com \
    --cc=vitaly.prosyak@amd.com \
    --cc=yiru.ma@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox