aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-09-20 15:16:50 -0400
committerChris Wilson <chris@chris-wilson.co.uk>2009-09-22 20:05:28 -0400
commit9a1e2582d8d397500d5241d1543709046e0f05ff (patch)
treed058191799e7d32da24bec5caa64ee69085e1921 /drivers/gpu
parentab5ee57650165dc342a20d1213d48d585f2a72bd (diff)
drm/i915: Search harder for a reusable object
As evict_something() is called by routines that do not repeatedly search again, try harder in the initial search to find an object that matches the request. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index d49ac1c2e396..874cce62f51a 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2113,7 +2113,6 @@ i915_gem_evict_something(struct drm_device *dev, int min_size)
2113{ 2113{
2114 drm_i915_private_t *dev_priv = dev->dev_private; 2114 drm_i915_private_t *dev_priv = dev->dev_private;
2115 struct drm_gem_object *obj; 2115 struct drm_gem_object *obj;
2116 int have_waited = 0;
2117 int ret; 2116 int ret;
2118 2117
2119 for (;;) { 2118 for (;;) {
@@ -2137,9 +2136,6 @@ i915_gem_evict_something(struct drm_device *dev, int min_size)
2137 return i915_gem_object_unbind(obj); 2136 return i915_gem_object_unbind(obj);
2138 } 2137 }
2139 2138
2140 if (have_waited)
2141 return 0;
2142
2143 /* If we didn't get anything, but the ring is still processing 2139 /* If we didn't get anything, but the ring is still processing
2144 * things, wait for the next to finish and hopefully leave us 2140 * things, wait for the next to finish and hopefully leave us
2145 * a buffer to evict. 2141 * a buffer to evict.
@@ -2155,7 +2151,6 @@ i915_gem_evict_something(struct drm_device *dev, int min_size)
2155 if (ret) 2151 if (ret)
2156 return ret; 2152 return ret;
2157 2153
2158 have_waited = 1;
2159 continue; 2154 continue;
2160 } 2155 }
2161 2156
@@ -2166,26 +2161,32 @@ i915_gem_evict_something(struct drm_device *dev, int min_size)
2166 */ 2161 */
2167 if (!list_empty(&dev_priv->mm.flushing_list)) { 2162 if (!list_empty(&dev_priv->mm.flushing_list)) {
2168 struct drm_i915_gem_object *obj_priv; 2163 struct drm_i915_gem_object *obj_priv;
2169 uint32_t seqno;
2170 2164
2171 obj_priv = list_first_entry(&dev_priv->mm.flushing_list, 2165 /* Find an object that we can immediately reuse */
2172 struct drm_i915_gem_object, 2166 list_for_each_entry(obj_priv, &dev_priv->mm.flushing_list, list) {
2173 list); 2167 obj = obj_priv->obj;
2174 obj = obj_priv->obj; 2168 if (obj->size >= min_size)
2169 break;
2175 2170
2176 i915_gem_flush(dev, 2171 obj = NULL;
2177 obj->write_domain, 2172 }
2178 obj->write_domain);
2179 seqno = i915_add_request(dev, NULL, obj->write_domain);
2180 if (seqno == 0)
2181 return -ENOMEM;
2182 2173
2183 ret = i915_wait_request(dev, seqno); 2174 if (obj != NULL) {
2184 if (ret) 2175 uint32_t seqno;
2185 return ret;
2186 2176
2187 have_waited = 1; 2177 i915_gem_flush(dev,
2188 continue; 2178 obj->write_domain,
2179 obj->write_domain);
2180 seqno = i915_add_request(dev, NULL, obj->write_domain);
2181 if (seqno == 0)
2182 return -ENOMEM;
2183
2184 ret = i915_wait_request(dev, seqno);
2185 if (ret)
2186 return ret;
2187
2188 continue;
2189 }
2189 } 2190 }
2190 2191
2191 /* If we didn't do any of the above, there's no single buffer 2192 /* If we didn't do any of the above, there's no single buffer