aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_debugfs_crc.c
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu.vizoso@collabora.com>2017-01-02 07:59:09 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2017-01-05 03:53:06 -0500
commit1aa81be3af121636824e40eec737706e62c9da0c (patch)
tree8151cf7dae481fee82fd09d49844532bbbb7f9ec /drivers/gpu/drm/drm_debugfs_crc.c
parent88017bd06e74c82dd0b953e3766ec0d1e3c8d63c (diff)
drm: Move locking into drm_debugfs_crtc_crc_add
There's no reason any more for callers of this function to take the lock themselves, so just move the lock to the function to avoid confusion and bugs when more callers are contributed. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Robert Foss <robert.foss@collabora.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/20170102125912.22305-2-tomeu.vizoso@collabora.com
Diffstat (limited to 'drivers/gpu/drm/drm_debugfs_crc.c')
-rw-r--r--drivers/gpu/drm/drm_debugfs_crc.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/gpu/drm/drm_debugfs_crc.c b/drivers/gpu/drm/drm_debugfs_crc.c
index 00e771fb7df2..68b171af237b 100644
--- a/drivers/gpu/drm/drm_debugfs_crc.c
+++ b/drivers/gpu/drm/drm_debugfs_crc.c
@@ -325,16 +325,19 @@ int drm_crtc_add_crc_entry(struct drm_crtc *crtc, bool has_frame,
325 struct drm_crtc_crc_entry *entry; 325 struct drm_crtc_crc_entry *entry;
326 int head, tail; 326 int head, tail;
327 327
328 assert_spin_locked(&crc->lock); 328 spin_lock(&crc->lock);
329 329
330 /* Caller may not have noticed yet that userspace has stopped reading */ 330 /* Caller may not have noticed yet that userspace has stopped reading */
331 if (!crc->opened) 331 if (!crc->opened) {
332 spin_unlock(&crc->lock);
332 return -EINVAL; 333 return -EINVAL;
334 }
333 335
334 head = crc->head; 336 head = crc->head;
335 tail = crc->tail; 337 tail = crc->tail;
336 338
337 if (CIRC_SPACE(head, tail, DRM_CRC_ENTRIES_NR) < 1) { 339 if (CIRC_SPACE(head, tail, DRM_CRC_ENTRIES_NR) < 1) {
340 spin_unlock(&crc->lock);
338 DRM_ERROR("Overflow of CRC buffer, userspace reads too slow.\n"); 341 DRM_ERROR("Overflow of CRC buffer, userspace reads too slow.\n");
339 return -ENOBUFS; 342 return -ENOBUFS;
340 } 343 }
@@ -347,6 +350,8 @@ int drm_crtc_add_crc_entry(struct drm_crtc *crtc, bool has_frame,
347 head = (head + 1) & (DRM_CRC_ENTRIES_NR - 1); 350 head = (head + 1) & (DRM_CRC_ENTRIES_NR - 1);
348 crc->head = head; 351 crc->head = head;
349 352
353 spin_unlock(&crc->lock);
354
350 return 0; 355 return 0;
351} 356}
352EXPORT_SYMBOL_GPL(drm_crtc_add_crc_entry); 357EXPORT_SYMBOL_GPL(drm_crtc_add_crc_entry);