Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tomasz Lis" <tomasz.lis@intel.com>, intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v1] drm/xe: Retry when drm_gpusvm_get_pages() gives -EBUSY
Date: Tue, 24 Nov 2026 15:54:09 +0000	[thread overview]
Message-ID: <sashiko-outbox-231491@kernel.org> (raw)
In-Reply-To: <20261124152300.2450568-1-tomasz.lis@intel.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/xe: missing -EAGAIN retry in xe_pagefault_handle_vma()
  for userptr
- [Medium] drm/xe: untranslated -EAGAIN in xe_vm_bind_ioctl() prefetch
  paths
--

commit f646c29e1d6daa1b730a627c9bb86fd464763df6
Author: Tomasz Lis <tomasz.lis@intel.com>

drm/xe: Retry when drm_gpusvm_get_pages() gives -EBUSY

This commit translates -EBUSY from drm_gpusvm_get_pages() into -EAGAIN in
xe_svm_range_get_pages() and xe_vma_userptr_pin_pages() so callers retry
on exhausted HMM retries, and updates new_vma() to map -EAGAIN to -ENOMEM.

> diff --git a/drivers/gpu/drm/xe/xe_userptr.c b/drivers/gpu/drm/xe/xe_userptr.c
> index 9c1dac0fce6f1..423c190ac68d6 100644
> --- a/drivers/gpu/drm/xe/xe_userptr.c
> +++ b/drivers/gpu/drm/xe/xe_userptr.c
[ ... ]
> @@ -91,12 +93,14 @@ int xe_vma_userptr_pin_pages(struct xe_userptr_vma *uvma)
>  	if (vma->gpuva.flags & XE_VMA_DESTROYED)
>  		return 0;
>  
> -	return drm_gpusvm_get_pages(&vm->svm.gpusvm, &uvma->userptr.pages, 1,
> -				    uvma->userptr.notifier.mm,
> -				    &uvma->userptr.notifier,
> -				    xe_vma_userptr(vma),
> -				    xe_vma_userptr(vma) + xe_vma_size(vma),
> -				    &ctx);
> +	err = drm_gpusvm_get_pages(&vm->svm.gpusvm, &uvma->userptr.pages, 1,
> +				   uvma->userptr.notifier.mm,
> +				   &uvma->userptr.notifier,
> +				   xe_vma_userptr(vma),
> +				   xe_vma_userptr(vma) + xe_vma_size(vma),
> +				   &ctx);
> +
> +	return xe_gpusvm_get_pages_err(err);
>  }

[Severity: Medium]
Does xe_pagefault_handle_vma() actually retry when
xe_vma_userptr_pin_pages() returns -EAGAIN?

drivers/gpu/drm/xe/xe_pagefault.c:xe_pagefault_handle_vma() {
	...
	do {
		xe_pagefault_set_error(pf, XE_PAGEFAULT_ERROR_NONE);

		if (xe_vma_is_userptr(vma) &&
		    xe_vma_userptr_check_repin(to_userptr_vma(vma))) {
			struct xe_userptr_vma *uvma = to_userptr_vma(vma);

			err = xe_vma_userptr_pin_pages(uvma);
			if (err) {
				xe_pagefault_set_error(pf, XE_PAGEFAULT_ERROR_VMA_USERPTR_PIN);
				return err;
			}
		}
		...
	} while (err == -EAGAIN);
}

Because xe_pagefault_handle_vma() returns directly on any non-zero err
instead of continuing when err == -EAGAIN, the error propagates to
xe_pagefault_service() and xe_pagefault_queue_work(), which treats it as
a fatal fault failure and NACKs the pagefault to the GPU.

> diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> index dd855876f571c..6e6937870ac6b 100644
> --- a/drivers/gpu/drm/xe/xe_vm.c
> +++ b/drivers/gpu/drm/xe/xe_vm.c
> @@ -2746,11 +2746,11 @@ static struct xe_vma *new_vma(struct xe_vm *vm, struct drm_gpuva_op_map *op,
>  			err = xe_vma_userptr_pin_pages(to_userptr_vma(vma));
>  			/*
>  			 * -EBUSY has dedicated meaning that a user fence
> -			 * attached to the VMA is busy, in practice
> -			 * xe_vma_userptr_pin_pages can only fail with -EBUSY if
> -			 * we are low on memory so convert this to -ENOMEM.
> +			 * attached to the VMA is busy. xe_vma_userptr_pin_pages
> +			 * reports exhausted HMM retries as -EAGAIN, which makes
> +			 * no sense for the bind ioctl, so convert it to -ENOMEM.
>  			 */
> -			if (err == -EBUSY)
> +			if (err == -EAGAIN)
>  				err = -ENOMEM;
>  		}
>  	}

[Severity: Medium]
Can DRM_GPUVA_OP_PREFETCH in the bind ioctl now leak -EAGAIN to userspace
when drm_gpusvm_get_pages() exhausts its HMM retry budget?

In vm_bind_ioctl_ops_parse(), the DRM_GPUVA_OP_PREFETCH userptr path
returns err from xe_vma_userptr_pin_pages() directly without converting
-EAGAIN to -ENOMEM.  Similarly, prefetch_thread_func() calls
xe_svm_range_get_pages() and only translates -EOPNOTSUPP, -EFAULT and
-EPERM to -ENODATA (unlike op_prepare() in xe_pt.c, which also translates
-EAGAIN to -ENODATA), causing xe_vm_bind_ioctl() to unwind all bind
operations and return -EAGAIN to userspace.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261124152300.2450568-1-tomasz.lis@intel.com?part=1

      parent reply	other threads:[~2026-11-24 15:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 15:23 [PATCH v1] drm/xe: Retry when drm_gpusvm_get_pages() gives -EBUSY Tomasz Lis
2026-11-24 15:27 ` Matthew Auld
2026-11-24 15:51 ` ✓ CI.KUnit: success for " Patchwork
2026-11-24 15:54 ` sashiko-bot [this message]

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=sashiko-outbox-231491@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tomasz.lis@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