From: Honglei Huang <honglei1.huang@amd.com>
To: <Felix.Kuehling@amd.com>, <alexander.deucher@amd.com>,
<christian.koenig@amd.com>, <Philip.Yang@amd.com>,
<Ray.Huang@amd.com>
Cc: <dmitry.osipenko@collabora.com>, <airlied@gmail.com>,
<daniel@ffwll.ch>, <amd-gfx@lists.freedesktop.org>,
<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>,
<linux-mm@kvack.org>, <akpm@linux-foundation.org>,
<honghuan@amd.com>
Subject: [PATCH v4 2/8] drm/amdkfd: Add user_range_info infrastructure to kgd_mem
Date: Mon, 9 Feb 2026 14:10:41 +0800 [thread overview]
Message-ID: <20260209061047.3881808-3-honglei1.huang@amd.com> (raw)
In-Reply-To: <20260209061047.3881808-1-honglei1.huang@amd.com>
From: Honglei Huang <honghuan@amd.com>
Add data structures to support batch userptr allocations with
multiple non-contiguous CPU virtual address ranges.
add:
- struct user_range_info: per-range metadata including HMM range,
invalidation counter, and interval tree node
- Fields to kgd_mem: num_user_ranges, user_ranges array,
batch_va_min/max, batch_notifier, and user_ranges_itree
Signed-off-by: Honglei Huang <honghuan@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 23 ++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
index 321cbf9a1..5b6d399f5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
@@ -48,6 +48,7 @@ enum TLB_FLUSH_TYPE {
struct amdgpu_device;
struct kfd_process_device;
+struct kfd_ioctl_userptr_range;
struct amdgpu_reset_context;
enum kfd_mem_attachment_type {
@@ -67,6 +68,15 @@ struct kfd_mem_attachment {
uint64_t pte_flags;
};
+/* Individual range info for batch userptr allocations */
+struct user_range_info {
+ uint64_t start; /* CPU virtual address start */
+ uint64_t size; /* Size in bytes */
+ struct hmm_range *range; /* HMM range for this userptr */
+ bool valid; /* Flag: true if pages are valid, false if invalidated */
+ struct interval_tree_node it_node; /* Interval tree node for fast overlap lookup */
+};
+
struct kgd_mem {
struct mutex lock;
struct amdgpu_bo *bo;
@@ -89,6 +99,14 @@ struct kgd_mem {
uint32_t gem_handle;
bool aql_queue;
bool is_imported;
+
+ /* For batch userptr allocation: multiple non-contiguous CPU VA ranges */
+ uint32_t num_user_ranges;
+ struct user_range_info *user_ranges;
+ uint64_t batch_va_min;
+ uint64_t batch_va_max;
+ struct mmu_interval_notifier batch_notifier;
+ struct rb_root_cached user_ranges_itree;
};
/* KFD Memory Eviction */
@@ -313,6 +331,11 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
struct amdgpu_device *adev, uint64_t va, uint64_t size,
void *drm_priv, struct kgd_mem **mem,
uint64_t *offset, uint32_t flags, bool criu_resume);
+int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu_batch(
+ struct amdgpu_device *adev, uint64_t va, uint64_t size,
+ void *drm_priv, struct kgd_mem **mem,
+ uint64_t *offset, struct kfd_ioctl_userptr_range *ranges,
+ uint32_t num_ranges, uint32_t flags, bool criu_resume);
int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
struct amdgpu_device *adev, struct kgd_mem *mem, void *drm_priv,
uint64_t *size);
--
2.34.1
next prev parent reply other threads:[~2026-02-09 6:11 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-09 6:10 [PATCH v4 0/8] drm/amdkfd: Add batch userptr allocation support Honglei Huang
2026-02-09 6:10 ` [PATCH v4 1/8] drm/amdkfd: Add userptr batch allocation UAPI structures Honglei Huang
2026-02-11 7:15 ` Claude review: " Claude Code Review Bot
2026-02-09 6:10 ` Honglei Huang [this message]
2026-02-11 7:15 ` Claude review: drm/amdkfd: Add user_range_info infrastructure to kgd_mem Claude Code Review Bot
2026-02-09 6:10 ` [PATCH v4 3/8] drm/amdkfd: Implement interval tree for userptr ranges Honglei Huang
2026-02-11 7:15 ` Claude review: " Claude Code Review Bot
2026-02-09 6:10 ` [PATCH v4 4/8] drm/amdkfd: Add batch MMU notifier support Honglei Huang
2026-02-11 7:15 ` Claude review: " Claude Code Review Bot
2026-02-09 6:10 ` [PATCH v4 5/8] drm/amdkfd: Implement batch userptr page management Honglei Huang
2026-02-11 7:15 ` Claude review: " Claude Code Review Bot
2026-02-09 6:10 ` [PATCH v4 6/8] drm/amdkfd: Add batch allocation function and export API Honglei Huang
2026-02-11 7:15 ` Claude review: " Claude Code Review Bot
2026-02-09 6:10 ` [PATCH v4 7/8] drm/amdkfd: Unify userptr cleanup and update paths Honglei Huang
2026-02-11 7:15 ` Claude review: " Claude Code Review Bot
2026-02-09 6:10 ` [PATCH v4 8/8] drm/amdkfd: Wire up batch allocation in ioctl handler Honglei Huang
2026-02-11 7:15 ` Claude review: " Claude Code Review Bot
2026-02-11 7:15 ` Claude review: drm/amdkfd: Add batch userptr allocation support Claude Code Review Bot
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=20260209061047.3881808-3-honglei1.huang@amd.com \
--to=honglei1.huang@amd.com \
--cc=Felix.Kuehling@amd.com \
--cc=Philip.Yang@amd.com \
--cc=Ray.Huang@amd.com \
--cc=airlied@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=daniel@ffwll.ch \
--cc=dmitry.osipenko@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=honghuan@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/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