From: Arvind Yadav <arvind.yadav@intel.com>
To: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: matthew.brost@intel.com, himal.prasad.ghimiray@intel.com,
thomas.hellstrom@linux.intel.com
Subject: [RFC v3 2/7] drm/xe/vm: Preserve cpu_autoreset_active across GPUVA operations
Date: Thu, 4 Jun 2026 15:20:07 +0530 [thread overview]
Message-ID: <20260604095012.367231-3-arvind.yadav@intel.com> (raw)
In-Reply-To: <20260604095012.367231-1-arvind.yadav@intel.com>
GPUVA split and remap operations rebuild VMAs from create flags. These
flags preserve persistent VMA state, but not runtime-only state such as
cpu_autoreset_active.
Forward XE_VMA_CPU_AUTORESET_ACTIVE explicitly through the MAP/REMAP
pipeline so xe_vma_create() can restore cpu_autoreset_active in the new
VMA. The bit remains pipeline-only and is stripped before storing
vma->gpuva.flags.
Also relax the UNMAP attribute warning for MADVISE_AUTORESET VMAs, since
they may legitimately carry non-default madvise-managed attributes.
v2:
- Move runtime state to xe_vma bool and keep
XE_VMA_CPU_AUTORESET_ACTIVE as pipeline-only. (Matt)
- Add xe_vma_effective_create_flags() to centralise flag handling.
v3:
- Guard cpu_autoreset_active assignment to CPU_ADDR_MIRROR VMAs only (Matt)
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 | 44 ++++++++++++++++++++++++++++++++------
1 file changed, 38 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index 080c2fff0e95..dec5279f08a2 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -1105,7 +1105,11 @@ static struct xe_vma *xe_vma_create(struct xe_vm *vm,
vma->gpuva.vm = &vm->gpuvm;
vma->gpuva.va.addr = start;
vma->gpuva.va.range = end - start + 1;
- vma->gpuva.flags = flags;
+ /* Pipeline-only, do not store in gpuva.flags. */
+ vma->gpuva.flags = flags & ~XE_VMA_CPU_AUTORESET_ACTIVE;
+ vma->cpu_autoreset_active =
+ (flags & XE_VMA_SYSTEM_ALLOCATOR) &&
+ (flags & XE_VMA_CPU_AUTORESET_ACTIVE);
for_each_tile(tile, vm->xe, id)
vma->tile_mask |= 0x1 << id;
@@ -2479,8 +2483,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.request_decompress = flags & DRM_XE_VM_BIND_FLAG_DECOMPRESS;
op->map.pat_index = pat_index;
op->map.invalidate_on_bind =
@@ -2800,6 +2806,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;
+ /* Forward pipeline-only state. */
+ 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);
@@ -2842,6 +2851,10 @@ static int vm_bind_ioctl_ops_parse(struct xe_vm *vm, struct drm_gpuva_ops *ops,
op->remap.old_range = op->remap.range;
flags |= op->base.remap.unmap->va->flags & XE_VMA_CREATE_MASK;
+ /* Forward pipeline-only state. */
+ if (xe_vma_has_cpu_autoreset_active(old))
+ flags |= XE_VMA_CPU_AUTORESET_ACTIVE;
+
if (op->base.remap.prev) {
vma = new_vma(vm, op->base.remap.prev,
&old->attr, flags);
@@ -4693,6 +4706,17 @@ int xe_vma_need_vram_for_atomic(struct xe_device *xe, struct xe_vma *vma, bool i
}
}
+/* Add pipeline-only autoreset state when rebuilding a VMA. */
+static unsigned int xe_vma_effective_create_flags(struct xe_vma *vma)
+{
+ unsigned int flags = vma->gpuva.flags;
+
+ if (xe_vma_has_cpu_autoreset_active(vma))
+ flags |= XE_VMA_CPU_AUTORESET_ACTIVE;
+
+ return flags;
+}
+
static int xe_vm_alloc_vma(struct xe_vm *vm,
struct drm_gpuvm_map_req *map_req,
bool is_madvise)
@@ -4728,19 +4752,24 @@ 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));
+ /* AUTORESET VMAs may carry madvise-managed attrs. */
+ XE_WARN_ON(!xe_vma_has_default_mem_attrs(vma) &&
+ !(vma->gpuva.flags & XE_VMA_MADV_AUTORESET));
default_pat = vma->attr.default_pat_index;
- vma_flags = vma->gpuva.flags;
+ vma_flags = xe_vma_effective_create_flags(vma);
}
if (__op->op == DRM_GPUVA_OP_REMAP) {
vma = gpuva_to_vma(op->base.remap.unmap->va);
default_pat = vma->attr.default_pat_index;
- vma_flags = vma->gpuva.flags;
+ vma_flags = xe_vma_effective_create_flags(vma);
}
if (__op->op == DRM_GPUVA_OP_MAP) {
op->map.vma_flags |= vma_flags & XE_VMA_CREATE_MASK;
+ /* Forward pipeline-only state. */
+ if (vma_flags & XE_VMA_CPU_AUTORESET_ACTIVE)
+ op->map.vma_flags |= XE_VMA_CPU_AUTORESET_ACTIVE;
op->map.pat_index = default_pat;
}
} else {
@@ -4749,7 +4778,7 @@ static int xe_vm_alloc_vma(struct xe_vm *vm,
xe_assert(vm->xe, !remap_op);
xe_assert(vm->xe, xe_vma_has_no_bo(vma));
remap_op = true;
- vma_flags = vma->gpuva.flags;
+ vma_flags = xe_vma_effective_create_flags(vma);
}
if (__op->op == DRM_GPUVA_OP_MAP) {
@@ -4762,6 +4791,9 @@ static int xe_vm_alloc_vma(struct xe_vm *vm,
* unmapping.
*/
op->map.vma_flags |= vma_flags & XE_VMA_CREATE_MASK;
+ /* Forward pipeline-only state. */
+ 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-06-04 9:50 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 9:50 [RFC v3 0/7] drm/xe/svm: Add MMU notifier-based madvise autoreset on munmap Arvind Yadav
2026-06-04 9:50 ` [RFC v3 1/7] drm/xe/vm: Track CPU_AUTORESET state in xe_vma Arvind Yadav
2026-06-04 9:50 ` Arvind Yadav [this message]
2026-06-04 10:07 ` [RFC v3 2/7] drm/xe/vm: Preserve cpu_autoreset_active across GPUVA operations sashiko-bot
2026-06-04 9:50 ` [RFC v3 3/7] drm/xe/svm: Clear CPU_AUTORESET_ACTIVE on first GPU fault Arvind Yadav
2026-06-04 9:50 ` [RFC v3 4/7] drm/xe/vm: Add madvise autoreset notifier worker Arvind Yadav
2026-06-04 10:14 ` sashiko-bot
2026-06-04 9:50 ` [RFC v3 5/7] drm/xe/vm: Disable madvise notifier on GPU touch Arvind Yadav
2026-06-04 10:03 ` sashiko-bot
2026-06-04 9:50 ` [RFC v3 6/7] drm/xe/vm: Wire MADVISE_AUTORESET notifiers into VM lifecycle Arvind Yadav
2026-06-04 10:05 ` sashiko-bot
2026-06-04 9:50 ` [RFC v3 7/7] drm/xe/svm: Correct memory attribute reset for partial unmap Arvind Yadav
2026-06-04 10:12 ` sashiko-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=20260604095012.367231-3-arvind.yadav@intel.com \
--to=arvind.yadav@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--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