From: Huang Rui <ray.huang@amd.com>
To: "Christian König" <christian.koenig@amd.com>,
"Philip Yang" <Philip.Yang@amd.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Felix Kuehling" <felix.kuehling@amd.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Matthew Brost" <matthew.brost@intel.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Danilo Krummrich" <dakr@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Aveline Noir" <jm5905938@gmail.com>,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: Xiaogang Chen <xiaogang.chen@amd.com>,
Oak Zeng <Oak.Zeng@amd.com>, "Jenny Liu" <Jenny-Jing.Liu@amd.com>,
Zhu Lingshan <lingshan.zhu@amd.com>,
"Honglei Huang" <honglei1.huang@amd.com>,
Junhua Shen <Junhua.Shen@amd.com>, Yiru Ma <yiru.ma@amd.com>,
Huang Rui <ray.huang@amd.com>, Honglei Huang <honghuan@amd.com>
Subject: [PATCH v11 09/22] drm/amdgpu: add SVM notifier invalidate callback
Date: Fri, 27 Nov 2026 16:41:32 +0800 [thread overview]
Message-ID: <20261127084149.925625-10-ray.huang@amd.com> (raw)
In-Reply-To: <20261127084149.925625-1-ray.huang@amd.com>
From: Honglei Huang <honghuan@amd.com>
Handle invalidation in two phases: zap affected GPU mappings and flush
translations before releasing their DMA mappings and queuing garbage
collection. Do not use an IH timestamp checkpoint to classify retry
faults: hardware timestamps can reset with GFXOFF and differ by engine.
Suggested-by: Christian König <christian.koenig@amd.com>
Suggested-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Honglei Huang <honghuan@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_svm_range.c | 31 +++++++++++++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_svm_range.h | 3 ++
2 files changed, 34 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_svm_range.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_svm_range.c
index 3b6db15bae680..f201105e94c53 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_svm_range.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_svm_range.c
@@ -659,3 +659,34 @@ void amdgpu_svm_range_unqueue(struct amdgpu_svm *svm, struct amdgpu_svm_range *r
if (put)
drm_gpusvm_range_put(&range->base);
}
+
+/**
+ * amdgpu_svm_range_invalidate() - MMU notifier invalidate_ranges callback
+ * @svm: The SVM context.
+ * @notifier: The GPU SVM notifier covering the invalidated ranges.
+ * @mmu_range: The MMU notifier range describing the event.
+ * @first: First GPU SVM range in the affected interval.
+ * @adj_start: Adjusted start address of the affected interval.
+ * @adj_end: Adjusted end address of the affected interval.
+ *
+ * Dispatch the two phase notifier handling across every range in
+ * [@adj_start, @adj_end): run the begin phase for all ranges, then
+ * the end phase.
+ */
+void amdgpu_svm_range_invalidate(struct amdgpu_svm *svm, struct drm_gpusvm_notifier *notifier,
+ const struct mmu_notifier_range *mmu_range,
+ struct drm_gpusvm_range *first, u64 adj_start, u64 adj_end)
+{
+ struct drm_gpusvm_range *r;
+ bool needs_flush = false;
+
+ r = first;
+ drm_gpusvm_for_each_range(r, notifier, adj_start, adj_end)
+ needs_flush |= amdgpu_svm_range_notifier_event_begin(svm, r, mmu_range);
+ if (needs_flush)
+ amdgpu_svm_flush_tlb(svm);
+
+ r = first;
+ drm_gpusvm_for_each_range(r, notifier, adj_start, adj_end)
+ amdgpu_svm_range_notifier_event_end(svm, r, mmu_range);
+}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_svm_range.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_svm_range.h
index 82ec0c769d25b..3de80ffe88e80 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_svm_range.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_svm_range.h
@@ -156,6 +156,9 @@ amdgpu_svm_range_find_or_insert(struct amdgpu_svm *svm, unsigned long addr,
struct drm_gpusvm_ctx *ctx);
int amdgpu_svm_range_get_pages(struct amdgpu_svm *svm, struct drm_gpusvm_range *range,
struct drm_gpusvm_ctx *ctx);
+void amdgpu_svm_range_invalidate(struct amdgpu_svm *svm, struct drm_gpusvm_notifier *notifier,
+ const struct mmu_notifier_range *mmu_range,
+ struct drm_gpusvm_range *first, u64 adj_start, u64 adj_end);
bool amdgpu_svm_range_notifier_event_begin(struct amdgpu_svm *svm, struct drm_gpusvm_range *range,
const struct mmu_notifier_range *mmu_range);
int amdgpu_svm_range_invalidate_interval(struct amdgpu_svm *svm, unsigned long start_page,
--
2.53.0
next prev parent reply other threads:[~2026-11-27 8:42 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 8:41 [PATCH v11 00/22] drm/amdgpu: AMDGPU SVM support based on DRM (Phase 1: single GPU, XNACK on) Huang Rui
2026-11-27 8:41 ` [PATCH v11 01/22] drm/amdgpu: decouple PTE encoding from buffer objects Huang Rui
2026-11-27 8:41 ` [PATCH v11 02/22] drm/amdgpu: add SVM ioctl UAPI definitions Huang Rui
2026-11-27 8:41 ` [PATCH v11 03/22] drm/amdgpu: add SVM core header and VM integration Huang Rui
2026-11-27 8:41 ` [PATCH v11 04/22] drm/amdgpu: implement SVM attribute tree and helper functions Huang Rui
2026-11-27 8:41 ` [PATCH v11 05/22] drm/amdgpu: implement SVM attribute set/get/clear operations Huang Rui
2026-11-27 8:41 ` [PATCH v11 06/22] drm/amdgpu: add SVM range types and work queue interface Huang Rui
2026-11-27 8:41 ` [PATCH v11 07/22] drm/amdgpu: implement SVM range GPU mapping core Huang Rui
2026-11-27 8:41 ` [PATCH v11 08/22] drm/amdgpu: implement SVM range notifier and GC helpers Huang Rui
2026-11-27 8:41 ` Huang Rui [this message]
2026-11-27 8:41 ` [PATCH v11 10/22] drm/amdgpu: implement SVM initialization and lifecycle Huang Rui
2026-11-27 8:41 ` [PATCH v11 11/22] drm/amdgpu: add SVM ioctl entry and fault handler module Huang Rui
2026-11-27 8:41 ` [PATCH v11 12/22] drm/amdgpu: integrate SVM into build system and VM fault path Huang Rui
2026-11-27 8:41 ` [PATCH v11 13/22] drm/amdgpu: make VM eviction lock read/write to match notifier lock Huang Rui
2026-11-27 8:41 ` [PATCH v11 14/22] drm/amdgpu: recheck range validity after page table allocation Huang Rui
2026-11-27 8:41 ` [PATCH v11 15/22] drm/amdgpu: use drm_gpusvm notifier lock for VM eviction Huang Rui
2026-11-27 8:41 ` [PATCH v11 16/22] drm/pagemap: fix page undercount for compound src entries Huang Rui
2026-11-27 8:41 ` [PATCH v11 17/22] drm/amdgpu: add VRAM migration infrastructure for drm_pagemap Huang Rui
2026-11-27 8:41 ` [PATCH v11 18/22] drm/amdgpu: implement drm_pagemap SDMA migration callbacks Huang Rui
2026-11-27 8:41 ` [PATCH v11 19/22] drm/amdgpu: implement synchronous TTM eviction for SVM BOs Huang Rui
2026-11-27 8:41 ` [PATCH v11 20/22] drm/amdgpu: hook up ZONE_DEVICE registration in device init and reset Huang Rui
2026-11-27 8:41 ` [PATCH v11 21/22] drm/amdgpu: add SVM range migration helpers for drm_pagemap Huang Rui
2026-11-27 8:41 ` [PATCH v11 22/22] drm/amdgpu: integrate VRAM migration into SVM fault and prefetch paths Huang Rui
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=20261127084149.925625-10-ray.huang@amd.com \
--to=ray.huang@amd.com \
--cc=Jenny-Jing.Liu@amd.com \
--cc=Junhua.Shen@amd.com \
--cc=Oak.Zeng@amd.com \
--cc=Philip.Yang@amd.com \
--cc=alexander.deucher@amd.com \
--cc=aliceryhl@google.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=felix.kuehling@amd.com \
--cc=honghuan@amd.com \
--cc=honglei1.huang@amd.com \
--cc=jm5905938@gmail.com \
--cc=lingshan.zhu@amd.com \
--cc=matthew.brost@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=simona@ffwll.ch \
--cc=thomas.hellstrom@linux.intel.com \
--cc=xiaogang.chen@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.