• Paul Cercueil's avatar
    gpu/drm: ingenic: Add option to mmap GEM buffers cached · 37054fc8
    Paul Cercueil authored
    Ingenic SoCs are most notably used in cheap chinese handheld gaming
    consoles. There, the games and applications generally render in software
    directly into GEM buffers.
    
    Traditionally, GEM buffers are mapped write-combine. Writes to the
    buffer are accelerated, and reads are slow. Application doing lots of
    alpha-blending paint inside shadow buffers, which is then memcpy'd into
    the final GEM buffer.
    
    On recent Ingenic SoCs however, it is much faster to have a fully cached
    GEM buffer, in which applications paint directly, and whose data is
    invalidated before scanout, than having a write-combine GEM buffer, even
    when alpha blending is not used.
    
    Add an optional 'cached_gem_buffers' parameter to the ingenic-drm driver
    to allow GEM buffers to be mapped fully-cached, in order to speed up
    software rendering.
    
    v2: Use standard noncoherent DMA APIs
    
    v3: Use damage clips instead of invalidating full frames
    
    v4: Avoid dma_pgprot() which is not exported. Using vm_get_page_prot()
        is enough in this case.
    
    v5:
    - Avoid calling drm_gem_cma_prime_mmap(). It has the side effect that an
      extra object reference is obtained, which causes our dumb buffers to
      never be freed. It should have been drm_gem_cma_mmap_obj(). However,
      our custom mmap function only differs with one flag, so we can cleanly
      handle both modes in ingenic_drm_gem_mmap().
    - Call drm_gem_vm_close() if drm_mmap_attrs() failed, just like in
      drm_gem_cma_mmap_obj().
    Signed-off-by: default avatarPaul Cercueil <paul@crapouillou.net>
    Acked-by: default avatarSam Ravnborg <sam@ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20200912195639.176001-1-paul@crapouillou.net
    37054fc8
ingenic-drm.h 5.42 KB