From a4f8cf10cf853b227b3acbf90ec6df516a240194 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 27 Feb 2019 15:44:41 +0100 Subject: [PATCH] BACKPORT: drm/virtio: implement prime export MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Gerd Hoffmann Acked-by: Noralf Trønnes Link: http://patchwork.freedesktop.org/patch/msgid/20190227144441.6755-4-kraxel@redhat.com (cherry picked from commit 98f41dc3b3eeabfc80d5d5eb1c1a6294ff59b4ec) Signed-off-by: Greg Hartman BUG: 139386237 Change-Id: If0ab11829ec7a6166928e26b8f75e1510742493e --- drivers/gpu/drm/virtio/virtgpu_prime.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c b/drivers/gpu/drm/virtio/virtgpu_prime.c index 11d82a866753..4bbdaed26c50 100644 --- a/drivers/gpu/drm/virtio/virtgpu_prime.c +++ b/drivers/gpu/drm/virtio/virtgpu_prime.c @@ -30,8 +30,14 @@ struct sg_table *virtgpu_gem_prime_get_sg_table(struct drm_gem_object *obj) { - WARN_ONCE(1, "not implemented"); - return ERR_PTR(-ENODEV); + 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); } struct drm_gem_object *virtgpu_gem_prime_import_sg_table(