diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2017-04-03 04:32:56 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2017-04-05 03:27:39 -0400 |
commit | 04ee39ba9fff5bf6278328e2da1740001159c4c6 (patch) | |
tree | f324808c625b97a78004dfcda9bbc9cac9a11de2 | |
parent | eb8eb02ed850df95ba2224515b95eb311904e992 (diff) |
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: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170403083304.9083-8-daniel.vetter@ffwll.ch
-rw-r--r-- | drivers/gpu/drm/drm_color_mgmt.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c index cc23b9a505c0..a32be59a72d1 100644 --- a/drivers/gpu/drm/drm_color_mgmt.c +++ b/drivers/gpu/drm/drm_color_mgmt.c | |||
@@ -295,19 +295,15 @@ int drm_mode_gamma_get_ioctl(struct drm_device *dev, | |||
295 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) | 295 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
296 | return -EINVAL; | 296 | return -EINVAL; |
297 | 297 | ||
298 | drm_modeset_lock_all(dev); | ||
299 | crtc = drm_crtc_find(dev, crtc_lut->crtc_id); | 298 | crtc = drm_crtc_find(dev, crtc_lut->crtc_id); |
300 | if (!crtc) { | 299 | if (!crtc) |
301 | ret = -ENOENT; | 300 | return -ENOENT; |
302 | goto out; | ||
303 | } | ||
304 | 301 | ||
305 | /* memcpy into gamma store */ | 302 | /* memcpy into gamma store */ |
306 | if (crtc_lut->gamma_size != crtc->gamma_size) { | 303 | if (crtc_lut->gamma_size != crtc->gamma_size) |
307 | ret = -EINVAL; | 304 | return -EINVAL; |
308 | goto out; | ||
309 | } | ||
310 | 305 | ||
306 | drm_modeset_lock(&crtc->mutex, NULL); | ||
311 | size = crtc_lut->gamma_size * (sizeof(uint16_t)); | 307 | size = crtc_lut->gamma_size * (sizeof(uint16_t)); |
312 | r_base = crtc->gamma_store; | 308 | r_base = crtc->gamma_store; |
313 | if (copy_to_user((void __user *)(unsigned long)crtc_lut->red, r_base, size)) { | 309 | 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 | goto out; | 323 | goto out; |
328 | } | 324 | } |
329 | out: | 325 | out: |
330 | drm_modeset_unlock_all(dev); | 326 | drm_modeset_unlock(&crtc->mutex); |
331 | return ret; | 327 | return ret; |
332 | } | 328 | } |