diff mbox

[v2,5/5] drm/tilcdc: WARN if CRTC is touched without CRTC lock

Message ID ce5d65c4c55c6e9ea67e23b78e8cfdb604cc934d.1473195205.git.jsarha@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jyri Sarha Sept. 6, 2016, 8:59 p.m. UTC
WARN if CRTC is touched without CRTC lock. The crtc functions should
not be called simultaneously from multiple threads. Having the DRM
CRTC lock should take care of that.

tilcdc_crtc_destroy() has to take the CRTC lock befor calling
tilcdc_crtc_disable() because drm_mode_config_cleanup() does not take
the lock. If this ever changes the CRTC locking has to be removed from
tilcdc_crtc_destroy().

Signed-off-by: Jyri Sarha <jsarha@ti.com>
---
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Tomi Valkeinen Sept. 7, 2016, 8:09 a.m. UTC | #1
On 06/09/16 23:59, Jyri Sarha wrote:
> WARN if CRTC is touched without CRTC lock. The crtc functions should
> not be called simultaneously from multiple threads. Having the DRM
> CRTC lock should take care of that.
> 
> tilcdc_crtc_destroy() has to take the CRTC lock befor calling
> tilcdc_crtc_disable() because drm_mode_config_cleanup() does not take
> the lock. If this ever changes the CRTC locking has to be removed from
> tilcdc_crtc_destroy().

Shouldn't these be two separate patches? This one is (according to
subject) adding WARNs, but it is actually also adding locking.

 Tomi
diff mbox

Patch

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 6974624..94a78e2 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -154,6 +154,8 @@  static void tilcdc_crtc_enable(struct drm_crtc *crtc)
 	struct drm_device *dev = crtc->dev;
 	struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
 
+	WARN_ON(!drm_modeset_is_locked(&crtc->mutex));
+
 	if (tilcdc_crtc->enabled)
 		return;
 
@@ -178,6 +180,8 @@  void tilcdc_crtc_disable(struct drm_crtc *crtc)
 	struct drm_device *dev = crtc->dev;
 	struct tilcdc_drm_private *priv = dev->dev_private;
 
+	WARN_ON(!drm_modeset_is_locked(&crtc->mutex));
+
 	if (!tilcdc_crtc->enabled)
 		return;
 
@@ -250,7 +254,9 @@  static void tilcdc_crtc_destroy(struct drm_crtc *crtc)
 	struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
 	struct tilcdc_drm_private *priv = crtc->dev->dev_private;
 
+	drm_modeset_lock_crtc(crtc, NULL);
 	tilcdc_crtc_disable(crtc);
+	drm_modeset_unlock_crtc(crtc);
 
 	flush_workqueue(priv->wq);
 
@@ -267,6 +273,8 @@  int tilcdc_crtc_update_fb(struct drm_crtc *crtc,
 	struct drm_device *dev = crtc->dev;
 	unsigned long flags;
 
+	WARN_ON(!drm_modeset_is_locked(&crtc->mutex));
+
 	if (tilcdc_crtc->event) {
 		dev_err(dev->dev, "already pending page flip!\n");
 		return -EBUSY;
@@ -371,6 +379,8 @@  static void tilcdc_crtc_mode_set_nofb(struct drm_crtc *crtc)
 	struct drm_display_mode *mode = &crtc->state->adjusted_mode;
 	struct drm_framebuffer *fb = crtc->primary->state->fb;
 
+	WARN_ON(!drm_modeset_is_locked(&crtc->mutex));
+
 	if (WARN_ON(!info))
 		return;