Commit 14ca83ee authored by Chris Wilson's avatar Chris Wilson
Browse files

drm/i915/gem: Drop lru bumping on display unpinning



Simplify the frontbuffer unpin by removing the lock requirement. The LRU
bumping was primarily to protect the GTT from being evicted and from
frontbuffers being eagerly shrunk. Now we protect frontbuffers from the
shrinker, and we avoid accidentally evicting from the GTT, so the
benefit from bumping LRU is no more, and we can save more time by not.

Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210119214336.1463-6-chris@chris-wilson.co.uk
parent e956996c
Loading
Loading
Loading
Loading
+2 −5
Original line number Original line Diff line number Diff line
@@ -2247,7 +2247,7 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
		 */
		 */
		ret = i915_vma_pin_fence(vma);
		ret = i915_vma_pin_fence(vma);
		if (ret != 0 && INTEL_GEN(dev_priv) < 4) {
		if (ret != 0 && INTEL_GEN(dev_priv) < 4) {
			i915_gem_object_unpin_from_display_plane(vma);
			i915_vma_unpin(vma);
			vma = ERR_PTR(ret);
			vma = ERR_PTR(ret);
			goto err;
			goto err;
		}
		}
@@ -2265,12 +2265,9 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long flags)
void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long flags)
{
{
	i915_gem_object_lock(vma->obj, NULL);
	if (flags & PLANE_HAS_FENCE)
	if (flags & PLANE_HAS_FENCE)
		i915_vma_unpin_fence(vma);
		i915_vma_unpin_fence(vma);
	i915_gem_object_unpin_from_display_plane(vma);
	i915_vma_unpin(vma);
	i915_gem_object_unlock(vma->obj);
	i915_vma_put(vma);
	i915_vma_put(vma);
}
}
+2 −2
Original line number Original line Diff line number Diff line
@@ -360,7 +360,7 @@ static void intel_overlay_release_old_vma(struct intel_overlay *overlay)
	intel_frontbuffer_flip_complete(overlay->i915,
	intel_frontbuffer_flip_complete(overlay->i915,
					INTEL_FRONTBUFFER_OVERLAY(overlay->crtc->pipe));
					INTEL_FRONTBUFFER_OVERLAY(overlay->crtc->pipe));


	i915_gem_object_unpin_from_display_plane(vma);
	i915_vma_unpin(vma);
	i915_vma_put(vma);
	i915_vma_put(vma);
}
}


@@ -861,7 +861,7 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay,
	return 0;
	return 0;


out_unpin:
out_unpin:
	i915_gem_object_unpin_from_display_plane(vma);
	i915_vma_unpin(vma);
out_pin_section:
out_pin_section:
	atomic_dec(&dev_priv->gpu_error.pending_fb_pin);
	atomic_dec(&dev_priv->gpu_error.pending_fb_pin);


+0 −45
Original line number Original line Diff line number Diff line
@@ -434,48 +434,6 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
	return vma;
	return vma;
}
}


static void i915_gem_object_bump_inactive_ggtt(struct drm_i915_gem_object *obj)
{
	struct drm_i915_private *i915 = to_i915(obj->base.dev);
	struct i915_vma *vma;

	if (list_empty(&obj->vma.list))
		return;

	mutex_lock(&i915->ggtt.vm.mutex);
	spin_lock(&obj->vma.lock);
	for_each_ggtt_vma(vma, obj) {
		if (!drm_mm_node_allocated(&vma->node))
			continue;

		GEM_BUG_ON(vma->vm != &i915->ggtt.vm);
		list_move_tail(&vma->vm_link, &vma->vm->bound_list);
	}
	spin_unlock(&obj->vma.lock);
	mutex_unlock(&i915->ggtt.vm.mutex);

	if (i915_gem_object_is_shrinkable(obj)) {
		unsigned long flags;

		spin_lock_irqsave(&i915->mm.obj_lock, flags);

		if (obj->mm.madv == I915_MADV_WILLNEED &&
		    !atomic_read(&obj->mm.shrink_pin))
			list_move_tail(&obj->mm.link, &i915->mm.shrink_list);

		spin_unlock_irqrestore(&i915->mm.obj_lock, flags);
	}
}

void
i915_gem_object_unpin_from_display_plane(struct i915_vma *vma)
{
	/* Bump the LRU to try and avoid premature eviction whilst flipping  */
	i915_gem_object_bump_inactive_ggtt(vma->obj);

	i915_vma_unpin(vma);
}

/**
/**
 * Moves a single object to the CPU read, and possibly write domain.
 * Moves a single object to the CPU read, and possibly write domain.
 * @obj: object to act on
 * @obj: object to act on
@@ -616,9 +574,6 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
	else
	else
		err = i915_gem_object_set_to_cpu_domain(obj, write_domain);
		err = i915_gem_object_set_to_cpu_domain(obj, write_domain);


	/* And bump the LRU for this access */
	i915_gem_object_bump_inactive_ggtt(obj);

	i915_gem_object_unlock(obj);
	i915_gem_object_unlock(obj);


	if (write_domain)
	if (write_domain)
+0 −1
Original line number Original line Diff line number Diff line
@@ -492,7 +492,6 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
				     u32 alignment,
				     u32 alignment,
				     const struct i915_ggtt_view *view,
				     const struct i915_ggtt_view *view,
				     unsigned int flags);
				     unsigned int flags);
void i915_gem_object_unpin_from_display_plane(struct i915_vma *vma);


void i915_gem_object_make_unshrinkable(struct drm_i915_gem_object *obj);
void i915_gem_object_make_unshrinkable(struct drm_i915_gem_object *obj);
void i915_gem_object_make_shrinkable(struct drm_i915_gem_object *obj);
void i915_gem_object_make_shrinkable(struct drm_i915_gem_object *obj);