From: Honglei Huang <honglei1.huang@amd.com>
To: <Felix.Kuehling@amd.com>, <alexander.deucher@amd.com>,
<christian.koenig@amd.com>, <Ray.Huang@amd.com>
Cc: <dmitry.osipenko@collabora.com>, <Xinhui.Pan@amd.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 v2 2/4] drm/amdkfd: Extend kgd_mem for batch userptr support
Date: Sun, 4 Jan 2026 15:21:20 +0800 [thread overview]
Message-ID: <20260104072122.3045656-3-honglei1.huang@amd.com> (raw)
In-Reply-To: <20260104072122.3045656-1-honglei1.huang@amd.com>
From: Honglei Huang <honghuan@amd.com>
Add necessary data structures to support tracking multiple user
address ranges within a single memory object.
The user_range_info structure tracks individual ranges with their
own HMM ranges and MMU notifiers, allowing per-range invalidation
tracking. The kgd_mem structure is extended to hold an array of
these ranges.
Signed-off-by: Honglei Huang <honghuan@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
index 321cbf9a1..1883833a2 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;
};
+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 */
+ uint32_t invalid; /* Invalidation counter */
+ struct mmu_interval_notifier notifier; /* MMU notifier for this range */
+ struct kgd_mem *mem; /* Back pointer to parent kgd_mem */
+};
+
struct kgd_mem {
struct mutex lock;
struct amdgpu_bo *bo;
@@ -89,6 +99,12 @@ struct kgd_mem {
uint32_t gem_handle;
bool aql_queue;
bool is_imported;
+
+ /* For batch userptr allocation: multiple non-contiguous CPU VA ranges
+ * mapped to a single contiguous GPU VA range
+ */
+ uint32_t num_user_ranges;
+ struct user_range_info *user_ranges;
};
/* KFD Memory Eviction */
@@ -313,6 +329,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-01-04 7:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-04 7:21 [PATCH v2 0/4] drm/amdkfd: Add batch userptr allocation support Honglei Huang
2026-01-04 7:21 ` [PATCH v2 1/4] drm/amdkfd: Add batch userptr allocation UAPI Honglei Huang
2026-01-04 7:21 ` Honglei Huang [this message]
2026-01-04 7:21 ` [PATCH v2 3/4] drm/amdkfd: Implement batch userptr allocation and management Honglei Huang
2026-01-04 7:21 ` [PATCH v2 4/4] drm/amdkfd: Wire up batch userptr ioctl handler Honglei Huang
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=20260104072122.3045656-3-honglei1.huang@amd.com \
--to=honglei1.huang@amd.com \
--cc=Felix.Kuehling@amd.com \
--cc=Ray.Huang@amd.com \
--cc=Xinhui.Pan@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