drm/ttm: Add vmap/vunmap to TTM and TTM GEM helpers
authorThomas Zimmermann <tzimmermann@suse.de>
Tue, 3 Nov 2020 09:30:10 +0000 (10:30 +0100)
committerThomas Zimmermann <tzimmermann@suse.de>
Mon, 9 Nov 2020 08:17:36 +0000 (09:17 +0100)
commit43676605f890b218e551f396a55dbaea7799acb4
treeb3ce6592acfafea411d364ed64b7e98e8666d864
parentf216fcb8e4d76038133926aec53df92bf6b15860
drm/ttm: Add vmap/vunmap to TTM and TTM GEM helpers

The new functions ttm_bo_{vmap,vunmap}() map and unmap a TTM BO in kernel
address space. The mapping's address is returned as struct dma_buf_map.
Each function is a simplified version of TTM's existing kmap code. Both
functions respect the memory's location ani/or writecombine flags.

On top TTM's functions, GEM TTM helpers got drm_gem_ttm_{vmap,vunmap}(),
two helpers that convert a GEM object into the TTM BO and forward the call
to TTM's vmap/vunmap. These helpers can be dropped into the rsp GEM object
callbacks.

v5:
* use size_t for storing mapping size (Christian)
* ignore premapped memory areas correctly in ttm_bo_vunmap()
* rebase onto latest TTM interfaces (Christian)
* remove BUG() from ttm_bo_vmap() (Christian)
v4:
* drop ttm_kmap_obj_to_dma_buf() in favor of vmap helpers (Daniel,
  Christian)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Christian König <christian.koenig@amd.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Tested-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20201103093015.1063-6-tzimmermann@suse.de
drivers/gpu/drm/drm_gem_ttm_helper.c
drivers/gpu/drm/ttm/ttm_bo_util.c
include/drm/drm_gem_ttm_helper.h
include/drm/ttm/ttm_bo_api.h
include/linux/dma-buf-map.h