All of 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 v8 02/18] drm/gpuvm: don't always WARN in drm_gpuvm_check_overflow()
Date: Fri,  3 Nov 2023 16:32:18 +0100	[thread overview]
Message-ID: <20231103153234.30407-2-thomas.hellstrom@linux.intel.com> (raw)
In-Reply-To: <20231103153234.30407-1-thomas.hellstrom@linux.intel.com>

From: Danilo Krummrich <dakr@redhat.com>

Don't always WARN in drm_gpuvm_check_overflow() and separate it into a
drm_gpuvm_check_overflow() and a dedicated
drm_gpuvm_warn_check_overflow() variant.

This avoids printing warnings due to invalid userspace requests.

Signed-off-by: Danilo Krummrich <dakr@redhat.com>
---
 drivers/gpu/drm/drm_gpuvm.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_gpuvm.c b/drivers/gpu/drm/drm_gpuvm.c
index b378554b81ac..1cbeb4169f9c 100644
--- a/drivers/gpu/drm/drm_gpuvm.c
+++ b/drivers/gpu/drm/drm_gpuvm.c
@@ -614,12 +614,18 @@ static int __drm_gpuva_insert(struct drm_gpuvm *gpuvm,
 static void __drm_gpuva_remove(struct drm_gpuva *va);
 
 static bool
-drm_gpuvm_check_overflow(struct drm_gpuvm *gpuvm, u64 addr, u64 range)
+drm_gpuvm_check_overflow(u64 addr, u64 range)
 {
 	u64 end;
 
-	return drm_WARN(gpuvm->drm, check_add_overflow(addr, range, &end),
-			"GPUVA address limited to %zu bytes.\n", sizeof(end));
+	return check_add_overflow(addr, range, &end);
+}
+
+static bool
+drm_gpuvm_warn_check_overflow(struct drm_gpuvm *gpuvm, u64 addr, u64 range)
+{
+	return drm_WARN(gpuvm->drm, drm_gpuvm_check_overflow(addr, range),
+			"GPUVA address limited to %zu bytes.\n", sizeof(addr));
 }
 
 static bool
@@ -647,7 +653,7 @@ static bool
 drm_gpuvm_range_valid(struct drm_gpuvm *gpuvm,
 		      u64 addr, u64 range)
 {
-	return !drm_gpuvm_check_overflow(gpuvm, addr, range) &&
+	return !drm_gpuvm_check_overflow(addr, range) &&
 	       drm_gpuvm_in_mm_range(gpuvm, addr, range) &&
 	       !drm_gpuvm_in_kernel_node(gpuvm, addr, range);
 }
@@ -682,7 +688,7 @@ drm_gpuvm_init(struct drm_gpuvm *gpuvm, const char *name,
 	gpuvm->ops = ops;
 	gpuvm->drm = drm;
 
-	drm_gpuvm_check_overflow(gpuvm, start_offset, range);
+	drm_gpuvm_warn_check_overflow(gpuvm, start_offset, range);
 	gpuvm->mm_start = start_offset;
 	gpuvm->mm_range = range;
 
@@ -691,8 +697,8 @@ drm_gpuvm_init(struct drm_gpuvm *gpuvm, const char *name,
 		gpuvm->kernel_alloc_node.va.addr = reserve_offset;
 		gpuvm->kernel_alloc_node.va.range = reserve_range;
 
-		if (likely(!drm_gpuvm_check_overflow(gpuvm, reserve_offset,
-						     reserve_range)))
+		if (likely(!drm_gpuvm_warn_check_overflow(gpuvm, reserve_offset,
+							  reserve_range)))
 			__drm_gpuva_insert(gpuvm, &gpuvm->kernel_alloc_node);
 	}
 }
-- 
2.41.0


  reply	other threads:[~2023-11-03 15:32 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-03 15:32 [Intel-xe] [CI v8 01/18] drm/gpuvm: convert WARN() to drm_WARN() variants Thomas Hellström
2023-11-03 15:32 ` Thomas Hellström [this message]
2023-11-03 15:32 ` [Intel-xe] [CI v8 03/18] drm/gpuvm: export drm_gpuvm_range_valid() Thomas Hellström
2023-11-03 15:32 ` [Intel-xe] [CI v8 04/18] drm/nouveau: make use of drm_gpuvm_range_valid() Thomas Hellström
2023-11-03 15:32 ` [Intel-xe] [CI v8 05/18] drm/gpuvm: add common dma-resv per struct drm_gpuvm Thomas Hellström
2023-11-03 15:32 ` [Intel-xe] [CI v8 06/18] drm/xe: Adjust to "drm/gpuvm: add common dma-resv per struct drm_gpuvm" Thomas Hellström
2023-11-03 15:32 ` [Intel-xe] [CI v8 07/18] drm/nouveau: make use of the GPUVM's shared dma-resv Thomas Hellström
2023-11-03 15:32 ` [Intel-xe] [CI v8 08/18] drm/gpuvm: add drm_gpuvm_flags to drm_gpuvm Thomas Hellström
2023-11-03 15:32 ` [Intel-xe] [CI v8 09/18] drm/xe: Adjust to commit "drm/gpuvm: add drm_gpuvm_flags to drm_gpuvm" Thomas Hellström
2023-11-12 22:07   ` Dafna Hirschfeld
2023-11-03 15:32 ` [Intel-xe] [CI v8 10/18] drm/nouveau: separately allocate struct nouveau_uvmm Thomas Hellström
2023-11-03 15:32 ` [Intel-xe] [CI v8 11/18] drm/gpuvm: reference count drm_gpuvm structures Thomas Hellström
2023-11-03 15:32 ` [Intel-xe] [CI v8 12/18] drm/xe: Adjust to commit " Thomas Hellström
2023-11-13  6:14   ` Dafna Hirschfeld
2023-11-03 15:32 ` [Intel-xe] [CI v8 13/18] drm/gpuvm: add an abstraction for a VM / BO combination Thomas Hellström
2023-11-03 15:32 ` [Intel-xe] [CI v8 14/18] drm/xe: Adjust to commit "drm/gpuvm: add an abstraction for a VM/BO combination" Thomas Hellström
2023-11-12 22:06   ` Dafna Hirschfeld
2023-11-03 15:32 ` [Intel-xe] [CI v8 15/18] drm/gpuvm: track/lock/validate external/evicted objects Thomas Hellström
2023-11-03 15:32 ` [Intel-xe] [CI v8 16/18] drm/xe: Adapt to GPUVM tracking of external / evicted objects Thomas Hellström
2023-11-03 15:32 ` [Intel-xe] [CI v8 17/18] drm/xe: Use DRM_GPUVM_RESV_PROTECTED for gpuvm Thomas Hellström
2023-11-03 15:32 ` [Intel-xe] [CI v8 18/18] drm/nouveau: use GPUVM common infrastructure Thomas Hellström
2023-11-03 15:35 ` [Intel-xe] ✓ CI.Patch_applied: success for series starting with [CI,v8,01/18] drm/gpuvm: convert WARN() to drm_WARN() variants Patchwork
2023-11-03 15:36 ` [Intel-xe] ✗ CI.checkpatch: warning " Patchwork
2023-11-03 15:37 ` [Intel-xe] ✓ CI.KUnit: success " Patchwork
2023-11-03 15:44 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-11-03 15:45 ` [Intel-xe] ✓ CI.Hooks: " Patchwork
2023-11-03 15:46 ` [Intel-xe] ✗ CI.checksparse: warning " Patchwork
2023-11-03 16:19 ` [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=20231103153234.30407-2-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.