summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/udl/udl_gem.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2012-03-26 14:36:56 +0100
committerDave Airlie <airlied@redhat.com>2012-05-31 14:13:59 +0100
commite8aa1d1ebcbcf98fbb20cad83098f25c7d52753f (patch)
treea4b4cb36871ac3174407c4baafef93c7fdf23f5e /drivers/gpu/drm/udl/udl_gem.c
parent9a70cc2a7882dfc0d44a623b4a84f279714a6372 (diff)
downloadlinux-3.10-e8aa1d1ebcbcf98fbb20cad83098f25c7d52753f.tar.gz
linux-3.10-e8aa1d1ebcbcf98fbb20cad83098f25c7d52753f.tar.bz2
linux-3.10-e8aa1d1ebcbcf98fbb20cad83098f25c7d52753f.zip
udl: support vmapping imported dma-bufs
This allows udl to get a vmapping of an imported buffer for scanout. Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/udl/udl_gem.c')
-rw-r--r--drivers/gpu/drm/udl/udl_gem.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
index 97acc9c6c95..7bd65bdd15a 100644
--- a/drivers/gpu/drm/udl/udl_gem.c
+++ b/drivers/gpu/drm/udl/udl_gem.c
@@ -180,6 +180,18 @@ int udl_gem_vmap(struct udl_gem_object *obj)
int page_count = obj->base.size / PAGE_SIZE;
int ret;
+ if (obj->base.import_attach) {
+ ret = dma_buf_begin_cpu_access(obj->base.import_attach->dmabuf,
+ 0, obj->base.size, DMA_BIDIRECTIONAL);
+ if (ret)
+ return -EINVAL;
+
+ obj->vmapping = dma_buf_vmap(obj->base.import_attach->dmabuf);
+ if (!obj->vmapping)
+ return -ENOMEM;
+ return 0;
+ }
+
ret = udl_gem_get_pages(obj, GFP_KERNEL);
if (ret)
return ret;
@@ -192,6 +204,13 @@ int udl_gem_vmap(struct udl_gem_object *obj)
void udl_gem_vunmap(struct udl_gem_object *obj)
{
+ if (obj->base.import_attach) {
+ dma_buf_vunmap(obj->base.import_attach->dmabuf, obj->vmapping);
+ dma_buf_end_cpu_access(obj->base.import_attach->dmabuf, 0,
+ obj->base.size, DMA_BIDIRECTIONAL);
+ return;
+ }
+
if (obj->vmapping)
vunmap(obj->vmapping);
@@ -202,12 +221,12 @@ void udl_gem_free_object(struct drm_gem_object *gem_obj)
{
struct udl_gem_object *obj = to_udl_bo(gem_obj);
- if (gem_obj->import_attach)
- drm_prime_gem_destroy(gem_obj, obj->sg);
-
if (obj->vmapping)
udl_gem_vunmap(obj);
+ if (gem_obj->import_attach)
+ drm_prime_gem_destroy(gem_obj, obj->sg);
+
if (obj->pages)
udl_gem_put_pages(obj);