Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: intel-xe@lists.freedesktop.org
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Matthew Brost" <matthew.brost@intel.com>,
	stable@vger.kernel.org
Subject: [PATCH v2 1/4] drm/xe/vm: Validate userptr during gpu vma prefetching
Date: Fri, 28 Feb 2025 08:30:55 +0100	[thread overview]
Message-ID: <20250228073058.59510-2-thomas.hellstrom@linux.intel.com> (raw)
In-Reply-To: <20250228073058.59510-1-thomas.hellstrom@linux.intel.com>

If a userptr vma subject to prefetching was already invalidated
or invalidated during the prefetch operation, the operation would
repeatedly return -EAGAIN which would typically cause an infinite
loop.

Validate the userptr to ensure this doesn't happen.

v2:
- Don't fallthrough from UNMAP to PREFETCH (Matthew Brost)

Fixes: 5bd24e78829a ("drm/xe/vm: Subclass userptr vmas")
Fixes: 617eebb9c480 ("drm/xe: Fix array of binds")
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: <stable@vger.kernel.org> # v6.9+
Suggested-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
 drivers/gpu/drm/xe/xe_vm.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index 996000f2424e..6fdc17be619e 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -2306,8 +2306,17 @@ static int vm_bind_ioctl_ops_parse(struct xe_vm *vm, struct drm_gpuva_ops *ops,
 			break;
 		}
 		case DRM_GPUVA_OP_UNMAP:
+			xe_vma_ops_incr_pt_update_ops(vops, op->tile_mask);
+			break;
 		case DRM_GPUVA_OP_PREFETCH:
-			/* FIXME: Need to skip some prefetch ops */
+			vma = gpuva_to_vma(op->base.prefetch.va);
+
+			if (xe_vma_is_userptr(vma)) {
+				err = xe_vma_userptr_pin_pages(to_userptr_vma(vma));
+				if (err)
+					return err;
+			}
+
 			xe_vma_ops_incr_pt_update_ops(vops, op->tile_mask);
 			break;
 		default:
-- 
2.48.1


  reply	other threads:[~2025-02-28  7:31 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-28  7:30 [PATCH v2 0/4] drm/xe: Fix userptr races and missed validations Thomas Hellström
2025-02-28  7:30 ` Thomas Hellström [this message]
2025-03-04 17:48   ` [PATCH v2 1/4] drm/xe/vm: Validate userptr during gpu vma prefetching Matthew Brost
2025-02-28  7:30 ` [PATCH v2 2/4] drm/xe/vm: Fix a misplaced #endif Thomas Hellström
2025-02-28  7:30 ` [PATCH v2 3/4] drm/xe: Fix fault mode invalidation with unbind Thomas Hellström
2025-02-28  7:30 ` [PATCH v2 4/4] drm/xe: Add staging tree for VM binds Thomas Hellström
2025-02-28  9:40 ` ✓ CI.Patch_applied: success for drm/xe: Fix userptr races and missed validations (rev2) Patchwork
2025-02-28  9:41 ` ✓ CI.checkpatch: " Patchwork
2025-02-28  9:42 ` ✓ CI.KUnit: " Patchwork
2025-02-28  9:59 ` ✓ CI.Build: " Patchwork
2025-02-28 10:01 ` ✓ CI.Hooks: " Patchwork
2025-02-28 10:02 ` ✓ CI.checksparse: " Patchwork
2025-02-28 10:21 ` ✓ Xe.CI.BAT: " Patchwork
2025-03-04 19:30 ` ✓ CI.Patch_applied: success for drm/xe: Fix userptr races and missed validations (rev3) Patchwork
2025-03-04 19:31 ` ✓ CI.checkpatch: " Patchwork
2025-03-04 19:32 ` ✓ CI.KUnit: " Patchwork
2025-03-04 19:49 ` ✓ CI.Build: " Patchwork
2025-03-04 19:51 ` ✓ CI.Hooks: " Patchwork
2025-03-04 19:53 ` ✓ CI.checksparse: " Patchwork
2025-03-04 20:11 ` ✓ Xe.CI.BAT: " Patchwork
2025-03-04 23:19 ` ✗ 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=20250228073058.59510-2-thomas.hellstrom@linux.intel.com \
    --to=thomas.hellstrom@linux.intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.brost@intel.com \
    --cc=stable@vger.kernel.org \
    /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