Commit 04ee39ba authored by Daniel Vetter's avatar Daniel Vetter

drm: Only take crtc lock in get_gamma ioctl

We don't call into drivers at all here, this is enough. Also, we can
reduce the critical section a bit to simplify the code.
crtc->gamma_size is set up once at driver load and then invariant, so
also doesn't need any protection.
Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170403083304.9083-8-daniel.vetter@ffwll.ch
parent eb8eb02e
...@@ -295,19 +295,15 @@ int drm_mode_gamma_get_ioctl(struct drm_device *dev, ...@@ -295,19 +295,15 @@ int drm_mode_gamma_get_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);
crtc = drm_crtc_find(dev, crtc_lut->crtc_id); crtc = drm_crtc_find(dev, crtc_lut->crtc_id);
if (!crtc) { if (!crtc)
ret = -ENOENT; return -ENOENT;
goto out;
}
/* memcpy into gamma store */ /* memcpy into gamma store */
if (crtc_lut->gamma_size != crtc->gamma_size) { if (crtc_lut->gamma_size != crtc->gamma_size)
ret = -EINVAL; return -EINVAL;
goto out;
}
drm_modeset_lock(&crtc->mutex, NULL);
size = crtc_lut->gamma_size * (sizeof(uint16_t)); size = crtc_lut->gamma_size * (sizeof(uint16_t));
r_base = crtc->gamma_store; r_base = crtc->gamma_store;
if (copy_to_user((void __user *)(unsigned long)crtc_lut->red, r_base, size)) { if (copy_to_user((void __user *)(unsigned long)crtc_lut->red, r_base, size)) {
...@@ -327,6 +323,6 @@ int drm_mode_gamma_get_ioctl(struct drm_device *dev, ...@@ -327,6 +323,6 @@ int drm_mode_gamma_get_ioctl(struct drm_device *dev,
goto out; goto out;
} }
out: out:
drm_modeset_unlock_all(dev); drm_modeset_unlock(&crtc->mutex);
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