• Ben Widawsky's avatar
    drm/i915: Track GEN6 page table usage · 678d96fb
    Ben Widawsky authored
    Instead of implementing the full tracking + dynamic allocation, this
    patch does a bit less than half of the work, by tracking and warning on
    unexpected conditions. The tracking itself follows which PTEs within a
    page table are currently being used for objects. The next patch will
    modify this to actually allocate the page tables only when necessary.
    
    With the current patch there isn't much in the way of making a gen
    agnostic range allocation function. However, in the next patch we'll add
    more specificity which makes having separate functions a bit easier to
    manage.
    
    One important change introduced here is that DMA mappings are
    created/destroyed at the same page directories/tables are
    allocated/deallocated.
    
    Notice that aliasing PPGTT is not managed here. The patch which actually
    begins dynamic allocation/teardown explains the reasoning for this.
    
    v2: s/pdp.page_directory/pdp.page_directories
    Make a scratch page allocation helper
    
    v3: Rebase and expand commit message.
    
    v4: Allocate required pagetables only when it is needed, _bind_to_vm
    instead of bind_vma (Daniel).
    
    v5: Rebased to remove the unnecessary noise in the diff, also:
     - PDE mask is GEN agnostic, renamed GEN6_PDE_MASK to I915_PDE_MASK.
     - Removed unnecessary checks in gen6_alloc_va_range.
     - Changed map/unmap_px_single macros to use dma functions directly and
       be part of a static inline function instead.
     - Moved drm_device plumbing through page tables operation to its own
       patch.
     - Moved allocate/teardown_va_range calls until they are fully
       implemented (in subsequent patch).
     - Merged pt and scratch_pt unmap_and_free path.
     - Moved scratch page allocator helper to the patch that will use it.
    
    v6: Reduce complexity by not tearing down pagetables dynamically, the
    same can be achieved while freeing empty vms. (Daniel)
    
    v7: s/i915_dma_map_px_single/i915_dma_map_single
    s/gen6_write_pdes/gen6_write_pde
    Prevent a NULL case when only GGTT is available. (Mika)
    
    v8: Rebased after s/page_tables/page_table/.
    
    v9: Reworked i915_pte_index and i915_pte_count.
    Also exercise bitmap allocation here (gen6_alloc_va_range) and fix
    incorrect write_page_range in i915_gem_restore_gtt_mappings (Mika).
    
    Cc: Daniel Vetter <daniel@ffwll.ch>
    Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
    Signed-off-by: default avatarBen Widawsky <ben@bwidawsk.net>
    Signed-off-by: Michel Thierry <michel.thierry@intel.com> (v3+)
    Reviewed-by: default avatarMika Kuoppala <mika.kuoppala@intel.com>
    Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
    678d96fb
i915_gem_gtt.c 66.3 KB