Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9a1e2582 authored by Chris Wilson's avatar Chris Wilson
Browse files

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: default avatarChris Wilson <chris@chris-wilson.co.uk>
parent ab5ee576
Loading
Loading
Loading
Loading
+22 −21
Original line number Original line Diff line number Diff line
@@ -2113,7 +2113,6 @@ i915_gem_evict_something(struct drm_device *dev, int min_size)
{
{
	drm_i915_private_t *dev_priv = dev->dev_private;
	drm_i915_private_t *dev_priv = dev->dev_private;
	struct drm_gem_object *obj;
	struct drm_gem_object *obj;
	int have_waited = 0;
	int ret;
	int ret;


	for (;;) {
	for (;;) {
@@ -2137,9 +2136,6 @@ i915_gem_evict_something(struct drm_device *dev, int min_size)
			return i915_gem_object_unbind(obj);
			return i915_gem_object_unbind(obj);
		}
		}


		if (have_waited)
			return 0;

		/* If we didn't get anything, but the ring is still processing
		/* If we didn't get anything, but the ring is still processing
		 * things, wait for the next to finish and hopefully leave us
		 * things, wait for the next to finish and hopefully leave us
		 * a buffer to evict.
		 * a buffer to evict.
@@ -2155,7 +2151,6 @@ i915_gem_evict_something(struct drm_device *dev, int min_size)
			if (ret)
			if (ret)
				return ret;
				return ret;


			have_waited = 1;
			continue;
			continue;
		}
		}


@@ -2166,12 +2161,18 @@ i915_gem_evict_something(struct drm_device *dev, int min_size)
		 */
		 */
		if (!list_empty(&dev_priv->mm.flushing_list)) {
		if (!list_empty(&dev_priv->mm.flushing_list)) {
			struct drm_i915_gem_object *obj_priv;
			struct drm_i915_gem_object *obj_priv;
			uint32_t seqno;


			obj_priv = list_first_entry(&dev_priv->mm.flushing_list,
			/* Find an object that we can immediately reuse */
						    struct drm_i915_gem_object,
			list_for_each_entry(obj_priv, &dev_priv->mm.flushing_list, list) {
						    list);
				obj = obj_priv->obj;
				obj = obj_priv->obj;
				if (obj->size >= min_size)
					break;

				obj = NULL;
			}

			if (obj != NULL) {
				uint32_t seqno;


				i915_gem_flush(dev,
				i915_gem_flush(dev,
					       obj->write_domain,
					       obj->write_domain,
@@ -2184,9 +2185,9 @@ i915_gem_evict_something(struct drm_device *dev, int min_size)
				if (ret)
				if (ret)
					return ret;
					return ret;


			have_waited = 1;
				continue;
				continue;
			}
			}
		}


		/* If we didn't do any of the above, there's no single buffer
		/* If we didn't do any of the above, there's no single buffer
		 * large enough to swap out for the new one, so just evict
		 * large enough to swap out for the new one, so just evict