Module Name: src
Committed By: rmind
Date: Tue May 24 20:26:35 UTC 2011
Modified Files:
src/sys/arch/alpha/alpha: machdep.c prom.c vm_machdep.c
src/sys/arch/alpha/include: pcb.h prom.h
src/sys/arch/alpha/pci: ttwoga_pci.c
Log Message:
Convert some simple_lock uses to mutex(9).
Tested by: jak@, mhitch@
To generate a diff of this commit:
cvs rdiff -u -r1.332 -r1.333 src/sys/arch/alpha/alpha/machdep.c
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/alpha/alpha/prom.c
cvs rdiff -u -r1.105 -r1.106 src/sys/arch/alpha/alpha/vm_machdep.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/alpha/include/pcb.h
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/alpha/include/prom.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/alpha/pci/ttwoga_pci.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/arch/alpha/alpha/machdep.c
diff -u src/sys/arch/alpha/alpha/machdep.c:1.332 src/sys/arch/alpha/alpha/machdep.c:1.333
--- src/sys/arch/alpha/alpha/machdep.c:1.332 Fri Apr 15 21:24:00 2011
+++ src/sys/arch/alpha/alpha/machdep.c Tue May 24 20:26:34 2011
@@ -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;
Index: src/sys/arch/alpha/alpha/prom.c
diff -u src/sys/arch/alpha/alpha/prom.c:1.46 src/sys/arch/alpha/alpha/prom.c:1.47
--- src/sys/arch/alpha/alpha/prom.c:1.46 Sat Nov 21 05:35:40 2009
+++ src/sys/arch/alpha/alpha/prom.c Tue May 24 20:26:34 2011
@@ -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;
Index: src/sys/arch/alpha/alpha/vm_machdep.c
diff -u src/sys/arch/alpha/alpha/vm_machdep.c:1.105 src/sys/arch/alpha/alpha/vm_machdep.c:1.106
--- src/sys/arch/alpha/alpha/vm_machdep.c:1.105 Thu Feb 10 14:46:46 2011
+++ src/sys/arch/alpha/alpha/vm_machdep.c Tue May 24 20:26:34 2011
@@ -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
Index: src/sys/arch/alpha/include/pcb.h
diff -u src/sys/arch/alpha/include/pcb.h:1.18 src/sys/arch/alpha/include/pcb.h:1.19
--- src/sys/arch/alpha/include/pcb.h:1.18 Fri Jan 4 21:47:20 2008
+++ src/sys/arch/alpha/include/pcb.h Tue May 24 20:26:35 2011
@@ -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
Index: src/sys/arch/alpha/include/prom.h
diff -u src/sys/arch/alpha/include/prom.h:1.12 src/sys/arch/alpha/include/prom.h:1.13
--- src/sys/arch/alpha/include/prom.h:1.12 Thu Jun 8 03:10:06 2000
+++ src/sys/arch/alpha/include/prom.h Tue May 24 20:26:35 2011
@@ -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);
Index: src/sys/arch/alpha/pci/ttwoga_pci.c
diff -u src/sys/arch/alpha/pci/ttwoga_pci.c:1.4 src/sys/arch/alpha/pci/ttwoga_pci.c:1.5
--- src/sys/arch/alpha/pci/ttwoga_pci.c:1.4 Mon Apr 28 20:23:11 2008
+++ src/sys/arch/alpha/pci/ttwoga_pci.c Tue May 24 20:26:35 2011
@@ -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() \
do { \
- (s) = splhigh(); \
- simple_lock(&ttwoga_conf_slock); \
+ mutex_enter(&ttwoga_conf_lock); \
ttwoga_conf_cpu = cpu_number(); \
} while (0)
-#define TTWOGA_CONF_UNLOCK(s) \
+#define TTWOGA_CONF_UNLOCK() \
do { \
ttwoga_conf_cpu = (cpuid_t)-1; \
- simple_unlock(&ttwoga_conf_slock); \
- splx((s)); \
+ mutex_exit(&ttwoga_conf_lock); \
} while (0)
void
ttwoga_pci_init(pci_chipset_tag_t pc, void *v)
{
- simple_lock_init(&ttwoga_conf_slock);
+ mutex_init(&ttwoga_conf_lock, MUTEX_DEFAULT, IPL_HIGH);
pc->pc_conf_v = v;
pc->pc_attach_hook = ttwoga_attach_hook;
@@ -145,7 +142,7 @@
{
struct ttwoga_config *tcp = cpv;
pcireg_t *datap, data;
- int s, b, d, f, ba;
+ int b, d, f, ba;
paddr_t addr;
u_int64_t old_hae3;
@@ -155,7 +152,7 @@
if (addr == (paddr_t)-1)
return ((pcireg_t) -1);
- TTWOGA_CONF_LOCK(s);
+ TTWOGA_CONF_LOCK();
alpha_mb();
old_hae3 = T2GA(tcp, T2_HAE0_3) & ~HAE0_3_PCA;
@@ -182,7 +179,7 @@
alpha_mb();
alpha_mb();
- TTWOGA_CONF_UNLOCK(s);
+ TTWOGA_CONF_UNLOCK();
#if 0
printf("ttwoga_conf_read: tag 0x%lx, reg 0x%x -> 0x%x @ %p%s\n",
@@ -197,7 +194,7 @@
{
struct ttwoga_config *tcp = cpv;
pcireg_t *datap;
- int s, b, d, f;
+ int b, d, f;
paddr_t addr;
u_int64_t old_hae3;
@@ -207,7 +204,7 @@
if (addr == (paddr_t)-1)
return;
- TTWOGA_CONF_LOCK(s);
+ TTWOGA_CONF_LOCK();
alpha_mb();
old_hae3 = T2GA(tcp, T2_HAE0_3) & ~HAE0_3_PCA;
@@ -232,7 +229,7 @@
alpha_mb();
alpha_mb();
- TTWOGA_CONF_UNLOCK(s);
+ TTWOGA_CONF_UNLOCK();
#if 0
printf("ttwoga_conf_write: tag 0x%lx, reg 0x%x -> 0x%x @ %p\n",