From: Natalie Vock <nat@pixelcluster.dev>
To: "Felix Kuehling" <Felix.Kuehling@amd.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"Timur Kristóf" <timur.kristof@gmail.com>
Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org,
Natalie Vock <nat@pixelcluster.dev>
Subject: [PATCH v2 05/10] drm/amdgpu: Track dirty bo_va structures in update ctx
Date: Tue, 17 Nov 2026 13:50:11 +0100 [thread overview]
Message-ID: <20261117-prt-explicit-sync-v2-5-bb3851cb6a0c@pixelcluster.dev> (raw)
In-Reply-To: <20261117-prt-explicit-sync-v2-0-bb3851cb6a0c@pixelcluster.dev>
So we can later update all changed BOs without needing to do tracking
separately.
Signed-off-by: Natalie Vock <nat@pixelcluster.dev>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 2 ++
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 16 ++++++++++++++--
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 5 +++++
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index e0090dc10682f..068c57ed537fd 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -80,6 +80,8 @@ struct amdgpu_bo_va {
/* protected by bo being reserved */
unsigned ref_count;
+ struct list_head update_link;
+
/* all other members protected by the VM PD being reserved */
struct dma_fence *last_pt_update;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 1e2d45979efdb..330c288053352 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1718,6 +1718,8 @@ amdgpu_vm_update_ctx_add_new_mapping(struct amdgpu_vm_update_ctx *ctx,
mapping->bo_va = bo_va;
WARN_ON(!list_empty(&mapping->pending_list));
list_add(&mapping->pending_list, &ctx->new);
+ if (list_empty(&mapping->bo_va->update_link))
+ list_add(&mapping->bo_va->update_link, &ctx->dirty_bo_vas);
return 0;
}
@@ -1733,8 +1735,10 @@ static void
amdgpu_vm_update_ctx_add_freed_mapping(struct amdgpu_vm_update_ctx *ctx,
struct amdgpu_bo_va_mapping *mapping)
{
- WARN_ON(!list_empty(&mapping->pending_list));
- list_add(&mapping->pending_list, &ctx->deleted);
+ if (list_empty(&mapping->bo_va->update_link))
+ list_add(&mapping->bo_va->update_link, &ctx->dirty_bo_vas);
+ if (list_empty(&mapping->pending_list))
+ list_add(&mapping->pending_list, &ctx->deleted);
}
int amdgpu_vm_update_ctx_execute_replace(struct amdgpu_vm_update_ctx *ctx)
@@ -1861,6 +1865,7 @@ void amdgpu_vm_update_ctx_init(struct amdgpu_vm_update_ctx *ctx,
ctx->pending_maps = RB_ROOT_CACHED;
ctx->cleared_ranges = RB_ROOT_CACHED;
+ INIT_LIST_HEAD(&ctx->dirty_bo_vas);
INIT_LIST_HEAD(&ctx->new);
INIT_LIST_HEAD(&ctx->deleted);
INIT_LIST_HEAD(&ctx->freed);
@@ -1878,10 +1883,16 @@ void amdgpu_vm_update_ctx_init(struct amdgpu_vm_update_ctx *ctx,
void amdgpu_vm_update_ctx_fini(struct amdgpu_vm_update_ctx *ctx)
{
struct interval_tree_node *node, *next_node;
+ struct amdgpu_bo_va *bo_va, *next_bo_va;
list_splice(&ctx->freed, &ctx->vm->delayed_freed);
amdgpu_sync_free(&ctx->sync);
+ list_for_each_entry_safe(bo_va, next_bo_va, &ctx->dirty_bo_vas,
+ update_link) {
+ list_del_init(&bo_va->update_link);
+ }
+
rbtree_postorder_for_each_entry_safe(node, next_node, &ctx->pending_maps.rb_root, rb) {
kfree(node);
}
@@ -2135,6 +2146,7 @@ struct amdgpu_bo_va *amdgpu_vm_bo_add(struct amdgpu_device *adev,
bo_va->ref_count = 1;
bo_va->last_pt_update = dma_fence_get_stub();
+ INIT_LIST_HEAD(&bo_va->update_link);
INIT_LIST_HEAD(&bo_va->valids);
INIT_LIST_HEAD(&bo_va->invalids);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index 5657aa63e9491..7a5f558970b5c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -305,6 +305,11 @@ struct amdgpu_vm_update_ctx {
*/
struct list_head cleared;
+ /**
+ * @dirty_bo_vas: amdgpu_bo_va structures touched by current pending mapping changes.
+ */
+ struct list_head dirty_bo_vas;
+
/**
* @freed: A list of mappings that are freed and pending PT/PD updates during
* this update operation.
--
2.56.1
next prev parent reply other threads:[~2026-11-17 12:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 12:50 [PATCH v2 00/10] drm/amdgpu: Rework VM update ops for batching and explicit sync Natalie Vock
2026-11-17 12:50 ` [PATCH v2 01/10] drm/amdgpu: Remove unused parameter from amdgpu_vm_pte_fragment Natalie Vock
2026-11-17 12:50 ` [PATCH v2 02/10] drm/amdgpu: Add and use vm_update_ctx struct Natalie Vock
2026-11-17 12:50 ` [PATCH v2 03/10] drm/amdgpu: Make VM maps pending per update context Natalie Vock
2026-11-17 12:50 ` [PATCH v2 04/10] drm/amdgpu: Make removed/cleared mappings " Natalie Vock
2026-11-17 12:50 ` Natalie Vock [this message]
2026-11-17 12:50 ` [PATCH v2 06/10] drm/amdgpu: Add function to roll back a VM update ctx Natalie Vock
2026-11-17 12:50 ` [PATCH v2 07/10] drm/amdgpu: Move some VA op validation to a helper Natalie Vock
2026-11-17 12:50 ` [PATCH v2 08/10] drm/amdgpu: Only reject conflicting mappings if they are not cleared Natalie Vock
2026-11-17 12:50 ` [PATCH v2 09/10] drm/amdgpu: Add new AMDGPU_GEM_VA2 ioctl Natalie Vock
2026-11-17 12:50 ` [PATCH v2 10/10] drm/amdgpu: Bump minor version Natalie Vock
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=20261117-prt-explicit-sync-v2-5-bb3851cb6a0c@pixelcluster.dev \
--to=nat@pixelcluster.dev \
--cc=Felix.Kuehling@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=timur.kristof@gmail.com \
--cc=tzimmermann@suse.de \
/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
all inboxes | Powered by JetHome®