Commit 98f41dc3 authored by Gerd Hoffmann's avatar Gerd Hoffmann

drm/virtio: implement prime export

Just run drm_prime_pages_to_sg() on the ttm pages list to get an
sg_table for export.  The pages list is created at object initialization
time, so there should be no need to handle an unpopulated page list.
Add a sanity check nevertheless.
Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
Acked-by: default avatarNoralf Trønnes <noralf@tronnes.org>
Link: http://patchwork.freedesktop.org/patch/msgid/20190227144441.6755-4-kraxel@redhat.com
parent 873f51d4
...@@ -205,8 +205,10 @@ static struct drm_driver driver = { ...@@ -205,8 +205,10 @@ static struct drm_driver driver = {
#if defined(CONFIG_DEBUG_FS) #if defined(CONFIG_DEBUG_FS)
.debugfs_init = virtio_gpu_debugfs_init, .debugfs_init = virtio_gpu_debugfs_init,
#endif #endif
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.gem_prime_export = drm_gem_prime_export, .gem_prime_export = drm_gem_prime_export,
.gem_prime_import = drm_gem_prime_import, .gem_prime_import = drm_gem_prime_import,
.gem_prime_get_sg_table = virtgpu_gem_prime_get_sg_table,
.gem_prime_vmap = virtgpu_gem_prime_vmap, .gem_prime_vmap = virtgpu_gem_prime_vmap,
.gem_prime_vunmap = virtgpu_gem_prime_vunmap, .gem_prime_vunmap = virtgpu_gem_prime_vunmap,
.gem_prime_mmap = virtgpu_gem_prime_mmap, .gem_prime_mmap = virtgpu_gem_prime_mmap,
......
...@@ -352,6 +352,7 @@ void virtio_gpu_object_free_sg_table(struct virtio_gpu_object *bo); ...@@ -352,6 +352,7 @@ void virtio_gpu_object_free_sg_table(struct virtio_gpu_object *bo);
int virtio_gpu_object_wait(struct virtio_gpu_object *bo, bool no_wait); int virtio_gpu_object_wait(struct virtio_gpu_object *bo, bool no_wait);
/* virtgpu_prime.c */ /* virtgpu_prime.c */
struct sg_table *virtgpu_gem_prime_get_sg_table(struct drm_gem_object *obj);
void *virtgpu_gem_prime_vmap(struct drm_gem_object *obj); void *virtgpu_gem_prime_vmap(struct drm_gem_object *obj);
void virtgpu_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr); void virtgpu_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
int virtgpu_gem_prime_mmap(struct drm_gem_object *obj, int virtgpu_gem_prime_mmap(struct drm_gem_object *obj,
......
...@@ -28,6 +28,18 @@ ...@@ -28,6 +28,18 @@
* device that might share buffers with virtgpu * device that might share buffers with virtgpu
*/ */
struct sg_table *virtgpu_gem_prime_get_sg_table(struct drm_gem_object *obj)
{
struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj);
if (!bo->tbo.ttm->pages || !bo->tbo.ttm->num_pages)
/* should not happen */
return ERR_PTR(-EINVAL);
return drm_prime_pages_to_sg(bo->tbo.ttm->pages,
bo->tbo.ttm->num_pages);
}
void *virtgpu_gem_prime_vmap(struct drm_gem_object *obj) void *virtgpu_gem_prime_vmap(struct drm_gem_object *obj)
{ {
struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj); struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj);
......
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