Commit 4ccf097f authored by Daniel Vetter's avatar Daniel Vetter

drm: fb refcounting for dirtyfb_ioctl

We only need to ensure that the fb stays around for long enough. While
at it, only grab the modeset locks when we need them (since most
drivers don't implement the dirty callback, this should help jitter
and stalls when using the generic modeset driver).
Reviewed-by: default avatarRob Clark <rob@ti.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 58c0dca1
...@@ -2580,14 +2580,9 @@ int drm_mode_dirtyfb_ioctl(struct drm_device *dev, ...@@ -2580,14 +2580,9 @@ int drm_mode_dirtyfb_ioctl(struct drm_device *dev,
if (!drm_core_check_feature(dev, DRIVER_MODESET)) if (!drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL; return -EINVAL;
drm_modeset_lock_all(dev);
fb = drm_framebuffer_lookup(dev, r->fb_id); fb = drm_framebuffer_lookup(dev, r->fb_id);
if (!fb) { if (!fb)
ret = -EINVAL; return -EINVAL;
goto out_err1;
}
/* fb is protect by the mode_config lock, so drop the ref immediately */
drm_framebuffer_unreference(fb);
num_clips = r->num_clips; num_clips = r->num_clips;
clips_ptr = (struct drm_clip_rect __user *)(unsigned long)r->clips_ptr; clips_ptr = (struct drm_clip_rect __user *)(unsigned long)r->clips_ptr;
...@@ -2625,17 +2620,19 @@ int drm_mode_dirtyfb_ioctl(struct drm_device *dev, ...@@ -2625,17 +2620,19 @@ int drm_mode_dirtyfb_ioctl(struct drm_device *dev,
} }
if (fb->funcs->dirty) { if (fb->funcs->dirty) {
drm_modeset_lock_all(dev);
ret = fb->funcs->dirty(fb, file_priv, flags, r->color, ret = fb->funcs->dirty(fb, file_priv, flags, r->color,
clips, num_clips); clips, num_clips);
drm_modeset_unlock_all(dev);
} else { } else {
ret = -ENOSYS; ret = -ENOSYS;
goto out_err2;
} }
out_err2: out_err2:
kfree(clips); kfree(clips);
out_err1: out_err1:
drm_modeset_unlock_all(dev); drm_framebuffer_unreference(fb);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment