[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220926153953.3836470-9-gwan-gyeong.mun@intel.com>
Date: Mon, 26 Sep 2022 18:39:52 +0300
From: Gwan-gyeong Mun <gwan-gyeong.mun@...el.com>
To: intel-gfx@...ts.freedesktop.org
Cc: linux-kernel@...r.kernel.org, dri-devel@...ts.freedesktop.org,
mchehab@...nel.org, chris@...is-wilson.co.uk,
matthew.auld@...el.com, thomas.hellstrom@...ux.intel.com,
jani.nikula@...el.com, nirmoy.das@...el.com, airlied@...hat.com,
daniel@...ll.ch, andi.shyti@...ux.intel.com,
andrzej.hajda@...el.com, keescook@...omium.org,
mauro.chehab@...ux.intel.com, linux@...musvillemoes.dk,
vitor@...saru.org, dlatypov@...gle.com, ndesaulniers@...gle.com,
trix@...hat.com, llvm@...ts.linux.dev,
linux-hardening@...r.kernel.org, linux-sparse@...r.kernel.org,
nathan@...nel.org, gustavoars@...nel.org,
luc.vanoostenryck@...il.com
Subject: [PATCH v12 8/9] drm/i915: Use error code as -E2BIG when the size of gem ttm object is too large
The ttm_bo_init_reserved() functions returns -ENOSPC if the size is too big
to add vma. The direct function that returns -ENOSPC is drm_mm_insert_node_in_range().
To handle the same error as other code returning -E2BIG when the size is
too large, it converts return value to -E2BIG.
Signed-off-by: Gwan-gyeong Mun <gwan-gyeong.mun@...el.com>
Cc: Chris Wilson <chris@...is-wilson.co.uk>
Cc: Matthew Auld <matthew.auld@...el.com>
Cc: Thomas Hellström <thomas.hellstrom@...ux.intel.com>
Reviewed-by: Nirmoy Das <nirmoy.das@...el.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab@...nel.org>
Reviewed-by: Andrzej Hajda <andrzej.hajda@...el.com>
---
drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
index e6bbc0f8b7e6..62d3924a6377 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
@@ -1242,6 +1242,17 @@ int __i915_gem_ttm_object_init(struct intel_memory_region *mem,
ret = ttm_bo_init_reserved(&i915->bdev, i915_gem_to_ttm(obj), bo_type,
&i915_sys_placement, page_size >> PAGE_SHIFT,
&ctx, NULL, NULL, i915_ttm_bo_destroy);
+
+ /*
+ * XXX: The ttm_bo_init_reserved() functions returns -ENOSPC if the size
+ * is too big to add vma. The direct function that returns -ENOSPC is
+ * drm_mm_insert_node_in_range(). To handle the same error as other code
+ * that returns -E2BIG when the size is too large, it converts -ENOSPC to
+ * -E2BIG.
+ */
+ if (size >> PAGE_SHIFT > INT_MAX && ret == -ENOSPC)
+ ret = -E2BIG;
+
if (ret)
return i915_ttm_err_to_gem(ret);
--
2.37.1
Powered by blists - more mailing lists