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

Commit 809b6334 authored by Chris Wilson's avatar Chris Wilson
Browse files

drm/i915: If we hit OOM when allocating GTT pages, clear the aperture



Rather than evicting an object at random, which is unlikely to alleviate
the memory pressure sufficient to allow us to continue, zap the entire
aperture. That should give the system long enough to recover and reap
some pages from the evicted objects, forestalling the allocation error
for the new object.

Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
parent 092de6f2
Loading
Loading
Loading
Loading
+4 −8
Original line number Original line Diff line number Diff line
@@ -2782,10 +2782,8 @@ i915_gem_object_bind_to_gtt(struct drm_i915_gem_object *obj,
		obj->gtt_space = NULL;
		obj->gtt_space = NULL;


		if (ret == -ENOMEM) {
		if (ret == -ENOMEM) {
			/* first try to clear up some space from the GTT */
			/* first try to reclaim some memory by clearing the GTT */
			ret = i915_gem_evict_something(dev, size,
			ret = i915_gem_evict_everything(dev, false);
						       alignment,
						       map_and_fenceable);
			if (ret) {
			if (ret) {
				/* now try to shrink everyone else */
				/* now try to shrink everyone else */
				if (gfpmask) {
				if (gfpmask) {
@@ -2793,7 +2791,7 @@ i915_gem_object_bind_to_gtt(struct drm_i915_gem_object *obj,
					goto search_free;
					goto search_free;
				}
				}


				return ret;
				return -ENOMEM;
			}
			}


			goto search_free;
			goto search_free;
@@ -2808,9 +2806,7 @@ i915_gem_object_bind_to_gtt(struct drm_i915_gem_object *obj,
		drm_mm_put_block(obj->gtt_space);
		drm_mm_put_block(obj->gtt_space);
		obj->gtt_space = NULL;
		obj->gtt_space = NULL;


		ret = i915_gem_evict_something(dev, size,
		if (i915_gem_evict_everything(dev, false))
					       alignment, map_and_fenceable);
		if (ret)
			return ret;
			return ret;


		goto search_free;
		goto search_free;