From: Arvind Yadav <arvind.yadav@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: matthew.brost@intel.com, himal.prasad.ghimiray@intel.com,
thomas.hellstrom@linux.intel.com
Subject: [RFC 2/7] drm/xe/vm: Preserve CPU_AUTORESET_ACTIVE across GPUVA operations
Date: Thu, 19 Feb 2026 14:43:07 +0530 [thread overview]
Message-ID: <20260219091312.796749-3-arvind.yadav@intel.com> (raw)
In-Reply-To: <20260219091312.796749-1-arvind.yadav@intel.com>
GPUVA split/merge operations rebuild VMA flags from XE_VMA_CREATE_MASK.
While this preserves XE_VMA_MADV_AUTORESET, it drops runtime-only state
such as XE_VMA_CPU_AUTORESET_ACTIVE.
Preserve CPU_AUTORESET_ACTIVE when creating new VMAs during MAP/REMAP
so the CPU-only vs GPU-touched state survives VMA transformations.
Without this, split VMAs would lose their CPU-only state and be
incorrectly treated as GPU-touched.
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Signed-off-by: Arvind Yadav <arvind.yadav@intel.com>
---
drivers/gpu/drm/xe/xe_vm.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index 8fe54a998385..152ee355e5c3 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -2350,8 +2350,10 @@ vm_bind_ioctl_ops_create(struct xe_vm *vm, struct xe_vma_ops *vops,
op->map.vma_flags |= XE_VMA_SYSTEM_ALLOCATOR;
if (flags & DRM_XE_VM_BIND_FLAG_DUMPABLE)
op->map.vma_flags |= XE_VMA_DUMPABLE;
- if (flags & DRM_XE_VM_BIND_FLAG_MADVISE_AUTORESET)
+ if (flags & DRM_XE_VM_BIND_FLAG_MADVISE_AUTORESET) {
op->map.vma_flags |= XE_VMA_MADV_AUTORESET;
+ op->map.vma_flags |= XE_VMA_CPU_AUTORESET_ACTIVE;
+ }
op->map.pat_index = pat_index;
op->map.invalidate_on_bind =
__xe_vm_needs_clear_scratch_pages(vm, flags);
@@ -2668,6 +2670,9 @@ static int vm_bind_ioctl_ops_parse(struct xe_vm *vm, struct drm_gpuva_ops *ops,
};
flags |= op->map.vma_flags & XE_VMA_CREATE_MASK;
+ /* Preserve CPU_AUTORESET_ACTIVE (runtime-only). */
+ if (op->map.vma_flags & XE_VMA_CPU_AUTORESET_ACTIVE)
+ flags |= XE_VMA_CPU_AUTORESET_ACTIVE;
vma = new_vma(vm, &op->base.map, &default_attr,
flags);
@@ -2708,6 +2713,10 @@ static int vm_bind_ioctl_ops_parse(struct xe_vm *vm, struct drm_gpuva_ops *ops,
op->remap.range = xe_vma_size(old);
flags |= op->base.remap.unmap->va->flags & XE_VMA_CREATE_MASK;
+ /* Preserve CPU_AUTORESET_ACTIVE (runtime-only). */
+ if (op->base.remap.unmap->va->flags & XE_VMA_CPU_AUTORESET_ACTIVE)
+ flags |= XE_VMA_CPU_AUTORESET_ACTIVE;
+
if (op->base.remap.prev) {
vma = new_vma(vm, op->base.remap.prev,
&old->attr, flags);
@@ -4409,19 +4418,28 @@ static int xe_vm_alloc_vma(struct xe_vm *vm,
if (!is_madvise) {
if (__op->op == DRM_GPUVA_OP_UNMAP) {
vma = gpuva_to_vma(op->base.unmap.va);
- XE_WARN_ON(!xe_vma_has_default_mem_attrs(vma));
+ /*
+ * For CPU_AUTORESET_ACTIVE VMAs, attributes may be mid-reset and
+ * thus temporarily non-default.
+ */
+ XE_WARN_ON(!xe_vma_has_default_mem_attrs(vma) &&
+ !(vma->gpuva.flags & XE_VMA_CPU_AUTORESET_ACTIVE));
default_pat = vma->attr.default_pat_index;
vma_flags = vma->gpuva.flags;
}
if (__op->op == DRM_GPUVA_OP_REMAP) {
vma = gpuva_to_vma(op->base.remap.unmap->va);
- default_pat = vma->attr.default_pat_index;
+ /* Preserve current PAT index, not default, for remap */
+ default_pat = vma->attr.pat_index;
vma_flags = vma->gpuva.flags;
}
if (__op->op == DRM_GPUVA_OP_MAP) {
op->map.vma_flags |= vma_flags & XE_VMA_CREATE_MASK;
+ /* Preserve CPU_AUTORESET_ACTIVE (runtime-only). */
+ if (vma_flags & XE_VMA_CPU_AUTORESET_ACTIVE)
+ op->map.vma_flags |= XE_VMA_CPU_AUTORESET_ACTIVE;
op->map.pat_index = default_pat;
}
} else {
@@ -4434,6 +4452,7 @@ static int xe_vm_alloc_vma(struct xe_vm *vm,
}
if (__op->op == DRM_GPUVA_OP_MAP) {
+ /* Madvise MAP follows REMAP (split/merge). */
xe_assert(vm->xe, remap_op);
remap_op = false;
/*
@@ -4443,6 +4462,9 @@ static int xe_vm_alloc_vma(struct xe_vm *vm,
* unmapping.
*/
op->map.vma_flags |= vma_flags & XE_VMA_CREATE_MASK;
+ /* Preserve CPU_AUTORESET_ACTIVE (not in CREATE_MASK). */
+ if (vma_flags & XE_VMA_CPU_AUTORESET_ACTIVE)
+ op->map.vma_flags |= XE_VMA_CPU_AUTORESET_ACTIVE;
}
}
print_op(vm->xe, __op);
--
2.43.0
next prev parent reply other threads:[~2026-02-19 9:13 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-19 9:13 [RFC 0/7] drm/xe/svm: Add MMU notifier-based madvise autoreset on munmap Arvind Yadav
2026-02-19 9:13 ` [RFC 1/7] drm/xe/vm: Add CPU_AUTORESET_ACTIVE VMA flag Arvind Yadav
2026-02-19 9:13 ` Arvind Yadav [this message]
2026-02-19 9:13 ` [RFC 3/7] drm/xe/svm: Clear CPU_AUTORESET_ACTIVE on first GPU fault Arvind Yadav
2026-02-20 20:12 ` Matthew Brost
2026-02-20 22:33 ` Matthew Brost
2026-03-05 3:38 ` Yadav, Arvind
2026-02-19 9:13 ` [RFC 4/7] drm/xe/vm: Add madvise autoreset interval notifier worker infrastructure Arvind Yadav
2026-02-25 23:34 ` Matthew Brost
2026-03-09 7:07 ` Yadav, Arvind
2026-03-09 9:32 ` Thomas Hellström
2026-03-11 6:34 ` Yadav, Arvind
2026-02-19 9:13 ` [RFC 5/7] drm/xe/vm: Deactivate madvise notifier on GPU touch Arvind Yadav
2026-02-19 9:13 ` [RFC 6/7] drm/xe/vm: Wire MADVISE_AUTORESET notifiers into VM lifecycle Arvind Yadav
2026-02-19 9:13 ` [RFC 7/7] drm/xe/svm: Correct memory attribute reset for partial unmap Arvind Yadav
2026-02-19 9:40 ` ✗ CI.checkpatch: warning for drm/xe/svm: Add MMU notifier-based madvise autoreset on munmap Patchwork
2026-02-19 9:42 ` ✓ CI.KUnit: success " Patchwork
2026-02-19 10:40 ` ✓ Xe.CI.BAT: " Patchwork
2026-02-19 13:04 ` ✗ Xe.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=20260219091312.796749-3-arvind.yadav@intel.com \
--to=arvind.yadav@intel.com \
--cc=himal.prasad.ghimiray@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=thomas.hellstrom@linux.intel.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