Convert some simple_lock uses to mutex(9).
Tested by: jak@, mhitch@
This commit is contained in:
parent
9d8a062828
commit
5b0095de8b
|
@ -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 @@ nobootinfo:
|
|||
*/
|
||||
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;
|
||||
|
|
|
@ -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 @@ int alpha_console;
|
|||
|
||||
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 @@ init_prom_interface(struct rpb *rpb)
|
|||
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 @@ init_bootstrap_console(void)
|
|||
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_enter(void)
|
|||
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_leave(int s)
|
|||
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 @@ promcnputc(dev_t dev, int c)
|
|||
{
|
||||
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 @@ int
|
|||
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 @@ int
|
|||
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 @@ prom_getenv(int id, char *buf, int len)
|
|||
{
|
||||
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;
|
||||
|
|
|
@ -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 @@ cpu_lwp_free(struct lwp *l, int proc)
|
|||
|
||||
if (pcb->pcb_fpcpu != NULL)
|
||||
fpusave_proc(l, 0);
|
||||
|
||||
mutex_destroy(&pcb->pcb_fpcpu_lock);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -116,7 +118,8 @@ cpu_lwp_fork(struct lwp *l1, struct lwp *l2, void *stack, size_t stacksize,
|
|||
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
|
||||
|
|
|
@ -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 @@ struct pcb {
|
|||
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
|
||||
|
|
|
@ -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 @@ void hwrpb_restart_setup(void);
|
|||
|
||||
#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);
|
||||
|
|
|
@ -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 @@ paddr_t ttwoga_make_type0addr(int, int);
|
|||
* 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 @@ ttwoga_conf_read(void *cpv, pcitag_t tag, int offset)
|
|||
{
|
||||
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 @@ ttwoga_conf_read(void *cpv, pcitag_t tag, int offset)
|
|||
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 @@ ttwoga_conf_read(void *cpv, pcitag_t tag, int offset)
|
|||
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 @@ ttwoga_conf_write(void *cpv, pcitag_t tag, int offset, pcireg_t data)
|
|||
{
|
||||
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 @@ ttwoga_conf_write(void *cpv, pcitag_t tag, int offset, pcireg_t data)
|
|||
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 @@ ttwoga_conf_write(void *cpv, pcitag_t tag, int offset, pcireg_t data)
|
|||
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",
|
||||
|
|
Loading…
Reference in New Issue