public inbox for intel-xe@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: Arvind Yadav <arvind.yadav@intel.com>
Cc: <intel-xe@lists.freedesktop.org>,
	<himal.prasad.ghimiray@intel.com>,
	<thomas.hellstrom@linux.intel.com>
Subject: Re: [PATCH v7 12/12] drm/xe/madvise: Accept canonical GPU addresses in xe_vm_madvise_ioctl
Date: Mon, 23 Mar 2026 20:35:32 -0700	[thread overview]
Message-ID: <acIGhP36TAvjAR4x@lstrano-desk.jf.intel.com> (raw)
In-Reply-To: <20260323093106.2986900-13-arvind.yadav@intel.com>

On Mon, Mar 23, 2026 at 03:01:01PM +0530, Arvind Yadav wrote:
> Userspace passes canonical (sign-extended) GPU addresses where bits 63:48
> mirror bit 47. The internal GPUVM uses non-canonical form (upper bits
> zeroed), so passing raw canonical addresses into GPUVM lookups causes
> mismatches for addresses above 128TiB.
> 
> Strip the sign extension with xe_device_uncanonicalize_addr() at the
> top of xe_vm_madvise_ioctl(). Non-canonical addresses are unaffected.
> 
> Fixes: ada7486c5668 ("drm/xe: Implement madvise ioctl for xe")
> 
> Suggested-by: Matthew Brost <matthew.brost@intel.com>
> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>

Reviewed-by: Matthew Brost <matthew.brost@intel.com>

> Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
> Signed-off-by: Arvind Yadav <arvind.yadav@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_vm_madvise.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_vm_madvise.c b/drivers/gpu/drm/xe/xe_vm_madvise.c
> index 4a19da5e86d4..2d03676ee595 100644
> --- a/drivers/gpu/drm/xe/xe_vm_madvise.c
> +++ b/drivers/gpu/drm/xe/xe_vm_madvise.c
> @@ -673,8 +673,15 @@ int xe_vm_madvise_ioctl(struct drm_device *dev, void *data, struct drm_file *fil
>  	struct xe_device *xe = to_xe_device(dev);
>  	struct xe_file *xef = to_xe_file(file);
>  	struct drm_xe_madvise *args = data;
> -	struct xe_vmas_in_madvise_range madvise_range = {.addr = args->start,
> -							 .range =  args->range, };
> +	struct xe_vmas_in_madvise_range madvise_range = {
> +		/*
> +		 * Userspace may pass canonical (sign-extended) addresses.
> +		 * Strip the sign extension to get the internal non-canonical
> +		 * form used by the GPUVM, matching xe_vm_bind_ioctl() behavior.
> +		 */
> +		.addr = xe_device_uncanonicalize_addr(xe, args->start),
> +		.range = args->range,
> +	};
>  	struct xe_madvise_details details;
>  	struct xe_vm *vm;
>  	struct drm_exec exec;
> @@ -724,7 +731,7 @@ int xe_vm_madvise_ioctl(struct drm_device *dev, void *data, struct drm_file *fil
>  	if (err)
>  		goto unlock_vm;
>  
> -	err = xe_vm_alloc_madvise_vma(vm, args->start, args->range);
> +	err = xe_vm_alloc_madvise_vma(vm, madvise_range.addr, args->range);
>  	if (err)
>  		goto madv_fini;
>  
> @@ -774,7 +781,8 @@ int xe_vm_madvise_ioctl(struct drm_device *dev, void *data, struct drm_file *fil
>  	madvise_funcs[attr_type](xe, vm, madvise_range.vmas, madvise_range.num_vmas, args,
>  				 &details);
>  
> -	err = xe_vm_invalidate_madvise_range(vm, args->start, args->start + args->range);
> +	err = xe_vm_invalidate_madvise_range(vm, madvise_range.addr,
> +					     madvise_range.addr + args->range);
>  
>  	if (madvise_range.has_svm_userptr_vmas)
>  		xe_svm_notifier_unlock(vm);
> -- 
> 2.43.0
> 

  reply	other threads:[~2026-03-24  3:35 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-23  9:30 [PATCH v7 00/12] drm/xe/madvise: Add support for purgeable buffer objects Arvind Yadav
2026-03-23  9:30 ` [PATCH v7 01/12] drm/xe/uapi: Add UAPI " Arvind Yadav
2026-03-23  9:30 ` [PATCH v7 02/12] drm/xe/bo: Add purgeable bo state tracking and field madv to xe_bo Arvind Yadav
2026-03-23  9:30 ` [PATCH v7 03/12] drm/xe/madvise: Implement purgeable buffer object support Arvind Yadav
2026-03-25 15:01   ` Thomas Hellström
2026-03-26  4:02     ` Yadav, Arvind
2026-03-23  9:30 ` [PATCH v7 04/12] drm/xe/bo: Block CPU faults to purgeable buffer objects Arvind Yadav
2026-03-23  9:30 ` [PATCH v7 05/12] drm/xe/vm: Prevent binding of purged " Arvind Yadav
2026-03-24 12:21   ` Thomas Hellström
2026-03-23  9:30 ` [PATCH v7 06/12] drm/xe/madvise: Implement per-VMA purgeable state tracking Arvind Yadav
2026-03-24 12:25   ` Thomas Hellström
2026-03-23  9:30 ` [PATCH v7 07/12] drm/xe/madvise: Block imported and exported dma-bufs Arvind Yadav
2026-03-24 14:13   ` Thomas Hellström
2026-03-23  9:30 ` [PATCH v7 08/12] drm/xe/bo: Block mmap of DONTNEED/purged BOs Arvind Yadav
2026-03-26  1:33   ` Matthew Brost
2026-03-26  2:49     ` Yadav, Arvind
2026-03-23  9:30 ` [PATCH v7 09/12] drm/xe/dma_buf: Block export " Arvind Yadav
2026-03-24 14:47   ` Thomas Hellström
2026-03-26  2:50     ` Yadav, Arvind
2026-03-23  9:30 ` [PATCH v7 10/12] drm/xe/bo: Add purgeable shrinker state helpers Arvind Yadav
2026-03-24 14:51   ` Thomas Hellström
2026-03-23  9:31 ` [PATCH v7 11/12] drm/xe/madvise: Enable purgeable buffer object IOCTL support Arvind Yadav
2026-03-23  9:31 ` [PATCH v7 12/12] drm/xe/madvise: Accept canonical GPU addresses in xe_vm_madvise_ioctl Arvind Yadav
2026-03-24  3:35   ` Matthew Brost [this message]
2026-03-23  9:40 ` ✗ CI.checkpatch: warning for drm/xe/madvise: Add support for purgeable buffer objects (rev8) Patchwork
2026-03-23  9:42 ` ✓ CI.KUnit: success " Patchwork
2026-03-23 10:40 ` ✓ Xe.CI.BAT: " Patchwork
2026-03-23 12:05 ` ✓ Xe.CI.FULL: " Patchwork
2026-03-23 15:45 ` [PATCH v7 00/12] drm/xe/madvise: Add support for purgeable buffer objects Souza, Jose

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=acIGhP36TAvjAR4x@lstrano-desk.jf.intel.com \
    --to=matthew.brost@intel.com \
    --cc=arvind.yadav@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