[PATCH 1/7] only flush when no space
Tvrtko Ursulin
tvrtko.ursulin at linux.intel.com
Wed Jul 5 14:06:06 UTC 2023
From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
drivers/gpu/drm/i915/gem/i915_gem_create.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_create.c b/drivers/gpu/drm/i915/gem/i915_gem_create.c
index d24c0ce8805c..eb9a5c1e1a03 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_create.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_create.c
@@ -95,11 +95,10 @@ __i915_gem_object_create_user_ext(struct drm_i915_private *i915, u64 size,
{
struct intel_memory_region *mr = placements[0];
struct drm_i915_gem_object *obj;
+ bool flushed = false;
unsigned int flags;
int ret;
- i915_gem_flush_free_objects(i915);
-
size = round_up(size, object_max_page_size(placements, n_placements));
if (size == 0)
return ERR_PTR(-EINVAL);
@@ -110,9 +109,12 @@ __i915_gem_object_create_user_ext(struct drm_i915_private *i915, u64 size,
if (i915_gem_object_size_2big(size))
return ERR_PTR(-E2BIG);
+retry:
obj = i915_gem_object_alloc();
- if (!obj)
- return ERR_PTR(-ENOMEM);
+ if (!obj) {
+ ret = -ENOMEM;
+ goto err_no_mem;
+ }
ret = object_set_placements(obj, placements, n_placements);
if (ret)
@@ -140,6 +142,13 @@ __i915_gem_object_create_user_ext(struct drm_i915_private *i915, u64 size,
if (obj->mm.n_placements > 1)
kfree(obj->mm.placements);
i915_gem_object_free(obj);
+err_no_mem:
+ if (!flushed &&
+ (ret == -ENOMEM || ret == -ENOSPC || ret == -ENXIO /* TTM */)) {
+ i915_gem_flush_free_objects(i915);
+ flushed = true;
+ goto retry;
+ }
return ERR_PTR(ret);
}
--
2.39.2
More information about the Intel-gfx-trybot
mailing list