Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2/dist/drm drm: Fix lock order reversal ...



details:   https://anonhg.NetBSD.org/src/rev/c96411e358b7
branches:  trunk
changeset: 1028726:c96411e358b7
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 11:52:16 2021 +0000

description:
drm: Fix lock order reversal in merge botch.

Add a note reminding myself what the lock order is.

diffstat:

 sys/external/bsd/drm2/dist/drm/drm_vblank.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (44 lines):

diff -r c05cbc39e5e5 -r c96411e358b7 sys/external/bsd/drm2/dist/drm/drm_vblank.c
--- a/sys/external/bsd/drm2/dist/drm/drm_vblank.c       Sun Dec 19 11:52:07 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_vblank.c       Sun Dec 19 11:52:16 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_vblank.c,v 1.8 2021/12/19 11:48:42 riastradh Exp $ */
+/*     $NetBSD: drm_vblank.c,v 1.9 2021/12/19 11:52:16 riastradh Exp $ */
 
 /*
  * drm_irq.c IRQ and vblank support
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_vblank.c,v 1.8 2021/12/19 11:48:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_vblank.c,v 1.9 2021/12/19 11:52:16 riastradh Exp $");
 
 #include <linux/export.h>
 #include <linux/moduleparam.h>
@@ -75,6 +75,8 @@
  * &drm_driver.max_vblank_count. In that case the vblank core only disables the
  * vblanks after a timer has expired, which can be configured through the
  * ``vblankoffdelay`` module parameter.
+ *
+ * Lock order: event_lock -> vbl_lock -> vblank_time_lock
  */
 
 /* Retry timestamp calculation up to 3 times to satisfy
@@ -1875,14 +1877,14 @@
 
        spin_lock_irqsave(&dev->event_lock, irqflags);
 
+       spin_lock(&dev->vbl_lock);
+
        /* Need timestamp lock to prevent concurrent execution with
         * vblank enable/disable, as this would cause inconsistent
         * or corrupted timestamps and vblank counts.
         */
        spin_lock(&dev->vblank_time_lock);
 
-       spin_lock(&dev->vbl_lock);
-
        /* Vblank irq handling disabled. Nothing to do. */
        if (!vblank->enabled) {
                spin_unlock(&dev->vbl_lock);



Home | Main Index | Thread Index | Old Index