Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210119214336.1463-6-chris@chris-wilson.co.uk

+4 -53
+2 -5
drivers/gpu/drm/i915/display/intel_display.c
··· 2247 2247 */ 2248 2248 ret = i915_vma_pin_fence(vma); 2249 2249 if (ret != 0 && INTEL_GEN(dev_priv) < 4) { 2250 - i915_gem_object_unpin_from_display_plane(vma); 2250 + i915_vma_unpin(vma); 2251 2251 vma = ERR_PTR(ret); 2252 2252 goto err; 2253 2253 } ··· 2265 2265 2266 2266 void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long flags) 2267 2267 { 2268 - i915_gem_object_lock(vma->obj, NULL); 2269 2268 if (flags & PLANE_HAS_FENCE) 2270 2269 i915_vma_unpin_fence(vma); 2271 - i915_gem_object_unpin_from_display_plane(vma); 2272 - i915_gem_object_unlock(vma->obj); 2273 - 2270 + i915_vma_unpin(vma); 2274 2271 i915_vma_put(vma); 2275 2272 } 2276 2273
+2 -2
drivers/gpu/drm/i915/display/intel_overlay.c
··· 360 360 intel_frontbuffer_flip_complete(overlay->i915, 361 361 INTEL_FRONTBUFFER_OVERLAY(overlay->crtc->pipe)); 362 362 363 - i915_gem_object_unpin_from_display_plane(vma); 363 + i915_vma_unpin(vma); 364 364 i915_vma_put(vma); 365 365 } 366 366 ··· 861 861 return 0; 862 862 863 863 out_unpin: 864 - i915_gem_object_unpin_from_display_plane(vma); 864 + i915_vma_unpin(vma); 865 865 out_pin_section: 866 866 atomic_dec(&dev_priv->gpu_error.pending_fb_pin); 867 867
-45
drivers/gpu/drm/i915/gem/i915_gem_domain.c
··· 434 434 return vma; 435 435 } 436 436 437 - static void i915_gem_object_bump_inactive_ggtt(struct drm_i915_gem_object *obj) 438 - { 439 - struct drm_i915_private *i915 = to_i915(obj->base.dev); 440 - struct i915_vma *vma; 441 - 442 - if (list_empty(&obj->vma.list)) 443 - return; 444 - 445 - mutex_lock(&i915->ggtt.vm.mutex); 446 - spin_lock(&obj->vma.lock); 447 - for_each_ggtt_vma(vma, obj) { 448 - if (!drm_mm_node_allocated(&vma->node)) 449 - continue; 450 - 451 - GEM_BUG_ON(vma->vm != &i915->ggtt.vm); 452 - list_move_tail(&vma->vm_link, &vma->vm->bound_list); 453 - } 454 - spin_unlock(&obj->vma.lock); 455 - mutex_unlock(&i915->ggtt.vm.mutex); 456 - 457 - if (i915_gem_object_is_shrinkable(obj)) { 458 - unsigned long flags; 459 - 460 - spin_lock_irqsave(&i915->mm.obj_lock, flags); 461 - 462 - if (obj->mm.madv == I915_MADV_WILLNEED && 463 - !atomic_read(&obj->mm.shrink_pin)) 464 - list_move_tail(&obj->mm.link, &i915->mm.shrink_list); 465 - 466 - spin_unlock_irqrestore(&i915->mm.obj_lock, flags); 467 - } 468 - } 469 - 470 - void 471 - i915_gem_object_unpin_from_display_plane(struct i915_vma *vma) 472 - { 473 - /* Bump the LRU to try and avoid premature eviction whilst flipping */ 474 - i915_gem_object_bump_inactive_ggtt(vma->obj); 475 - 476 - i915_vma_unpin(vma); 477 - } 478 - 479 437 /** 480 438 * Moves a single object to the CPU read, and possibly write domain. 481 439 * @obj: object to act on ··· 573 615 err = i915_gem_object_set_to_gtt_domain(obj, write_domain); 574 616 else 575 617 err = i915_gem_object_set_to_cpu_domain(obj, write_domain); 576 - 577 - /* And bump the LRU for this access */ 578 - i915_gem_object_bump_inactive_ggtt(obj); 579 618 580 619 i915_gem_object_unlock(obj); 581 620
-1
drivers/gpu/drm/i915/gem/i915_gem_object.h
··· 492 492 u32 alignment, 493 493 const struct i915_ggtt_view *view, 494 494 unsigned int flags); 495 - void i915_gem_object_unpin_from_display_plane(struct i915_vma *vma); 496 495 497 496 void i915_gem_object_make_unshrinkable(struct drm_i915_gem_object *obj); 498 497 void i915_gem_object_make_shrinkable(struct drm_i915_gem_object *obj);