Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org,
	thomas.hellstrom@linux.intel.com,
	himal.prasad.ghimiray@intel.com
Subject: [PATCH v3 1/5] drm/gpusvm: Introduce devmem_only flag for allocation
Date: Tue, 22 Apr 2025 09:57:19 -0700	[thread overview]
Message-ID: <20250422165723.584286-2-matthew.brost@intel.com> (raw)
In-Reply-To: <20250422165723.584286-1-matthew.brost@intel.com>

From: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>

This commit adds a new flag, devmem_only, to the drm_gpusvm structure. The
purpose of this flag is to ensure that the get_pages function allocates
memory exclusively from the device's memory. If the allocation from
device memory fails, the function will return an -EFAULT error.

v3:
 - s/vram_only/devmem_only/

Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
---
 drivers/gpu/drm/drm_gpusvm.c | 5 +++++
 include/drm/drm_gpusvm.h     | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/drm_gpusvm.c b/drivers/gpu/drm/drm_gpusvm.c
index 38431e8360e7..edf107809d20 100644
--- a/drivers/gpu/drm/drm_gpusvm.c
+++ b/drivers/gpu/drm/drm_gpusvm.c
@@ -1454,6 +1454,11 @@ int drm_gpusvm_range_get_pages(struct drm_gpusvm *gpusvm,
 				goto err_unmap;
 			}
 
+			if (ctx->devmem_only) {
+				err = -EFAULT;
+				goto err_unmap;
+			}
+
 			addr = dma_map_page(gpusvm->drm->dev,
 					    page, 0,
 					    PAGE_SIZE << order,
diff --git a/include/drm/drm_gpusvm.h b/include/drm/drm_gpusvm.h
index df120b4d1f83..9fd25fc880a4 100644
--- a/include/drm/drm_gpusvm.h
+++ b/include/drm/drm_gpusvm.h
@@ -286,6 +286,7 @@ struct drm_gpusvm {
  * @in_notifier: entering from a MMU notifier
  * @read_only: operating on read-only memory
  * @devmem_possible: possible to use device memory
+ * @devmem_only: use only device memory
  *
  * Context that is DRM GPUSVM is operating in (i.e. user arguments).
  */
@@ -294,6 +295,7 @@ struct drm_gpusvm_ctx {
 	unsigned int in_notifier :1;
 	unsigned int read_only :1;
 	unsigned int devmem_possible :1;
+	unsigned int devmem_only :1;
 };
 
 int drm_gpusvm_init(struct drm_gpusvm *gpusvm,
-- 
2.34.1


  reply	other threads:[~2025-04-22 16:56 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-22 16:57 [PATCH v3 0/5] Enable SVM atomics in Xe / GPU SVM Matthew Brost
2025-04-22 16:57 ` Matthew Brost [this message]
2025-04-22 16:57 ` [PATCH v3 2/5] drm/xe: Strict migration policy for atomic SVM faults Matthew Brost
2025-04-22 16:57 ` [PATCH v3 3/5] drm/gpusvm: Add timeslicing support to GPU SVM Matthew Brost
2025-04-22 16:57 ` [PATCH v3 4/5] drm/xe: Timeslice GPU on atomic SVM fault Matthew Brost
2025-04-22 16:57 ` [PATCH v3 5/5] drm/xe: Add atomic_svm_timeslice_ms debugfs entry Matthew Brost
2025-04-22 20:06 ` ✗ Xe.CI.Full: failure for Enable SVM atomics in Xe / GPU SVM (rev3) Patchwork
2025-04-23 11:32 ` ✓ Xe.CI.BAT: success " Patchwork
2025-04-23 12:48 ` ✓ CI.Patch_applied: " Patchwork
2025-04-23 12:48 ` ✗ CI.checkpatch: warning " Patchwork
2025-04-23 12:49 ` ✓ CI.KUnit: success " Patchwork
2025-04-23 12:58 ` ✓ CI.Build: " Patchwork
2025-04-24  1:19 ` ✓ CI.Patch_applied: " Patchwork
2025-04-24  1:19 ` ✗ CI.checkpatch: warning " Patchwork
2025-04-24  1:20 ` ✓ CI.KUnit: success " Patchwork
2025-04-24  1:28 ` ✓ CI.Build: " Patchwork
2025-04-24  1:30 ` ✗ CI.Hooks: failure " Patchwork
2025-04-24  1:32 ` ✓ CI.checksparse: success " Patchwork
2025-04-24 18:23 ` ✗ 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=20250422165723.584286-2-matthew.brost@intel.com \
    --to=matthew.brost@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --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