• Ben Widawsky's avatar
    drm/i915: Use drm_mm for PPGTT PDEs · c8d4c0d6
    Ben Widawsky authored
    When PPGTT support was originally enabled, it was only designed to
    support 1 PPGTT. It therefore made sense to simply hide the GGTT space
    required to enable this from the drm_mm allocator.
    
    Since we intend to support full PPGTT, which means more than 1, and they
    can be created and destroyed ad hoc it will be required to use the
    proper allocation techniques we already have.
    
    The first step here is to make the existing single PPGTT use the
    allocator.
    
    The astute observer will notice that we are reserving space in the GGTT
    for the PDEs for the lifetime of the address space, and would be right
    to question whether or not this is a good idea. It does not make a
    difference with this current patch only the aliasing PPGTT (indeed the
    PDEs should still be hidden from the shrinker). For the future, we are
    allocating from top to bottom to avoid using the precious "gtt
    space" The GGTT space at that point should only be used for scanout, HW
    contexts, ringbuffers, HWSP, PDEs, and a couple of other small buffers
    (potentially) used by the kernel. Everything else should be mapped into
    a PPGTT. To put the consumption in more tangible terms, it takes
    approximately 4 sets of PDEs to equal one 19x10 framebuffer (with no
    fancy stride or alignment constraints). 3/4 of the total [average] GGTT
    can be used for PDEs, and hopefully never touch the 1/4 that the
    framebuffer needs.
    
    The astute, and persistent observer might ask about the page tables
    which are also pinned for the address space. This waste is unfortunate.
    We use 2MB of memory per address space. We leave wrapping the PDEs as a
    real GEM object as a TODO.
    
    v2: Align PDEs to 64b in GTT
    Allocate the node dynamically so we can use drm_mm_put_block
    Now tested on IGT
    Allocate node at the top to avoid fragmentation (Chris)
    
    v3: Use Chris' top down allocator
    
    v4: Embed drm_mm_node into ppgtt struct (Jesse)
    Remove hunks which didn't belong (Jesse)
    
    v5: Don't subtract guard page since we now killed the guard page prior
    to this patch. (Ben)
    
    v6: Rebased and removed guard page stuff.
    Added a chunk to the commit message
    Allow adding a context to mappable region
    
    v7: Undo v3, so we can make the drm patch last in the series
    
    Cc: Chris Wilson <chris@chris-wilson.co.uk>
    Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org> (v4)
    Signed-off-by: default avatarBen Widawsky <ben@bwidawsk.net>
    
    squash: drm/i915: allow PPGTT to use mappable
    Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
    c8d4c0d6
i915_drv.h 78.5 KB