[PATCH 2/8] do not flush directly
Tvrtko Ursulin
tvrtko.ursulin at linux.intel.com
Thu Jul 6 13:23:24 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 | 7 ++++---
drivers/gpu/drm/i915/gem/i915_gem_object.c | 11 +++++------
drivers/gpu/drm/i915/gem/i915_gem_object.h | 2 +-
drivers/gpu/drm/i915/i915_gem.c | 3 +--
4 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_create.c b/drivers/gpu/drm/i915/gem/i915_gem_create.c
index eb9a5c1e1a03..fea1b8007cfc 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_create.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_create.c
@@ -145,9 +145,10 @@ __i915_gem_object_create_user_ext(struct drm_i915_private *i915, u64 size,
err_no_mem:
if (!flushed &&
(ret == -ENOMEM || ret == -ENOSPC || ret == -ENXIO /* TTM */)) {
- i915_gem_flush_free_objects(i915);
- flushed = true;
- goto retry;
+ if (i915_gem_flush_free_objects(i915)) {
+ flushed = true;
+ goto retry;
+ }
}
return ERR_PTR(ret);
}
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.c b/drivers/gpu/drm/i915/gem/i915_gem_object.c
index 97ac6fb37958..ac714d9e26d7 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object.c
@@ -418,20 +418,19 @@ static void __i915_gem_free_objects(struct drm_i915_private *i915,
}
}
-void i915_gem_flush_free_objects(struct drm_i915_private *i915)
+bool i915_gem_flush_free_objects(struct drm_i915_private *i915)
{
- struct llist_node *freed = llist_del_all(&i915->mm.free_list);
-
- if (unlikely(freed))
- __i915_gem_free_objects(i915, freed);
+ return flush_work(&i915->mm.free_work);
}
static void __i915_gem_free_work(struct work_struct *work)
{
struct drm_i915_private *i915 =
container_of(work, struct drm_i915_private, mm.free_work);
+ struct llist_node *freed = llist_del_all(&i915->mm.free_list);
- i915_gem_flush_free_objects(i915);
+ if (freed)
+ __i915_gem_free_objects(i915, freed);
}
static void i915_gem_free_object(struct drm_gem_object *gem_obj)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.h b/drivers/gpu/drm/i915/gem/i915_gem_object.h
index 884a17275b3a..15b37fe39ea2 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object.h
@@ -79,7 +79,7 @@ void i915_gem_object_put_pages_shmem(struct drm_i915_gem_object *obj,
void i915_gem_object_put_pages_phys(struct drm_i915_gem_object *obj,
struct sg_table *pages);
-void i915_gem_flush_free_objects(struct drm_i915_private *i915);
+bool i915_gem_flush_free_objects(struct drm_i915_private *i915);
struct sg_table *
__i915_gem_object_unset_pages(struct drm_i915_gem_object *obj);
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 1f65bb33dd21..00542fc2de56 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1113,8 +1113,7 @@ i915_gem_madvise_ioctl(struct drm_device *dev, void *data,
*/
void i915_gem_drain_freed_objects(struct drm_i915_private *i915)
{
- while (atomic_read(&i915->mm.free_count)) {
- flush_work(&i915->mm.free_work);
+ while (i915_gem_flush_free_objects(i915)) {
drain_workqueue(i915->bdev.wq);
rcu_barrier();
}
--
2.39.2
More information about the Intel-gfx-trybot
mailing list