Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/alpha Convert some simple_lock uses to mutex(9).



details:   https://anonhg.NetBSD.org/src/rev/34eb193aa768
branches:  trunk
changeset: 765386:34eb193aa768
user:      rmind <rmind%NetBSD.org@localhost>
date:      Tue May 24 20:26:34 2011 +0000

description:
Convert some simple_lock uses to mutex(9).
Tested by: jak@, mhitch@

diffstat:

 sys/arch/alpha/alpha/machdep.c    |   6 ++--
 sys/arch/alpha/alpha/prom.c       |  41 +++++++++++++++-----------------------
 sys/arch/alpha/alpha/vm_machdep.c |   9 +++++--
 sys/arch/alpha/include/pcb.h      |  15 ++++---------
 sys/arch/alpha/include/prom.h     |   6 ++--
 sys/arch/alpha/pci/ttwoga_pci.c   |  31 +++++++++++++----------------
 6 files changed, 47 insertions(+), 61 deletions(-)

diffs (truncated from 379 to 300 lines):

diff -r 6ef9b51ec6cb -r 34eb193aa768 sys/arch/alpha/alpha/machdep.c
--- a/sys/arch/alpha/alpha/machdep.c    Tue May 24 20:17:49 2011 +0000
+++ b/sys/arch/alpha/alpha/machdep.c    Tue May 24 20:26:34 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.332 2011/04/15 21:24:00 martin Exp $ */
+/* $NetBSD: machdep.c,v 1.333 2011/05/24 20:26:34 rmind Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.332 2011/04/15 21:24:00 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.333 2011/05/24 20:26:34 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -657,7 +657,7 @@
         */
        pcb0->pcb_hw.apcb_ksp = v + USPACE - sizeof(struct trapframe);
        lwp0.l_md.md_tf = (struct trapframe *)pcb0->pcb_hw.apcb_ksp;
-       simple_lock_init(&pcb0->pcb_fpcpu_slock);
+       mutex_init(&pcb0->pcb_fpcpu_lock, MUTEX_DEFAULT, IPL_HIGH);
 
        /* Indicate that lwp0 has a CPU. */
        lwp0.l_cpu = ci;
diff -r 6ef9b51ec6cb -r 34eb193aa768 sys/arch/alpha/alpha/prom.c
--- a/sys/arch/alpha/alpha/prom.c       Tue May 24 20:17:49 2011 +0000
+++ b/sys/arch/alpha/alpha/prom.c       Tue May 24 20:26:34 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: prom.c,v 1.46 2009/11/21 05:35:40 rmind Exp $ */
+/* $NetBSD: prom.c,v 1.47 2011/05/24 20:26:34 rmind Exp $ */
 
 /* 
  * Copyright (c) 1992, 1994, 1995, 1996 Carnegie Mellon University
@@ -27,13 +27,12 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: prom.c,v 1.46 2009/11/21 05:35:40 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: prom.c,v 1.47 2011/05/24 20:26:34 rmind Exp $");
 
 #include "opt_multiprocessor.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/simplelock.h>
 #include <sys/proc.h>
 #include <sys/cpu.h>
 
@@ -55,7 +54,7 @@
 
 extern struct prom_vec prom_dispatch_v;
 
-struct simplelock prom_slock;
+static kmutex_t        prom_lock;
 
 #ifdef _PMAP_MAY_USE_PROM_CONSOLE
 int            prom_mapped = 1;        /* Is PROM still mapped? */
@@ -86,7 +85,7 @@
         prom_dispatch_v.routine_arg = c->crb_v_dispatch;
         prom_dispatch_v.routine = c->crb_v_dispatch->entry_va;
 
-       simple_lock_init(&prom_slock);
+       mutex_init(&prom_lock, MUTEX_DEFAULT, IPL_HIGH);
 }
 
 void
@@ -107,13 +106,11 @@
 static void prom_cache_sync(void);
 #endif
 
-int
+void
 prom_enter(void)
 {
-       int s;
 
-       s = splhigh();
-       simple_lock(&prom_slock);
+       mutex_enter(&prom_lock);
 
 #ifdef _PMAP_MAY_USE_PROM_CONSOLE
        /*
@@ -134,11 +131,10 @@
                prom_cache_sync();                      /* XXX */
        }
 #endif
-       return s;
 }
 
 void
-prom_leave(int s)
+prom_leave(void)
 {
 
 #ifdef _PMAP_MAY_USE_PROM_CONSOLE
@@ -157,8 +153,7 @@
                prom_cache_sync();                      /* XXX */
        }
 #endif
-       simple_unlock(&prom_slock);
-       splx(s);
+       mutex_exit(&prom_lock);
 }
 
 #ifdef _PMAP_MAY_USE_PROM_CONSOLE
@@ -185,16 +180,15 @@
 {
         prom_return_t ret;
        unsigned char *to = (unsigned char *)0x20000000;
-       int s;
 
-       s = prom_enter();       /* splhigh() and map prom */
+       prom_enter();
        *to = c;
 
        do {
                ret.bits = prom_putstr(alpha_console, to, 1);
        } while ((ret.u.retval & 1) == 0);
 
-       prom_leave(s);          /* unmap prom and splx(s) */
+       prom_leave();
 }
 
 /*
@@ -206,12 +200,11 @@
 promcngetc(dev_t dev)
 {
         prom_return_t ret;
-       int s;
 
         for (;;) {
-               s = prom_enter();
+               prom_enter();
                 ret.bits = prom_getc(alpha_console);
-               prom_leave(s);
+               prom_leave();
                 if (ret.u.status == 0 || ret.u.status == 1)
                         return (ret.u.retval);
         }
@@ -226,11 +219,10 @@
 promcnlookc(dev_t dev, char *cp)
 {
         prom_return_t ret;
-       int s;
 
-       s = prom_enter();
+       prom_enter();
        ret.bits = prom_getc(alpha_console);
-       prom_leave(s);
+       prom_leave();
        if (ret.u.status == 0 || ret.u.status == 1) {
                *cp = ret.u.retval;
                return 1;
@@ -243,12 +235,11 @@
 {
        unsigned char *to = (unsigned char *)0x20000000;
        prom_return_t ret;
-       int s;
 
-       s = prom_enter();
+       prom_enter();
        ret.bits = prom_getenv_disp(id, to, len);
        memcpy(buf, to, len);
-       prom_leave(s);
+       prom_leave();
 
        if (ret.u.status & 0x4)
                ret.u.retval = 0;
diff -r 6ef9b51ec6cb -r 34eb193aa768 sys/arch/alpha/alpha/vm_machdep.c
--- a/sys/arch/alpha/alpha/vm_machdep.c Tue May 24 20:17:49 2011 +0000
+++ b/sys/arch/alpha/alpha/vm_machdep.c Tue May 24 20:26:34 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.105 2011/02/10 14:46:46 pooka Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.106 2011/05/24 20:26:34 rmind Exp $ */
 
 /*
  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.105 2011/02/10 14:46:46 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.106 2011/05/24 20:26:34 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -54,6 +54,8 @@
 
        if (pcb->pcb_fpcpu != NULL)
                fpusave_proc(l, 0);
+
+       mutex_destroy(&pcb->pcb_fpcpu_lock);
 }
 
 void
@@ -116,7 +118,8 @@
                pcb2->pcb_hw.apcb_usp = (u_long)stack + stacksize;
        else
                pcb2->pcb_hw.apcb_usp = alpha_pal_rdusp();
-       simple_lock_init(&pcb2->pcb_fpcpu_slock);
+
+       mutex_init(&pcb2->pcb_fpcpu_lock, MUTEX_DEFAULT, IPL_HIGH);
 
        /*
         * Arrange for a non-local goto when the new process
diff -r 6ef9b51ec6cb -r 34eb193aa768 sys/arch/alpha/include/pcb.h
--- a/sys/arch/alpha/include/pcb.h      Tue May 24 20:17:49 2011 +0000
+++ b/sys/arch/alpha/include/pcb.h      Tue May 24 20:26:34 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pcb.h,v 1.18 2008/01/04 21:47:20 ad Exp $ */
+/* $NetBSD: pcb.h,v 1.19 2011/05/24 20:26:35 rmind Exp $ */
 
 /*
  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -34,7 +34,7 @@
 #include "opt_multiprocessor.h"
 #endif
 
-#include <sys/simplelock.h>
+#include <sys/mutex.h>
 
 #include <machine/frame.h>
 #include <machine/reg.h>
@@ -61,16 +61,11 @@
        unsigned long   pcb_onfault;            /* for copy faults      [SW] */
        unsigned long   pcb_accessaddr;         /* for [fs]uswintr      [SW] */
        struct cpu_info * volatile pcb_fpcpu;   /* CPU with our FP state[SW] */
-       struct simplelock pcb_fpcpu_slock;      /* simple lock on fpcpu [SW] */
+       kmutex_t        pcb_fpcpu_lock;         /* lock on fpcpu        [SW] */
 };
 
-/*
- * MULTIPROCESSOR:
- * Need to block IPIs while holding the fpcpu_slock.  That is the
- * responsibility of the CALLER!
- */
-#define        FPCPU_LOCK(pcb)         simple_lock(&(pcb)->pcb_fpcpu_slock)
-#define        FPCPU_UNLOCK(pcb)       simple_unlock(&(pcb)->pcb_fpcpu_slock)
+#define        FPCPU_LOCK(pcb)         mutex_enter(&(pcb)->pcb_fpcpu_lock)
+#define        FPCPU_UNLOCK(pcb)       mutex_exit(&(pcb)->pcb_fpcpu_lock)
 
 /*
  * The pcb is augmented with machine-dependent additional data for
diff -r 6ef9b51ec6cb -r 34eb193aa768 sys/arch/alpha/include/prom.h
--- a/sys/arch/alpha/include/prom.h     Tue May 24 20:17:49 2011 +0000
+++ b/sys/arch/alpha/include/prom.h     Tue May 24 20:26:34 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: prom.h,v 1.12 2000/06/08 03:10:06 thorpej Exp $ */
+/* $NetBSD: prom.h,v 1.13 2011/05/24 20:26:35 rmind Exp $ */
 
 /*
  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -111,8 +111,8 @@
 
 #ifndef ASSEMBLER
 #ifdef _KERNEL
-int    prom_enter(void);
-void   prom_leave(int);
+void   prom_enter(void);
+void   prom_leave(void);
 
 void   promcnputc(dev_t, int);
 int    promcngetc(dev_t);
diff -r 6ef9b51ec6cb -r 34eb193aa768 sys/arch/alpha/pci/ttwoga_pci.c
--- a/sys/arch/alpha/pci/ttwoga_pci.c   Tue May 24 20:17:49 2011 +0000
+++ b/sys/arch/alpha/pci/ttwoga_pci.c   Tue May 24 20:26:34 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ttwoga_pci.c,v 1.4 2008/04/28 20:23:11 martin Exp $ */
+/* $NetBSD: ttwoga_pci.c,v 1.5 2011/05/24 20:26:35 rmind Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -31,13 +31,12 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: ttwoga_pci.c,v 1.4 2008/04/28 20:23:11 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ttwoga_pci.c,v 1.5 2011/05/24 20:26:35 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/device.h> 
-#include <sys/simplelock.h>
 
 #include <dev/pci/pcireg.h> 
 #include <dev/pci/pcivar.h>
@@ -66,28 +65,26 @@
  * the PCI configuration access routine.
  */
 
-struct simplelock ttwoga_conf_slock;
+static kmutex_t ttwoga_conf_lock;
 cpuid_t ttwoga_conf_cpu;               /* XXX core logic bug */
 
-#define        TTWOGA_CONF_LOCK(s)                                             \
+#define        TTWOGA_CONF_LOCK()                                              \



Home | Main Index | Thread Index | Old Index