aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2012-12-02 15:53:40 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-01-20 16:16:59 -0500
commit786b99ed13223d8ac58a937dd348aead45eb8191 (patch)
treed2fed735d5be17d37d02a2a30260c766c079cf43 /drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
parent4b096ac10da0b63f09bd123b86fed8deb80646ce (diff)
drm: create drm_framebuffer_lookup
And replace all fb lookups with it. Also add a WARN to drm_mode_object_find since that is now no longer the blessed interface to look up an fb. And add kerneldoc to both functions. This only updates all callsites, but immediately drops the acquired refence again. Hence all callers still rely on the fact that a mode fb can't disappear while they're holding the struct mutex. Subsequent patches will instate proper use of refcounts, and then rework the rmfb and unref code to no longer serialize fb destruction with the mode_config lock. We don't want that since otherwise a compositor might end up stalling for a few frames in rmfb. v2: Don't use kref_get_unless_zero - Greg KH doesn't like that kind of interface. Reviewed-by: Rob Clark <rob@ti.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c')
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
index 0d6a161b204b..1b8f428accae 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
@@ -131,7 +131,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
131 struct vmw_master *vmaster = vmw_master(file_priv->master); 131 struct vmw_master *vmaster = vmw_master(file_priv->master);
132 struct drm_vmw_rect __user *clips_ptr; 132 struct drm_vmw_rect __user *clips_ptr;
133 struct drm_vmw_rect *clips = NULL; 133 struct drm_vmw_rect *clips = NULL;
134 struct drm_mode_object *obj; 134 struct drm_framebuffer *fb;
135 struct vmw_framebuffer *vfb; 135 struct vmw_framebuffer *vfb;
136 struct vmw_resource *res; 136 struct vmw_resource *res;
137 uint32_t num_clips; 137 uint32_t num_clips;
@@ -165,15 +165,15 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
165 165
166 drm_modeset_lock_all(dev); 166 drm_modeset_lock_all(dev);
167 167
168 mutex_lock(&dev->mode_config.fb_lock); 168 fb = drm_framebuffer_lookup(dev, arg->fb_id);
169 obj = drm_mode_object_find(dev, arg->fb_id, DRM_MODE_OBJECT_FB); 169 if (!fb) {
170 mutex_unlock(&dev->mode_config.fb_lock);
171 if (!obj) {
172 DRM_ERROR("Invalid framebuffer id.\n"); 170 DRM_ERROR("Invalid framebuffer id.\n");
173 ret = -EINVAL; 171 ret = -EINVAL;
174 goto out_no_fb; 172 goto out_no_fb;
175 } 173 }
176 vfb = vmw_framebuffer_to_vfb(obj_to_fb(obj)); 174 /* fb is protect by the mode_config lock, so drop the ref immediately */
175 drm_framebuffer_unreference(fb);
176 vfb = vmw_framebuffer_to_vfb(fb);
177 177
178 ret = ttm_read_lock(&vmaster->lock, true); 178 ret = ttm_read_lock(&vmaster->lock, true);
179 if (unlikely(ret != 0)) 179 if (unlikely(ret != 0))
@@ -217,7 +217,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
217 struct vmw_master *vmaster = vmw_master(file_priv->master); 217 struct vmw_master *vmaster = vmw_master(file_priv->master);
218 struct drm_vmw_rect __user *clips_ptr; 218 struct drm_vmw_rect __user *clips_ptr;
219 struct drm_vmw_rect *clips = NULL; 219 struct drm_vmw_rect *clips = NULL;
220 struct drm_mode_object *obj; 220 struct drm_framebuffer *fb;
221 struct vmw_framebuffer *vfb; 221 struct vmw_framebuffer *vfb;
222 uint32_t num_clips; 222 uint32_t num_clips;
223 int ret; 223 int ret;
@@ -250,16 +250,16 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
250 250
251 drm_modeset_lock_all(dev); 251 drm_modeset_lock_all(dev);
252 252
253 mutex_lock(&dev->mode_config.fb_lock); 253 fb = drm_framebuffer_lookup(dev, arg->fb_id);
254 obj = drm_mode_object_find(dev, arg->fb_id, DRM_MODE_OBJECT_FB); 254 if (!fb) {
255 mutex_unlock(&dev->mode_config.fb_lock);
256 if (!obj) {
257 DRM_ERROR("Invalid framebuffer id.\n"); 255 DRM_ERROR("Invalid framebuffer id.\n");
258 ret = -EINVAL; 256 ret = -EINVAL;
259 goto out_no_fb; 257 goto out_no_fb;
260 } 258 }
259 /* fb is protect by the mode_config lock, so drop the ref immediately */
260 drm_framebuffer_unreference(fb);
261 261
262 vfb = vmw_framebuffer_to_vfb(obj_to_fb(obj)); 262 vfb = vmw_framebuffer_to_vfb(fb);
263 if (!vfb->dmabuf) { 263 if (!vfb->dmabuf) {
264 DRM_ERROR("Framebuffer not dmabuf backed.\n"); 264 DRM_ERROR("Framebuffer not dmabuf backed.\n");
265 ret = -EINVAL; 265 ret = -EINVAL;