Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: "Ghimiray, Himal Prasad" <himal.prasad.ghimiray@intel.com>
Cc: intel-xe@lists.freedesktop.org,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Subject: Re: [PATCH v4 4/5] drm/xe/svm: Enable UNMAP for VMA merging operations
Date: Mon, 24 Nov 2025 08:58:20 -0800	[thread overview]
Message-ID: <aSSOrBXaWb/pn/so@lstrano-desk.jf.intel.com> (raw)
In-Reply-To: <f85e4257-5235-4fbc-a4f9-818ce7476c5a@intel.com>

On Mon, Nov 24, 2025 at 11:31:07AM +0530, Ghimiray, Himal Prasad wrote:
> 
> 
> On 23-11-2025 03:31, Matthew Brost wrote:
> > On Mon, Nov 03, 2025 at 11:39:56AM +0530, Himal Prasad Ghimiray wrote:
> > > ALLOW UNMAP of VMAs associated with SVM mappings when the MAP operation
> > > is intended to merge adjacent CPU_ADDR_MIRROR VMAs.
> > > 
> > > Cc: Matthew Brost <matthew.brost@intel.com>
> > > Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> > > Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
> > > ---
> > >   drivers/gpu/drm/xe/xe_vm.c       | 10 +++++++---
> > >   drivers/gpu/drm/xe/xe_vm_types.h |  3 ++-
> > >   2 files changed, 9 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> > > index d78eb95a954f..12354e03c3e2 100644
> > > --- a/drivers/gpu/drm/xe/xe_vm.c
> > > +++ b/drivers/gpu/drm/xe/xe_vm.c
> > > @@ -2244,8 +2244,10 @@ vm_bind_ioctl_ops_create(struct xe_vm *vm, struct xe_vma_ops *vops,
> > >   	switch (operation) {
> > >   	case DRM_XE_VM_BIND_OP_MAP:
> > > -		if (flags & DRM_XE_VM_BIND_FLAG_CPU_ADDR_MIRROR)
> > > +		if (flags & DRM_XE_VM_BIND_FLAG_CPU_ADDR_MIRROR) {
> > >   			xe_vm_find_cpu_addr_mirror_vma_range(vm, &range_start, &range_end);
> > > +			vops->flags |= XE_VMA_OPS_FLAG_ALLOW_SVM_UNMAP;
> > > +		}
> > >   		fallthrough;
> > >   	case DRM_XE_VM_BIND_OP_MAP_USERPTR: {
> > > @@ -2727,7 +2729,8 @@ static int vm_bind_ioctl_ops_parse(struct xe_vm *vm, struct drm_gpuva_ops *ops,
> > >   			if (xe_vma_is_cpu_addr_mirror(vma) &&
> > >   			    xe_svm_has_mapping(vm, xe_vma_start(vma),
> > > -					       xe_vma_end(vma)))
> > > +					       xe_vma_end(vma)) &&
> > > +			    !(vops->flags & XE_VMA_OPS_FLAG_ALLOW_SVM_UNMAP))
> > 
> > Do we need similar change to the DRM_GPUVA_OP_REMAP case statement which
> > has similar logic?
> 
> 
> As far as I can tell, REMAP is only possible within the
> svm_garbage_collector. In that function, we perform the REMAP operation
> after the range has been unmapped. Therefore, the REMAP should proceed
> safely without this check.
> 
> 

I believe this is right now that I think about this.

> > 
> > >   				return -EBUSY;
> > >   			if (!xe_vma_is_cpu_addr_mirror(vma))
> > > @@ -4295,6 +4298,8 @@ static int xe_vm_alloc_vma(struct xe_vm *vm,
> > >   	if (is_madvise)
> > >   		vops.flags |= XE_VMA_OPS_FLAG_MADVISE;
> > > +	else
> > > +		vops.flags |= XE_VMA_OPS_FLAG_ALLOW_SVM_UNMAP;
> > >   	err = vm_bind_ioctl_ops_parse(vm, ops, &vops);
> > >   	if (err)
> > > @@ -4371,7 +4376,6 @@ int xe_vm_alloc_madvise_vma(struct xe_vm *vm, uint64_t start, uint64_t range)
> > >   static bool is_cpu_addr_vma_with_default_attr(struct xe_vma *vma)
> > >   {
> > >   	return vma && xe_vma_is_cpu_addr_mirror(vma) &&
> > > -	       !xe_svm_has_mapping(xe_vma_vm(vma), xe_vma_start(vma), xe_vma_end(vma)) &&
> > 
> > Ah, ok this answers my question in patch #1 [1]. But then in this patch
> > should we also remove the similar check in patch #2 [2] in which I asked
> > the same question?
> 
> Thanks for pointing this. Will address in next version.
> 

+1

Matt

> > 
> > Matt
> > 
> > [1] https://patchwork.freedesktop.org/patch/685118/?series=154832&rev=4#comment_1267065
> > [2] https://patchwork.freedesktop.org/patch/685119/?series=154832&rev=4
> > 
> > >   	       xe_vma_has_default_mem_attrs(vma);
> > >   }
> > > diff --git a/drivers/gpu/drm/xe/xe_vm_types.h b/drivers/gpu/drm/xe/xe_vm_types.h
> > > index 830ed7b05c27..7578ccada2cf 100644
> > > --- a/drivers/gpu/drm/xe/xe_vm_types.h
> > > +++ b/drivers/gpu/drm/xe/xe_vm_types.h
> > > @@ -470,7 +470,8 @@ struct xe_vma_ops {
> > >   	/** @flag: signify the properties within xe_vma_ops*/
> > >   #define XE_VMA_OPS_FLAG_HAS_SVM_PREFETCH BIT(0)
> > >   #define XE_VMA_OPS_FLAG_MADVISE          BIT(1)
> > > -#define XE_VMA_OPS_ARRAY_OF_BINDS	 BIT(2)
> > > +#define XE_VMA_OPS_FLAG_ALLOW_SVM_UNMAP  BIT(2)
> > > +#define XE_VMA_OPS_ARRAY_OF_BINDS        BIT(3)
> > >   	u32 flags;
> > >   #ifdef TEST_VM_OPS_ERROR
> > >   	/** @inject_error: inject error to test error handling */
> > > -- 
> > > 2.34.1
> > > 
> 

  reply	other threads:[~2025-11-24 16:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-03  6:09 [PATCH v4 0/5] Improve VMA merging for CPU-address-mirrored mappings Himal Prasad Ghimiray
2025-11-03  5:53 ` ✓ CI.KUnit: success for Improve VMA merging for CPU-address-mirrored mappings (rev4) Patchwork
2025-11-03  6:09 ` [PATCH v4 1/5] drm/xe: Add helper to extend CPU-mirrored VMA range for merge Himal Prasad Ghimiray
2025-11-22 21:48   ` Matthew Brost
2025-11-03  6:09 ` [PATCH v4 2/5] drm/xe: Merge adjacent default-attribute VMAs during garbage collection Himal Prasad Ghimiray
2025-11-22 21:55   ` Matthew Brost
2025-11-03  6:09 ` [PATCH v4 3/5] drm/xe/svm: Extend MAP range to reduce vma fragmentation Himal Prasad Ghimiray
2025-11-03  6:09 ` [PATCH v4 4/5] drm/xe/svm: Enable UNMAP for VMA merging operations Himal Prasad Ghimiray
2025-11-22 22:01   ` Matthew Brost
2025-11-24  6:01     ` Ghimiray, Himal Prasad
2025-11-24 16:58       ` Matthew Brost [this message]
2025-11-03  6:09 ` [PATCH v4 5/5] drm/xe/vm: Skip ufence association for CPU address mirror VMA during MAP Himal Prasad Ghimiray
2025-11-22 22:02   ` Matthew Brost
2025-11-03  7:04 ` ✓ Xe.CI.BAT: success for Improve VMA merging for CPU-address-mirrored mappings (rev4) Patchwork
2025-11-03  8:20 ` ✗ 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=aSSOrBXaWb/pn/so@lstrano-desk.jf.intel.com \
    --to=matthew.brost@intel.com \
    --cc=himal.prasad.ghimiray@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --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