]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
drm/vmwgfx: add proper framebuffer refcounting
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 11 Dec 2012 15:28:34 +0000 (16:28 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Sun, 20 Jan 2013 21:17:11 +0000 (22:17 +0100)
Afact vmwgfx already has all the right refcounting implemented on the
backing storage, and we only need to ensure that the drm fb doesn't
disappear untimely. So holding onto the fb reference from _lookup
until vmw_kms_present has completed should be enough.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c

index 1b8f428accaea045792d05cd2c58e77daf5de635..c509d40c4897ad9e1bdf8fd37d6618c9ccb44be0 100644 (file)
@@ -171,8 +171,6 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
                ret = -EINVAL;
                goto out_no_fb;
        }
-       /* fb is protect by the mode_config lock, so drop the ref immediately */
-       drm_framebuffer_unreference(fb);
        vfb = vmw_framebuffer_to_vfb(fb);
 
        ret = ttm_read_lock(&vmaster->lock, true);
@@ -197,6 +195,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
 out_no_surface:
        ttm_read_unlock(&vmaster->lock);
 out_no_ttm_lock:
+       drm_framebuffer_unreference(fb);
 out_no_fb:
        drm_modeset_unlock_all(dev);
 out_no_copy:
@@ -256,14 +255,12 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
                ret = -EINVAL;
                goto out_no_fb;
        }
-       /* fb is protect by the mode_config lock, so drop the ref immediately */
-       drm_framebuffer_unreference(fb);
 
        vfb = vmw_framebuffer_to_vfb(fb);
        if (!vfb->dmabuf) {
                DRM_ERROR("Framebuffer not dmabuf backed.\n");
                ret = -EINVAL;
-               goto out_no_fb;
+               goto out_no_ttm_lock;
        }
 
        ret = ttm_read_lock(&vmaster->lock, true);
@@ -276,6 +273,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
 
        ttm_read_unlock(&vmaster->lock);
 out_no_ttm_lock:
+       drm_framebuffer_unreference(fb);
 out_no_fb:
        drm_modeset_unlock_all(dev);
 out_no_copy: