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/nouveau Use a spin lock -- we...



details:   https://anonhg.NetBSD.org/src/rev/11b02d2d47f2
branches:  trunk
changeset: 823052:11b02d2d47f2
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Tue Apr 11 04:43:12 2017 +0000

description:
Use a spin lock -- we take this in interrupt context.

The nv_wait is a busy-wait, so holding a spin lock over it is OK.

Found, fixed, and tested by maya.  Cosmetically tweaked by me.

diffstat:

 sys/external/bsd/drm2/dist/drm/nouveau/nouveau_nv50_display.c |  20 ++++------
 1 files changed, 8 insertions(+), 12 deletions(-)

diffs (74 lines):

diff -r 24ab5857fb71 -r 11b02d2d47f2 sys/external/bsd/drm2/dist/drm/nouveau/nouveau_nv50_display.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_nv50_display.c     Tue Apr 11 01:22:13 2017 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_nv50_display.c     Tue Apr 11 04:43:12 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nouveau_nv50_display.c,v 1.5 2016/02/05 23:46:40 riastradh Exp $       */
+/*     $NetBSD: nouveau_nv50_display.c,v 1.6 2017/04/11 04:43:12 riastradh Exp $       */
 
        /*
  * Copyright 2011 Red Hat Inc.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_nv50_display.c,v 1.5 2016/02/05 23:46:40 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_nv50_display.c,v 1.6 2017/04/11 04:43:12 riastradh Exp $");
 
 #include <linux/dma-mapping.h>
 #include <linux/err.h>
@@ -163,7 +163,7 @@
        /* Protects against concurrent pushbuf access to this channel, lock is
         * grabbed by evo_wait (if the pushbuf reservation is successful) and
         * dropped again by evo_kick. */
-       struct mutex lock;
+       struct spinlock lock;
 };
 
 static void
@@ -187,7 +187,7 @@
        }
 
 #ifdef __NetBSD__
-       linux_mutex_destroy(&dmac->lock);
+       spin_lock_destroy(&dmac->lock);
 #endif
 
        nv50_chan_destroy(core, &dmac->base);
@@ -323,11 +323,7 @@
        u32 pushbuf = *(u32 *)data;
        int ret;
 
-#ifdef __NetBSD__
-       linux_mutex_init(&dmac->lock);
-#else
-       mutex_init(&dmac->lock);
-#endif
+       spin_lock_init(&dmac->lock);
 
 #ifdef __NetBSD__
     {
@@ -495,13 +491,13 @@
        struct nv50_dmac *dmac = evoc;
        u32 put = nv_ro32(dmac->base.user, 0x0000) / 4;
 
-       mutex_lock(&dmac->lock);
+       spin_lock(&dmac->lock);
        if (put + nr >= (PAGE_SIZE / 4) - 8) {
                dmac->ptr[put] = 0x20000000;
 
                nv_wo32(dmac->base.user, 0x0000, 0x00000000);
                if (!nv_wait(dmac->base.user, 0x0004, ~0, 0x00000000)) {
-                       mutex_unlock(&dmac->lock);
+                       spin_unlock(&dmac->lock);
                        NV_ERROR(dmac->base.user, "channel stalled\n");
                        return NULL;
                }
@@ -517,7 +513,7 @@
 {
        struct nv50_dmac *dmac = evoc;
        nv_wo32(dmac->base.user, 0x0000, (push - dmac->ptr) << 2);
-       mutex_unlock(&dmac->lock);
+       spin_unlock(&dmac->lock);
 }
 
 #define evo_mthd(p,m,s) *((p)++) = (((s) << 18) | (m))



Home | Main Index | Thread Index | Old Index