Commit 1709474b authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/client: Pin vmap'ed GEM buffers

The function drm_client_buffer_vmap() establishes a long-term mapping
of the client's buffer object into the kernel address space. Make sure
that buffer does not move by pinning it to its current location. Same
for vunmap with unpin.

The only caller of drm_client_buffer_vmap() is fbdev-dma, which uses
gem-dma. As DMA-backed GEM buffers do not move, this change is for
correctness with little impact in practice.
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarDmitry Osipenko <dmitry.osipenko@collabora.com>
Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> # virtio-gpu
Acked-by: default avatarZack Rusin <zack.rusin@broadcom.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240227113853.8464-12-tzimmermann@suse.de
parent b4b0193e
...@@ -388,16 +388,30 @@ int ...@@ -388,16 +388,30 @@ int
drm_client_buffer_vmap(struct drm_client_buffer *buffer, drm_client_buffer_vmap(struct drm_client_buffer *buffer,
struct iosys_map *map_copy) struct iosys_map *map_copy)
{ {
struct drm_gem_object *gem = buffer->gem;
struct iosys_map *map = &buffer->map; struct iosys_map *map = &buffer->map;
int ret; int ret;
ret = drm_gem_vmap_unlocked(buffer->gem, map); drm_gem_lock(gem);
ret = drm_gem_pin_locked(gem);
if (ret) if (ret)
return ret; goto err_drm_gem_pin_locked;
ret = drm_gem_vmap(gem, map);
if (ret)
goto err_drm_gem_vmap;
drm_gem_unlock(gem);
*map_copy = *map; *map_copy = *map;
return 0; return 0;
err_drm_gem_vmap:
drm_gem_unpin_locked(buffer->gem);
err_drm_gem_pin_locked:
drm_gem_unlock(gem);
return ret;
} }
EXPORT_SYMBOL(drm_client_buffer_vmap); EXPORT_SYMBOL(drm_client_buffer_vmap);
...@@ -411,9 +425,13 @@ EXPORT_SYMBOL(drm_client_buffer_vmap); ...@@ -411,9 +425,13 @@ EXPORT_SYMBOL(drm_client_buffer_vmap);
*/ */
void drm_client_buffer_vunmap(struct drm_client_buffer *buffer) void drm_client_buffer_vunmap(struct drm_client_buffer *buffer)
{ {
struct drm_gem_object *gem = buffer->gem;
struct iosys_map *map = &buffer->map; struct iosys_map *map = &buffer->map;
drm_gem_vunmap_unlocked(buffer->gem, map); drm_gem_lock(gem);
drm_gem_vunmap(gem, map);
drm_gem_unpin_locked(gem);
drm_gem_unlock(gem);
} }
EXPORT_SYMBOL(drm_client_buffer_vunmap); EXPORT_SYMBOL(drm_client_buffer_vunmap);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment