Module Name:    src
Committed By:   riastradh
Date:           Sun Dec 19 12:04:42 UTC 2021

Modified Files:
        src/sys/external/bsd/drm2/dist/drm/i915/display: intel_sprite.c

Log Message:
i915: Rework locking in intel_pipe_update_start/end.

Use event_lock rather than vbl_lock for the operation; narrow the
scope of vbl_lock.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
    src/sys/external/bsd/drm2/dist/drm/i915/display/intel_sprite.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/dist/drm/i915/display/intel_sprite.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/display/intel_sprite.c:1.4 src/sys/external/bsd/drm2/dist/drm/i915/display/intel_sprite.c:1.5
--- src/sys/external/bsd/drm2/dist/drm/i915/display/intel_sprite.c:1.4	Sun Dec 19 12:04:33 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/display/intel_sprite.c	Sun Dec 19 12:04:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: intel_sprite.c,v 1.4 2021/12/19 12:04:33 riastradh Exp $	*/
+/*	$NetBSD: intel_sprite.c,v 1.5 2021/12/19 12:04:42 riastradh Exp $	*/
 
 /*
  * Copyright © 2011 Intel Corporation
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intel_sprite.c,v 1.4 2021/12/19 12:04:33 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intel_sprite.c,v 1.5 2021/12/19 12:04:42 riastradh Exp $");
 
 #include <drm/drm_atomic.h>
 #include <drm/drm_atomic_helper.h>
@@ -122,12 +122,12 @@ void intel_pipe_update_start(const struc
 			  psr_status);
 
 	spin_lock(&crtc->base.dev->event_lock);
-	spin_lock(&dev_priv->drm.vbl_lock);
 
 	crtc->debug.min_vbl = min;
 	crtc->debug.max_vbl = max;
 	trace_intel_pipe_update_start(crtc);
 
+	spin_lock(&dev_priv->drm.vbl_lock);
 	DRM_SPIN_TIMED_WAIT_NOINTR_UNTIL(ret, wq, &dev_priv->drm.vbl_lock,
 	    timeout,
 	    (scanline = intel_get_crtc_scanline(crtc),
@@ -154,6 +154,7 @@ void intel_pipe_update_start(const struc
 	 */
 	while (need_vlv_dsi_wa && scanline == vblank_start)
 		scanline = intel_get_crtc_scanline(crtc);
+	spin_unlock(&dev_priv->drm.vbl_lock);
 
 	crtc->debug.scanline_start = scanline;
 	crtc->debug.start_vbl_time = ktime_get();
@@ -164,7 +165,6 @@ void intel_pipe_update_start(const struc
 
 irq_disable:
 	spin_lock(&crtc->base.dev->event_lock);
-	spin_lock(&dev_priv->drm.vbl_lock);
 }
 
 /**
@@ -191,9 +191,7 @@ void intel_pipe_update_end(struct intel_
 	 * event outside of the critical section - the spinlock might spin for a
 	 * while ... */
 	if (new_crtc_state->uapi.event) {
-#ifndef __NetBSD__		/* XXX locking against self */
 		WARN_ON(drm_crtc_vblank_get(&crtc->base) != 0);
-#endif
 
 		drm_crtc_arm_vblank_event(&crtc->base,
 				          new_crtc_state->uapi.event);
@@ -201,7 +199,6 @@ void intel_pipe_update_end(struct intel_
 		new_crtc_state->uapi.event = NULL;
 	}
 
-	spin_unlock(&dev_priv->drm.vbl_lock);
 	spin_unlock(&crtc->base.dev->event_lock);
 
 	if (intel_vgpu_active(dev_priv))

Reply via email to