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
Subject: [Intel-xe] [CI 03/17] drm/gpuvm: export drm_gpuvm_range_valid()
Date: Wed,  6 Dec 2023 13:58:03 +0100	[thread overview]
Message-ID: <20231206125818.4164-3-thomas.hellstrom@linux.intel.com> (raw)
In-Reply-To: <20231206125818.4164-1-thomas.hellstrom@linux.intel.com>

From: Danilo Krummrich <dakr@redhat.com>

Drivers may use this function to validate userspace requests in advance,
hence export it.

Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Danilo Krummrich <dakr@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231108001259.15123-4-dakr@redhat.com
(cherry picked from commit 9297cfc9405bc6b60540b8b8aaf930b7e449e15a)
---
 drivers/gpu/drm/drm_gpuvm.c | 14 +++++++++++++-
 include/drm/drm_gpuvm.h     |  1 +
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_gpuvm.c b/drivers/gpu/drm/drm_gpuvm.c
index 1cbeb4169f9c..dd46d14fd3e6 100644
--- a/drivers/gpu/drm/drm_gpuvm.c
+++ b/drivers/gpu/drm/drm_gpuvm.c
@@ -649,7 +649,18 @@ drm_gpuvm_in_kernel_node(struct drm_gpuvm *gpuvm, u64 addr, u64 range)
 	return krange && addr < kend && kstart < end;
 }
 
-static bool
+/**
+ * drm_gpuvm_range_valid() - checks whether the given range is valid for the
+ * given &drm_gpuvm
+ * @gpuvm: the GPUVM to check the range for
+ * @addr: the base address
+ * @range: the range starting from the base address
+ *
+ * Checks whether the range is within the GPUVM's managed boundaries.
+ *
+ * Returns: true for a valid range, false otherwise
+ */
+bool
 drm_gpuvm_range_valid(struct drm_gpuvm *gpuvm,
 		      u64 addr, u64 range)
 {
@@ -657,6 +668,7 @@ drm_gpuvm_range_valid(struct drm_gpuvm *gpuvm,
 	       drm_gpuvm_in_mm_range(gpuvm, addr, range) &&
 	       !drm_gpuvm_in_kernel_node(gpuvm, addr, range);
 }
+EXPORT_SYMBOL_GPL(drm_gpuvm_range_valid);
 
 /**
  * drm_gpuvm_init() - initialize a &drm_gpuvm
diff --git a/include/drm/drm_gpuvm.h b/include/drm/drm_gpuvm.h
index baa1a96c038c..ed766dd9d96b 100644
--- a/include/drm/drm_gpuvm.h
+++ b/include/drm/drm_gpuvm.h
@@ -253,6 +253,7 @@ void drm_gpuvm_init(struct drm_gpuvm *gpuvm, const char *name,
 		    const struct drm_gpuvm_ops *ops);
 void drm_gpuvm_destroy(struct drm_gpuvm *gpuvm);
 
+bool drm_gpuvm_range_valid(struct drm_gpuvm *gpuvm, u64 addr, u64 range);
 bool drm_gpuvm_interval_empty(struct drm_gpuvm *gpuvm, u64 addr, u64 range);
 
 static inline struct drm_gpuva *
-- 
2.42.0


  parent reply	other threads:[~2023-12-06 12:58 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-06 12:58 [Intel-xe] [CI 01/17] drm/gpuvm: convert WARN() to drm_WARN() variants Thomas Hellström
2023-12-06 12:58 ` [Intel-xe] [CI 02/17] drm/gpuvm: don't always WARN in drm_gpuvm_check_overflow() Thomas Hellström
2023-12-06 12:58 ` Thomas Hellström [this message]
2023-12-06 12:58 ` [Intel-xe] [CI 04/17] drm/nouveau: make use of drm_gpuvm_range_valid() Thomas Hellström
2023-12-06 12:58 ` [Intel-xe] [CI 05/17] drm/gpuvm: add common dma-resv per struct drm_gpuvm Thomas Hellström
2023-12-06 12:58 ` [Intel-xe] [CI 06/17] drm/nouveau: make use of the GPUVM's shared dma-resv Thomas Hellström
2023-12-06 12:58 ` [Intel-xe] [CI 07/17] drm/gpuvm: add drm_gpuvm_flags to drm_gpuvm Thomas Hellström
2023-12-06 12:58 ` [Intel-xe] [CI 08/17] drm/nouveau: separately allocate struct nouveau_uvmm Thomas Hellström
2023-12-06 12:58 ` [Intel-xe] [CI 09/17] drm/gpuvm: reference count drm_gpuvm structures Thomas Hellström
2023-12-06 12:58 ` [Intel-xe] [CI 10/17] drm/gpuvm: add an abstraction for a VM / BO combination Thomas Hellström
2023-12-06 12:58 ` [Intel-xe] [CI 11/17] drm/gpuvm: track/lock/validate external/evicted objects Thomas Hellström
2023-12-06 12:58 ` [Intel-xe] [CI 12/17] drm/xe: Adjust to "drm/gpuvm: add common dma-resv per struct drm_gpuvm" Thomas Hellström
2023-12-06 12:58 ` [Intel-xe] [CI 13/17] drm/xe: Adjust to commit "drm/gpuvm: add drm_gpuvm_flags to drm_gpuvm" Thomas Hellström
2023-12-06 12:58 ` [Intel-xe] [CI 14/17] drm/xe: Adjust to commit drm/gpuvm: reference count drm_gpuvm structures Thomas Hellström
2023-12-06 12:58 ` [Intel-xe] [CI 15/17] drm/xe: Adjust to commit "drm/gpuvm: add an abstraction for a VM/BO combination" Thomas Hellström
2023-12-06 12:58 ` [Intel-xe] [CI 16/17] drm/xe: Use DRM_GPUVM_RESV_PROTECTED for gpuvm Thomas Hellström
2023-12-06 12:58 ` [Intel-xe] [CI 17/17] drm/xe: Disable panic_on_warn for testing purposes Thomas Hellström
2023-12-06 14:10 ` [Intel-xe] ✓ CI.Patch_applied: success for series starting with [CI,01/17] drm/gpuvm: convert WARN() to drm_WARN() variants Patchwork
2023-12-06 14:11 ` [Intel-xe] ✗ CI.checkpatch: warning " Patchwork
2023-12-06 14:12 ` [Intel-xe] ✓ CI.KUnit: success " Patchwork
2023-12-06 14:19 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-12-06 14:20 ` [Intel-xe] ✓ CI.Hooks: " Patchwork
2023-12-06 14:21 ` [Intel-xe] ✗ CI.checksparse: warning " Patchwork
2023-12-06 15:00 ` [Intel-xe] ✗ CI.BAT: 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=20231206125818.4164-3-thomas.hellstrom@linux.intel.com \
    --to=thomas.hellstrom@linux.intel.com \
    --cc=intel-xe@lists.freedesktop.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