]> git.baikalelectronics.ru Git - kernel.git/commit
gpu/drm: ingenic: Add option to mmap GEM buffers cached
authorPaul Cercueil <paul@crapouillou.net>
Sat, 12 Sep 2020 19:56:39 +0000 (21:56 +0200)
committerPaul Cercueil <paul@crapouillou.net>
Mon, 14 Sep 2020 23:32:26 +0000 (01:32 +0200)
commit0b80a4637d340c8d417d0d4436d70c6c9843df56
tree675a8ee5d85d2b9d0f41a1f36ef14c7e6ca6a590
parent4442c22fb6af527cf1c4f2adda1e5d364692c203
gpu/drm: ingenic: Add option to mmap GEM buffers cached

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: Paul Cercueil <paul@crapouillou.net>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20200912195639.176001-1-paul@crapouillou.net
drivers/gpu/drm/ingenic/ingenic-drm-drv.c
drivers/gpu/drm/ingenic/ingenic-drm.h
drivers/gpu/drm/ingenic/ingenic-ipu.c