Commit a6c3464f authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/gem-vram: Support pinning buffers to current location

Pinning a buffer prevents it from being moved to a different memory
location. For some operations, such as buffer updates, it is not
important where the buffer is located. Setting the pin function's
pl_flag argument to 0 will pin the buffer to whereever it is stored.

v2:
	* document pin flags in PRIME pin helper
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Acked-by: default avatarGerd Hoffmann <kraxel@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190613073041.29350-2-tzimmermann@suse.de
parent bb5ce9a0
...@@ -224,7 +224,9 @@ EXPORT_SYMBOL(drm_gem_vram_offset); ...@@ -224,7 +224,9 @@ EXPORT_SYMBOL(drm_gem_vram_offset);
* *
* Pinning a buffer object ensures that it is not evicted from * Pinning a buffer object ensures that it is not evicted from
* a memory region. A pinned buffer object has to be unpinned before * a memory region. A pinned buffer object has to be unpinned before
* it can be pinned to another region. * it can be pinned to another region. If the pl_flag argument is 0,
* the buffer is pinned at its current location (video RAM or system
* memory).
* *
* Returns: * Returns:
* 0 on success, or * 0 on success, or
...@@ -242,7 +244,9 @@ int drm_gem_vram_pin(struct drm_gem_vram_object *gbo, unsigned long pl_flag) ...@@ -242,7 +244,9 @@ int drm_gem_vram_pin(struct drm_gem_vram_object *gbo, unsigned long pl_flag)
if (gbo->pin_count) if (gbo->pin_count)
goto out; goto out;
if (pl_flag)
drm_gem_vram_placement(gbo, pl_flag); drm_gem_vram_placement(gbo, pl_flag);
for (i = 0; i < gbo->placement.num_placement; ++i) for (i = 0; i < gbo->placement.num_placement; ++i)
gbo->placements[i].flags |= TTM_PL_FLAG_NO_EVICT; gbo->placements[i].flags |= TTM_PL_FLAG_NO_EVICT;
...@@ -691,7 +695,15 @@ int drm_gem_vram_driver_gem_prime_pin(struct drm_gem_object *gem) ...@@ -691,7 +695,15 @@ int drm_gem_vram_driver_gem_prime_pin(struct drm_gem_object *gem)
{ {
struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(gem); struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(gem);
return drm_gem_vram_pin(gbo, DRM_GEM_VRAM_PL_FLAG_VRAM); /* Fbdev console emulation is the use case of these PRIME
* helpers. This may involve updating a hardware buffer from
* a shadow FB. We pin the buffer to it's current location
* (either video RAM or system memory) to prevent it from
* being relocated during the update operation. If you require
* the buffer to be pinned to VRAM, implement a callback that
* sets the flags accordingly.
*/
return drm_gem_vram_pin(gbo, 0);
} }
EXPORT_SYMBOL(drm_gem_vram_driver_gem_prime_pin); EXPORT_SYMBOL(drm_gem_vram_driver_gem_prime_pin);
...@@ -723,7 +735,7 @@ void *drm_gem_vram_driver_gem_prime_vmap(struct drm_gem_object *gem) ...@@ -723,7 +735,7 @@ void *drm_gem_vram_driver_gem_prime_vmap(struct drm_gem_object *gem)
int ret; int ret;
void *base; void *base;
ret = drm_gem_vram_pin(gbo, DRM_GEM_VRAM_PL_FLAG_VRAM); ret = drm_gem_vram_pin(gbo, 0);
if (ret) if (ret)
return NULL; return NULL;
base = drm_gem_vram_kmap(gbo, true, NULL); base = drm_gem_vram_kmap(gbo, true, NULL);
......
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