Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1541904 > unrolled thread

[PATCH v13 1/3] drm: Move locking into drm_debugfs_crtc_crc_add

Started byTomeu Vizoso <tomeu.vizoso@collabora.com>
First post2016-12-14 14:40 +0100
Last post2016-12-14 18:00 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v13 1/3] drm: Move locking into drm_debugfs_crtc_crc_add Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2016-12-14 14:40 +0100
    Re: [PATCH v13 1/3] drm: Move locking into drm_debugfs_crtc_crc_add Emil Velikov <emil.l.velikov@gmail.com> - 2016-12-14 18:00 +0100

#1541904 — [PATCH v13 1/3] drm: Move locking into drm_debugfs_crtc_crc_add

FromTomeu Vizoso <tomeu.vizoso@collabora.com>
Date2016-12-14 14:40 +0100
Subject[PATCH v13 1/3] drm: Move locking into drm_debugfs_crtc_crc_add
Message-ID<sOhWN-717-3@gated-at.bofh.it>
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>
---

 drivers/gpu/drm/drm_debugfs_crc.c | 9 +++++++--
 1 file 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,
 	struct drm_crtc_crc_entry *entry;
 	int head, tail;
 
-	assert_spin_locked(&crc->lock);
+	spin_lock(&crc->lock);
 
 	/* Caller may not have noticed yet that userspace has stopped reading */
-	if (!crc->opened)
+	if (!crc->opened) {
+		spin_unlock(&crc->lock);
 		return -EINVAL;
+	}
 
 	head = crc->head;
 	tail = crc->tail;
 
 	if (CIRC_SPACE(head, tail, DRM_CRC_ENTRIES_NR) < 1) {
+		spin_unlock(&crc->lock);
 		DRM_ERROR("Overflow of CRC buffer, userspace reads too slow.\n");
 		return -ENOBUFS;
 	}
@@ -347,6 +350,8 @@ int drm_crtc_add_crc_entry(struct drm_crtc *crtc, bool has_frame,
 	head = (head + 1) & (DRM_CRC_ENTRIES_NR - 1);
 	crc->head = head;
 
+	spin_unlock(&crc->lock);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(drm_crtc_add_crc_entry);
-- 
2.7.4

[toc] | [next] | [standalone]


#1542050

FromEmil Velikov <emil.l.velikov@gmail.com>
Date2016-12-14 18:00 +0100
Message-ID<sOl4w-mI-35@gated-at.bofh.it>
In reply to#1541904
On 14 December 2016 at 13:34, Tomeu Vizoso <tomeu.vizoso@collabora.com> wrote:
> 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>

-Emil

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web