• Thomas Hellström's avatar
    drm/i915: Introduce refcounted sg-tables · cad7109a
    Thomas Hellström authored
    As we start to introduce asynchronous failsafe object migration,
    where we update the object state and then submit asynchronous
    commands we need to record what memory resources are actually used
    by various part of the command stream. Initially for three purposes:
    
    1) Error capture.
    2) Asynchronous migration error recovery.
    3) Asynchronous vma bind.
    
    At the time where these happens, the object state may have been updated
    to be several migrations ahead and object sg-tables discarded.
    
    In order to make it possible to keep sg-tables with memory resource
    information for these operations, introduce refcounted sg-tables that
    aren't freed until the last user is done with them.
    
    The alternative would be to reference information sitting on the
    corresponding ttm_resources which typically have the same lifetime as
    these refcountes sg_tables, but that leads to other awkward constructs:
    Due to the design direction chosen for ttm resource managers that would
    lead to diamond-style inheritance, the LMEM resources may sometimes be
    prematurely freed, and finally the subclassed struct ttm_resource would
    have to bleed into the asynchronous vma bind code.
    
    v3:
    - Address a number of style issues (Matthew Auld)
    v4:
    - Dont check for st->sgl being NULL in i915_ttm_tt__shmem_unpopulate(),
      that should never happen. (Matthew Auld)
    v5:
    - Fix a Potential double-free (Matthew Auld)
    Signed-off-by: default avatarThomas Hellström <thomas.hellstrom@linux.intel.com>
    Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211101122444.114607-1-thomas.hellstrom@linux.intel.com
    cad7109a
i915_gem_ttm.c 36.1 KB