drm/vgem: Move get_pages to gem_create
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 30 Mar 2016 09:40:50 +0000 (11:40 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 20 Apr 2016 10:58:40 +0000 (12:58 +0200)
vgem doesn't have a shrinker or anything like that and drops backing
storage only at object_free time. There's no use in trying to be
clever and allocating backing storage delayed, it only causes trouble
by requiring locking.

Instead grab pages when we allocate the object right away.

v2: Fix compiling.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1459330852-27668-12-git-send-email-daniel.vetter@ffwll.ch
drivers/gpu/drm/vgem/vgem_drv.c

index f3ee1c41da1ed6f013f3762e3fb554e0ce6291a9..75f18987411afd58aee44205ab2b6d87620fb2e6 100644 (file)
@@ -154,6 +154,10 @@ static struct drm_gem_object *vgem_gem_create(struct drm_device *dev,
        if (err)
                goto out;
 
+       err = vgem_gem_get_pages(obj);
+       if (err)
+               goto out;
+
        err = drm_gem_handle_create(file, gem_object, handle);
        if (err)
                goto handle_out;
@@ -216,16 +220,8 @@ int vgem_gem_dumb_map(struct drm_file *file, struct drm_device *dev,
 
        obj->filp->private_data = obj;
 
-       ret = vgem_gem_get_pages(to_vgem_bo(obj));
-       if (ret)
-               goto fail_get_pages;
-
        *offset = drm_vma_node_offset_addr(&obj->vma_node);
 
-       goto unref;
-
-fail_get_pages:
-       drm_gem_free_mmap_offset(obj);
 unref:
        drm_gem_object_unreference(obj);
 unlock: