aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/i915/i915_gem_batch_pool.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem_batch_pool.c b/drivers/gpu/drm/i915/i915_gem_batch_pool.c
index 99ceae7855f8..41aa598c4f3b 100644
--- a/drivers/gpu/drm/i915/i915_gem_batch_pool.c
+++ b/drivers/gpu/drm/i915/i915_gem_batch_pool.c
@@ -96,8 +96,7 @@ struct drm_i915_gem_object *
96i915_gem_batch_pool_get(struct i915_gem_batch_pool *pool, 96i915_gem_batch_pool_get(struct i915_gem_batch_pool *pool,
97 size_t size) 97 size_t size)
98{ 98{
99 struct drm_i915_gem_object *obj = NULL; 99 struct drm_i915_gem_object *obj;
100 struct drm_i915_gem_object *tmp;
101 struct list_head *list; 100 struct list_head *list;
102 int n, ret; 101 int n, ret;
103 102
@@ -112,31 +111,29 @@ i915_gem_batch_pool_get(struct i915_gem_batch_pool *pool,
112 n = ARRAY_SIZE(pool->cache_list) - 1; 111 n = ARRAY_SIZE(pool->cache_list) - 1;
113 list = &pool->cache_list[n]; 112 list = &pool->cache_list[n];
114 113
115 list_for_each_entry(tmp, list, batch_pool_link) { 114 list_for_each_entry(obj, list, batch_pool_link) {
116 /* The batches are strictly LRU ordered */ 115 /* The batches are strictly LRU ordered */
117 if (i915_gem_object_is_active(tmp)) 116 if (i915_gem_object_is_active(obj)) {
118 break; 117 if (!reservation_object_test_signaled_rcu(obj->resv,
118 true))
119 break;
119 120
120 GEM_BUG_ON(!reservation_object_test_signaled_rcu(tmp->resv, 121 i915_gem_retire_requests(pool->engine->i915);
121 true)); 122 GEM_BUG_ON(i915_gem_object_is_active(obj));
123 }
122 124
123 if (tmp->base.size >= size) { 125 GEM_BUG_ON(!reservation_object_test_signaled_rcu(obj->resv,
124 /* Clear the set of shared fences early */ 126 true));
125 reservation_object_lock(tmp->resv, NULL);
126 reservation_object_add_excl_fence(tmp->resv, NULL);
127 reservation_object_unlock(tmp->resv);
128 127
129 obj = tmp; 128 if (obj->base.size >= size)
130 break; 129 goto found;
131 }
132 } 130 }
133 131
134 if (obj == NULL) { 132 obj = i915_gem_object_create_internal(pool->engine->i915, size);
135 obj = i915_gem_object_create_internal(pool->engine->i915, size); 133 if (IS_ERR(obj))
136 if (IS_ERR(obj)) 134 return obj;
137 return obj;
138 }
139 135
136found:
140 ret = i915_gem_object_pin_pages(obj); 137 ret = i915_gem_object_pin_pages(obj);
141 if (ret) 138 if (ret)
142 return ERR_PTR(ret); 139 return ERR_PTR(ret);