• Chris Wilson's avatar
    drm/i915: Lazily unbind vma on close · 3365e226
    Chris Wilson authored
    When userspace is passing around swapbuffers using DRI, we frequently
    have to open and close the same object in the foreign address space.
    This shows itself as the same object being rebound at roughly 30fps
    (with a second object also being rebound at 30fps), which involves us
    having to rewrite the page tables and maintain the drm_mm range manager
    every time.
    
    However, since the object still exists and it is only the local handle
    that disappears, if we are lazy and do not unbind the VMA immediately
    when the local user closes the object but defer it until the GPU is
    idle, then we can reuse the same VMA binding. We still have to be
    careful to mark the handle and lookup tables as closed to maintain the
    uABI, just allowing the underlying VMA to be resurrected if the user is
    able to access the same object from the same context again.
    
    If the object itself is destroyed (neither userspace keeping a handle to
    it), the VMA will be reaped immediately as usual.
    
    In the future, this will be even more useful as instantiating a new VMA
    for use on the GPU will become heavier. A nuisance indeed, so nip it in
    the bud.
    
    v2: s/__i915_vma_final_close/i915_vma_destroy/ etc.
    v3: Leave a hint as to why we deferred the unbind on close.
    Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
    Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
    Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20180503195115.22309-1-chris@chris-wilson.co.uk
    3365e226
i915_vma.c 23.5 KB