mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:
mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)
similarily, for releasing a lock, we now have:
mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.
The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.
Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:
MTX_QUIET and MTX_NOSWITCH
The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:
mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.
Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.
Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.
Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.
Finally, caught up to the interface changes in all sys code.
Contributors: jake, jhb, jasone (in no particular order)
This commit is contained in:
parent
c27eb220c2
commit
9ed346bab0
200 changed files with 3574 additions and 3786 deletions
|
|
@ -614,11 +614,11 @@ alloc_bounce_pages(bus_dma_tag_t dmat, u_int numpages)
|
|||
break;
|
||||
}
|
||||
bpage->busaddr = pmap_kextract(bpage->vaddr);
|
||||
mtx_enter(&bounce_lock, MTX_DEF);
|
||||
mtx_lock(&bounce_lock);
|
||||
STAILQ_INSERT_TAIL(&bounce_page_list, bpage, links);
|
||||
total_bpages++;
|
||||
free_bpages++;
|
||||
mtx_exit(&bounce_lock, MTX_DEF);
|
||||
mtx_unlock(&bounce_lock);
|
||||
count++;
|
||||
numpages--;
|
||||
}
|
||||
|
|
@ -653,7 +653,7 @@ add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, vm_offset_t vaddr,
|
|||
panic("add_bounce_page: map doesn't need any pages");
|
||||
map->pagesreserved--;
|
||||
|
||||
mtx_enter(&bounce_lock, MTX_DEF);
|
||||
mtx_lock(&bounce_lock);
|
||||
bpage = STAILQ_FIRST(&bounce_page_list);
|
||||
if (bpage == NULL)
|
||||
panic("add_bounce_page: free page list is empty");
|
||||
|
|
@ -661,7 +661,7 @@ add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, vm_offset_t vaddr,
|
|||
STAILQ_REMOVE_HEAD(&bounce_page_list, links);
|
||||
reserved_bpages--;
|
||||
active_bpages++;
|
||||
mtx_exit(&bounce_lock, MTX_DEF);
|
||||
mtx_unlock(&bounce_lock);
|
||||
|
||||
bpage->datavaddr = vaddr;
|
||||
bpage->datacount = size;
|
||||
|
|
@ -677,7 +677,7 @@ free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage)
|
|||
bpage->datavaddr = 0;
|
||||
bpage->datacount = 0;
|
||||
|
||||
mtx_enter(&bounce_lock, MTX_DEF);
|
||||
mtx_lock(&bounce_lock);
|
||||
STAILQ_INSERT_HEAD(&bounce_page_list, bpage, links);
|
||||
free_bpages++;
|
||||
active_bpages--;
|
||||
|
|
@ -690,7 +690,7 @@ free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage)
|
|||
sched_swi(vm_ih, SWI_NOSWITCH);
|
||||
}
|
||||
}
|
||||
mtx_exit(&bounce_lock, MTX_DEF);
|
||||
mtx_unlock(&bounce_lock);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -698,13 +698,13 @@ busdma_swi(void)
|
|||
{
|
||||
struct bus_dmamap *map;
|
||||
|
||||
mtx_enter(&bounce_lock, MTX_DEF);
|
||||
mtx_lock(&bounce_lock);
|
||||
while ((map = STAILQ_FIRST(&bounce_map_callbacklist)) != NULL) {
|
||||
STAILQ_REMOVE_HEAD(&bounce_map_callbacklist, links);
|
||||
mtx_exit(&bounce_lock, MTX_DEF);
|
||||
mtx_unlock(&bounce_lock);
|
||||
bus_dmamap_load(map->dmat, map, map->buf, map->buflen,
|
||||
map->callback, map->callback_arg, /*flags*/0);
|
||||
mtx_enter(&bounce_lock, MTX_DEF);
|
||||
mtx_lock(&bounce_lock);
|
||||
}
|
||||
mtx_exit(&bounce_lock, MTX_DEF);
|
||||
mtx_unlock(&bounce_lock);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -560,7 +560,7 @@ alpha_dispatch_intr(void *frame, unsigned long vector)
|
|||
"alpha_dispatch_intr: disabling vector 0x%x", i->vector);
|
||||
i->disable(i->vector);
|
||||
}
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (ithd->it_proc->p_stat == SWAIT) {
|
||||
/* not on the run queue and not running */
|
||||
CTR1(KTR_INTR, "alpha_dispatch_intr: setrunqueue %d",
|
||||
|
|
@ -587,7 +587,7 @@ alpha_dispatch_intr(void *frame, unsigned long vector)
|
|||
ithd->it_proc->p_pid, ithd->it_need, ithd->it_proc->p_stat);
|
||||
need_resched();
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -626,10 +626,10 @@ ithd_loop(void *dummy)
|
|||
ih->ih_flags);
|
||||
|
||||
if ((ih->ih_flags & INTR_MPSAFE) == 0)
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
ih->ih_handler(ih->ih_argument);
|
||||
if ((ih->ih_flags & INTR_MPSAFE) == 0)
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -646,7 +646,7 @@ ithd_loop(void *dummy)
|
|||
* set again, so we have to check it again.
|
||||
*/
|
||||
mtx_assert(&Giant, MA_NOTOWNED);
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (!ithd->it_need) {
|
||||
ithd->it_proc->p_stat = SWAIT; /* we're idle */
|
||||
CTR1(KTR_INTR, "ithd_loop pid %d: done",
|
||||
|
|
@ -655,7 +655,7 @@ ithd_loop(void *dummy)
|
|||
CTR1(KTR_INTR, "ithd_loop pid %d: resumed",
|
||||
ithd->it_proc->p_pid);
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1012,7 +1012,7 @@ alpha_init(pfn, ptb, bim, bip, biv)
|
|||
*/
|
||||
mtx_init(&Giant, "Giant", MTX_DEF | MTX_RECURSE);
|
||||
mtx_init(&sched_lock, "sched lock", MTX_SPIN | MTX_RECURSE);
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
|
||||
/*
|
||||
* Look at arguments passed to us and compute boothowto.
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ smp_init_secondary(void)
|
|||
alpha_pal_wrent(XentUna, ALPHA_KENTRY_UNA);
|
||||
alpha_pal_wrent(XentSys, ALPHA_KENTRY_SYS);
|
||||
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
|
||||
printf("smp_init_secondary: called\n");
|
||||
CTR0(KTR_SMP, "smp_init_secondary");
|
||||
|
|
@ -176,7 +176,7 @@ smp_init_secondary(void)
|
|||
spl0();
|
||||
smp_ipi_all(0);
|
||||
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
|
||||
extern void smp_init_secondary_glue(void);
|
||||
|
|
@ -657,14 +657,14 @@ forward_signal(struct proc *p)
|
|||
return;
|
||||
if (!forward_signal_enabled)
|
||||
return;
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
while (1) {
|
||||
if (p->p_stat != SRUN) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return;
|
||||
}
|
||||
id = p->p_oncpu;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
if (id == 0xff)
|
||||
return;
|
||||
map = (1<<id);
|
||||
|
|
@ -682,9 +682,9 @@ forward_signal(struct proc *p)
|
|||
break;
|
||||
}
|
||||
}
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (id == p->p_oncpu) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -841,7 +841,7 @@ smp_rendezvous(void (* setup_func)(void *),
|
|||
{
|
||||
|
||||
/* obtain rendezvous lock */
|
||||
mtx_enter(&smp_rv_mtx, MTX_SPIN);
|
||||
mtx_lock_spin(&smp_rv_mtx);
|
||||
|
||||
/* set static function pointers */
|
||||
smp_rv_setup_func = setup_func;
|
||||
|
|
@ -858,7 +858,7 @@ smp_rendezvous(void (* setup_func)(void *),
|
|||
smp_rendezvous_action();
|
||||
|
||||
/* release lock */
|
||||
mtx_exit(&smp_rv_mtx, MTX_SPIN);
|
||||
mtx_unlock_spin(&smp_rv_mtx);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -86,12 +86,12 @@ procfs_read_regs(p, regs)
|
|||
struct reg *regs;
|
||||
{
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if ((p->p_sflag & PS_INMEM) == 0) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (EIO);
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (fill_regs(p, regs));
|
||||
}
|
||||
|
||||
|
|
@ -101,12 +101,12 @@ procfs_write_regs(p, regs)
|
|||
struct reg *regs;
|
||||
{
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if ((p->p_sflag & PS_INMEM) == 0) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (EIO);
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (set_regs(p, regs));
|
||||
}
|
||||
|
||||
|
|
@ -121,12 +121,12 @@ procfs_read_fpregs(p, fpregs)
|
|||
struct fpreg *fpregs;
|
||||
{
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if ((p->p_sflag & PS_INMEM) == 0) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (EIO);
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (fill_fpregs(p, fpregs));
|
||||
}
|
||||
|
||||
|
|
@ -136,12 +136,12 @@ procfs_write_fpregs(p, fpregs)
|
|||
struct fpreg *fpregs;
|
||||
{
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if ((p->p_sflag & PS_INMEM) == 0) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (EIO);
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (set_fpregs(p, fpregs));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -106,10 +106,10 @@ userret(p, frame, oticks)
|
|||
/* take pending signals */
|
||||
while ((sig = CURSIG(p)) != 0) {
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
postsig(sig);
|
||||
}
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
p->p_priority = p->p_usrpri;
|
||||
if (want_resched) {
|
||||
/*
|
||||
|
|
@ -125,30 +125,30 @@ userret(p, frame, oticks)
|
|||
setrunqueue(p);
|
||||
p->p_stats->p_ru.ru_nivcsw++;
|
||||
mi_switch();
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
PICKUP_GIANT();
|
||||
splx(s);
|
||||
while ((sig = CURSIG(p)) != 0) {
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
postsig(sig);
|
||||
}
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
* If profiling, charge recent system time to the trapped pc.
|
||||
*/
|
||||
if (p->p_sflag & PS_PROFIL) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock(&Giant);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
addupc_task(p, frame->tf_regs[FRAME_PC],
|
||||
(int)(p->p_sticks - oticks) * psratio);
|
||||
}
|
||||
curpriority = p->p_priority;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -230,9 +230,9 @@ trap(a0, a1, a2, entry, framep)
|
|||
ucode = 0;
|
||||
user = (framep->tf_regs[FRAME_PS] & ALPHA_PSL_USERMODE) != 0;
|
||||
if (user) {
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
sticks = p->p_sticks;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
p->p_md.md_tf = framep;
|
||||
#if 0
|
||||
/* This is to catch some weird stuff on the UDB (mj) */
|
||||
|
|
@ -259,12 +259,12 @@ trap(a0, a1, a2, entry, framep)
|
|||
* and per-process unaligned-access-handling flags).
|
||||
*/
|
||||
if (user) {
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
if ((i = unaligned_fixup(a0, a1, a2, p)) == 0) {
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
goto out;
|
||||
}
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
ucode = a0; /* VA */
|
||||
break;
|
||||
}
|
||||
|
|
@ -288,13 +288,13 @@ trap(a0, a1, a2, entry, framep)
|
|||
* is not requested or if the completion fails.
|
||||
*/
|
||||
if (user) {
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
if (a0 & EXCSUM_SWC)
|
||||
if (fp_software_completion(a1, p)) {
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
goto out;
|
||||
}
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
i = SIGFPE;
|
||||
ucode = a0; /* exception summary */
|
||||
break;
|
||||
|
|
@ -415,7 +415,7 @@ trap(a0, a1, a2, entry, framep)
|
|||
goto out;
|
||||
}
|
||||
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
/*
|
||||
* It is only a kernel address space fault iff:
|
||||
* 1. !user and
|
||||
|
|
@ -529,11 +529,11 @@ trap(a0, a1, a2, entry, framep)
|
|||
rv = KERN_INVALID_ADDRESS;
|
||||
}
|
||||
if (rv == KERN_SUCCESS) {
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
goto out;
|
||||
}
|
||||
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
if (!user) {
|
||||
/* Check for copyin/copyout fault */
|
||||
if (p != NULL &&
|
||||
|
|
@ -575,7 +575,7 @@ out:
|
|||
framep->tf_regs[FRAME_SP] = alpha_pal_rdusp();
|
||||
userret(p, framep, sticks);
|
||||
if (mtx_owned(&Giant))
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
return;
|
||||
|
||||
|
|
@ -621,7 +621,7 @@ syscall(code, framep)
|
|||
* Find our per-cpu globals.
|
||||
*/
|
||||
globalp = (struct globaldata *) alpha_pal_rdval();
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
|
||||
framep->tf_regs[FRAME_TRAPARG_A0] = 0;
|
||||
framep->tf_regs[FRAME_TRAPARG_A1] = 0;
|
||||
|
|
@ -635,9 +635,9 @@ syscall(code, framep)
|
|||
p = curproc;
|
||||
p->p_md.md_tf = framep;
|
||||
opc = framep->tf_regs[FRAME_PC] - 4;
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
sticks = p->p_sticks;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
alpha_fpstate_check(p);
|
||||
|
|
@ -739,7 +739,7 @@ syscall(code, framep)
|
|||
* is not the case, this code will need to be revisited.
|
||||
*/
|
||||
STOPEVENT(p, S_SCX, code);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
|
||||
#ifdef WITNESS
|
||||
if (witness_list(p)) {
|
||||
|
|
@ -763,9 +763,9 @@ ast(framep)
|
|||
u_quad_t sticks;
|
||||
|
||||
p = curproc;
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
sticks = p->p_sticks;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
p->p_md.md_tf = framep;
|
||||
|
||||
if ((framep->tf_regs[FRAME_PS] & ALPHA_PSL_USERMODE) == 0)
|
||||
|
|
@ -774,36 +774,36 @@ ast(framep)
|
|||
cnt.v_soft++;
|
||||
|
||||
PCPU_SET(astpending, 0);
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (p->p_sflag & PS_OWEUPC) {
|
||||
p->p_sflag &= ~PS_OWEUPC;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
mtx_lock(&Giant);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
addupc_task(p, p->p_stats->p_prof.pr_addr,
|
||||
p->p_stats->p_prof.pr_ticks);
|
||||
}
|
||||
if (p->p_sflag & PS_ALRMPEND) {
|
||||
p->p_sflag &= ~PS_ALRMPEND;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
psignal(p, SIGVTALRM);
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
}
|
||||
if (p->p_sflag & PS_PROFPEND) {
|
||||
p->p_sflag &= ~PS_PROFPEND;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
psignal(p, SIGPROF);
|
||||
} else
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
|
||||
userret(p, framep, sticks);
|
||||
|
||||
if (mtx_owned(&Giant))
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -253,8 +253,8 @@ cpu_exit(p)
|
|||
{
|
||||
alpha_fpstate_drop(p);
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_exit(&Giant, MTX_DEF | MTX_NOSWITCH);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
mtx_unlock_flags(&Giant, MTX_NOSWITCH);
|
||||
mtx_assert(&Giant, MA_NOTOWNED);
|
||||
|
||||
/*
|
||||
|
|
@ -437,7 +437,7 @@ vm_page_zero_idle()
|
|||
if (vm_page_zero_count >= ZIDLE_HI(cnt.v_free_count))
|
||||
return(0);
|
||||
|
||||
if (mtx_try_enter(&Giant, MTX_DEF)) {
|
||||
if (mtx_trylock(&Giant)) {
|
||||
s = splvm();
|
||||
m = vm_page_list_find(PQ_FREE, free_rover, FALSE);
|
||||
zero_state = 0;
|
||||
|
|
@ -466,7 +466,7 @@ vm_page_zero_idle()
|
|||
}
|
||||
free_rover = (free_rover + PQ_PRIME2) & PQ_L2_MASK;
|
||||
splx(s);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
|
|
|
|||
|
|
@ -81,9 +81,9 @@ struct clockframe {
|
|||
* through trap, marking the proc as needing a profiling tick.
|
||||
*/
|
||||
#define need_proftick(p) do { \
|
||||
mtx_enter(&sched_lock, MTX_SPIN); \
|
||||
mtx_lock_spin(&sched_lock); \
|
||||
(p)->p_sflag |= PS_OWEUPC; \
|
||||
mtx_exit(&sched_lock, MTX_SPIN); \
|
||||
mtx_unlock_spin(&sched_lock); \
|
||||
aston(); \
|
||||
} while (0)
|
||||
|
||||
|
|
|
|||
|
|
@ -39,26 +39,12 @@
|
|||
/*
|
||||
* Debugging
|
||||
*/
|
||||
#ifdef MUTEX_DEBUG
|
||||
|
||||
#ifdef _KERN_MUTEX_C_
|
||||
char STR_IEN[] = "ps & IPL == IPL_0";
|
||||
char STR_IDIS[] = "ps & IPL == IPL_HIGH";
|
||||
char STR_SIEN[] = "mpp->mtx_saveintr == IPL_0";
|
||||
#else /* _KERN_MUTEX_C_ */
|
||||
extern char STR_IEN[];
|
||||
extern char STR_IDIS[];
|
||||
extern char STR_SIEN[];
|
||||
#endif /* _KERN_MUTEX_C_ */
|
||||
|
||||
#endif /* MUTEX_DEBUG */
|
||||
|
||||
#define ASS_IEN MPASS2((alpha_pal_rdps() & ALPHA_PSL_IPL_MASK) \
|
||||
== ALPHA_PSL_IPL_0, STR_IEN)
|
||||
== ALPHA_PSL_IPL_0, "ps & IPL == IPL_0")
|
||||
#define ASS_IDIS MPASS2((alpha_pal_rdps() & ALPHA_PSL_IPL_MASK) \
|
||||
== ALPHA_PSL_IPL_HIGH, STR_IDIS)
|
||||
== ALPHA_PSL_IPL_HIGH, "ps & IPL == IPL_HIGH")
|
||||
#define ASS_SIEN(mpp) MPASS2((mpp)->mtx_saveintr \
|
||||
== ALPHA_PSL_IPL_0, STR_SIEN)
|
||||
== ALPHA_PSL_IPL_0, "mpp->mtx_saveintr == IPL_0")
|
||||
|
||||
#define mtx_legal2block() \
|
||||
((alpha_pal_rdps() & ALPHA_PSL_IPL_MASK) == ALPHA_PSL_IPL_0)
|
||||
|
|
@ -68,34 +54,33 @@ extern char STR_SIEN[];
|
|||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifdef _KERN_MUTEX_C_
|
||||
|
||||
#define _V(x) __STRING(x)
|
||||
|
||||
/*
|
||||
* Get a spin lock, handle recusion inline (as the less common case)
|
||||
* Get a spin lock, handle recusion inline.
|
||||
*/
|
||||
|
||||
#define _getlock_spin_block(mp, tid, type) do { \
|
||||
#define _get_spin_lock(mp, tid, opts) do { \
|
||||
u_int _ipl = alpha_pal_swpipl(ALPHA_PSL_IPL_HIGH); \
|
||||
if (!_obtain_lock(mp, tid)) \
|
||||
mtx_enter_hard(mp, (type) & MTX_HARDOPTS, _ipl); \
|
||||
else { \
|
||||
if (!_obtain_lock((mp), (tid))) { \
|
||||
if ((mp)->mtx_lock == (uintptr_t)(tid)) \
|
||||
(mp)->mtx_recurse++; \
|
||||
else \
|
||||
_mtx_lock_spin((mp), (opts), _ipl, __FILE__, \
|
||||
__LINE__); \
|
||||
} else { \
|
||||
alpha_mb(); \
|
||||
(mp)->mtx_saveintr = _ipl; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#undef _V
|
||||
|
||||
#endif /* _KERN_MUTEX_C_ */
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#else /* !LOCORE */
|
||||
|
||||
/*
|
||||
* Simple assembly macros to get and release non-recursive spin locks
|
||||
*
|
||||
* XXX: These are presently unused and cannot be used right now. Need to be
|
||||
* re-written (they are wrong). If you plan to use this and still see
|
||||
* this message, know not to unless you fix them first! :-)
|
||||
*/
|
||||
#define MTX_ENTER(lck) \
|
||||
ldiq a0, ALPHA_PSL_IPL_HIGH; \
|
||||
|
|
|
|||
|
|
@ -1341,9 +1341,9 @@ osf1_getrusage(p, uap)
|
|||
switch (uap->who) {
|
||||
case RUSAGE_SELF:
|
||||
rup = &p->p_stats->p_ru;
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
calcru(p, &rup->ru_utime, &rup->ru_stime, NULL);
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
break;
|
||||
|
||||
case RUSAGE_CHILDREN:
|
||||
|
|
|
|||
|
|
@ -724,7 +724,7 @@ npx_intr(dummy)
|
|||
u_short control;
|
||||
struct intrframe *frame;
|
||||
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
if (PCPU_GET(npxproc) == NULL || !npx_exists) {
|
||||
printf("npxintr: npxproc = %p, curproc = %p, npx_exists = %d\n",
|
||||
PCPU_GET(npxproc), curproc, npx_exists);
|
||||
|
|
@ -783,7 +783,7 @@ npx_intr(dummy)
|
|||
*/
|
||||
psignal(curproc, SIGFPE);
|
||||
}
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -1910,7 +1910,7 @@ init386(first)
|
|||
* Giant is used early for at least debugger traps and unexpected traps.
|
||||
*/
|
||||
mtx_init(&Giant, "Giant", MTX_DEF | MTX_RECURSE);
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
|
||||
/* make ldt memory segments */
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -2268,7 +2268,7 @@ ap_init(void)
|
|||
PCPU_SET(curproc, PCPU_GET(idleproc));
|
||||
|
||||
/* lock against other AP's that are waking up */
|
||||
mtx_enter(&ap_boot_mtx, MTX_SPIN);
|
||||
mtx_lock_spin(&ap_boot_mtx);
|
||||
|
||||
/* BSP may have changed PTD while we're waiting for the lock */
|
||||
cpu_invltlb();
|
||||
|
|
@ -2317,7 +2317,7 @@ ap_init(void)
|
|||
}
|
||||
|
||||
/* let other AP's wake up now */
|
||||
mtx_exit(&ap_boot_mtx, MTX_SPIN);
|
||||
mtx_unlock_spin(&ap_boot_mtx);
|
||||
|
||||
/* wait until all the AP's are up */
|
||||
while (smp_started == 0)
|
||||
|
|
@ -2328,7 +2328,7 @@ ap_init(void)
|
|||
|
||||
/* ok, now grab sched_lock and enter the scheduler */
|
||||
enable_intr();
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
cpu_throw(); /* doesn't return */
|
||||
|
||||
panic("scheduler returned us to ap_init");
|
||||
|
|
@ -2662,14 +2662,14 @@ forward_signal(struct proc *p)
|
|||
return;
|
||||
if (!forward_signal_enabled)
|
||||
return;
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
while (1) {
|
||||
if (p->p_stat != SRUN) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return;
|
||||
}
|
||||
id = p->p_oncpu;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
if (id == 0xff)
|
||||
return;
|
||||
map = (1<<id);
|
||||
|
|
@ -2687,9 +2687,9 @@ forward_signal(struct proc *p)
|
|||
break;
|
||||
}
|
||||
}
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (id == p->p_oncpu) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -2867,7 +2867,7 @@ smp_rendezvous(void (* setup_func)(void *),
|
|||
{
|
||||
|
||||
/* obtain rendezvous lock */
|
||||
mtx_enter(&smp_rv_mtx, MTX_SPIN);
|
||||
mtx_lock_spin(&smp_rv_mtx);
|
||||
|
||||
/* set static function pointers */
|
||||
smp_rv_setup_func = setup_func;
|
||||
|
|
@ -2886,7 +2886,7 @@ smp_rendezvous(void (* setup_func)(void *),
|
|||
smp_rendezvous_action();
|
||||
|
||||
/* release lock */
|
||||
mtx_exit(&smp_rv_mtx, MTX_SPIN);
|
||||
mtx_unlock_spin(&smp_rv_mtx);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -2268,7 +2268,7 @@ ap_init(void)
|
|||
PCPU_SET(curproc, PCPU_GET(idleproc));
|
||||
|
||||
/* lock against other AP's that are waking up */
|
||||
mtx_enter(&ap_boot_mtx, MTX_SPIN);
|
||||
mtx_lock_spin(&ap_boot_mtx);
|
||||
|
||||
/* BSP may have changed PTD while we're waiting for the lock */
|
||||
cpu_invltlb();
|
||||
|
|
@ -2317,7 +2317,7 @@ ap_init(void)
|
|||
}
|
||||
|
||||
/* let other AP's wake up now */
|
||||
mtx_exit(&ap_boot_mtx, MTX_SPIN);
|
||||
mtx_unlock_spin(&ap_boot_mtx);
|
||||
|
||||
/* wait until all the AP's are up */
|
||||
while (smp_started == 0)
|
||||
|
|
@ -2328,7 +2328,7 @@ ap_init(void)
|
|||
|
||||
/* ok, now grab sched_lock and enter the scheduler */
|
||||
enable_intr();
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
cpu_throw(); /* doesn't return */
|
||||
|
||||
panic("scheduler returned us to ap_init");
|
||||
|
|
@ -2662,14 +2662,14 @@ forward_signal(struct proc *p)
|
|||
return;
|
||||
if (!forward_signal_enabled)
|
||||
return;
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
while (1) {
|
||||
if (p->p_stat != SRUN) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return;
|
||||
}
|
||||
id = p->p_oncpu;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
if (id == 0xff)
|
||||
return;
|
||||
map = (1<<id);
|
||||
|
|
@ -2687,9 +2687,9 @@ forward_signal(struct proc *p)
|
|||
break;
|
||||
}
|
||||
}
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (id == p->p_oncpu) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -2867,7 +2867,7 @@ smp_rendezvous(void (* setup_func)(void *),
|
|||
{
|
||||
|
||||
/* obtain rendezvous lock */
|
||||
mtx_enter(&smp_rv_mtx, MTX_SPIN);
|
||||
mtx_lock_spin(&smp_rv_mtx);
|
||||
|
||||
/* set static function pointers */
|
||||
smp_rv_setup_func = setup_func;
|
||||
|
|
@ -2886,7 +2886,7 @@ smp_rendezvous(void (* setup_func)(void *),
|
|||
smp_rendezvous_action();
|
||||
|
||||
/* release lock */
|
||||
mtx_exit(&smp_rv_mtx, MTX_SPIN);
|
||||
mtx_unlock_spin(&smp_rv_mtx);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -174,11 +174,11 @@ userret(p, frame, oticks)
|
|||
|
||||
while ((sig = CURSIG(p)) != 0) {
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
postsig(sig);
|
||||
}
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
p->p_priority = p->p_usrpri;
|
||||
if (resched_wanted()) {
|
||||
/*
|
||||
|
|
@ -193,30 +193,30 @@ userret(p, frame, oticks)
|
|||
setrunqueue(p);
|
||||
p->p_stats->p_ru.ru_nivcsw++;
|
||||
mi_switch();
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
PICKUP_GIANT();
|
||||
while ((sig = CURSIG(p)) != 0) {
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
postsig(sig);
|
||||
}
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
* Charge system time if profiling.
|
||||
*/
|
||||
if (p->p_sflag & PS_PROFIL) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
/* XXX - do we need Giant? */
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock(&Giant);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
addupc_task(p, frame->tf_eip,
|
||||
(u_int)(p->p_sticks - oticks) * psratio);
|
||||
}
|
||||
curpriority = p->p_priority;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -282,9 +282,9 @@ restart:
|
|||
((frame.tf_eflags & PSL_VM) && !in_vm86call)) {
|
||||
/* user trap */
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
sticks = p->p_sticks;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
p->p_md.md_regs = &frame;
|
||||
|
||||
switch (type) {
|
||||
|
|
@ -312,9 +312,9 @@ restart:
|
|||
case T_PROTFLT: /* general protection fault */
|
||||
case T_STKFLT: /* stack fault */
|
||||
if (frame.tf_eflags & PSL_VM) {
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
i = vm86_emulate((struct vm86frame *)&frame);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
if (i == 0)
|
||||
goto user;
|
||||
break;
|
||||
|
|
@ -339,9 +339,9 @@ restart:
|
|||
*/
|
||||
eva = rcr2();
|
||||
enable_intr();
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
i = trap_pfault(&frame, TRUE, eva);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
#if defined(I586_CPU) && !defined(NO_F00F_HACK)
|
||||
if (i == -2) {
|
||||
/*
|
||||
|
|
@ -371,13 +371,13 @@ restart:
|
|||
#ifndef TIMER_FREQ
|
||||
# define TIMER_FREQ 1193182
|
||||
#endif
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
if (time_second - lastalert > 10) {
|
||||
log(LOG_WARNING, "NMI: power fail\n");
|
||||
sysbeep(TIMER_FREQ/880, hz);
|
||||
lastalert = time_second;
|
||||
}
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
goto out;
|
||||
#else /* !POWERFAIL_NMI */
|
||||
/* machine/parity/power fail/"kitchen sink" faults */
|
||||
|
|
@ -421,9 +421,9 @@ restart:
|
|||
ucode = FPE_FPU_NP_TRAP;
|
||||
break;
|
||||
}
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
i = (*pmath_emulate)(&frame);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
if (i == 0) {
|
||||
if (!(frame.tf_eflags & PSL_T))
|
||||
goto out;
|
||||
|
|
@ -452,9 +452,9 @@ restart:
|
|||
*/
|
||||
eva = rcr2();
|
||||
enable_intr();
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
(void) trap_pfault(&frame, FALSE, eva);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
goto out;
|
||||
|
||||
case T_DNA:
|
||||
|
|
@ -477,9 +477,9 @@ restart:
|
|||
case T_PROTFLT: /* general protection fault */
|
||||
case T_STKFLT: /* stack fault */
|
||||
if (frame.tf_eflags & PSL_VM) {
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
i = vm86_emulate((struct vm86frame *)&frame);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
if (i != 0)
|
||||
/*
|
||||
* returns to original process
|
||||
|
|
@ -510,9 +510,9 @@ restart:
|
|||
*/
|
||||
if (frame.tf_eip == (int)cpu_switch_load_gs) {
|
||||
PCPU_GET(curpcb)->pcb_gs = 0;
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
psignal(p, SIGBUS);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
@ -621,13 +621,13 @@ restart:
|
|||
#ifdef DEV_ISA
|
||||
case T_NMI:
|
||||
#ifdef POWERFAIL_NMI
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
if (time_second - lastalert > 10) {
|
||||
log(LOG_WARNING, "NMI: power fail\n");
|
||||
sysbeep(TIMER_FREQ/880, hz);
|
||||
lastalert = time_second;
|
||||
}
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
goto out;
|
||||
#else /* !POWERFAIL_NMI */
|
||||
/* XXX Giant */
|
||||
|
|
@ -651,13 +651,13 @@ restart:
|
|||
#endif /* DEV_ISA */
|
||||
}
|
||||
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
trap_fatal(&frame, eva);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
goto out;
|
||||
}
|
||||
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
/* Translate fault for emulators (e.g. Linux) */
|
||||
if (*p->p_sysent->sv_transtrap)
|
||||
i = (*p->p_sysent->sv_transtrap)(i, type);
|
||||
|
|
@ -673,12 +673,12 @@ restart:
|
|||
uprintf("\n");
|
||||
}
|
||||
#endif
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
|
||||
user:
|
||||
userret(p, &frame, sticks);
|
||||
if (mtx_owned(&Giant))
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
out:
|
||||
return;
|
||||
}
|
||||
|
|
@ -1103,15 +1103,15 @@ syscall2(frame)
|
|||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (ISPL(frame.tf_cs) != SEL_UPL) {
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
panic("syscall");
|
||||
/* NOT REACHED */
|
||||
}
|
||||
#endif
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
sticks = p->p_sticks;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
|
||||
p->p_md.md_regs = &frame;
|
||||
params = (caddr_t)frame.tf_esp + sizeof(int);
|
||||
|
|
@ -1121,9 +1121,9 @@ syscall2(frame)
|
|||
/*
|
||||
* The prep code is not MP aware.
|
||||
*/
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
(*p->p_sysent->sv_prepsyscall)(&frame, args, &code, ¶ms);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
} else {
|
||||
/*
|
||||
* Need to check if this is a 32 bit or 64 bit syscall.
|
||||
|
|
@ -1160,7 +1160,7 @@ syscall2(frame)
|
|||
*/
|
||||
if (params && (i = narg * sizeof(int)) &&
|
||||
(error = copyin(params, (caddr_t)args, (u_int)i))) {
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
#ifdef KTRACE
|
||||
if (KTRPOINT(p, KTR_SYSCALL))
|
||||
ktrsyscall(p->p_tracep, code, narg, args);
|
||||
|
|
@ -1174,13 +1174,13 @@ syscall2(frame)
|
|||
* we are ktracing
|
||||
*/
|
||||
if ((callp->sy_narg & SYF_MPSAFE) == 0) {
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
}
|
||||
|
||||
#ifdef KTRACE
|
||||
if (KTRPOINT(p, KTR_SYSCALL)) {
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
ktrsyscall(p->p_tracep, code, narg, args);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1230,7 +1230,7 @@ bad:
|
|||
*/
|
||||
if ((frame.tf_eflags & PSL_T) && !(frame.tf_eflags & PSL_VM)) {
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
frame.tf_eflags &= ~PSL_T;
|
||||
trapsignal(p, SIGTRAP, 0);
|
||||
}
|
||||
|
|
@ -1243,7 +1243,7 @@ bad:
|
|||
#ifdef KTRACE
|
||||
if (KTRPOINT(p, KTR_SYSRET)) {
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
ktrsysret(p->p_tracep, code, error, p->p_retval[0]);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1259,7 +1259,7 @@ bad:
|
|||
* Release Giant if we had to get it
|
||||
*/
|
||||
if (mtx_owned(&Giant))
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
|
||||
#ifdef WITNESS
|
||||
if (witness_list(p)) {
|
||||
|
|
@ -1278,38 +1278,38 @@ ast(frame)
|
|||
struct proc *p = CURPROC;
|
||||
u_quad_t sticks;
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
sticks = p->p_sticks;
|
||||
|
||||
astoff();
|
||||
atomic_add_int(&cnt.v_soft, 1);
|
||||
if (p->p_sflag & PS_OWEUPC) {
|
||||
p->p_sflag &= ~PS_OWEUPC;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
mtx_lock(&Giant);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
addupc_task(p, p->p_stats->p_prof.pr_addr,
|
||||
p->p_stats->p_prof.pr_ticks);
|
||||
}
|
||||
if (p->p_sflag & PS_ALRMPEND) {
|
||||
p->p_sflag &= ~PS_ALRMPEND;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
psignal(p, SIGVTALRM);
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
}
|
||||
if (p->p_sflag & PS_PROFPEND) {
|
||||
p->p_sflag &= ~PS_PROFPEND;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
psignal(p, SIGPROF);
|
||||
} else
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
|
||||
userret(p, &frame, sticks);
|
||||
|
||||
if (mtx_owned(&Giant))
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ clkintr(struct clockframe frame)
|
|||
{
|
||||
|
||||
if (timecounter->tc_get_timecount == i8254_get_timecount) {
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
if (i8254_ticked)
|
||||
i8254_ticked = 0;
|
||||
else {
|
||||
|
|
@ -215,7 +215,7 @@ clkintr(struct clockframe frame)
|
|||
i8254_lastcount = 0;
|
||||
}
|
||||
clkintr_pending = 0;
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
}
|
||||
timer_func(&frame);
|
||||
switch (timer0_state) {
|
||||
|
|
@ -232,14 +232,14 @@ clkintr(struct clockframe frame)
|
|||
break;
|
||||
|
||||
case ACQUIRE_PENDING:
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
i8254_offset = i8254_get_timecount(NULL);
|
||||
i8254_lastcount = 0;
|
||||
timer0_max_count = TIMER_DIV(new_rate);
|
||||
outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
|
||||
outb(TIMER_CNTR0, timer0_max_count & 0xff);
|
||||
outb(TIMER_CNTR0, timer0_max_count >> 8);
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
timer_func = new_function;
|
||||
timer0_state = ACQUIRED;
|
||||
break;
|
||||
|
|
@ -247,7 +247,7 @@ clkintr(struct clockframe frame)
|
|||
case RELEASE_PENDING:
|
||||
if ((timer0_prescaler_count += timer0_max_count)
|
||||
>= hardclock_max_count) {
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
i8254_offset = i8254_get_timecount(NULL);
|
||||
i8254_lastcount = 0;
|
||||
timer0_max_count = hardclock_max_count;
|
||||
|
|
@ -255,7 +255,7 @@ clkintr(struct clockframe frame)
|
|||
TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
|
||||
outb(TIMER_CNTR0, timer0_max_count & 0xff);
|
||||
outb(TIMER_CNTR0, timer0_max_count >> 8);
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
timer0_prescaler_count = 0;
|
||||
timer_func = hardclock;
|
||||
timer0_state = RELEASED;
|
||||
|
|
@ -403,7 +403,7 @@ getit(void)
|
|||
{
|
||||
int high, low;
|
||||
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
|
||||
/* Select timer0 and latch counter value. */
|
||||
outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
|
||||
|
|
@ -411,7 +411,7 @@ getit(void)
|
|||
low = inb(TIMER_CNTR0);
|
||||
high = inb(TIMER_CNTR0);
|
||||
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
return ((high << 8) | low);
|
||||
}
|
||||
|
||||
|
|
@ -525,10 +525,10 @@ sysbeep(int pitch, int period)
|
|||
splx(x);
|
||||
return (-1); /* XXX Should be EBUSY, but nobody cares anyway. */
|
||||
}
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
outb(TIMER_CNTR2, pitch);
|
||||
outb(TIMER_CNTR2, (pitch>>8));
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
if (!beeping) {
|
||||
/* enable counter2 output to speaker */
|
||||
outb(IO_PPI, inb(IO_PPI) | 3);
|
||||
|
|
@ -679,7 +679,7 @@ set_timer_freq(u_int freq, int intr_freq)
|
|||
{
|
||||
int new_timer0_max_count;
|
||||
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
timer_freq = freq;
|
||||
new_timer0_max_count = hardclock_max_count = TIMER_DIV(intr_freq);
|
||||
if (new_timer0_max_count != timer0_max_count) {
|
||||
|
|
@ -688,7 +688,7 @@ set_timer_freq(u_int freq, int intr_freq)
|
|||
outb(TIMER_CNTR0, timer0_max_count & 0xff);
|
||||
outb(TIMER_CNTR0, timer0_max_count >> 8);
|
||||
}
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -703,11 +703,11 @@ void
|
|||
i8254_restore(void)
|
||||
{
|
||||
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
|
||||
outb(TIMER_CNTR0, timer0_max_count & 0xff);
|
||||
outb(TIMER_CNTR0, timer0_max_count >> 8);
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1194,7 +1194,7 @@ i8254_get_timecount(struct timecounter *tc)
|
|||
u_int eflags;
|
||||
|
||||
eflags = read_eflags();
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
|
||||
/* Select timer0 and latch counter value. */
|
||||
outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
|
||||
|
|
@ -1218,7 +1218,7 @@ i8254_get_timecount(struct timecounter *tc)
|
|||
}
|
||||
i8254_lastcount = count;
|
||||
count += i8254_offset;
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
return (count);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -261,8 +261,8 @@ cpu_exit(p)
|
|||
reset_dbregs();
|
||||
pcb->pcb_flags &= ~PCB_DBREGS;
|
||||
}
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_exit(&Giant, MTX_DEF | MTX_NOSWITCH);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
mtx_unlock_flags(&Giant, MTX_NOSWITCH);
|
||||
mtx_assert(&Giant, MA_NOTOWNED);
|
||||
|
||||
/*
|
||||
|
|
@ -574,7 +574,7 @@ vm_page_zero_idle()
|
|||
if (vm_page_zero_count >= ZIDLE_HI(cnt.v_free_count))
|
||||
return(0);
|
||||
|
||||
if (mtx_try_enter(&Giant, MTX_DEF)) {
|
||||
if (mtx_trylock(&Giant)) {
|
||||
s = splvm();
|
||||
zero_state = 0;
|
||||
m = vm_page_list_find(PQ_FREE, free_rover, FALSE);
|
||||
|
|
@ -597,7 +597,7 @@ vm_page_zero_idle()
|
|||
}
|
||||
free_rover = (free_rover + PQ_PRIME2) & PQ_L2_MASK;
|
||||
splx(s);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
|
|
|
|||
|
|
@ -92,9 +92,9 @@
|
|||
* counter in the proc table and flag isn't really necessary.
|
||||
*/
|
||||
#define need_proftick(p) do { \
|
||||
mtx_enter(&sched_lock, MTX_SPIN); \
|
||||
mtx_lock_spin(&sched_lock); \
|
||||
(p)->p_sflag |= PS_OWEUPC; \
|
||||
mtx_exit(&sched_lock, MTX_SPIN); \
|
||||
mtx_unlock_spin(&sched_lock); \
|
||||
aston(); \
|
||||
} while (0)
|
||||
|
||||
|
|
|
|||
|
|
@ -2268,7 +2268,7 @@ ap_init(void)
|
|||
PCPU_SET(curproc, PCPU_GET(idleproc));
|
||||
|
||||
/* lock against other AP's that are waking up */
|
||||
mtx_enter(&ap_boot_mtx, MTX_SPIN);
|
||||
mtx_lock_spin(&ap_boot_mtx);
|
||||
|
||||
/* BSP may have changed PTD while we're waiting for the lock */
|
||||
cpu_invltlb();
|
||||
|
|
@ -2317,7 +2317,7 @@ ap_init(void)
|
|||
}
|
||||
|
||||
/* let other AP's wake up now */
|
||||
mtx_exit(&ap_boot_mtx, MTX_SPIN);
|
||||
mtx_unlock_spin(&ap_boot_mtx);
|
||||
|
||||
/* wait until all the AP's are up */
|
||||
while (smp_started == 0)
|
||||
|
|
@ -2328,7 +2328,7 @@ ap_init(void)
|
|||
|
||||
/* ok, now grab sched_lock and enter the scheduler */
|
||||
enable_intr();
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
cpu_throw(); /* doesn't return */
|
||||
|
||||
panic("scheduler returned us to ap_init");
|
||||
|
|
@ -2662,14 +2662,14 @@ forward_signal(struct proc *p)
|
|||
return;
|
||||
if (!forward_signal_enabled)
|
||||
return;
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
while (1) {
|
||||
if (p->p_stat != SRUN) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return;
|
||||
}
|
||||
id = p->p_oncpu;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
if (id == 0xff)
|
||||
return;
|
||||
map = (1<<id);
|
||||
|
|
@ -2687,9 +2687,9 @@ forward_signal(struct proc *p)
|
|||
break;
|
||||
}
|
||||
}
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (id == p->p_oncpu) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -2867,7 +2867,7 @@ smp_rendezvous(void (* setup_func)(void *),
|
|||
{
|
||||
|
||||
/* obtain rendezvous lock */
|
||||
mtx_enter(&smp_rv_mtx, MTX_SPIN);
|
||||
mtx_lock_spin(&smp_rv_mtx);
|
||||
|
||||
/* set static function pointers */
|
||||
smp_rv_setup_func = setup_func;
|
||||
|
|
@ -2886,7 +2886,7 @@ smp_rendezvous(void (* setup_func)(void *),
|
|||
smp_rendezvous_action();
|
||||
|
||||
/* release lock */
|
||||
mtx_exit(&smp_rv_mtx, MTX_SPIN);
|
||||
mtx_unlock_spin(&smp_rv_mtx);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -43,22 +43,10 @@ extern struct mtx clock_lock;
|
|||
/*
|
||||
* Debugging
|
||||
*/
|
||||
#ifdef MUTEX_DEBUG
|
||||
|
||||
#ifdef _KERN_MUTEX_C_
|
||||
char STR_IEN[] = "fl & PSL_I";
|
||||
char STR_IDIS[] = "!(fl & PSL_I)";
|
||||
char STR_SIEN[] = "mpp->mtx_saveintr & PSL_I";
|
||||
#else /* _KERN_MUTEX_C_ */
|
||||
extern char STR_IEN[];
|
||||
extern char STR_IDIS[];
|
||||
extern char STR_SIEN[];
|
||||
#endif /* _KERN_MUTEX_C_ */
|
||||
#endif /* MUTEX_DEBUG */
|
||||
|
||||
#define ASS_IEN MPASS2(read_eflags() & PSL_I, STR_IEN)
|
||||
#define ASS_IDIS MPASS2((read_eflags() & PSL_I) == 0, STR_IDIS)
|
||||
#define ASS_SIEN(mpp) MPASS2((mpp)->mtx_saveintr & PSL_I, STR_SIEN)
|
||||
#define ASS_IEN MPASS2(read_eflags() & PSL_I, "fl & PSL_I")
|
||||
#define ASS_IDIS MPASS2((read_eflags() & PSL_I) == 0, "!(fl & PSL_I)")
|
||||
#define ASS_SIEN(mpp) MPASS2((mpp)->mtx_saveintr & PSL_I, \
|
||||
"mpp->mtx_saveintr & PSL_I")
|
||||
|
||||
#define mtx_legal2block() (read_eflags() & PSL_I)
|
||||
|
||||
|
|
@ -66,9 +54,6 @@ extern char STR_SIEN[];
|
|||
* Assembly macros (for internal use only)
|
||||
*------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifdef _KERN_MUTEX_C_
|
||||
|
||||
#define _V(x) __STRING(x)
|
||||
|
||||
#if 0
|
||||
|
|
@ -252,22 +237,80 @@ extern char STR_SIEN[];
|
|||
|
||||
#undef _V
|
||||
|
||||
#endif /* _KERN_MUTEX_C_ */
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#else /* !LOCORE */
|
||||
|
||||
/*
|
||||
* Simple assembly macros to get and release mutexes.
|
||||
*
|
||||
* Note: All of these macros accept a "flags" argument and are analoguous
|
||||
* to the mtx_lock_flags and mtx_unlock_flags general macros. If one
|
||||
* desires to not pass a flag, the value 0 may be passed as second
|
||||
* argument.
|
||||
*
|
||||
* XXX: We only have MTX_LOCK_SPIN and MTX_UNLOCK_SPIN for now, since that's
|
||||
* all we use right now. We should add MTX_LOCK and MTX_UNLOCK (for sleep
|
||||
* locks) in the near future, however.
|
||||
*/
|
||||
#define MTX_LOCK_SPIN(lck, flags) \
|
||||
pushl %eax ; \
|
||||
pushl %ecx ; \
|
||||
pushl %ebx ; \
|
||||
movl $(MTX_UNOWNED) , %eax ; \
|
||||
movl PCPU(CURPROC), %ebx ; \
|
||||
pushfl ; \
|
||||
popl %ecx ; \
|
||||
cli ; \
|
||||
MPLOCKED cmpxchgl %ebx, lck+MTX_LOCK ; \
|
||||
jz 2f ; \
|
||||
cmpl lck+MTX_LOCK, %ebx ; \
|
||||
je 3f ; \
|
||||
pushl $0 ; \
|
||||
pushl $0 ; \
|
||||
pushl %ecx ; \
|
||||
pushl $flags ; \
|
||||
pushl $lck ; \
|
||||
call _mtx_lock_spin ; \
|
||||
addl $0x14, %esp ; \
|
||||
jmp 1f ; \
|
||||
3: movl lck+MTX_RECURSECNT, %ebx ; \
|
||||
incl %ebx ; \
|
||||
movl %ebx, lck+MTX_RECURSECNT ; \
|
||||
jmp 1f ; \
|
||||
2: movl %ecx, lck+MTX_SAVEINTR ; \
|
||||
1: popl %ebx ; \
|
||||
popl %ecx ; \
|
||||
popl %eax
|
||||
|
||||
#define MTX_UNLOCK_SPIN(lck) \
|
||||
pushl %edx ; \
|
||||
pushl %eax ; \
|
||||
movl lck+MTX_SAVEINTR, %edx ; \
|
||||
movl lck+MTX_RECURSECNT, %eax ; \
|
||||
testl %eax, %eax ; \
|
||||
jne 2f ; \
|
||||
movl $(MTX_UNOWNED), %eax ; \
|
||||
xchgl %eax, lck+MTX_LOCK ; \
|
||||
pushl %edx ; \
|
||||
popfl ; \
|
||||
jmp 1f ; \
|
||||
2: decl %eax ; \
|
||||
movl %eax, lck+MTX_RECURSECNT ; \
|
||||
1: popl %eax ; \
|
||||
popl %edx
|
||||
|
||||
/*
|
||||
* XXX: These two are broken right now and need to be made to work for
|
||||
* XXX: sleep locks, as the above two work for spin locks. We're not in
|
||||
* XXX: too much of a rush to do these as we do not use them right now.
|
||||
*/
|
||||
#define MTX_ENTER(lck, type) \
|
||||
pushl $0 ; /* dummy __LINE__ */ \
|
||||
pushl $0 ; /* dummy __FILE__ */ \
|
||||
pushl $type ; \
|
||||
pushl $lck ; \
|
||||
call _mtx_enter ; \
|
||||
call _mtx_lock_XXX ; \
|
||||
addl $16,%esp
|
||||
|
||||
#define MTX_EXIT(lck, type) \
|
||||
|
|
@ -275,7 +318,7 @@ extern char STR_SIEN[];
|
|||
pushl $0 ; /* dummy __FILE__ */ \
|
||||
pushl $type ; \
|
||||
pushl $lck ; \
|
||||
call _mtx_exit ; \
|
||||
call _mtx_unlock_XXX ; \
|
||||
addl $16,%esp
|
||||
|
||||
#endif /* !LOCORE */
|
||||
|
|
|
|||
|
|
@ -66,8 +66,8 @@
|
|||
#ifdef SMP
|
||||
#define MCOUNT_ENTER(s) { s = read_eflags(); \
|
||||
__asm __volatile("cli" : : : "memory"); \
|
||||
mtx_enter(&mcount_mtx, MTX_DEF); }
|
||||
#define MCOUNT_EXIT(s) { mtx_exit(&mcount_mtx, MTX_DEF); write_eflags(s); }
|
||||
mtx_lock(&mcount_mtx); }
|
||||
#define MCOUNT_EXIT(s) { mtx_unlock(&mcount_mtx); write_eflags(s); }
|
||||
#else
|
||||
#define MCOUNT_ENTER(s) { s = read_eflags(); disable_intr(); }
|
||||
#define MCOUNT_EXIT(s) (write_eflags(s))
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ clkintr(struct clockframe frame)
|
|||
{
|
||||
|
||||
if (timecounter->tc_get_timecount == i8254_get_timecount) {
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
if (i8254_ticked)
|
||||
i8254_ticked = 0;
|
||||
else {
|
||||
|
|
@ -215,7 +215,7 @@ clkintr(struct clockframe frame)
|
|||
i8254_lastcount = 0;
|
||||
}
|
||||
clkintr_pending = 0;
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
}
|
||||
timer_func(&frame);
|
||||
switch (timer0_state) {
|
||||
|
|
@ -232,14 +232,14 @@ clkintr(struct clockframe frame)
|
|||
break;
|
||||
|
||||
case ACQUIRE_PENDING:
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
i8254_offset = i8254_get_timecount(NULL);
|
||||
i8254_lastcount = 0;
|
||||
timer0_max_count = TIMER_DIV(new_rate);
|
||||
outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
|
||||
outb(TIMER_CNTR0, timer0_max_count & 0xff);
|
||||
outb(TIMER_CNTR0, timer0_max_count >> 8);
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
timer_func = new_function;
|
||||
timer0_state = ACQUIRED;
|
||||
break;
|
||||
|
|
@ -247,7 +247,7 @@ clkintr(struct clockframe frame)
|
|||
case RELEASE_PENDING:
|
||||
if ((timer0_prescaler_count += timer0_max_count)
|
||||
>= hardclock_max_count) {
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
i8254_offset = i8254_get_timecount(NULL);
|
||||
i8254_lastcount = 0;
|
||||
timer0_max_count = hardclock_max_count;
|
||||
|
|
@ -255,7 +255,7 @@ clkintr(struct clockframe frame)
|
|||
TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
|
||||
outb(TIMER_CNTR0, timer0_max_count & 0xff);
|
||||
outb(TIMER_CNTR0, timer0_max_count >> 8);
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
timer0_prescaler_count = 0;
|
||||
timer_func = hardclock;
|
||||
timer0_state = RELEASED;
|
||||
|
|
@ -403,7 +403,7 @@ getit(void)
|
|||
{
|
||||
int high, low;
|
||||
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
|
||||
/* Select timer0 and latch counter value. */
|
||||
outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
|
||||
|
|
@ -411,7 +411,7 @@ getit(void)
|
|||
low = inb(TIMER_CNTR0);
|
||||
high = inb(TIMER_CNTR0);
|
||||
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
return ((high << 8) | low);
|
||||
}
|
||||
|
||||
|
|
@ -525,10 +525,10 @@ sysbeep(int pitch, int period)
|
|||
splx(x);
|
||||
return (-1); /* XXX Should be EBUSY, but nobody cares anyway. */
|
||||
}
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
outb(TIMER_CNTR2, pitch);
|
||||
outb(TIMER_CNTR2, (pitch>>8));
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
if (!beeping) {
|
||||
/* enable counter2 output to speaker */
|
||||
outb(IO_PPI, inb(IO_PPI) | 3);
|
||||
|
|
@ -679,7 +679,7 @@ set_timer_freq(u_int freq, int intr_freq)
|
|||
{
|
||||
int new_timer0_max_count;
|
||||
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
timer_freq = freq;
|
||||
new_timer0_max_count = hardclock_max_count = TIMER_DIV(intr_freq);
|
||||
if (new_timer0_max_count != timer0_max_count) {
|
||||
|
|
@ -688,7 +688,7 @@ set_timer_freq(u_int freq, int intr_freq)
|
|||
outb(TIMER_CNTR0, timer0_max_count & 0xff);
|
||||
outb(TIMER_CNTR0, timer0_max_count >> 8);
|
||||
}
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -703,11 +703,11 @@ void
|
|||
i8254_restore(void)
|
||||
{
|
||||
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
|
||||
outb(TIMER_CNTR0, timer0_max_count & 0xff);
|
||||
outb(TIMER_CNTR0, timer0_max_count >> 8);
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1194,7 +1194,7 @@ i8254_get_timecount(struct timecounter *tc)
|
|||
u_int eflags;
|
||||
|
||||
eflags = read_eflags();
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
|
||||
/* Select timer0 and latch counter value. */
|
||||
outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
|
||||
|
|
@ -1218,7 +1218,7 @@ i8254_get_timecount(struct timecounter *tc)
|
|||
}
|
||||
i8254_lastcount = count;
|
||||
count += i8254_offset;
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
return (count);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -701,7 +701,7 @@ inthand_remove(struct intrhand *idesc)
|
|||
ithds[ithd->irq] = NULL;
|
||||
|
||||
if ((idesc->ih_flags & INTR_FAST) == 0) {
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (ithd->it_proc->p_stat == SWAIT) {
|
||||
ithd->it_proc->p_intr_nesting_level = 0;
|
||||
ithd->it_proc->p_stat = SRUN;
|
||||
|
|
@ -713,7 +713,7 @@ inthand_remove(struct intrhand *idesc)
|
|||
* XXX: should we lower the threads priority?
|
||||
*/
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
}
|
||||
free(idesc->ih_name, M_DEVBUF);
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ sched_ithd(void *cookie)
|
|||
* is higher priority than their current thread, it gets run now.
|
||||
*/
|
||||
ir->it_need = 1;
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (ir->it_proc->p_stat == SWAIT) { /* not on run queue */
|
||||
CTR1(KTR_INTR, "sched_ithd: setrunqueue %d",
|
||||
ir->it_proc->p_pid);
|
||||
|
|
@ -134,7 +134,7 @@ sched_ithd(void *cookie)
|
|||
ir->it_proc->p_stat );
|
||||
need_resched();
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -163,7 +163,7 @@ ithd_loop(void *dummy)
|
|||
me->it_proc->p_pid, me->it_proc->p_comm);
|
||||
curproc->p_ithd = NULL;
|
||||
free(me, M_DEVBUF);
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
kthread_exit(0);
|
||||
}
|
||||
|
||||
|
|
@ -188,10 +188,10 @@ ithd_loop(void *dummy)
|
|||
ih->ih_flags);
|
||||
|
||||
if ((ih->ih_flags & INTR_MPSAFE) == 0)
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
ih->ih_handler(ih->ih_argument);
|
||||
if ((ih->ih_flags & INTR_MPSAFE) == 0)
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -201,7 +201,7 @@ ithd_loop(void *dummy)
|
|||
* set again, so we have to check it again.
|
||||
*/
|
||||
mtx_assert(&Giant, MA_NOTOWNED);
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (!me->it_need) {
|
||||
|
||||
INTREN (1 << me->irq); /* reset the mask bit */
|
||||
|
|
@ -217,6 +217,6 @@ ithd_loop(void *dummy)
|
|||
CTR1(KTR_INTR, "ithd_loop pid %d: resumed",
|
||||
me->it_proc->p_pid);
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -701,7 +701,7 @@ inthand_remove(struct intrhand *idesc)
|
|||
ithds[ithd->irq] = NULL;
|
||||
|
||||
if ((idesc->ih_flags & INTR_FAST) == 0) {
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (ithd->it_proc->p_stat == SWAIT) {
|
||||
ithd->it_proc->p_intr_nesting_level = 0;
|
||||
ithd->it_proc->p_stat = SRUN;
|
||||
|
|
@ -713,7 +713,7 @@ inthand_remove(struct intrhand *idesc)
|
|||
* XXX: should we lower the threads priority?
|
||||
*/
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
}
|
||||
free(idesc->ih_name, M_DEVBUF);
|
||||
|
|
|
|||
|
|
@ -724,7 +724,7 @@ npx_intr(dummy)
|
|||
u_short control;
|
||||
struct intrframe *frame;
|
||||
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
if (PCPU_GET(npxproc) == NULL || !npx_exists) {
|
||||
printf("npxintr: npxproc = %p, curproc = %p, npx_exists = %d\n",
|
||||
PCPU_GET(npxproc), curproc, npx_exists);
|
||||
|
|
@ -783,7 +783,7 @@ npx_intr(dummy)
|
|||
*/
|
||||
psignal(curproc, SIGFPE);
|
||||
}
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -454,12 +454,12 @@ linprocfs_doprocstatus(curp, p, pfs, uio)
|
|||
|
||||
sbuf_new(&sb, NULL, 1024, 0);
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (p->p_stat > sizeof state_str / sizeof *state_str)
|
||||
state = state_str[0];
|
||||
else
|
||||
state = state_str[(int)p->p_stat];
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
|
||||
PROCTREE_LOCK(PT_SHARED);
|
||||
ppid = p->p_pptr ? p->p_pptr->p_pid : 0;
|
||||
|
|
|
|||
|
|
@ -454,12 +454,12 @@ linprocfs_doprocstatus(curp, p, pfs, uio)
|
|||
|
||||
sbuf_new(&sb, NULL, 1024, 0);
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (p->p_stat > sizeof state_str / sizeof *state_str)
|
||||
state = state_str[0];
|
||||
else
|
||||
state = state_str[(int)p->p_stat];
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
|
||||
PROCTREE_LOCK(PT_SHARED);
|
||||
ppid = p->p_pptr ? p->p_pptr->p_pid : 0;
|
||||
|
|
|
|||
|
|
@ -642,9 +642,9 @@ linux_times(struct proc *p, struct linux_times_args *args)
|
|||
#ifdef DEBUG
|
||||
printf("Linux-emul(%ld): times(*)\n", (long)p->p_pid);
|
||||
#endif
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
calcru(p, &ru.ru_utime, &ru.ru_stime, NULL);
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
|
||||
tms.tms_utime = CONVTCK(ru.ru_utime);
|
||||
tms.tms_stime = CONVTCK(ru.ru_stime);
|
||||
|
|
|
|||
|
|
@ -1141,7 +1141,7 @@ svr4_setinfo(p, st, s)
|
|||
|
||||
if (p) {
|
||||
i.si_pid = p->p_pid;
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (p->p_stat == SZOMB) {
|
||||
i.si_stime = p->p_ru->ru_stime.tv_sec;
|
||||
i.si_utime = p->p_ru->ru_utime.tv_sec;
|
||||
|
|
@ -1150,7 +1150,7 @@ svr4_setinfo(p, st, s)
|
|||
i.si_stime = p->p_stats->p_ru.ru_stime.tv_sec;
|
||||
i.si_utime = p->p_stats->p_ru.ru_utime.tv_sec;
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
|
||||
if (WIFEXITED(st)) {
|
||||
|
|
@ -1226,10 +1226,10 @@ loop:
|
|||
}
|
||||
nfound++;
|
||||
PROC_LOCK(q);
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (q->p_stat == SZOMB &&
|
||||
((SCARG(uap, options) & (SVR4_WEXITED|SVR4_WTRAPPED)))) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
PROC_UNLOCK(q);
|
||||
PROCTREE_LOCK(PT_RELEASE);
|
||||
*retval = 0;
|
||||
|
|
@ -1357,7 +1357,7 @@ loop:
|
|||
if (q->p_stat == SSTOP && (q->p_flag & P_WAITED) == 0 &&
|
||||
(q->p_flag & P_TRACED ||
|
||||
(SCARG(uap, options) & (SVR4_WSTOPPED|SVR4_WCONTINUED)))) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
DPRINTF(("jobcontrol %d\n", q->p_pid));
|
||||
if (((SCARG(uap, options) & SVR4_WNOWAIT)) == 0)
|
||||
q->p_flag |= P_WAITED;
|
||||
|
|
@ -1366,7 +1366,7 @@ loop:
|
|||
return svr4_setinfo(q, W_STOPCODE(q->p_xstat),
|
||||
SCARG(uap, info));
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
PROC_UNLOCK(q);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ AcpiOsWaitSemaphore(ACPI_HANDLE Handle, UINT32 Units, UINT32 Timeout)
|
|||
tmo = 1;
|
||||
}
|
||||
|
||||
mtx_enter(&as->as_mtx, MTX_DEF);
|
||||
mtx_lock(&as->as_mtx);
|
||||
DEBUG_PRINT(TRACE_MUTEX, ("get %d units from semaphore %p (has %d), timeout %d\n",
|
||||
Units, as, as->as_units, Timeout));
|
||||
for (;;) {
|
||||
|
|
@ -163,7 +163,7 @@ AcpiOsWaitSemaphore(ACPI_HANDLE Handle, UINT32 Units, UINT32 Timeout)
|
|||
break;
|
||||
}
|
||||
}
|
||||
mtx_exit(&as->as_mtx, MTX_DEF);
|
||||
mtx_unlock(&as->as_mtx);
|
||||
|
||||
return_ACPI_STATUS(result);
|
||||
#else
|
||||
|
|
@ -182,14 +182,14 @@ AcpiOsSignalSemaphore(ACPI_HANDLE Handle, UINT32 Units)
|
|||
if (as == NULL)
|
||||
return_ACPI_STATUS(AE_BAD_PARAMETER);
|
||||
|
||||
mtx_enter(&as->as_mtx, MTX_DEF);
|
||||
mtx_lock(&as->as_mtx);
|
||||
DEBUG_PRINT(TRACE_MUTEX, ("return %d units to semaphore %p (has %d)\n",
|
||||
Units, as, as->as_units));
|
||||
as->as_units += Units;
|
||||
if (as->as_units > as->as_maxunits)
|
||||
as->as_units = as->as_maxunits;
|
||||
wakeup(as);
|
||||
mtx_exit(&as->as_mtx, MTX_DEF);
|
||||
mtx_unlock(&as->as_mtx);
|
||||
return_ACPI_STATUS(AE_OK);
|
||||
#else
|
||||
return(AE_OK);
|
||||
|
|
|
|||
|
|
@ -844,8 +844,8 @@ struct an_softc {
|
|||
device_t an_dev;
|
||||
};
|
||||
|
||||
#define AN_LOCK(_sc) mtx_enter(&(_sc)->an_mtx, MTX_DEF)
|
||||
#define AN_UNLOCK(_sc) mtx_exit(&(_sc)->an_mtx, MTX_DEF)
|
||||
#define AN_LOCK(_sc) mtx_lock(&(_sc)->an_mtx)
|
||||
#define AN_UNLOCK(_sc) mtx_unlock(&(_sc)->an_mtx)
|
||||
|
||||
void an_release_resources __P((device_t));
|
||||
int an_alloc_port __P((device_t, int, int));
|
||||
|
|
|
|||
|
|
@ -702,8 +702,8 @@ struct dc_softc {
|
|||
};
|
||||
|
||||
|
||||
#define DC_LOCK(_sc) mtx_enter(&(_sc)->dc_mtx, MTX_DEF)
|
||||
#define DC_UNLOCK(_sc) mtx_exit(&(_sc)->dc_mtx, MTX_DEF)
|
||||
#define DC_LOCK(_sc) mtx_lock(&(_sc)->dc_mtx)
|
||||
#define DC_UNLOCK(_sc) mtx_unlock(&(_sc)->dc_mtx)
|
||||
|
||||
#define DC_TX_POLL 0x00000001
|
||||
#define DC_TX_COALESCE 0x00000002
|
||||
|
|
|
|||
|
|
@ -86,5 +86,5 @@ struct fxp_softc {
|
|||
|
||||
#define sc_if arpcom.ac_if
|
||||
#define FXP_UNIT(_sc) (_sc)->arpcom.ac_if.if_unit
|
||||
#define FXP_LOCK(_sc) mtx_enter(&(_sc)->sc_mtx, MTX_DEF)
|
||||
#define FXP_UNLOCK(_sc) mtx_exit(&(_sc)->sc_mtx, MTX_DEF)
|
||||
#define FXP_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
|
||||
#define FXP_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx)
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ ichsmb_quick(device_t dev, u_char slave, int how)
|
|||
switch (how) {
|
||||
case SMB_QREAD:
|
||||
case SMB_QWRITE:
|
||||
mtx_enter(&sc->mutex, MTX_DEF);
|
||||
mtx_lock(&sc->mutex);
|
||||
sc->ich_cmd = ICH_HST_CNT_SMB_CMD_QUICK;
|
||||
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_XMIT_SLVA,
|
||||
(slave << 1) | (how == SMB_QREAD ?
|
||||
|
|
@ -175,7 +175,7 @@ ichsmb_quick(device_t dev, u_char slave, int how)
|
|||
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_HST_CNT,
|
||||
ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd);
|
||||
smb_error = ichsmb_wait(sc);
|
||||
mtx_exit(&sc->mutex, MTX_DEF);
|
||||
mtx_unlock(&sc->mutex);
|
||||
break;
|
||||
default:
|
||||
smb_error = SMB_ENOTSUPP;
|
||||
|
|
@ -193,7 +193,7 @@ ichsmb_sendb(device_t dev, u_char slave, char byte)
|
|||
DBG("slave=0x%02x byte=0x%02x\n", slave, (u_char)byte);
|
||||
KASSERT(sc->ich_cmd == -1,
|
||||
("%s: ich_cmd=%d\n", __FUNCTION__ , sc->ich_cmd));
|
||||
mtx_enter(&sc->mutex, MTX_DEF);
|
||||
mtx_lock(&sc->mutex);
|
||||
sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BYTE;
|
||||
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_XMIT_SLVA,
|
||||
(slave << 1) | ICH_XMIT_SLVA_WRITE);
|
||||
|
|
@ -201,7 +201,7 @@ ichsmb_sendb(device_t dev, u_char slave, char byte)
|
|||
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_HST_CNT,
|
||||
ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd);
|
||||
smb_error = ichsmb_wait(sc);
|
||||
mtx_exit(&sc->mutex, MTX_DEF);
|
||||
mtx_unlock(&sc->mutex);
|
||||
DBG("smb_error=%d\n", smb_error);
|
||||
return (smb_error);
|
||||
}
|
||||
|
|
@ -215,7 +215,7 @@ ichsmb_recvb(device_t dev, u_char slave, char *byte)
|
|||
DBG("slave=0x%02x\n", slave);
|
||||
KASSERT(sc->ich_cmd == -1,
|
||||
("%s: ich_cmd=%d\n", __FUNCTION__ , sc->ich_cmd));
|
||||
mtx_enter(&sc->mutex, MTX_DEF);
|
||||
mtx_lock(&sc->mutex);
|
||||
sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BYTE;
|
||||
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_XMIT_SLVA,
|
||||
(slave << 1) | ICH_XMIT_SLVA_READ);
|
||||
|
|
@ -223,7 +223,7 @@ ichsmb_recvb(device_t dev, u_char slave, char *byte)
|
|||
ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd);
|
||||
if ((smb_error = ichsmb_wait(sc)) == SMB_ENOERR)
|
||||
*byte = bus_space_read_1(sc->io_bst, sc->io_bsh, ICH_D0);
|
||||
mtx_exit(&sc->mutex, MTX_DEF);
|
||||
mtx_unlock(&sc->mutex);
|
||||
DBG("smb_error=%d byte=0x%02x\n", smb_error, (u_char)*byte);
|
||||
return (smb_error);
|
||||
}
|
||||
|
|
@ -238,7 +238,7 @@ ichsmb_writeb(device_t dev, u_char slave, char cmd, char byte)
|
|||
slave, (u_char)cmd, (u_char)byte);
|
||||
KASSERT(sc->ich_cmd == -1,
|
||||
("%s: ich_cmd=%d\n", __FUNCTION__ , sc->ich_cmd));
|
||||
mtx_enter(&sc->mutex, MTX_DEF);
|
||||
mtx_lock(&sc->mutex);
|
||||
sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BYTE_DATA;
|
||||
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_XMIT_SLVA,
|
||||
(slave << 1) | ICH_XMIT_SLVA_WRITE);
|
||||
|
|
@ -247,7 +247,7 @@ ichsmb_writeb(device_t dev, u_char slave, char cmd, char byte)
|
|||
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_HST_CNT,
|
||||
ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd);
|
||||
smb_error = ichsmb_wait(sc);
|
||||
mtx_exit(&sc->mutex, MTX_DEF);
|
||||
mtx_unlock(&sc->mutex);
|
||||
DBG("smb_error=%d\n", smb_error);
|
||||
return (smb_error);
|
||||
}
|
||||
|
|
@ -262,7 +262,7 @@ ichsmb_writew(device_t dev, u_char slave, char cmd, short word)
|
|||
slave, (u_char)cmd, (u_int16_t)word);
|
||||
KASSERT(sc->ich_cmd == -1,
|
||||
("%s: ich_cmd=%d\n", __FUNCTION__ , sc->ich_cmd));
|
||||
mtx_enter(&sc->mutex, MTX_DEF);
|
||||
mtx_lock(&sc->mutex);
|
||||
sc->ich_cmd = ICH_HST_CNT_SMB_CMD_WORD_DATA;
|
||||
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_XMIT_SLVA,
|
||||
(slave << 1) | ICH_XMIT_SLVA_WRITE);
|
||||
|
|
@ -272,7 +272,7 @@ ichsmb_writew(device_t dev, u_char slave, char cmd, short word)
|
|||
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_HST_CNT,
|
||||
ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd);
|
||||
smb_error = ichsmb_wait(sc);
|
||||
mtx_exit(&sc->mutex, MTX_DEF);
|
||||
mtx_unlock(&sc->mutex);
|
||||
DBG("smb_error=%d\n", smb_error);
|
||||
return (smb_error);
|
||||
}
|
||||
|
|
@ -286,7 +286,7 @@ ichsmb_readb(device_t dev, u_char slave, char cmd, char *byte)
|
|||
DBG("slave=0x%02x cmd=0x%02x\n", slave, (u_char)cmd);
|
||||
KASSERT(sc->ich_cmd == -1,
|
||||
("%s: ich_cmd=%d\n", __FUNCTION__ , sc->ich_cmd));
|
||||
mtx_enter(&sc->mutex, MTX_DEF);
|
||||
mtx_lock(&sc->mutex);
|
||||
sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BYTE_DATA;
|
||||
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_XMIT_SLVA,
|
||||
(slave << 1) | ICH_XMIT_SLVA_READ);
|
||||
|
|
@ -295,7 +295,7 @@ ichsmb_readb(device_t dev, u_char slave, char cmd, char *byte)
|
|||
ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd);
|
||||
if ((smb_error = ichsmb_wait(sc)) == SMB_ENOERR)
|
||||
*byte = bus_space_read_1(sc->io_bst, sc->io_bsh, ICH_D0);
|
||||
mtx_exit(&sc->mutex, MTX_DEF);
|
||||
mtx_unlock(&sc->mutex);
|
||||
DBG("smb_error=%d byte=0x%02x\n", smb_error, (u_char)*byte);
|
||||
return (smb_error);
|
||||
}
|
||||
|
|
@ -309,7 +309,7 @@ ichsmb_readw(device_t dev, u_char slave, char cmd, short *word)
|
|||
DBG("slave=0x%02x cmd=0x%02x\n", slave, (u_char)cmd);
|
||||
KASSERT(sc->ich_cmd == -1,
|
||||
("%s: ich_cmd=%d\n", __FUNCTION__ , sc->ich_cmd));
|
||||
mtx_enter(&sc->mutex, MTX_DEF);
|
||||
mtx_lock(&sc->mutex);
|
||||
sc->ich_cmd = ICH_HST_CNT_SMB_CMD_WORD_DATA;
|
||||
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_XMIT_SLVA,
|
||||
(slave << 1) | ICH_XMIT_SLVA_READ);
|
||||
|
|
@ -322,7 +322,7 @@ ichsmb_readw(device_t dev, u_char slave, char cmd, short *word)
|
|||
| (bus_space_read_1(sc->io_bst,
|
||||
sc->io_bsh, ICH_D1) << 8);
|
||||
}
|
||||
mtx_exit(&sc->mutex, MTX_DEF);
|
||||
mtx_unlock(&sc->mutex);
|
||||
DBG("smb_error=%d word=0x%04x\n", smb_error, (u_int16_t)*word);
|
||||
return (smb_error);
|
||||
}
|
||||
|
|
@ -337,7 +337,7 @@ ichsmb_pcall(device_t dev, u_char slave, char cmd, short sdata, short *rdata)
|
|||
slave, (u_char)cmd, (u_int16_t)sdata);
|
||||
KASSERT(sc->ich_cmd == -1,
|
||||
("%s: ich_cmd=%d\n", __FUNCTION__ , sc->ich_cmd));
|
||||
mtx_enter(&sc->mutex, MTX_DEF);
|
||||
mtx_lock(&sc->mutex);
|
||||
sc->ich_cmd = ICH_HST_CNT_SMB_CMD_PROC_CALL;
|
||||
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_XMIT_SLVA,
|
||||
(slave << 1) | ICH_XMIT_SLVA_WRITE);
|
||||
|
|
@ -352,7 +352,7 @@ ichsmb_pcall(device_t dev, u_char slave, char cmd, short sdata, short *rdata)
|
|||
| (bus_space_read_1(sc->io_bst,
|
||||
sc->io_bsh, ICH_D1) << 8);
|
||||
}
|
||||
mtx_exit(&sc->mutex, MTX_DEF);
|
||||
mtx_unlock(&sc->mutex);
|
||||
DBG("smb_error=%d rdata=0x%04x\n", smb_error, (u_int16_t)*rdata);
|
||||
return (smb_error);
|
||||
}
|
||||
|
|
@ -388,7 +388,7 @@ ichsmb_bwrite(device_t dev, u_char slave, char cmd, u_char count, char *buf)
|
|||
sc->block_index = 1;
|
||||
sc->block_write = 1;
|
||||
|
||||
mtx_enter(&sc->mutex, MTX_DEF);
|
||||
mtx_lock(&sc->mutex);
|
||||
sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BLOCK;
|
||||
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_XMIT_SLVA,
|
||||
(slave << 1) | ICH_XMIT_SLVA_WRITE);
|
||||
|
|
@ -398,7 +398,7 @@ ichsmb_bwrite(device_t dev, u_char slave, char cmd, u_char count, char *buf)
|
|||
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_HST_CNT,
|
||||
ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd);
|
||||
smb_error = ichsmb_wait(sc);
|
||||
mtx_exit(&sc->mutex, MTX_DEF);
|
||||
mtx_unlock(&sc->mutex);
|
||||
DBG("smb_error=%d\n", smb_error);
|
||||
return (smb_error);
|
||||
}
|
||||
|
|
@ -419,7 +419,7 @@ ichsmb_bread(device_t dev, u_char slave, char cmd, u_char count, char *buf)
|
|||
sc->block_index = 0;
|
||||
sc->block_write = 0;
|
||||
|
||||
mtx_enter(&sc->mutex, MTX_DEF);
|
||||
mtx_lock(&sc->mutex);
|
||||
sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BLOCK;
|
||||
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_XMIT_SLVA,
|
||||
(slave << 1) | ICH_XMIT_SLVA_READ);
|
||||
|
|
@ -429,7 +429,7 @@ ichsmb_bread(device_t dev, u_char slave, char cmd, u_char count, char *buf)
|
|||
ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd);
|
||||
if ((smb_error = ichsmb_wait(sc)) == SMB_ENOERR)
|
||||
bcopy(sc->block_data, buf, sc->block_count);
|
||||
mtx_exit(&sc->mutex, MTX_DEF);
|
||||
mtx_unlock(&sc->mutex);
|
||||
DBG("smb_error=%d\n", smb_error);
|
||||
#if ICHSMB_DEBUG
|
||||
#define DISP(ch) (((ch) < 0x20 || (ch) >= 0x7e) ? '.' : (ch))
|
||||
|
|
@ -491,7 +491,7 @@ ichsmb_device_intr(void *cookie)
|
|||
int cmd_index;
|
||||
int count;
|
||||
|
||||
mtx_enter(&sc->mutex, MTX_DEF);
|
||||
mtx_lock(&sc->mutex);
|
||||
for (count = 0; count < maxloops; count++) {
|
||||
|
||||
/* Get and reset status bits */
|
||||
|
|
@ -603,7 +603,7 @@ finished:
|
|||
/* Clear status bits and try again */
|
||||
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_HST_STA, status);
|
||||
}
|
||||
mtx_exit(&sc->mutex, MTX_DEF);
|
||||
mtx_unlock(&sc->mutex);
|
||||
|
||||
/* Too many loops? */
|
||||
if (count == maxloops) {
|
||||
|
|
|
|||
|
|
@ -1992,9 +1992,9 @@ isp_done(struct ccb_scsiio *sccb)
|
|||
XS_CMD_S_CLEAR(sccb);
|
||||
ISP_UNLOCK(isp);
|
||||
#ifdef ISP_SMPLOCK
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
xpt_done((union ccb *) sccb);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
#else
|
||||
xpt_done((union ccb *) sccb);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -124,8 +124,8 @@ struct isposinfo {
|
|||
*/
|
||||
|
||||
#ifdef ISP_SMPLOCK
|
||||
#define ISP_LOCK(x) mtx_enter(&(x)->isp_osinfo.lock, MTX_DEF)
|
||||
#define ISP_UNLOCK(x) mtx_exit(&(x)->isp_osinfo.lock, MTX_DEF)
|
||||
#define ISP_LOCK(x) mtx_lock(&(x)->isp_osinfo.lock)
|
||||
#define ISP_UNLOCK(x) mtx_unlock(&(x)->isp_osinfo.lock)
|
||||
#else
|
||||
#define ISP_LOCK isp_lock
|
||||
#define ISP_UNLOCK isp_unlock
|
||||
|
|
|
|||
|
|
@ -530,13 +530,13 @@ pccbb_detach(device_t dev)
|
|||
if (error > 0)
|
||||
return ENXIO;
|
||||
|
||||
mtx_enter(&sc->sc_mtx, MTX_DEF);
|
||||
mtx_lock(&sc->sc_mtx);
|
||||
bus_teardown_intr(dev, sc->sc_irq_res, sc->sc_intrhand);
|
||||
|
||||
sc->sc_flags |= PCCBB_KTHREAD_DONE;
|
||||
if (sc->sc_flags & PCCBB_KTHREAD_RUNNING) {
|
||||
wakeup(sc);
|
||||
mtx_exit(&sc->sc_mtx, MTX_DEF);
|
||||
mtx_unlock(&sc->sc_mtx);
|
||||
DEVPRINTF((dev, "waiting for kthread exit..."));
|
||||
error = tsleep(sc, PWAIT, "pccbb-detach-wait", 60 * hz);
|
||||
if (error)
|
||||
|
|
@ -544,7 +544,7 @@ pccbb_detach(device_t dev)
|
|||
else
|
||||
DPRINTF(("done\n"));
|
||||
} else
|
||||
mtx_exit(&sc->sc_mtx, MTX_DEF);
|
||||
mtx_unlock(&sc->sc_mtx);
|
||||
|
||||
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq_res);
|
||||
bus_release_resource(dev, SYS_RES_MEMORY, PCCBBR_SOCKBASE,
|
||||
|
|
@ -572,17 +572,17 @@ pccbb_driver_added(device_t dev, driver_t *driver)
|
|||
sc->sc_cbdev = devlist[tmp];
|
||||
if ((sc->sc_socketreg->socket_state
|
||||
& PCCBB_SOCKET_STAT_CD) == 0) {
|
||||
mtx_enter(&sc->sc_mtx, MTX_DEF);
|
||||
mtx_lock(&sc->sc_mtx);
|
||||
wakeup(sc);
|
||||
mtx_exit(&sc->sc_mtx, MTX_DEF);
|
||||
mtx_unlock(&sc->sc_mtx);
|
||||
}
|
||||
} else if (strcmp(driver->name, "pccard") == 0) {
|
||||
sc->sc_pccarddev = devlist[tmp];
|
||||
if ((sc->sc_socketreg->socket_state
|
||||
& PCCBB_SOCKET_STAT_CD) == 0) {
|
||||
mtx_enter(&sc->sc_mtx, MTX_DEF);
|
||||
mtx_lock(&sc->sc_mtx);
|
||||
wakeup(sc);
|
||||
mtx_exit(&sc->sc_mtx, MTX_DEF);
|
||||
mtx_unlock(&sc->sc_mtx);
|
||||
}
|
||||
} else
|
||||
device_printf(dev,
|
||||
|
|
@ -616,7 +616,7 @@ pccbb_event_thread (void *arg)
|
|||
struct pccbb_softc *sc = arg;
|
||||
u_int32_t status;
|
||||
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
for(;;) {
|
||||
if (!(sc->sc_flags & PCCBB_KTHREAD_RUNNING))
|
||||
sc->sc_flags |= PCCBB_KTHREAD_RUNNING;
|
||||
|
|
@ -629,7 +629,7 @@ pccbb_event_thread (void *arg)
|
|||
*/
|
||||
tsleep (&sc->sc_flags, PWAIT, "pccbbev", 1*hz);
|
||||
}
|
||||
mtx_enter(&sc->sc_mtx, MTX_DEF);
|
||||
mtx_lock(&sc->sc_mtx);
|
||||
if (sc->sc_flags & PCCBB_KTHREAD_DONE)
|
||||
break;
|
||||
|
||||
|
|
@ -639,9 +639,9 @@ pccbb_event_thread (void *arg)
|
|||
} else {
|
||||
pccbb_removal(sc);
|
||||
}
|
||||
mtx_exit(&sc->sc_mtx, MTX_DEF);
|
||||
mtx_unlock(&sc->sc_mtx);
|
||||
}
|
||||
mtx_exit(&sc->sc_mtx, MTX_DEF);
|
||||
mtx_unlock(&sc->sc_mtx);
|
||||
sc->sc_flags &= ~PCCBB_KTHREAD_RUNNING;
|
||||
wakeup(sc);
|
||||
kthread_exit(0);
|
||||
|
|
@ -744,9 +744,9 @@ pccbb_intr(void* arg)
|
|||
sc->sc_socketreg->socket_event = sockevent | 0x01;
|
||||
|
||||
if (sockevent & PCCBB_SOCKET_EVENT_CD) {
|
||||
mtx_enter(&sc->sc_mtx, MTX_DEF);
|
||||
mtx_lock(&sc->sc_mtx);
|
||||
wakeup(sc);
|
||||
mtx_exit(&sc->sc_mtx, MTX_DEF);
|
||||
mtx_unlock(&sc->sc_mtx);
|
||||
} else {
|
||||
if (sockevent & PCCBB_SOCKET_EVENT_CSTS) {
|
||||
DPRINTF((" cstsevent occures, 0x%08x\n",
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ void
|
|||
random_set_wakeup_exit(void *control)
|
||||
{
|
||||
wakeup(control);
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
kthread_exit(0);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,10 +96,10 @@ random_kthread(void *arg /* NOTUSED */)
|
|||
struct source *source;
|
||||
|
||||
#ifdef DEBUG
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
printf("OWNERSHIP Giant == %d sched_lock == %d\n",
|
||||
mtx_owned(&Giant), mtx_owned(&sched_lock));
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
#endif
|
||||
|
||||
for (pl = 0; pl < 2; pl++)
|
||||
|
|
@ -114,11 +114,11 @@ random_kthread(void *arg /* NOTUSED */)
|
|||
|
||||
else {
|
||||
#ifdef DEBUG1
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
printf("HARVEST src=%d bits=%d/%d pool=%d count=%lld\n",
|
||||
event->source, event->bits, event->frac,
|
||||
event->pool, event->somecounter);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
#endif
|
||||
|
||||
/* Suck the harvested entropy out of the queue and hash
|
||||
|
|
@ -160,9 +160,9 @@ random_kthread(void *arg /* NOTUSED */)
|
|||
/* Is the thread scheduled for a shutdown? */
|
||||
if (random_kthread_control != 0) {
|
||||
#ifdef DEBUG
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
printf("Random kthread setting terminate\n");
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
#endif
|
||||
random_set_wakeup_exit(&random_kthread_control);
|
||||
/* NOTREACHED */
|
||||
|
|
@ -179,9 +179,9 @@ random_init(void)
|
|||
int error;
|
||||
|
||||
#ifdef DEBUG
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
printf("Random initialise\n");
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
#endif
|
||||
|
||||
/* This can be turned off by the very paranoid
|
||||
|
|
@ -213,9 +213,9 @@ random_init(void)
|
|||
random_init_harvester(random_harvest_internal, read_random_real);
|
||||
|
||||
#ifdef DEBUG
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
printf("Random initialise finish\n");
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
|
@ -225,31 +225,31 @@ void
|
|||
random_deinit(void)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
printf("Random deinitialise\n");
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
#endif
|
||||
|
||||
/* Deregister the randomness harvesting routine */
|
||||
random_deinit_harvester();
|
||||
|
||||
#ifdef DEBUG
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
printf("Random deinitialise waiting for thread to terminate\n");
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
#endif
|
||||
|
||||
/* Command the hash/reseed thread to end and wait for it to finish */
|
||||
mtx_enter(&harvestring.lockout_mtx, MTX_DEF);
|
||||
mtx_lock(&harvestring.lockout_mtx);
|
||||
random_kthread_control = -1;
|
||||
msleep((void *)&random_kthread_control, &harvestring.lockout_mtx, PUSER,
|
||||
"rndend", 0);
|
||||
mtx_exit(&harvestring.lockout_mtx, MTX_DEF);
|
||||
mtx_unlock(&harvestring.lockout_mtx);
|
||||
|
||||
#ifdef DEBUG
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
printf("Random deinitialise removing mutexes\n");
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
#endif
|
||||
|
||||
/* Remove the mutexes */
|
||||
|
|
@ -257,9 +257,9 @@ random_deinit(void)
|
|||
mtx_destroy(&harvestring.lockout_mtx);
|
||||
|
||||
#ifdef DEBUG
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
printf("Random deinitialise finish\n");
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -276,13 +276,13 @@ reseed(int fastslow)
|
|||
int i, j;
|
||||
|
||||
#ifdef DEBUG
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
printf("Reseed type %d\n", fastslow);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
#endif
|
||||
|
||||
/* The reseed task must not be jumped on */
|
||||
mtx_enter(&random_reseed_mtx, MTX_DEF);
|
||||
mtx_lock(&random_reseed_mtx);
|
||||
|
||||
/* 1. Hash the accumulated entropy into v[0] */
|
||||
|
||||
|
|
@ -353,12 +353,12 @@ reseed(int fastslow)
|
|||
/* XXX Not done here yet */
|
||||
|
||||
/* Release the reseed mutex */
|
||||
mtx_exit(&random_reseed_mtx, MTX_DEF);
|
||||
mtx_unlock(&random_reseed_mtx);
|
||||
|
||||
#ifdef DEBUG
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
printf("Reseed finish\n");
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
#endif
|
||||
|
||||
if (!random_state.seeded) {
|
||||
|
|
@ -379,7 +379,7 @@ read_random_real(void *buf, u_int count)
|
|||
u_int retval;
|
||||
|
||||
/* The reseed task must not be jumped on */
|
||||
mtx_enter(&random_reseed_mtx, MTX_DEF);
|
||||
mtx_lock(&random_reseed_mtx);
|
||||
|
||||
if (gate) {
|
||||
generator_gate();
|
||||
|
|
@ -423,7 +423,7 @@ read_random_real(void *buf, u_int count)
|
|||
cur -= retval;
|
||||
}
|
||||
}
|
||||
mtx_exit(&random_reseed_mtx, MTX_DEF);
|
||||
mtx_unlock(&random_reseed_mtx);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
@ -462,9 +462,9 @@ generator_gate(void)
|
|||
u_char temp[KEYSIZE];
|
||||
|
||||
#ifdef DEBUG
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
printf("Generator gate\n");
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < KEYSIZE; i += sizeof(random_state.counter)) {
|
||||
|
|
@ -477,9 +477,9 @@ generator_gate(void)
|
|||
memset((void *)temp, 0, KEYSIZE);
|
||||
|
||||
#ifdef DEBUG
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
printf("Generator gate finish\n");
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -495,16 +495,16 @@ random_harvest_internal(u_int64_t somecounter, void *entropy, u_int count,
|
|||
int newhead, tail;
|
||||
|
||||
#ifdef DEBUG1
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
printf("Random harvest\n");
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
#endif
|
||||
if (origin < ENTROPYSOURCE) {
|
||||
|
||||
/* Add the harvested data to the ring buffer, but
|
||||
* do not block.
|
||||
*/
|
||||
if (mtx_try_enter(&harvestring.lockout_mtx, MTX_DEF)) {
|
||||
if (mtx_trylock(&harvestring.lockout_mtx)) {
|
||||
|
||||
tail = atomic_load_acq_int(&harvestring.tail);
|
||||
newhead = (harvestring.head + 1) % HARVEST_RING_SIZE;
|
||||
|
|
@ -533,7 +533,7 @@ random_harvest_internal(u_int64_t somecounter, void *entropy, u_int count,
|
|||
wakeup(&harvestring.head);
|
||||
|
||||
}
|
||||
mtx_exit(&harvestring.lockout_mtx, MTX_DEF);
|
||||
mtx_unlock(&harvestring.lockout_mtx);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1048,8 +1048,8 @@ struct sf_softc {
|
|||
};
|
||||
|
||||
|
||||
#define SF_LOCK(_sc) mtx_enter(&(_sc)->sf_mtx, MTX_DEF)
|
||||
#define SF_UNLOCK(_sc) mtx_exit(&(_sc)->sf_mtx, MTX_DEF)
|
||||
#define SF_LOCK(_sc) mtx_lock(&(_sc)->sf_mtx)
|
||||
#define SF_UNLOCK(_sc) mtx_unlock(&(_sc)->sf_mtx)
|
||||
|
||||
#define SF_TIMEOUT 1000
|
||||
|
||||
|
|
|
|||
|
|
@ -856,7 +856,7 @@ sioprobe(dev, xrid)
|
|||
* but mask them in the processor as well in case there are some
|
||||
* (misconfigured) shared interrupts.
|
||||
*/
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
/* EXTRA DELAY? */
|
||||
|
||||
/*
|
||||
|
|
@ -953,7 +953,7 @@ sioprobe(dev, xrid)
|
|||
CLR_FLAG(dev, COM_C_IIR_TXRDYBUG);
|
||||
}
|
||||
sio_setreg(com, com_cfcr, CFCR_8BITS);
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
|
||||
return (iobase == siocniobase ? 0 : result);
|
||||
}
|
||||
|
|
@ -993,7 +993,7 @@ sioprobe(dev, xrid)
|
|||
irqmap[3] = isa_irq_pending();
|
||||
failures[9] = (sio_getreg(com, com_iir) & IIR_IMASK) - IIR_NOPEND;
|
||||
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
|
||||
irqs = irqmap[1] & ~irqmap[0];
|
||||
if (bus_get_resource(idev, SYS_RES_IRQ, 0, &xirq, NULL) == 0 &&
|
||||
|
|
@ -1181,7 +1181,7 @@ sioattach(dev, xrid)
|
|||
} else
|
||||
com->it_in.c_ispeed = com->it_in.c_ospeed = TTYDEF_SPEED;
|
||||
if (siosetwater(com, com->it_in.c_ispeed) != 0) {
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
/*
|
||||
* Leave i/o resources allocated if this is a `cn'-level
|
||||
* console, so that other devices can't snarf them.
|
||||
|
|
@ -1190,7 +1190,7 @@ sioattach(dev, xrid)
|
|||
bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
|
||||
return (ENOMEM);
|
||||
}
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
termioschars(&com->it_in);
|
||||
com->it_out = com->it_in;
|
||||
|
||||
|
|
@ -1485,7 +1485,7 @@ open_top:
|
|||
}
|
||||
}
|
||||
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
(void) inb(com->line_status_port);
|
||||
(void) inb(com->data_port);
|
||||
com->prev_modem_status = com->last_modem_status
|
||||
|
|
@ -1497,7 +1497,7 @@ open_top:
|
|||
outb(com->intr_ctl_port, IER_ERXRDY | IER_ETXRDY
|
||||
| IER_ERLS | IER_EMSC);
|
||||
}
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
/*
|
||||
* Handle initial DCD. Callout devices get a fake initial
|
||||
* DCD (trapdoor DCD). If we are callout, then any sleeping
|
||||
|
|
@ -1753,7 +1753,7 @@ sioinput(com)
|
|||
* semantics instead of the save-and-disable semantics
|
||||
* that are used everywhere else.
|
||||
*/
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
incc = com->iptr - buf;
|
||||
if (tp->t_rawq.c_cc + incc > tp->t_ihiwat
|
||||
&& (com->state & CS_RTS_IFLOW
|
||||
|
|
@ -1774,7 +1774,7 @@ sioinput(com)
|
|||
tp->t_lflag &= ~FLUSHO;
|
||||
comstart(tp);
|
||||
}
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
} while (buf < com->iptr);
|
||||
} else {
|
||||
do {
|
||||
|
|
@ -1783,7 +1783,7 @@ sioinput(com)
|
|||
* semantics instead of the save-and-disable semantics
|
||||
* that are used everywhere else.
|
||||
*/
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
line_status = buf[com->ierroff];
|
||||
recv_data = *buf++;
|
||||
if (line_status
|
||||
|
|
@ -1798,7 +1798,7 @@ sioinput(com)
|
|||
recv_data |= TTY_PE;
|
||||
}
|
||||
(*linesw[tp->t_line].l_rint)(recv_data, tp);
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
} while (buf < com->iptr);
|
||||
}
|
||||
com_events -= (com->iptr - com->ibuf);
|
||||
|
|
@ -1823,9 +1823,9 @@ siointr(arg)
|
|||
#ifndef COM_MULTIPORT
|
||||
com = (struct com_s *)arg;
|
||||
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
siointr1(com);
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
#else /* COM_MULTIPORT */
|
||||
bool_t possibly_more_intrs;
|
||||
int unit;
|
||||
|
|
@ -1837,7 +1837,7 @@ siointr(arg)
|
|||
* devices, then the edge from one may be lost because another is
|
||||
* on.
|
||||
*/
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
do {
|
||||
possibly_more_intrs = FALSE;
|
||||
for (unit = 0; unit < sio_numunits; ++unit) {
|
||||
|
|
@ -1856,7 +1856,7 @@ siointr(arg)
|
|||
/* XXX COM_UNLOCK(); */
|
||||
}
|
||||
} while (possibly_more_intrs);
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
#endif /* COM_MULTIPORT */
|
||||
}
|
||||
|
||||
|
|
@ -2264,7 +2264,7 @@ repeat:
|
|||
* Discard any events related to never-opened or
|
||||
* going-away devices.
|
||||
*/
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
incc = com->iptr - com->ibuf;
|
||||
com->iptr = com->ibuf;
|
||||
if (com->state & CS_CHECKMSR) {
|
||||
|
|
@ -2272,33 +2272,33 @@ repeat:
|
|||
com->state &= ~CS_CHECKMSR;
|
||||
}
|
||||
com_events -= incc;
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
continue;
|
||||
}
|
||||
if (com->iptr != com->ibuf) {
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
sioinput(com);
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
}
|
||||
if (com->state & CS_CHECKMSR) {
|
||||
u_char delta_modem_status;
|
||||
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
delta_modem_status = com->last_modem_status
|
||||
^ com->prev_modem_status;
|
||||
com->prev_modem_status = com->last_modem_status;
|
||||
com_events -= LOTS_OF_EVENTS;
|
||||
com->state &= ~CS_CHECKMSR;
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
if (delta_modem_status & MSR_DCD)
|
||||
(*linesw[tp->t_line].l_modem)
|
||||
(tp, com->prev_modem_status & MSR_DCD);
|
||||
}
|
||||
if (com->state & CS_ODONE) {
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
com_events -= LOTS_OF_EVENTS;
|
||||
com->state &= ~CS_ODONE;
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
if (!(com->state & CS_BUSY)
|
||||
&& !(com->extra_state & CSE_BUSYCHECK)) {
|
||||
timeout(siobusycheck, com, hz / 100);
|
||||
|
|
@ -2484,7 +2484,7 @@ comparam(tp, t)
|
|||
if (com->state >= (CS_BUSY | CS_TTGO))
|
||||
siointr1(com);
|
||||
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
splx(s);
|
||||
comstart(tp);
|
||||
if (com->ibufold != NULL) {
|
||||
|
|
@ -2518,7 +2518,7 @@ siosetwater(com, speed)
|
|||
for (ibufsize = 128; ibufsize < cp4ticks;)
|
||||
ibufsize <<= 1;
|
||||
if (ibufsize == com->ibufsize) {
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
@ -2528,7 +2528,7 @@ siosetwater(com, speed)
|
|||
*/
|
||||
ibuf = malloc(2 * ibufsize, M_DEVBUF, M_NOWAIT);
|
||||
if (ibuf == NULL) {
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
|
|
@ -2546,7 +2546,7 @@ siosetwater(com, speed)
|
|||
* Read current input buffer, if any. Continue with interrupts
|
||||
* disabled.
|
||||
*/
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
if (com->iptr != com->ibuf)
|
||||
sioinput(com);
|
||||
|
||||
|
|
@ -2581,7 +2581,7 @@ comstart(tp)
|
|||
if (com == NULL)
|
||||
return;
|
||||
s = spltty();
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
if (tp->t_state & TS_TTSTOP)
|
||||
com->state &= ~CS_TTGO;
|
||||
else
|
||||
|
|
@ -2594,7 +2594,7 @@ comstart(tp)
|
|||
&& com->state & CS_RTS_IFLOW)
|
||||
outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
|
||||
}
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
if (tp->t_state & (TS_TIMEOUT | TS_TTSTOP)) {
|
||||
ttwwakeup(tp);
|
||||
splx(s);
|
||||
|
|
@ -2610,7 +2610,7 @@ comstart(tp)
|
|||
sizeof com->obuf1);
|
||||
com->obufs[0].l_next = NULL;
|
||||
com->obufs[0].l_queued = TRUE;
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
if (com->state & CS_BUSY) {
|
||||
qp = com->obufq.l_next;
|
||||
while ((next = qp->l_next) != NULL)
|
||||
|
|
@ -2622,7 +2622,7 @@ comstart(tp)
|
|||
com->obufq.l_next = &com->obufs[0];
|
||||
com->state |= CS_BUSY;
|
||||
}
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
}
|
||||
if (tp->t_outq.c_cc != 0 && !com->obufs[1].l_queued) {
|
||||
com->obufs[1].l_tail
|
||||
|
|
@ -2630,7 +2630,7 @@ comstart(tp)
|
|||
sizeof com->obuf2);
|
||||
com->obufs[1].l_next = NULL;
|
||||
com->obufs[1].l_queued = TRUE;
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
if (com->state & CS_BUSY) {
|
||||
qp = com->obufq.l_next;
|
||||
while ((next = qp->l_next) != NULL)
|
||||
|
|
@ -2642,14 +2642,14 @@ comstart(tp)
|
|||
com->obufq.l_next = &com->obufs[1];
|
||||
com->state |= CS_BUSY;
|
||||
}
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
}
|
||||
tp->t_state |= TS_BUSY;
|
||||
}
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
if (com->state >= (CS_BUSY | CS_TTGO))
|
||||
siointr1(com); /* fake interrupt to start output */
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
ttwwakeup(tp);
|
||||
splx(s);
|
||||
}
|
||||
|
|
@ -2664,7 +2664,7 @@ comstop(tp, rw)
|
|||
com = com_addr(DEV_TO_UNIT(tp->t_dev));
|
||||
if (com == NULL || com->gone)
|
||||
return;
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
if (rw & FWRITE) {
|
||||
if (com->hasfifo)
|
||||
#ifdef COM_ESP
|
||||
|
|
@ -2691,7 +2691,7 @@ comstop(tp, rw)
|
|||
com_events -= (com->iptr - com->ibuf);
|
||||
com->iptr = com->ibuf;
|
||||
}
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
comstart(tp);
|
||||
}
|
||||
|
||||
|
|
@ -2734,7 +2734,7 @@ commctl(com, bits, how)
|
|||
mcr |= MCR_RTS;
|
||||
if (com->gone)
|
||||
return(0);
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
switch (how) {
|
||||
case DMSET:
|
||||
outb(com->modem_ctl_port,
|
||||
|
|
@ -2747,7 +2747,7 @@ commctl(com, bits, how)
|
|||
outb(com->modem_ctl_port, com->mcr_image &= ~mcr);
|
||||
break;
|
||||
}
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
@ -2806,9 +2806,9 @@ comwakeup(chan)
|
|||
com = com_addr(unit);
|
||||
if (com != NULL && !com->gone
|
||||
&& (com->state >= (CS_BUSY | CS_TTGO) || com->poll)) {
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
siointr1(com);
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2830,10 +2830,10 @@ comwakeup(chan)
|
|||
u_int delta;
|
||||
u_long total;
|
||||
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
delta = com->delta_error_counts[errnum];
|
||||
com->delta_error_counts[errnum] = 0;
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
if (delta == 0)
|
||||
continue;
|
||||
total = com->error_counts[errnum] += delta;
|
||||
|
|
|
|||
|
|
@ -1182,10 +1182,10 @@ struct sk_softc {
|
|||
struct mtx sk_mtx;
|
||||
};
|
||||
|
||||
#define SK_LOCK(_sc) mtx_enter(&(_sc)->sk_mtx, MTX_DEF)
|
||||
#define SK_UNLOCK(_sc) mtx_exit(&(_sc)->sk_mtx, MTX_DEF)
|
||||
#define SK_IF_LOCK(_sc) mtx_enter(&(_sc)->sk_softc->sk_mtx, MTX_DEF)
|
||||
#define SK_IF_UNLOCK(_sc) mtx_exit(&(_sc)->sk_softc->sk_mtx, MTX_DEF)
|
||||
#define SK_LOCK(_sc) mtx_lock(&(_sc)->sk_mtx)
|
||||
#define SK_UNLOCK(_sc) mtx_unlock(&(_sc)->sk_mtx)
|
||||
#define SK_IF_LOCK(_sc) mtx_lock(&(_sc)->sk_softc->sk_mtx)
|
||||
#define SK_IF_UNLOCK(_sc) mtx_unlock(&(_sc)->sk_softc->sk_mtx)
|
||||
|
||||
/* Softc for each logical interface */
|
||||
struct sk_if_softc {
|
||||
|
|
|
|||
|
|
@ -1147,8 +1147,8 @@ struct ti_softc {
|
|||
struct mtx ti_mtx;
|
||||
};
|
||||
|
||||
#define TI_LOCK(_sc) mtx_enter(&(_sc)->ti_mtx, MTX_DEF)
|
||||
#define TI_UNLOCK(_sc) mtx_exit(&(_sc)->ti_mtx, MTX_DEF)
|
||||
#define TI_LOCK(_sc) mtx_lock(&(_sc)->ti_mtx)
|
||||
#define TI_UNLOCK(_sc) mtx_unlock(&(_sc)->ti_mtx)
|
||||
|
||||
/*
|
||||
* Microchip Technology 24Cxx EEPROM control bytes
|
||||
|
|
|
|||
|
|
@ -249,8 +249,8 @@ struct aue_softc {
|
|||
struct mtx aue_mtx;
|
||||
};
|
||||
|
||||
#define AUE_LOCK(_sc) mtx_enter(&(_sc)->aue_mtx, MTX_DEF)
|
||||
#define AUE_UNLOCK(_sc) mtx_exit(&(_sc)->aue_mtx, MTX_DEF)
|
||||
#define AUE_LOCK(_sc) mtx_lock(&(_sc)->aue_mtx)
|
||||
#define AUE_UNLOCK(_sc) mtx_unlock(&(_sc)->aue_mtx)
|
||||
|
||||
#define AUE_TIMEOUT 1000
|
||||
#define ETHER_ALIGN 2
|
||||
|
|
|
|||
|
|
@ -182,5 +182,5 @@ struct cue_softc {
|
|||
struct mtx cue_mtx;
|
||||
};
|
||||
|
||||
#define CUE_LOCK(_sc) mtx_enter(&(_sc)->cue_mtx, MTX_DEF)
|
||||
#define CUE_UNLOCK(_sc) mtx_exit(&(_sc)->cue_mtx, MTX_DEF)
|
||||
#define CUE_LOCK(_sc) mtx_lock(&(_sc)->cue_mtx)
|
||||
#define CUE_UNLOCK(_sc) mtx_unlock(&(_sc)->cue_mtx)
|
||||
|
|
|
|||
|
|
@ -173,5 +173,5 @@ struct kue_softc {
|
|||
struct mtx kue_mtx;
|
||||
};
|
||||
|
||||
#define KUE_LOCK(_sc) mtx_enter(&(_sc)->kue_mtx, MTX_DEF)
|
||||
#define KUE_UNLOCK(_sc) mtx_exit(&(_sc)->kue_mtx, MTX_DEF)
|
||||
#define KUE_LOCK(_sc) mtx_lock(&(_sc)->kue_mtx)
|
||||
#define KUE_UNLOCK(_sc) mtx_unlock(&(_sc)->kue_mtx)
|
||||
|
|
|
|||
|
|
@ -72,9 +72,9 @@ vinum_daemon(void)
|
|||
PROC_LOCK(curproc);
|
||||
curproc->p_flag |= P_SYSTEM; /* we're a system process */
|
||||
PROC_UNLOCK(curproc);
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
curproc->p_sflag |= PS_INMEM;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
daemon_save_config(); /* start by saving the configuration */
|
||||
daemonpid = curproc->p_pid; /* mark our territory */
|
||||
while (1) {
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ lockrange(daddr_t stripe, struct buf *bp, struct plex *plex)
|
|||
* increment all addresses by 1.
|
||||
*/
|
||||
stripe++;
|
||||
mtx_enter(&plex->lockmtx, MTX_DEF);
|
||||
mtx_lock(&plex->lockmtx);
|
||||
|
||||
/* Wait here if the table is full */
|
||||
while (plex->usedlocks == PLEX_LOCKS) /* all in use */
|
||||
|
|
@ -187,7 +187,7 @@ lockrange(daddr_t stripe, struct buf *bp, struct plex *plex)
|
|||
pos->stripe = stripe;
|
||||
pos->bp = bp;
|
||||
plex->usedlocks++; /* one more lock */
|
||||
mtx_exit(&plex->lockmtx, MTX_DEF);
|
||||
mtx_unlock(&plex->lockmtx);
|
||||
#ifdef VINUMDEBUG
|
||||
if (debug & DEBUG_LASTREQS)
|
||||
logrq(loginfo_lock, (union rqinfou) pos, bp);
|
||||
|
|
|
|||
|
|
@ -414,8 +414,8 @@ struct vr_softc {
|
|||
struct mtx vr_mtx;
|
||||
};
|
||||
|
||||
#define VR_LOCK(_sc) mtx_enter(&(_sc)->vr_mtx, MTX_DEF)
|
||||
#define VR_UNLOCK(_sc) mtx_exit(&(_sc)->vr_mtx, MTX_DEF)
|
||||
#define VR_LOCK(_sc) mtx_lock(&(_sc)->vr_mtx)
|
||||
#define VR_UNLOCK(_sc) mtx_unlock(&(_sc)->vr_mtx)
|
||||
|
||||
/*
|
||||
* register space access macros
|
||||
|
|
|
|||
|
|
@ -128,8 +128,8 @@ struct wi_softc {
|
|||
int wi_prism2; /* set to 1 if it uses a Prism II chip */
|
||||
};
|
||||
|
||||
#define WI_LOCK(_sc) mtx_enter(&(_sc)->wi_mtx, MTX_DEF)
|
||||
#define WI_UNLOCK(_sc) mtx_exit(&(_sc)->wi_mtx, MTX_DEF)
|
||||
#define WI_LOCK(_sc) mtx_lock(&(_sc)->wi_mtx)
|
||||
#define WI_UNLOCK(_sc) mtx_unlock(&(_sc)->wi_mtx)
|
||||
|
||||
#define WI_TIMEOUT 65536
|
||||
|
||||
|
|
|
|||
|
|
@ -102,18 +102,18 @@ cd9660_ihashget(dev, inum)
|
|||
struct vnode *vp;
|
||||
|
||||
loop:
|
||||
mtx_enter(&cd9660_ihash_mtx, MTX_DEF);
|
||||
mtx_lock(&cd9660_ihash_mtx);
|
||||
for (ip = isohashtbl[INOHASH(dev, inum)]; ip; ip = ip->i_next) {
|
||||
if (inum == ip->i_number && dev == ip->i_dev) {
|
||||
vp = ITOV(ip);
|
||||
mtx_enter(&vp->v_interlock, MTX_DEF);
|
||||
mtx_exit(&cd9660_ihash_mtx, MTX_DEF);
|
||||
mtx_lock(&vp->v_interlock);
|
||||
mtx_unlock(&cd9660_ihash_mtx);
|
||||
if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p))
|
||||
goto loop;
|
||||
return (vp);
|
||||
}
|
||||
}
|
||||
mtx_exit(&cd9660_ihash_mtx, MTX_DEF);
|
||||
mtx_unlock(&cd9660_ihash_mtx);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
|
@ -127,14 +127,14 @@ cd9660_ihashins(ip)
|
|||
struct proc *p = curproc; /* XXX */
|
||||
struct iso_node **ipp, *iq;
|
||||
|
||||
mtx_enter(&cd9660_ihash_mtx, MTX_DEF);
|
||||
mtx_lock(&cd9660_ihash_mtx);
|
||||
ipp = &isohashtbl[INOHASH(ip->i_dev, ip->i_number)];
|
||||
if ((iq = *ipp) != NULL)
|
||||
iq->i_prev = &ip->i_next;
|
||||
ip->i_next = iq;
|
||||
ip->i_prev = ipp;
|
||||
*ipp = ip;
|
||||
mtx_exit(&cd9660_ihash_mtx, MTX_DEF);
|
||||
mtx_unlock(&cd9660_ihash_mtx);
|
||||
|
||||
lockmgr(&ip->i_vnode->v_lock, LK_EXCLUSIVE, (struct mtx *)0, p);
|
||||
}
|
||||
|
|
@ -148,7 +148,7 @@ cd9660_ihashrem(ip)
|
|||
{
|
||||
register struct iso_node *iq;
|
||||
|
||||
mtx_enter(&cd9660_ihash_mtx, MTX_DEF);
|
||||
mtx_lock(&cd9660_ihash_mtx);
|
||||
if ((iq = ip->i_next) != NULL)
|
||||
iq->i_prev = ip->i_prev;
|
||||
*ip->i_prev = iq;
|
||||
|
|
@ -156,7 +156,7 @@ cd9660_ihashrem(ip)
|
|||
ip->i_next = NULL;
|
||||
ip->i_prev = NULL;
|
||||
#endif
|
||||
mtx_exit(&cd9660_ihash_mtx, MTX_DEF);
|
||||
mtx_unlock(&cd9660_ihash_mtx);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ dead_lock(ap)
|
|||
* the interlock here.
|
||||
*/
|
||||
if (ap->a_flags & LK_INTERLOCK) {
|
||||
mtx_exit(&vp->v_interlock, MTX_DEF);
|
||||
mtx_unlock(&vp->v_interlock);
|
||||
ap->a_flags &= ~LK_INTERLOCK;
|
||||
}
|
||||
if (!chkvnlock(vp))
|
||||
|
|
|
|||
|
|
@ -92,11 +92,11 @@ hpfs_hphashlookup(dev, ino)
|
|||
{
|
||||
struct hpfsnode *hp;
|
||||
|
||||
mtx_enter(&hpfs_hphash_mtx, MTX_DEF);
|
||||
mtx_lock(&hpfs_hphash_mtx);
|
||||
LIST_FOREACH(hp, HPNOHASH(dev, ino), h_hash)
|
||||
if (ino == hp->h_no && dev == hp->h_dev)
|
||||
break;
|
||||
mtx_exit(&hpfs_hphash_mtx, MTX_DEF);
|
||||
mtx_unlock(&hpfs_hphash_mtx);
|
||||
|
||||
return (hp);
|
||||
}
|
||||
|
|
@ -110,14 +110,14 @@ hpfs_hphashget(dev, ino)
|
|||
struct hpfsnode *hp;
|
||||
|
||||
loop:
|
||||
mtx_enter(&hpfs_hphash_mtx, MTX_DEF);
|
||||
mtx_lock(&hpfs_hphash_mtx);
|
||||
LIST_FOREACH(hp, HPNOHASH(dev, ino), h_hash) {
|
||||
if (ino == hp->h_no && dev == hp->h_dev) {
|
||||
LOCKMGR(&hp->h_intlock, LK_EXCLUSIVE | LK_INTERLOCK, &hpfs_hphash_slock, NULL);
|
||||
return (hp);
|
||||
}
|
||||
}
|
||||
mtx_exit(&hpfs_hphash_mtx, MTX_DEF);
|
||||
mtx_unlock(&hpfs_hphash_mtx);
|
||||
return (hp);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -132,18 +132,18 @@ hpfs_hphashvget(dev, ino, p)
|
|||
struct vnode *vp;
|
||||
|
||||
loop:
|
||||
mtx_enter(&hpfs_hphash_mtx, MTX_DEF);
|
||||
mtx_lock(&hpfs_hphash_mtx);
|
||||
LIST_FOREACH(hp, HPNOHASH(dev, ino), h_hash) {
|
||||
if (ino == hp->h_no && dev == hp->h_dev) {
|
||||
vp = HPTOV(hp);
|
||||
mtx_enter(&vp->v_interlock, MTX_DEF);
|
||||
mtx_exit(&hpfs_hphash_mtx, MTX_DEF);
|
||||
mtx_lock(&vp->v_interlock);
|
||||
mtx_unlock(&hpfs_hphash_mtx);
|
||||
if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p))
|
||||
goto loop;
|
||||
return (vp);
|
||||
}
|
||||
}
|
||||
mtx_exit(&hpfs_hphash_mtx, MTX_DEF);
|
||||
mtx_unlock(&hpfs_hphash_mtx);
|
||||
return (NULLVP);
|
||||
}
|
||||
|
||||
|
|
@ -156,11 +156,11 @@ hpfs_hphashins(hp)
|
|||
{
|
||||
struct hphashhead *hpp;
|
||||
|
||||
mtx_enter(&hpfs_hphash_mtx, MTX_DEF);
|
||||
mtx_lock(&hpfs_hphash_mtx);
|
||||
hpp = HPNOHASH(hp->h_dev, hp->h_no);
|
||||
hp->h_flag |= H_HASHED;
|
||||
LIST_INSERT_HEAD(hpp, hp, h_hash);
|
||||
mtx_exit(&hpfs_hphash_mtx, MTX_DEF);
|
||||
mtx_unlock(&hpfs_hphash_mtx);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -170,10 +170,10 @@ void
|
|||
hpfs_hphashrem(hp)
|
||||
struct hpfsnode *hp;
|
||||
{
|
||||
mtx_enter(&hpfs_hphash_mtx, MTX_DEF);
|
||||
mtx_lock(&hpfs_hphash_mtx);
|
||||
if (hp->h_flag & H_HASHED) {
|
||||
hp->h_flag &= ~H_HASHED;
|
||||
LIST_REMOVE(hp, h_hash);
|
||||
}
|
||||
mtx_exit(&hpfs_hphash_mtx, MTX_DEF);
|
||||
mtx_unlock(&hpfs_hphash_mtx);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,21 +130,21 @@ msdosfs_hashget(dev, dirclust, diroff)
|
|||
struct vnode *vp;
|
||||
|
||||
loop:
|
||||
mtx_enter(&dehash_mtx, MTX_DEF);
|
||||
mtx_lock(&dehash_mtx);
|
||||
for (dep = DEHASH(dev, dirclust, diroff); dep; dep = dep->de_next) {
|
||||
if (dirclust == dep->de_dirclust
|
||||
&& diroff == dep->de_diroffset
|
||||
&& dev == dep->de_dev
|
||||
&& dep->de_refcnt != 0) {
|
||||
vp = DETOV(dep);
|
||||
mtx_enter(&vp->v_interlock, MTX_DEF);
|
||||
mtx_exit(&dehash_mtx, MTX_DEF);
|
||||
mtx_lock(&vp->v_interlock);
|
||||
mtx_unlock(&dehash_mtx);
|
||||
if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p))
|
||||
goto loop;
|
||||
return (dep);
|
||||
}
|
||||
}
|
||||
mtx_exit(&dehash_mtx, MTX_DEF);
|
||||
mtx_unlock(&dehash_mtx);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ msdosfs_hashins(dep)
|
|||
{
|
||||
struct denode **depp, *deq;
|
||||
|
||||
mtx_enter(&dehash_mtx, MTX_DEF);
|
||||
mtx_lock(&dehash_mtx);
|
||||
depp = &DEHASH(dep->de_dev, dep->de_dirclust, dep->de_diroffset);
|
||||
deq = *depp;
|
||||
if (deq)
|
||||
|
|
@ -162,7 +162,7 @@ msdosfs_hashins(dep)
|
|||
dep->de_next = deq;
|
||||
dep->de_prev = depp;
|
||||
*depp = dep;
|
||||
mtx_exit(&dehash_mtx, MTX_DEF);
|
||||
mtx_unlock(&dehash_mtx);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -171,7 +171,7 @@ msdosfs_hashrem(dep)
|
|||
{
|
||||
struct denode *deq;
|
||||
|
||||
mtx_enter(&dehash_mtx, MTX_DEF);
|
||||
mtx_lock(&dehash_mtx);
|
||||
deq = dep->de_next;
|
||||
if (deq)
|
||||
deq->de_prev = dep->de_prev;
|
||||
|
|
@ -180,7 +180,7 @@ msdosfs_hashrem(dep)
|
|||
dep->de_next = NULL;
|
||||
dep->de_prev = NULL;
|
||||
#endif
|
||||
mtx_exit(&dehash_mtx, MTX_DEF);
|
||||
mtx_unlock(&dehash_mtx);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -862,7 +862,7 @@ msdosfs_sync(mp, waitfor, cred, p)
|
|||
/*
|
||||
* Write back each (modified) denode.
|
||||
*/
|
||||
mtx_enter(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_lock(&mntvnode_mtx);
|
||||
loop:
|
||||
for (vp = LIST_FIRST(&mp->mnt_vnodelist); vp != NULL; vp = nvp) {
|
||||
/*
|
||||
|
|
@ -872,20 +872,20 @@ loop:
|
|||
if (vp->v_mount != mp)
|
||||
goto loop;
|
||||
|
||||
mtx_enter(&vp->v_interlock, MTX_DEF);
|
||||
mtx_lock(&vp->v_interlock);
|
||||
nvp = LIST_NEXT(vp, v_mntvnodes);
|
||||
dep = VTODE(vp);
|
||||
if (vp->v_type == VNON ||
|
||||
((dep->de_flag &
|
||||
(DE_ACCESS | DE_CREATE | DE_UPDATE | DE_MODIFIED)) == 0 &&
|
||||
(TAILQ_EMPTY(&vp->v_dirtyblkhd) || waitfor == MNT_LAZY))) {
|
||||
mtx_exit(&vp->v_interlock, MTX_DEF);
|
||||
mtx_unlock(&vp->v_interlock);
|
||||
continue;
|
||||
}
|
||||
mtx_exit(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_unlock(&mntvnode_mtx);
|
||||
error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, p);
|
||||
if (error) {
|
||||
mtx_enter(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_lock(&mntvnode_mtx);
|
||||
if (error == ENOENT)
|
||||
goto loop;
|
||||
continue;
|
||||
|
|
@ -895,9 +895,9 @@ loop:
|
|||
allerror = error;
|
||||
VOP_UNLOCK(vp, 0, p);
|
||||
vrele(vp);
|
||||
mtx_enter(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_lock(&mntvnode_mtx);
|
||||
}
|
||||
mtx_exit(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_unlock(&mntvnode_mtx);
|
||||
|
||||
/*
|
||||
* Flush filesystem control info.
|
||||
|
|
|
|||
|
|
@ -233,12 +233,12 @@ msdosfs_close(ap)
|
|||
struct denode *dep = VTODE(vp);
|
||||
struct timespec ts;
|
||||
|
||||
mtx_enter(&vp->v_interlock, MTX_DEF);
|
||||
mtx_lock(&vp->v_interlock);
|
||||
if (vp->v_usecount > 1) {
|
||||
getnanotime(&ts);
|
||||
DETIMES(dep, &ts, &ts, &ts);
|
||||
}
|
||||
mtx_exit(&vp->v_interlock, MTX_DEF);
|
||||
mtx_unlock(&vp->v_interlock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,11 +93,11 @@ ntfs_nthashlookup(dev, inum)
|
|||
{
|
||||
struct ntnode *ip;
|
||||
|
||||
mtx_enter(&ntfs_nthash_mtx, MTX_DEF);
|
||||
mtx_lock(&ntfs_nthash_mtx);
|
||||
LIST_FOREACH(ip, NTNOHASH(dev, inum), i_hash)
|
||||
if (inum == ip->i_number && dev == ip->i_dev)
|
||||
break;
|
||||
mtx_exit(&ntfs_nthash_mtx, MTX_DEF);
|
||||
mtx_unlock(&ntfs_nthash_mtx);
|
||||
|
||||
return (ip);
|
||||
}
|
||||
|
|
@ -111,11 +111,11 @@ ntfs_nthashins(ip)
|
|||
{
|
||||
struct nthashhead *ipp;
|
||||
|
||||
mtx_enter(&ntfs_nthash_mtx, MTX_DEF);
|
||||
mtx_lock(&ntfs_nthash_mtx);
|
||||
ipp = NTNOHASH(ip->i_dev, ip->i_number);
|
||||
LIST_INSERT_HEAD(ipp, ip, i_hash);
|
||||
ip->i_flag |= IN_HASHED;
|
||||
mtx_exit(&ntfs_nthash_mtx, MTX_DEF);
|
||||
mtx_unlock(&ntfs_nthash_mtx);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -125,10 +125,10 @@ void
|
|||
ntfs_nthashrem(ip)
|
||||
struct ntnode *ip;
|
||||
{
|
||||
mtx_enter(&ntfs_nthash_mtx, MTX_DEF);
|
||||
mtx_lock(&ntfs_nthash_mtx);
|
||||
if (ip->i_flag & IN_HASHED) {
|
||||
ip->i_flag &= ~IN_HASHED;
|
||||
LIST_REMOVE(ip, i_hash);
|
||||
}
|
||||
mtx_exit(&ntfs_nthash_mtx, MTX_DEF);
|
||||
mtx_unlock(&ntfs_nthash_mtx);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -360,7 +360,7 @@ ntfs_ntget(ip)
|
|||
dprintf(("ntfs_ntget: get ntnode %d: %p, usecount: %d\n",
|
||||
ip->i_number, ip, ip->i_usecount));
|
||||
|
||||
mtx_enter(&ip->i_interlock, MTX_DEF);
|
||||
mtx_lock(&ip->i_interlock);
|
||||
ip->i_usecount++;
|
||||
LOCKMGR(&ip->i_lock, LK_EXCLUSIVE | LK_INTERLOCK, &ip->i_interlock);
|
||||
|
||||
|
|
@ -438,7 +438,7 @@ ntfs_ntput(ip)
|
|||
dprintf(("ntfs_ntput: rele ntnode %d: %p, usecount: %d\n",
|
||||
ip->i_number, ip, ip->i_usecount));
|
||||
|
||||
mtx_enter(&ip->i_interlock, MTX_DEF);
|
||||
mtx_lock(&ip->i_interlock);
|
||||
ip->i_usecount--;
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
|
|
@ -462,7 +462,7 @@ ntfs_ntput(ip)
|
|||
LIST_REMOVE(vap,va_list);
|
||||
ntfs_freentvattr(vap);
|
||||
}
|
||||
mtx_exit(&ip->i_interlock, MTX_DEF);
|
||||
mtx_unlock(&ip->i_interlock);
|
||||
mtx_destroy(&ip->i_interlock);
|
||||
lockdestroy(&ip->i_lock);
|
||||
|
||||
|
|
@ -479,9 +479,9 @@ void
|
|||
ntfs_ntref(ip)
|
||||
struct ntnode *ip;
|
||||
{
|
||||
mtx_enter(&ip->i_interlock, MTX_DEF);
|
||||
mtx_lock(&ip->i_interlock);
|
||||
ip->i_usecount++;
|
||||
mtx_exit(&ip->i_interlock, MTX_DEF);
|
||||
mtx_unlock(&ip->i_interlock);
|
||||
|
||||
dprintf(("ntfs_ntref: ino %d, usecount: %d\n",
|
||||
ip->i_number, ip->i_usecount));
|
||||
|
|
@ -498,13 +498,13 @@ ntfs_ntrele(ip)
|
|||
dprintf(("ntfs_ntrele: rele ntnode %d: %p, usecount: %d\n",
|
||||
ip->i_number, ip, ip->i_usecount));
|
||||
|
||||
mtx_enter(&ip->i_interlock, MTX_DEF);
|
||||
mtx_lock(&ip->i_interlock);
|
||||
ip->i_usecount--;
|
||||
|
||||
if (ip->i_usecount < 0)
|
||||
panic("ntfs_ntrele: ino: %d usecount: %d \n",
|
||||
ip->i_number,ip->i_usecount);
|
||||
mtx_exit(&ip->i_interlock, MTX_DEF);
|
||||
mtx_unlock(&ip->i_interlock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -196,9 +196,9 @@ ntfs_mountroot()
|
|||
return (error);
|
||||
}
|
||||
|
||||
mtx_enter(&mountlist_mtx, MTX_DEF);
|
||||
mtx_lock(&mountlist_mtx);
|
||||
TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list);
|
||||
mtx_exit(&mountlist_mtx, MTX_DEF);
|
||||
mtx_unlock(&mountlist_mtx);
|
||||
(void)ntfs_statfs(mp, &mp->mnt_stat, p);
|
||||
vfs_unbusy(mp);
|
||||
return (0);
|
||||
|
|
|
|||
|
|
@ -624,7 +624,7 @@ null_lock(ap)
|
|||
if (lvp == NULL)
|
||||
return (lockmgr(&vp->v_lock, flags, &vp->v_interlock, p));
|
||||
if (flags & LK_INTERLOCK) {
|
||||
mtx_exit(&vp->v_interlock, MTX_DEF);
|
||||
mtx_unlock(&vp->v_interlock);
|
||||
flags &= ~LK_INTERLOCK;
|
||||
}
|
||||
if ((flags & LK_TYPE_MASK) == LK_DRAIN) {
|
||||
|
|
@ -671,7 +671,7 @@ null_unlock(ap)
|
|||
return (lockmgr(&vp->v_lock, flags | LK_RELEASE, &vp->v_interlock, p));
|
||||
if ((flags & LK_THISLAYER) == 0) {
|
||||
if (flags & LK_INTERLOCK) {
|
||||
mtx_exit(&vp->v_interlock, MTX_DEF);
|
||||
mtx_unlock(&vp->v_interlock);
|
||||
flags &= ~LK_INTERLOCK;
|
||||
}
|
||||
VOP_UNLOCK(lvp, flags & ~LK_INTERLOCK, p);
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ loop:
|
|||
rescan:
|
||||
if (nwfs_hashlookup(nmp, fid, &np) == 0) {
|
||||
vp = NWTOV(np);
|
||||
mtx_enter(&vp->v_interlock, MTX_DEF);
|
||||
mtx_lock(&vp->v_interlock);
|
||||
lockmgr(&nwhashlock, LK_RELEASE, NULL, p);
|
||||
if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p))
|
||||
goto loop;
|
||||
|
|
|
|||
|
|
@ -256,24 +256,24 @@ nwfs_close(ap)
|
|||
|
||||
if (vp->v_type == VDIR) return 0; /* nothing to do now */
|
||||
error = 0;
|
||||
mtx_enter(&vp->v_interlock, MTX_DEF);
|
||||
mtx_lock(&vp->v_interlock);
|
||||
if (np->opened == 0) {
|
||||
mtx_exit(&vp->v_interlock, MTX_DEF);
|
||||
mtx_unlock(&vp->v_interlock);
|
||||
return 0;
|
||||
}
|
||||
mtx_exit(&vp->v_interlock, MTX_DEF);
|
||||
mtx_unlock(&vp->v_interlock);
|
||||
error = nwfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p, 1);
|
||||
mtx_enter(&vp->v_interlock, MTX_DEF);
|
||||
mtx_lock(&vp->v_interlock);
|
||||
if (np->opened == 0) {
|
||||
mtx_exit(&vp->v_interlock, MTX_DEF);
|
||||
mtx_unlock(&vp->v_interlock);
|
||||
return 0;
|
||||
}
|
||||
if (--np->opened == 0) {
|
||||
mtx_exit(&vp->v_interlock, MTX_DEF);
|
||||
mtx_unlock(&vp->v_interlock);
|
||||
error = ncp_close_file(NWFSTOCONN(VTONWFS(vp)), &np->n_fh,
|
||||
ap->a_p, ap->a_cred);
|
||||
} else
|
||||
mtx_exit(&vp->v_interlock, MTX_DEF);
|
||||
mtx_unlock(&vp->v_interlock);
|
||||
np->n_atime = 0;
|
||||
return (error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,13 +167,13 @@ procfs_control(curp, p, op)
|
|||
|
||||
default:
|
||||
PROCTREE_LOCK(PT_SHARED);
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (!TRACE_WAIT_P(curp, p)) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
PROCTREE_LOCK(PT_RELEASE);
|
||||
return (EBUSY);
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
PROCTREE_LOCK(PT_RELEASE);
|
||||
}
|
||||
|
||||
|
|
@ -252,31 +252,31 @@ procfs_control(curp, p, op)
|
|||
error = 0;
|
||||
if (p->p_flag & P_TRACED) {
|
||||
PROCTREE_LOCK(PT_SHARED);
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
while (error == 0 &&
|
||||
(p->p_stat != SSTOP) &&
|
||||
(p->p_flag & P_TRACED) &&
|
||||
(p->p_pptr == curp)) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
PROCTREE_LOCK(PT_RELEASE);
|
||||
error = tsleep((caddr_t) p,
|
||||
PWAIT|PCATCH, "procfsx", 0);
|
||||
PROCTREE_LOCK(PT_SHARED);
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
}
|
||||
if (error == 0 && !TRACE_WAIT_P(curp, p))
|
||||
error = EBUSY;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
PROCTREE_LOCK(PT_RELEASE);
|
||||
} else {
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
while (error == 0 && p->p_stat != SSTOP) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
error = tsleep((caddr_t) p,
|
||||
PWAIT|PCATCH, "procfs", 0);
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
return (error);
|
||||
|
||||
|
|
@ -284,10 +284,10 @@ procfs_control(curp, p, op)
|
|||
panic("procfs_control");
|
||||
}
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (p->p_stat == SSTOP)
|
||||
setrunnable(p);
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
@ -329,17 +329,17 @@ procfs_doctl(curp, p, pfs, uio)
|
|||
nm = vfs_findname(signames, msg, xlen);
|
||||
if (nm) {
|
||||
PROCTREE_LOCK(PT_SHARED);
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (TRACE_WAIT_P(curp, p)) {
|
||||
p->p_xstat = nm->nm_val;
|
||||
#ifdef FIX_SSTEP
|
||||
FIX_SSTEP(p);
|
||||
#endif
|
||||
setrunnable(p);
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
PROCTREE_LOCK(PT_RELEASE);
|
||||
} else {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
PROCTREE_LOCK(PT_RELEASE);
|
||||
psignal(p, nm->nm_val);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,12 +123,12 @@ procfs_dostatus(curp, p, pfs, uio)
|
|||
DOCHECK();
|
||||
}
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (p->p_sflag & PS_INMEM) {
|
||||
struct timeval ut, st;
|
||||
|
||||
calcru(p, &ut, &st, (struct timeval *) NULL);
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
ps += snprintf(ps, psbuf + sizeof(psbuf) - ps,
|
||||
" %ld,%ld %ld,%ld %ld,%ld",
|
||||
p->p_stats->p_start.tv_sec,
|
||||
|
|
@ -136,7 +136,7 @@ procfs_dostatus(curp, p, pfs, uio)
|
|||
ut.tv_sec, ut.tv_usec,
|
||||
st.tv_sec, st.tv_usec);
|
||||
} else {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
ps += snprintf(ps, psbuf + sizeof(psbuf) - ps,
|
||||
" -1,-1 -1,-1 -1,-1");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,11 +77,11 @@ ufs_ihashlookup(dev, inum)
|
|||
{
|
||||
struct inode *ip;
|
||||
|
||||
mtx_enter(&ufs_ihash_mtx, MTX_DEF);
|
||||
mtx_lock(&ufs_ihash_mtx);
|
||||
LIST_FOREACH(ip, INOHASH(dev, inum), i_hash)
|
||||
if (inum == ip->i_number && dev == ip->i_dev)
|
||||
break;
|
||||
mtx_exit(&ufs_ihash_mtx, MTX_DEF);
|
||||
mtx_unlock(&ufs_ihash_mtx);
|
||||
|
||||
if (ip)
|
||||
return (ITOV(ip));
|
||||
|
|
@ -102,18 +102,18 @@ ufs_ihashget(dev, inum)
|
|||
struct vnode *vp;
|
||||
|
||||
loop:
|
||||
mtx_enter(&ufs_ihash_mtx, MTX_DEF);
|
||||
mtx_lock(&ufs_ihash_mtx);
|
||||
LIST_FOREACH(ip, INOHASH(dev, inum), i_hash) {
|
||||
if (inum == ip->i_number && dev == ip->i_dev) {
|
||||
vp = ITOV(ip);
|
||||
mtx_enter(&vp->v_interlock, MTX_DEF);
|
||||
mtx_exit(&ufs_ihash_mtx, MTX_DEF);
|
||||
mtx_lock(&vp->v_interlock);
|
||||
mtx_unlock(&ufs_ihash_mtx);
|
||||
if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p))
|
||||
goto loop;
|
||||
return (vp);
|
||||
}
|
||||
}
|
||||
mtx_exit(&ufs_ihash_mtx, MTX_DEF);
|
||||
mtx_unlock(&ufs_ihash_mtx);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
|
@ -130,11 +130,11 @@ ufs_ihashins(ip)
|
|||
/* lock the inode, then put it on the appropriate hash list */
|
||||
lockmgr(&ip->i_vnode->v_lock, LK_EXCLUSIVE, (struct mtx *)0, p);
|
||||
|
||||
mtx_enter(&ufs_ihash_mtx, MTX_DEF);
|
||||
mtx_lock(&ufs_ihash_mtx);
|
||||
ipp = INOHASH(ip->i_dev, ip->i_number);
|
||||
LIST_INSERT_HEAD(ipp, ip, i_hash);
|
||||
ip->i_flag |= IN_HASHED;
|
||||
mtx_exit(&ufs_ihash_mtx, MTX_DEF);
|
||||
mtx_unlock(&ufs_ihash_mtx);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -144,10 +144,10 @@ void
|
|||
ufs_ihashrem(ip)
|
||||
struct inode *ip;
|
||||
{
|
||||
mtx_enter(&ufs_ihash_mtx, MTX_DEF);
|
||||
mtx_lock(&ufs_ihash_mtx);
|
||||
if (ip->i_flag & IN_HASHED) {
|
||||
ip->i_flag &= ~IN_HASHED;
|
||||
LIST_REMOVE(ip, i_hash);
|
||||
}
|
||||
mtx_exit(&ufs_ihash_mtx, MTX_DEF);
|
||||
mtx_unlock(&ufs_ihash_mtx);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -561,10 +561,10 @@ ext2_reload(mountp, cred, p)
|
|||
brelse(bp);
|
||||
|
||||
loop:
|
||||
mtx_enter(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_lock(&mntvnode_mtx);
|
||||
for (vp = LIST_FIRST(&mountp->mnt_vnodelist); vp != NULL; vp = nvp) {
|
||||
if (vp->v_mount != mountp) {
|
||||
mtx_exit(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_unlock(&mntvnode_mtx);
|
||||
goto loop;
|
||||
}
|
||||
nvp = LIST_NEXT(vp, v_mntvnodes);
|
||||
|
|
@ -576,8 +576,8 @@ loop:
|
|||
/*
|
||||
* Step 5: invalidate all cached file data.
|
||||
*/
|
||||
mtx_enter(&vp->v_interlock, MTX_DEF);
|
||||
mtx_exit(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_lock(&vp->v_interlock);
|
||||
mtx_unlock(&mntvnode_mtx);
|
||||
if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) {
|
||||
goto loop;
|
||||
}
|
||||
|
|
@ -599,9 +599,9 @@ loop:
|
|||
&ip->i_din);
|
||||
brelse(bp);
|
||||
vput(vp);
|
||||
mtx_enter(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_lock(&mntvnode_mtx);
|
||||
}
|
||||
mtx_exit(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_unlock(&mntvnode_mtx);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
@ -918,7 +918,7 @@ ext2_sync(mp, waitfor, cred, p)
|
|||
/*
|
||||
* Write back each (modified) inode.
|
||||
*/
|
||||
mtx_enter(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_lock(&mntvnode_mtx);
|
||||
loop:
|
||||
for (vp = LIST_FIRST(&mp->mnt_vnodelist); vp != NULL; vp = nvp) {
|
||||
/*
|
||||
|
|
@ -927,20 +927,20 @@ loop:
|
|||
*/
|
||||
if (vp->v_mount != mp)
|
||||
goto loop;
|
||||
mtx_enter(&vp->v_interlock, MTX_DEF);
|
||||
mtx_lock(&vp->v_interlock);
|
||||
nvp = LIST_NEXT(vp, v_mntvnodes);
|
||||
ip = VTOI(vp);
|
||||
if (vp->v_type == VNON ||
|
||||
((ip->i_flag &
|
||||
(IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0 &&
|
||||
(TAILQ_EMPTY(&vp->v_dirtyblkhd) || waitfor == MNT_LAZY))) {
|
||||
mtx_exit(&vp->v_interlock, MTX_DEF);
|
||||
mtx_unlock(&vp->v_interlock);
|
||||
continue;
|
||||
}
|
||||
mtx_exit(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_unlock(&mntvnode_mtx);
|
||||
error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, p);
|
||||
if (error) {
|
||||
mtx_enter(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_lock(&mntvnode_mtx);
|
||||
if (error == ENOENT)
|
||||
goto loop;
|
||||
continue;
|
||||
|
|
@ -949,9 +949,9 @@ loop:
|
|||
allerror = error;
|
||||
VOP_UNLOCK(vp, 0, p);
|
||||
vrele(vp);
|
||||
mtx_enter(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_lock(&mntvnode_mtx);
|
||||
}
|
||||
mtx_exit(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_unlock(&mntvnode_mtx);
|
||||
/*
|
||||
* Force stale file system control information to be flushed.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -561,10 +561,10 @@ ext2_reload(mountp, cred, p)
|
|||
brelse(bp);
|
||||
|
||||
loop:
|
||||
mtx_enter(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_lock(&mntvnode_mtx);
|
||||
for (vp = LIST_FIRST(&mountp->mnt_vnodelist); vp != NULL; vp = nvp) {
|
||||
if (vp->v_mount != mountp) {
|
||||
mtx_exit(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_unlock(&mntvnode_mtx);
|
||||
goto loop;
|
||||
}
|
||||
nvp = LIST_NEXT(vp, v_mntvnodes);
|
||||
|
|
@ -576,8 +576,8 @@ loop:
|
|||
/*
|
||||
* Step 5: invalidate all cached file data.
|
||||
*/
|
||||
mtx_enter(&vp->v_interlock, MTX_DEF);
|
||||
mtx_exit(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_lock(&vp->v_interlock);
|
||||
mtx_unlock(&mntvnode_mtx);
|
||||
if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) {
|
||||
goto loop;
|
||||
}
|
||||
|
|
@ -599,9 +599,9 @@ loop:
|
|||
&ip->i_din);
|
||||
brelse(bp);
|
||||
vput(vp);
|
||||
mtx_enter(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_lock(&mntvnode_mtx);
|
||||
}
|
||||
mtx_exit(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_unlock(&mntvnode_mtx);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
@ -918,7 +918,7 @@ ext2_sync(mp, waitfor, cred, p)
|
|||
/*
|
||||
* Write back each (modified) inode.
|
||||
*/
|
||||
mtx_enter(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_lock(&mntvnode_mtx);
|
||||
loop:
|
||||
for (vp = LIST_FIRST(&mp->mnt_vnodelist); vp != NULL; vp = nvp) {
|
||||
/*
|
||||
|
|
@ -927,20 +927,20 @@ loop:
|
|||
*/
|
||||
if (vp->v_mount != mp)
|
||||
goto loop;
|
||||
mtx_enter(&vp->v_interlock, MTX_DEF);
|
||||
mtx_lock(&vp->v_interlock);
|
||||
nvp = LIST_NEXT(vp, v_mntvnodes);
|
||||
ip = VTOI(vp);
|
||||
if (vp->v_type == VNON ||
|
||||
((ip->i_flag &
|
||||
(IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0 &&
|
||||
(TAILQ_EMPTY(&vp->v_dirtyblkhd) || waitfor == MNT_LAZY))) {
|
||||
mtx_exit(&vp->v_interlock, MTX_DEF);
|
||||
mtx_unlock(&vp->v_interlock);
|
||||
continue;
|
||||
}
|
||||
mtx_exit(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_unlock(&mntvnode_mtx);
|
||||
error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, p);
|
||||
if (error) {
|
||||
mtx_enter(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_lock(&mntvnode_mtx);
|
||||
if (error == ENOENT)
|
||||
goto loop;
|
||||
continue;
|
||||
|
|
@ -949,9 +949,9 @@ loop:
|
|||
allerror = error;
|
||||
VOP_UNLOCK(vp, 0, p);
|
||||
vrele(vp);
|
||||
mtx_enter(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_lock(&mntvnode_mtx);
|
||||
}
|
||||
mtx_exit(&mntvnode_mtx, MTX_DEF);
|
||||
mtx_unlock(&mntvnode_mtx);
|
||||
/*
|
||||
* Force stale file system control information to be flushed.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1910,7 +1910,7 @@ init386(first)
|
|||
* Giant is used early for at least debugger traps and unexpected traps.
|
||||
*/
|
||||
mtx_init(&Giant, "Giant", MTX_DEF | MTX_RECURSE);
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
|
||||
/* make ldt memory segments */
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -2268,7 +2268,7 @@ ap_init(void)
|
|||
PCPU_SET(curproc, PCPU_GET(idleproc));
|
||||
|
||||
/* lock against other AP's that are waking up */
|
||||
mtx_enter(&ap_boot_mtx, MTX_SPIN);
|
||||
mtx_lock_spin(&ap_boot_mtx);
|
||||
|
||||
/* BSP may have changed PTD while we're waiting for the lock */
|
||||
cpu_invltlb();
|
||||
|
|
@ -2317,7 +2317,7 @@ ap_init(void)
|
|||
}
|
||||
|
||||
/* let other AP's wake up now */
|
||||
mtx_exit(&ap_boot_mtx, MTX_SPIN);
|
||||
mtx_unlock_spin(&ap_boot_mtx);
|
||||
|
||||
/* wait until all the AP's are up */
|
||||
while (smp_started == 0)
|
||||
|
|
@ -2328,7 +2328,7 @@ ap_init(void)
|
|||
|
||||
/* ok, now grab sched_lock and enter the scheduler */
|
||||
enable_intr();
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
cpu_throw(); /* doesn't return */
|
||||
|
||||
panic("scheduler returned us to ap_init");
|
||||
|
|
@ -2662,14 +2662,14 @@ forward_signal(struct proc *p)
|
|||
return;
|
||||
if (!forward_signal_enabled)
|
||||
return;
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
while (1) {
|
||||
if (p->p_stat != SRUN) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return;
|
||||
}
|
||||
id = p->p_oncpu;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
if (id == 0xff)
|
||||
return;
|
||||
map = (1<<id);
|
||||
|
|
@ -2687,9 +2687,9 @@ forward_signal(struct proc *p)
|
|||
break;
|
||||
}
|
||||
}
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (id == p->p_oncpu) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -2867,7 +2867,7 @@ smp_rendezvous(void (* setup_func)(void *),
|
|||
{
|
||||
|
||||
/* obtain rendezvous lock */
|
||||
mtx_enter(&smp_rv_mtx, MTX_SPIN);
|
||||
mtx_lock_spin(&smp_rv_mtx);
|
||||
|
||||
/* set static function pointers */
|
||||
smp_rv_setup_func = setup_func;
|
||||
|
|
@ -2886,7 +2886,7 @@ smp_rendezvous(void (* setup_func)(void *),
|
|||
smp_rendezvous_action();
|
||||
|
||||
/* release lock */
|
||||
mtx_exit(&smp_rv_mtx, MTX_SPIN);
|
||||
mtx_unlock_spin(&smp_rv_mtx);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -210,11 +210,11 @@ io_apic_setup_intpin(int apic, int pin)
|
|||
* shouldn't and stop the carnage.
|
||||
*/
|
||||
vector = NRSVIDT + pin; /* IDT vec */
|
||||
mtx_enter(&imen_mtx, MTX_SPIN);
|
||||
mtx_lock_spin(&imen_mtx);
|
||||
io_apic_write(apic, select,
|
||||
(io_apic_read(apic, select) & ~IOART_INTMASK
|
||||
& ~0xff)|IOART_INTMSET|vector);
|
||||
mtx_exit(&imen_mtx, MTX_SPIN);
|
||||
mtx_unlock_spin(&imen_mtx);
|
||||
|
||||
/* we only deal with vectored INTs here */
|
||||
if (apic_int_type(apic, pin) != 0)
|
||||
|
|
@ -258,10 +258,10 @@ io_apic_setup_intpin(int apic, int pin)
|
|||
printf("IOAPIC #%d intpin %d -> irq %d\n",
|
||||
apic, pin, irq);
|
||||
vector = NRSVIDT + irq; /* IDT vec */
|
||||
mtx_enter(&imen_mtx, MTX_SPIN);
|
||||
mtx_lock_spin(&imen_mtx);
|
||||
io_apic_write(apic, select, flags | vector);
|
||||
io_apic_write(apic, select + 1, target);
|
||||
mtx_exit(&imen_mtx, MTX_SPIN);
|
||||
mtx_unlock_spin(&imen_mtx);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
|||
|
|
@ -2268,7 +2268,7 @@ ap_init(void)
|
|||
PCPU_SET(curproc, PCPU_GET(idleproc));
|
||||
|
||||
/* lock against other AP's that are waking up */
|
||||
mtx_enter(&ap_boot_mtx, MTX_SPIN);
|
||||
mtx_lock_spin(&ap_boot_mtx);
|
||||
|
||||
/* BSP may have changed PTD while we're waiting for the lock */
|
||||
cpu_invltlb();
|
||||
|
|
@ -2317,7 +2317,7 @@ ap_init(void)
|
|||
}
|
||||
|
||||
/* let other AP's wake up now */
|
||||
mtx_exit(&ap_boot_mtx, MTX_SPIN);
|
||||
mtx_unlock_spin(&ap_boot_mtx);
|
||||
|
||||
/* wait until all the AP's are up */
|
||||
while (smp_started == 0)
|
||||
|
|
@ -2328,7 +2328,7 @@ ap_init(void)
|
|||
|
||||
/* ok, now grab sched_lock and enter the scheduler */
|
||||
enable_intr();
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
cpu_throw(); /* doesn't return */
|
||||
|
||||
panic("scheduler returned us to ap_init");
|
||||
|
|
@ -2662,14 +2662,14 @@ forward_signal(struct proc *p)
|
|||
return;
|
||||
if (!forward_signal_enabled)
|
||||
return;
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
while (1) {
|
||||
if (p->p_stat != SRUN) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return;
|
||||
}
|
||||
id = p->p_oncpu;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
if (id == 0xff)
|
||||
return;
|
||||
map = (1<<id);
|
||||
|
|
@ -2687,9 +2687,9 @@ forward_signal(struct proc *p)
|
|||
break;
|
||||
}
|
||||
}
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (id == p->p_oncpu) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -2867,7 +2867,7 @@ smp_rendezvous(void (* setup_func)(void *),
|
|||
{
|
||||
|
||||
/* obtain rendezvous lock */
|
||||
mtx_enter(&smp_rv_mtx, MTX_SPIN);
|
||||
mtx_lock_spin(&smp_rv_mtx);
|
||||
|
||||
/* set static function pointers */
|
||||
smp_rv_setup_func = setup_func;
|
||||
|
|
@ -2886,7 +2886,7 @@ smp_rendezvous(void (* setup_func)(void *),
|
|||
smp_rendezvous_action();
|
||||
|
||||
/* release lock */
|
||||
mtx_exit(&smp_rv_mtx, MTX_SPIN);
|
||||
mtx_unlock_spin(&smp_rv_mtx);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -86,12 +86,12 @@ procfs_read_regs(p, regs)
|
|||
struct reg *regs;
|
||||
{
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if ((p->p_sflag & PS_INMEM) == 0) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (EIO);
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (fill_regs(p, regs));
|
||||
}
|
||||
|
||||
|
|
@ -101,12 +101,12 @@ procfs_write_regs(p, regs)
|
|||
struct reg *regs;
|
||||
{
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if ((p->p_sflag & PS_INMEM) == 0) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (EIO);
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (set_regs(p, regs));
|
||||
}
|
||||
|
||||
|
|
@ -116,12 +116,12 @@ procfs_read_dbregs(p, dbregs)
|
|||
struct dbreg *dbregs;
|
||||
{
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if ((p->p_sflag & PS_INMEM) == 0) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (EIO);
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (fill_dbregs(p, dbregs));
|
||||
}
|
||||
|
||||
|
|
@ -131,12 +131,12 @@ procfs_write_dbregs(p, dbregs)
|
|||
struct dbreg *dbregs;
|
||||
{
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if ((p->p_sflag & PS_INMEM) == 0) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (EIO);
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (set_dbregs(p, dbregs));
|
||||
}
|
||||
|
||||
|
|
@ -151,12 +151,12 @@ procfs_read_fpregs(p, fpregs)
|
|||
struct fpreg *fpregs;
|
||||
{
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if ((p->p_sflag & PS_INMEM) == 0) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (EIO);
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (fill_fpregs(p, fpregs));
|
||||
}
|
||||
|
||||
|
|
@ -166,12 +166,12 @@ procfs_write_fpregs(p, fpregs)
|
|||
struct fpreg *fpregs;
|
||||
{
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if ((p->p_sflag & PS_INMEM) == 0) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (EIO);
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (set_fpregs(p, fpregs));
|
||||
}
|
||||
|
||||
|
|
@ -180,11 +180,11 @@ procfs_sstep(p)
|
|||
struct proc *p;
|
||||
{
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if ((p->p_sflag & PS_INMEM) == 0) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (EIO);
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (ptrace_single_step(p));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,11 +174,11 @@ userret(p, frame, oticks)
|
|||
|
||||
while ((sig = CURSIG(p)) != 0) {
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
postsig(sig);
|
||||
}
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
p->p_priority = p->p_usrpri;
|
||||
if (resched_wanted()) {
|
||||
/*
|
||||
|
|
@ -193,30 +193,30 @@ userret(p, frame, oticks)
|
|||
setrunqueue(p);
|
||||
p->p_stats->p_ru.ru_nivcsw++;
|
||||
mi_switch();
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
PICKUP_GIANT();
|
||||
while ((sig = CURSIG(p)) != 0) {
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
postsig(sig);
|
||||
}
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
* Charge system time if profiling.
|
||||
*/
|
||||
if (p->p_sflag & PS_PROFIL) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
/* XXX - do we need Giant? */
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock(&Giant);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
addupc_task(p, frame->tf_eip,
|
||||
(u_int)(p->p_sticks - oticks) * psratio);
|
||||
}
|
||||
curpriority = p->p_priority;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -282,9 +282,9 @@ restart:
|
|||
((frame.tf_eflags & PSL_VM) && !in_vm86call)) {
|
||||
/* user trap */
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
sticks = p->p_sticks;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
p->p_md.md_regs = &frame;
|
||||
|
||||
switch (type) {
|
||||
|
|
@ -312,9 +312,9 @@ restart:
|
|||
case T_PROTFLT: /* general protection fault */
|
||||
case T_STKFLT: /* stack fault */
|
||||
if (frame.tf_eflags & PSL_VM) {
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
i = vm86_emulate((struct vm86frame *)&frame);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
if (i == 0)
|
||||
goto user;
|
||||
break;
|
||||
|
|
@ -339,9 +339,9 @@ restart:
|
|||
*/
|
||||
eva = rcr2();
|
||||
enable_intr();
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
i = trap_pfault(&frame, TRUE, eva);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
#if defined(I586_CPU) && !defined(NO_F00F_HACK)
|
||||
if (i == -2) {
|
||||
/*
|
||||
|
|
@ -371,13 +371,13 @@ restart:
|
|||
#ifndef TIMER_FREQ
|
||||
# define TIMER_FREQ 1193182
|
||||
#endif
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
if (time_second - lastalert > 10) {
|
||||
log(LOG_WARNING, "NMI: power fail\n");
|
||||
sysbeep(TIMER_FREQ/880, hz);
|
||||
lastalert = time_second;
|
||||
}
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
goto out;
|
||||
#else /* !POWERFAIL_NMI */
|
||||
/* machine/parity/power fail/"kitchen sink" faults */
|
||||
|
|
@ -421,9 +421,9 @@ restart:
|
|||
ucode = FPE_FPU_NP_TRAP;
|
||||
break;
|
||||
}
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
i = (*pmath_emulate)(&frame);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
if (i == 0) {
|
||||
if (!(frame.tf_eflags & PSL_T))
|
||||
goto out;
|
||||
|
|
@ -452,9 +452,9 @@ restart:
|
|||
*/
|
||||
eva = rcr2();
|
||||
enable_intr();
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
(void) trap_pfault(&frame, FALSE, eva);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
goto out;
|
||||
|
||||
case T_DNA:
|
||||
|
|
@ -477,9 +477,9 @@ restart:
|
|||
case T_PROTFLT: /* general protection fault */
|
||||
case T_STKFLT: /* stack fault */
|
||||
if (frame.tf_eflags & PSL_VM) {
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
i = vm86_emulate((struct vm86frame *)&frame);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
if (i != 0)
|
||||
/*
|
||||
* returns to original process
|
||||
|
|
@ -510,9 +510,9 @@ restart:
|
|||
*/
|
||||
if (frame.tf_eip == (int)cpu_switch_load_gs) {
|
||||
PCPU_GET(curpcb)->pcb_gs = 0;
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
psignal(p, SIGBUS);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
@ -621,13 +621,13 @@ restart:
|
|||
#ifdef DEV_ISA
|
||||
case T_NMI:
|
||||
#ifdef POWERFAIL_NMI
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
if (time_second - lastalert > 10) {
|
||||
log(LOG_WARNING, "NMI: power fail\n");
|
||||
sysbeep(TIMER_FREQ/880, hz);
|
||||
lastalert = time_second;
|
||||
}
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
goto out;
|
||||
#else /* !POWERFAIL_NMI */
|
||||
/* XXX Giant */
|
||||
|
|
@ -651,13 +651,13 @@ restart:
|
|||
#endif /* DEV_ISA */
|
||||
}
|
||||
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
trap_fatal(&frame, eva);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
goto out;
|
||||
}
|
||||
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
/* Translate fault for emulators (e.g. Linux) */
|
||||
if (*p->p_sysent->sv_transtrap)
|
||||
i = (*p->p_sysent->sv_transtrap)(i, type);
|
||||
|
|
@ -673,12 +673,12 @@ restart:
|
|||
uprintf("\n");
|
||||
}
|
||||
#endif
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
|
||||
user:
|
||||
userret(p, &frame, sticks);
|
||||
if (mtx_owned(&Giant))
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
out:
|
||||
return;
|
||||
}
|
||||
|
|
@ -1103,15 +1103,15 @@ syscall2(frame)
|
|||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (ISPL(frame.tf_cs) != SEL_UPL) {
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
panic("syscall");
|
||||
/* NOT REACHED */
|
||||
}
|
||||
#endif
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
sticks = p->p_sticks;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
|
||||
p->p_md.md_regs = &frame;
|
||||
params = (caddr_t)frame.tf_esp + sizeof(int);
|
||||
|
|
@ -1121,9 +1121,9 @@ syscall2(frame)
|
|||
/*
|
||||
* The prep code is not MP aware.
|
||||
*/
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
(*p->p_sysent->sv_prepsyscall)(&frame, args, &code, ¶ms);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
} else {
|
||||
/*
|
||||
* Need to check if this is a 32 bit or 64 bit syscall.
|
||||
|
|
@ -1160,7 +1160,7 @@ syscall2(frame)
|
|||
*/
|
||||
if (params && (i = narg * sizeof(int)) &&
|
||||
(error = copyin(params, (caddr_t)args, (u_int)i))) {
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
#ifdef KTRACE
|
||||
if (KTRPOINT(p, KTR_SYSCALL))
|
||||
ktrsyscall(p->p_tracep, code, narg, args);
|
||||
|
|
@ -1174,13 +1174,13 @@ syscall2(frame)
|
|||
* we are ktracing
|
||||
*/
|
||||
if ((callp->sy_narg & SYF_MPSAFE) == 0) {
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
}
|
||||
|
||||
#ifdef KTRACE
|
||||
if (KTRPOINT(p, KTR_SYSCALL)) {
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
ktrsyscall(p->p_tracep, code, narg, args);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1230,7 +1230,7 @@ bad:
|
|||
*/
|
||||
if ((frame.tf_eflags & PSL_T) && !(frame.tf_eflags & PSL_VM)) {
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
frame.tf_eflags &= ~PSL_T;
|
||||
trapsignal(p, SIGTRAP, 0);
|
||||
}
|
||||
|
|
@ -1243,7 +1243,7 @@ bad:
|
|||
#ifdef KTRACE
|
||||
if (KTRPOINT(p, KTR_SYSRET)) {
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
ktrsysret(p->p_tracep, code, error, p->p_retval[0]);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1259,7 +1259,7 @@ bad:
|
|||
* Release Giant if we had to get it
|
||||
*/
|
||||
if (mtx_owned(&Giant))
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
|
||||
#ifdef WITNESS
|
||||
if (witness_list(p)) {
|
||||
|
|
@ -1278,38 +1278,38 @@ ast(frame)
|
|||
struct proc *p = CURPROC;
|
||||
u_quad_t sticks;
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
sticks = p->p_sticks;
|
||||
|
||||
astoff();
|
||||
atomic_add_int(&cnt.v_soft, 1);
|
||||
if (p->p_sflag & PS_OWEUPC) {
|
||||
p->p_sflag &= ~PS_OWEUPC;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
mtx_lock(&Giant);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
addupc_task(p, p->p_stats->p_prof.pr_addr,
|
||||
p->p_stats->p_prof.pr_ticks);
|
||||
}
|
||||
if (p->p_sflag & PS_ALRMPEND) {
|
||||
p->p_sflag &= ~PS_ALRMPEND;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
psignal(p, SIGVTALRM);
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
}
|
||||
if (p->p_sflag & PS_PROFPEND) {
|
||||
p->p_sflag &= ~PS_PROFPEND;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
psignal(p, SIGPROF);
|
||||
} else
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
|
||||
userret(p, &frame, sticks);
|
||||
|
||||
if (mtx_owned(&Giant))
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ clkintr(struct clockframe frame)
|
|||
{
|
||||
|
||||
if (timecounter->tc_get_timecount == i8254_get_timecount) {
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
if (i8254_ticked)
|
||||
i8254_ticked = 0;
|
||||
else {
|
||||
|
|
@ -215,7 +215,7 @@ clkintr(struct clockframe frame)
|
|||
i8254_lastcount = 0;
|
||||
}
|
||||
clkintr_pending = 0;
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
}
|
||||
timer_func(&frame);
|
||||
switch (timer0_state) {
|
||||
|
|
@ -232,14 +232,14 @@ clkintr(struct clockframe frame)
|
|||
break;
|
||||
|
||||
case ACQUIRE_PENDING:
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
i8254_offset = i8254_get_timecount(NULL);
|
||||
i8254_lastcount = 0;
|
||||
timer0_max_count = TIMER_DIV(new_rate);
|
||||
outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
|
||||
outb(TIMER_CNTR0, timer0_max_count & 0xff);
|
||||
outb(TIMER_CNTR0, timer0_max_count >> 8);
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
timer_func = new_function;
|
||||
timer0_state = ACQUIRED;
|
||||
break;
|
||||
|
|
@ -247,7 +247,7 @@ clkintr(struct clockframe frame)
|
|||
case RELEASE_PENDING:
|
||||
if ((timer0_prescaler_count += timer0_max_count)
|
||||
>= hardclock_max_count) {
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
i8254_offset = i8254_get_timecount(NULL);
|
||||
i8254_lastcount = 0;
|
||||
timer0_max_count = hardclock_max_count;
|
||||
|
|
@ -255,7 +255,7 @@ clkintr(struct clockframe frame)
|
|||
TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
|
||||
outb(TIMER_CNTR0, timer0_max_count & 0xff);
|
||||
outb(TIMER_CNTR0, timer0_max_count >> 8);
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
timer0_prescaler_count = 0;
|
||||
timer_func = hardclock;
|
||||
timer0_state = RELEASED;
|
||||
|
|
@ -403,7 +403,7 @@ getit(void)
|
|||
{
|
||||
int high, low;
|
||||
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
|
||||
/* Select timer0 and latch counter value. */
|
||||
outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
|
||||
|
|
@ -411,7 +411,7 @@ getit(void)
|
|||
low = inb(TIMER_CNTR0);
|
||||
high = inb(TIMER_CNTR0);
|
||||
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
return ((high << 8) | low);
|
||||
}
|
||||
|
||||
|
|
@ -525,10 +525,10 @@ sysbeep(int pitch, int period)
|
|||
splx(x);
|
||||
return (-1); /* XXX Should be EBUSY, but nobody cares anyway. */
|
||||
}
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
outb(TIMER_CNTR2, pitch);
|
||||
outb(TIMER_CNTR2, (pitch>>8));
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
if (!beeping) {
|
||||
/* enable counter2 output to speaker */
|
||||
outb(IO_PPI, inb(IO_PPI) | 3);
|
||||
|
|
@ -679,7 +679,7 @@ set_timer_freq(u_int freq, int intr_freq)
|
|||
{
|
||||
int new_timer0_max_count;
|
||||
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
timer_freq = freq;
|
||||
new_timer0_max_count = hardclock_max_count = TIMER_DIV(intr_freq);
|
||||
if (new_timer0_max_count != timer0_max_count) {
|
||||
|
|
@ -688,7 +688,7 @@ set_timer_freq(u_int freq, int intr_freq)
|
|||
outb(TIMER_CNTR0, timer0_max_count & 0xff);
|
||||
outb(TIMER_CNTR0, timer0_max_count >> 8);
|
||||
}
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -703,11 +703,11 @@ void
|
|||
i8254_restore(void)
|
||||
{
|
||||
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
|
||||
outb(TIMER_CNTR0, timer0_max_count & 0xff);
|
||||
outb(TIMER_CNTR0, timer0_max_count >> 8);
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1194,7 +1194,7 @@ i8254_get_timecount(struct timecounter *tc)
|
|||
u_int eflags;
|
||||
|
||||
eflags = read_eflags();
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
|
||||
/* Select timer0 and latch counter value. */
|
||||
outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
|
||||
|
|
@ -1218,7 +1218,7 @@ i8254_get_timecount(struct timecounter *tc)
|
|||
}
|
||||
i8254_lastcount = count;
|
||||
count += i8254_offset;
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
return (count);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -576,9 +576,9 @@ vm86_intcall(int intnum, struct vm86frame *vmf)
|
|||
return (EINVAL);
|
||||
|
||||
vmf->vmf_trapno = intnum;
|
||||
mtx_enter(&vm86pcb_lock, MTX_DEF);
|
||||
mtx_lock(&vm86pcb_lock);
|
||||
retval = vm86_bioscall(vmf);
|
||||
mtx_exit(&vm86pcb_lock, MTX_DEF);
|
||||
mtx_unlock(&vm86pcb_lock);
|
||||
return (retval);
|
||||
}
|
||||
|
||||
|
|
@ -606,9 +606,9 @@ vm86_datacall(intnum, vmf, vmc)
|
|||
}
|
||||
|
||||
vmf->vmf_trapno = intnum;
|
||||
mtx_enter(&vm86pcb_lock, MTX_DEF);
|
||||
mtx_lock(&vm86pcb_lock);
|
||||
retval = vm86_bioscall(vmf);
|
||||
mtx_exit(&vm86pcb_lock, MTX_DEF);
|
||||
mtx_unlock(&vm86pcb_lock);
|
||||
|
||||
for (i = 0; i < vmc->npages; i++) {
|
||||
entry = vmc->pmap[i].pte_num;
|
||||
|
|
|
|||
|
|
@ -261,8 +261,8 @@ cpu_exit(p)
|
|||
reset_dbregs();
|
||||
pcb->pcb_flags &= ~PCB_DBREGS;
|
||||
}
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_exit(&Giant, MTX_DEF | MTX_NOSWITCH);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
mtx_unlock_flags(&Giant, MTX_NOSWITCH);
|
||||
mtx_assert(&Giant, MA_NOTOWNED);
|
||||
|
||||
/*
|
||||
|
|
@ -574,7 +574,7 @@ vm_page_zero_idle()
|
|||
if (vm_page_zero_count >= ZIDLE_HI(cnt.v_free_count))
|
||||
return(0);
|
||||
|
||||
if (mtx_try_enter(&Giant, MTX_DEF)) {
|
||||
if (mtx_trylock(&Giant)) {
|
||||
s = splvm();
|
||||
zero_state = 0;
|
||||
m = vm_page_list_find(PQ_FREE, free_rover, FALSE);
|
||||
|
|
@ -597,7 +597,7 @@ vm_page_zero_idle()
|
|||
}
|
||||
free_rover = (free_rover + PQ_PRIME2) & PQ_L2_MASK;
|
||||
splx(s);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
|
|
|
|||
|
|
@ -92,9 +92,9 @@
|
|||
* counter in the proc table and flag isn't really necessary.
|
||||
*/
|
||||
#define need_proftick(p) do { \
|
||||
mtx_enter(&sched_lock, MTX_SPIN); \
|
||||
mtx_lock_spin(&sched_lock); \
|
||||
(p)->p_sflag |= PS_OWEUPC; \
|
||||
mtx_exit(&sched_lock, MTX_SPIN); \
|
||||
mtx_unlock_spin(&sched_lock); \
|
||||
aston(); \
|
||||
} while (0)
|
||||
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@
|
|||
/*
|
||||
* Protects the IO APIC and apic_imen as a critical region.
|
||||
*/
|
||||
#define IMASK_LOCK MTX_ENTER(_imen_mtx, MTX_SPIN)
|
||||
#define IMASK_UNLOCK MTX_EXIT(_imen_mtx, MTX_SPIN)
|
||||
#define IMASK_LOCK MTX_LOCK_SPIN(_imen_mtx, 0)
|
||||
#define IMASK_UNLOCK MTX_UNLOCK_SPIN(_imen_mtx)
|
||||
|
||||
#else /* SMP */
|
||||
|
||||
|
|
@ -62,8 +62,8 @@
|
|||
* XXX should rc (RISCom/8) use this?
|
||||
*/
|
||||
#ifdef USE_COMLOCK
|
||||
#define COM_LOCK() mtx_enter(&com_mtx, MTX_SPIN)
|
||||
#define COM_UNLOCK() mtx_exit(&com_mtx, MTX_SPIN)
|
||||
#define COM_LOCK() mtx_lock_spin(&com_mtx)
|
||||
#define COM_UNLOCK() mtx_unlock_spin(&com_mtx)
|
||||
#else
|
||||
#define COM_LOCK()
|
||||
#define COM_UNLOCK()
|
||||
|
|
|
|||
|
|
@ -2268,7 +2268,7 @@ ap_init(void)
|
|||
PCPU_SET(curproc, PCPU_GET(idleproc));
|
||||
|
||||
/* lock against other AP's that are waking up */
|
||||
mtx_enter(&ap_boot_mtx, MTX_SPIN);
|
||||
mtx_lock_spin(&ap_boot_mtx);
|
||||
|
||||
/* BSP may have changed PTD while we're waiting for the lock */
|
||||
cpu_invltlb();
|
||||
|
|
@ -2317,7 +2317,7 @@ ap_init(void)
|
|||
}
|
||||
|
||||
/* let other AP's wake up now */
|
||||
mtx_exit(&ap_boot_mtx, MTX_SPIN);
|
||||
mtx_unlock_spin(&ap_boot_mtx);
|
||||
|
||||
/* wait until all the AP's are up */
|
||||
while (smp_started == 0)
|
||||
|
|
@ -2328,7 +2328,7 @@ ap_init(void)
|
|||
|
||||
/* ok, now grab sched_lock and enter the scheduler */
|
||||
enable_intr();
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
cpu_throw(); /* doesn't return */
|
||||
|
||||
panic("scheduler returned us to ap_init");
|
||||
|
|
@ -2662,14 +2662,14 @@ forward_signal(struct proc *p)
|
|||
return;
|
||||
if (!forward_signal_enabled)
|
||||
return;
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
while (1) {
|
||||
if (p->p_stat != SRUN) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return;
|
||||
}
|
||||
id = p->p_oncpu;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
if (id == 0xff)
|
||||
return;
|
||||
map = (1<<id);
|
||||
|
|
@ -2687,9 +2687,9 @@ forward_signal(struct proc *p)
|
|||
break;
|
||||
}
|
||||
}
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (id == p->p_oncpu) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -2867,7 +2867,7 @@ smp_rendezvous(void (* setup_func)(void *),
|
|||
{
|
||||
|
||||
/* obtain rendezvous lock */
|
||||
mtx_enter(&smp_rv_mtx, MTX_SPIN);
|
||||
mtx_lock_spin(&smp_rv_mtx);
|
||||
|
||||
/* set static function pointers */
|
||||
smp_rv_setup_func = setup_func;
|
||||
|
|
@ -2886,7 +2886,7 @@ smp_rendezvous(void (* setup_func)(void *),
|
|||
smp_rendezvous_action();
|
||||
|
||||
/* release lock */
|
||||
mtx_exit(&smp_rv_mtx, MTX_SPIN);
|
||||
mtx_unlock_spin(&smp_rv_mtx);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -43,22 +43,10 @@ extern struct mtx clock_lock;
|
|||
/*
|
||||
* Debugging
|
||||
*/
|
||||
#ifdef MUTEX_DEBUG
|
||||
|
||||
#ifdef _KERN_MUTEX_C_
|
||||
char STR_IEN[] = "fl & PSL_I";
|
||||
char STR_IDIS[] = "!(fl & PSL_I)";
|
||||
char STR_SIEN[] = "mpp->mtx_saveintr & PSL_I";
|
||||
#else /* _KERN_MUTEX_C_ */
|
||||
extern char STR_IEN[];
|
||||
extern char STR_IDIS[];
|
||||
extern char STR_SIEN[];
|
||||
#endif /* _KERN_MUTEX_C_ */
|
||||
#endif /* MUTEX_DEBUG */
|
||||
|
||||
#define ASS_IEN MPASS2(read_eflags() & PSL_I, STR_IEN)
|
||||
#define ASS_IDIS MPASS2((read_eflags() & PSL_I) == 0, STR_IDIS)
|
||||
#define ASS_SIEN(mpp) MPASS2((mpp)->mtx_saveintr & PSL_I, STR_SIEN)
|
||||
#define ASS_IEN MPASS2(read_eflags() & PSL_I, "fl & PSL_I")
|
||||
#define ASS_IDIS MPASS2((read_eflags() & PSL_I) == 0, "!(fl & PSL_I)")
|
||||
#define ASS_SIEN(mpp) MPASS2((mpp)->mtx_saveintr & PSL_I, \
|
||||
"mpp->mtx_saveintr & PSL_I")
|
||||
|
||||
#define mtx_legal2block() (read_eflags() & PSL_I)
|
||||
|
||||
|
|
@ -66,9 +54,6 @@ extern char STR_SIEN[];
|
|||
* Assembly macros (for internal use only)
|
||||
*------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifdef _KERN_MUTEX_C_
|
||||
|
||||
#define _V(x) __STRING(x)
|
||||
|
||||
#if 0
|
||||
|
|
@ -252,22 +237,80 @@ extern char STR_SIEN[];
|
|||
|
||||
#undef _V
|
||||
|
||||
#endif /* _KERN_MUTEX_C_ */
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#else /* !LOCORE */
|
||||
|
||||
/*
|
||||
* Simple assembly macros to get and release mutexes.
|
||||
*
|
||||
* Note: All of these macros accept a "flags" argument and are analoguous
|
||||
* to the mtx_lock_flags and mtx_unlock_flags general macros. If one
|
||||
* desires to not pass a flag, the value 0 may be passed as second
|
||||
* argument.
|
||||
*
|
||||
* XXX: We only have MTX_LOCK_SPIN and MTX_UNLOCK_SPIN for now, since that's
|
||||
* all we use right now. We should add MTX_LOCK and MTX_UNLOCK (for sleep
|
||||
* locks) in the near future, however.
|
||||
*/
|
||||
#define MTX_LOCK_SPIN(lck, flags) \
|
||||
pushl %eax ; \
|
||||
pushl %ecx ; \
|
||||
pushl %ebx ; \
|
||||
movl $(MTX_UNOWNED) , %eax ; \
|
||||
movl PCPU(CURPROC), %ebx ; \
|
||||
pushfl ; \
|
||||
popl %ecx ; \
|
||||
cli ; \
|
||||
MPLOCKED cmpxchgl %ebx, lck+MTX_LOCK ; \
|
||||
jz 2f ; \
|
||||
cmpl lck+MTX_LOCK, %ebx ; \
|
||||
je 3f ; \
|
||||
pushl $0 ; \
|
||||
pushl $0 ; \
|
||||
pushl %ecx ; \
|
||||
pushl $flags ; \
|
||||
pushl $lck ; \
|
||||
call _mtx_lock_spin ; \
|
||||
addl $0x14, %esp ; \
|
||||
jmp 1f ; \
|
||||
3: movl lck+MTX_RECURSECNT, %ebx ; \
|
||||
incl %ebx ; \
|
||||
movl %ebx, lck+MTX_RECURSECNT ; \
|
||||
jmp 1f ; \
|
||||
2: movl %ecx, lck+MTX_SAVEINTR ; \
|
||||
1: popl %ebx ; \
|
||||
popl %ecx ; \
|
||||
popl %eax
|
||||
|
||||
#define MTX_UNLOCK_SPIN(lck) \
|
||||
pushl %edx ; \
|
||||
pushl %eax ; \
|
||||
movl lck+MTX_SAVEINTR, %edx ; \
|
||||
movl lck+MTX_RECURSECNT, %eax ; \
|
||||
testl %eax, %eax ; \
|
||||
jne 2f ; \
|
||||
movl $(MTX_UNOWNED), %eax ; \
|
||||
xchgl %eax, lck+MTX_LOCK ; \
|
||||
pushl %edx ; \
|
||||
popfl ; \
|
||||
jmp 1f ; \
|
||||
2: decl %eax ; \
|
||||
movl %eax, lck+MTX_RECURSECNT ; \
|
||||
1: popl %eax ; \
|
||||
popl %edx
|
||||
|
||||
/*
|
||||
* XXX: These two are broken right now and need to be made to work for
|
||||
* XXX: sleep locks, as the above two work for spin locks. We're not in
|
||||
* XXX: too much of a rush to do these as we do not use them right now.
|
||||
*/
|
||||
#define MTX_ENTER(lck, type) \
|
||||
pushl $0 ; /* dummy __LINE__ */ \
|
||||
pushl $0 ; /* dummy __FILE__ */ \
|
||||
pushl $type ; \
|
||||
pushl $lck ; \
|
||||
call _mtx_enter ; \
|
||||
call _mtx_lock_XXX ; \
|
||||
addl $16,%esp
|
||||
|
||||
#define MTX_EXIT(lck, type) \
|
||||
|
|
@ -275,7 +318,7 @@ extern char STR_SIEN[];
|
|||
pushl $0 ; /* dummy __FILE__ */ \
|
||||
pushl $type ; \
|
||||
pushl $lck ; \
|
||||
call _mtx_exit ; \
|
||||
call _mtx_unlock_XXX ; \
|
||||
addl $16,%esp
|
||||
|
||||
#endif /* !LOCORE */
|
||||
|
|
|
|||
|
|
@ -66,8 +66,8 @@
|
|||
#ifdef SMP
|
||||
#define MCOUNT_ENTER(s) { s = read_eflags(); \
|
||||
__asm __volatile("cli" : : : "memory"); \
|
||||
mtx_enter(&mcount_mtx, MTX_DEF); }
|
||||
#define MCOUNT_EXIT(s) { mtx_exit(&mcount_mtx, MTX_DEF); write_eflags(s); }
|
||||
mtx_lock(&mcount_mtx); }
|
||||
#define MCOUNT_EXIT(s) { mtx_unlock(&mcount_mtx); write_eflags(s); }
|
||||
#else
|
||||
#define MCOUNT_ENTER(s) { s = read_eflags(); disable_intr(); }
|
||||
#define MCOUNT_EXIT(s) (write_eflags(s))
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ clkintr(struct clockframe frame)
|
|||
{
|
||||
|
||||
if (timecounter->tc_get_timecount == i8254_get_timecount) {
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
if (i8254_ticked)
|
||||
i8254_ticked = 0;
|
||||
else {
|
||||
|
|
@ -215,7 +215,7 @@ clkintr(struct clockframe frame)
|
|||
i8254_lastcount = 0;
|
||||
}
|
||||
clkintr_pending = 0;
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
}
|
||||
timer_func(&frame);
|
||||
switch (timer0_state) {
|
||||
|
|
@ -232,14 +232,14 @@ clkintr(struct clockframe frame)
|
|||
break;
|
||||
|
||||
case ACQUIRE_PENDING:
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
i8254_offset = i8254_get_timecount(NULL);
|
||||
i8254_lastcount = 0;
|
||||
timer0_max_count = TIMER_DIV(new_rate);
|
||||
outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
|
||||
outb(TIMER_CNTR0, timer0_max_count & 0xff);
|
||||
outb(TIMER_CNTR0, timer0_max_count >> 8);
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
timer_func = new_function;
|
||||
timer0_state = ACQUIRED;
|
||||
break;
|
||||
|
|
@ -247,7 +247,7 @@ clkintr(struct clockframe frame)
|
|||
case RELEASE_PENDING:
|
||||
if ((timer0_prescaler_count += timer0_max_count)
|
||||
>= hardclock_max_count) {
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
i8254_offset = i8254_get_timecount(NULL);
|
||||
i8254_lastcount = 0;
|
||||
timer0_max_count = hardclock_max_count;
|
||||
|
|
@ -255,7 +255,7 @@ clkintr(struct clockframe frame)
|
|||
TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
|
||||
outb(TIMER_CNTR0, timer0_max_count & 0xff);
|
||||
outb(TIMER_CNTR0, timer0_max_count >> 8);
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
timer0_prescaler_count = 0;
|
||||
timer_func = hardclock;
|
||||
timer0_state = RELEASED;
|
||||
|
|
@ -403,7 +403,7 @@ getit(void)
|
|||
{
|
||||
int high, low;
|
||||
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
|
||||
/* Select timer0 and latch counter value. */
|
||||
outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
|
||||
|
|
@ -411,7 +411,7 @@ getit(void)
|
|||
low = inb(TIMER_CNTR0);
|
||||
high = inb(TIMER_CNTR0);
|
||||
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
return ((high << 8) | low);
|
||||
}
|
||||
|
||||
|
|
@ -525,10 +525,10 @@ sysbeep(int pitch, int period)
|
|||
splx(x);
|
||||
return (-1); /* XXX Should be EBUSY, but nobody cares anyway. */
|
||||
}
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
outb(TIMER_CNTR2, pitch);
|
||||
outb(TIMER_CNTR2, (pitch>>8));
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
if (!beeping) {
|
||||
/* enable counter2 output to speaker */
|
||||
outb(IO_PPI, inb(IO_PPI) | 3);
|
||||
|
|
@ -679,7 +679,7 @@ set_timer_freq(u_int freq, int intr_freq)
|
|||
{
|
||||
int new_timer0_max_count;
|
||||
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
timer_freq = freq;
|
||||
new_timer0_max_count = hardclock_max_count = TIMER_DIV(intr_freq);
|
||||
if (new_timer0_max_count != timer0_max_count) {
|
||||
|
|
@ -688,7 +688,7 @@ set_timer_freq(u_int freq, int intr_freq)
|
|||
outb(TIMER_CNTR0, timer0_max_count & 0xff);
|
||||
outb(TIMER_CNTR0, timer0_max_count >> 8);
|
||||
}
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -703,11 +703,11 @@ void
|
|||
i8254_restore(void)
|
||||
{
|
||||
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
|
||||
outb(TIMER_CNTR0, timer0_max_count & 0xff);
|
||||
outb(TIMER_CNTR0, timer0_max_count >> 8);
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1194,7 +1194,7 @@ i8254_get_timecount(struct timecounter *tc)
|
|||
u_int eflags;
|
||||
|
||||
eflags = read_eflags();
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
|
||||
/* Select timer0 and latch counter value. */
|
||||
outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
|
||||
|
|
@ -1218,7 +1218,7 @@ i8254_get_timecount(struct timecounter *tc)
|
|||
}
|
||||
i8254_lastcount = count;
|
||||
count += i8254_offset;
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
return (count);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -110,8 +110,8 @@ DRIVER_MODULE(if_el, isa, el_driver, el_devclass, 0, 0);
|
|||
#define CSR_READ_1(sc, reg) \
|
||||
bus_space_read_1(sc->el_btag, sc->el_bhandle, reg)
|
||||
|
||||
#define EL_LOCK(_sc) mtx_enter(&(_sc)->el_mtx, MTX_DEF)
|
||||
#define EL_UNLOCK(_sc) mtx_exit(&(_sc)->el_mtx, MTX_DEF)
|
||||
#define EL_LOCK(_sc) mtx_lock(&(_sc)->el_mtx)
|
||||
#define EL_UNLOCK(_sc) mtx_unlock(&(_sc)->el_mtx)
|
||||
|
||||
/* Probe routine. See if the card is there and at the right place. */
|
||||
static int
|
||||
|
|
|
|||
|
|
@ -701,7 +701,7 @@ inthand_remove(struct intrhand *idesc)
|
|||
ithds[ithd->irq] = NULL;
|
||||
|
||||
if ((idesc->ih_flags & INTR_FAST) == 0) {
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (ithd->it_proc->p_stat == SWAIT) {
|
||||
ithd->it_proc->p_intr_nesting_level = 0;
|
||||
ithd->it_proc->p_stat = SRUN;
|
||||
|
|
@ -713,7 +713,7 @@ inthand_remove(struct intrhand *idesc)
|
|||
* XXX: should we lower the threads priority?
|
||||
*/
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
}
|
||||
free(idesc->ih_name, M_DEVBUF);
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ sched_ithd(void *cookie)
|
|||
* is higher priority than their current thread, it gets run now.
|
||||
*/
|
||||
ir->it_need = 1;
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (ir->it_proc->p_stat == SWAIT) { /* not on run queue */
|
||||
CTR1(KTR_INTR, "sched_ithd: setrunqueue %d",
|
||||
ir->it_proc->p_pid);
|
||||
|
|
@ -134,7 +134,7 @@ sched_ithd(void *cookie)
|
|||
ir->it_proc->p_stat );
|
||||
need_resched();
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -163,7 +163,7 @@ ithd_loop(void *dummy)
|
|||
me->it_proc->p_pid, me->it_proc->p_comm);
|
||||
curproc->p_ithd = NULL;
|
||||
free(me, M_DEVBUF);
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
kthread_exit(0);
|
||||
}
|
||||
|
||||
|
|
@ -188,10 +188,10 @@ ithd_loop(void *dummy)
|
|||
ih->ih_flags);
|
||||
|
||||
if ((ih->ih_flags & INTR_MPSAFE) == 0)
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
ih->ih_handler(ih->ih_argument);
|
||||
if ((ih->ih_flags & INTR_MPSAFE) == 0)
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -201,7 +201,7 @@ ithd_loop(void *dummy)
|
|||
* set again, so we have to check it again.
|
||||
*/
|
||||
mtx_assert(&Giant, MA_NOTOWNED);
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (!me->it_need) {
|
||||
|
||||
INTREN (1 << me->irq); /* reset the mask bit */
|
||||
|
|
@ -217,6 +217,6 @@ ithd_loop(void *dummy)
|
|||
CTR1(KTR_INTR, "ithd_loop pid %d: resumed",
|
||||
me->it_proc->p_pid);
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -701,7 +701,7 @@ inthand_remove(struct intrhand *idesc)
|
|||
ithds[ithd->irq] = NULL;
|
||||
|
||||
if ((idesc->ih_flags & INTR_FAST) == 0) {
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (ithd->it_proc->p_stat == SWAIT) {
|
||||
ithd->it_proc->p_intr_nesting_level = 0;
|
||||
ithd->it_proc->p_stat = SRUN;
|
||||
|
|
@ -713,7 +713,7 @@ inthand_remove(struct intrhand *idesc)
|
|||
* XXX: should we lower the threads priority?
|
||||
*/
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
}
|
||||
free(idesc->ih_name, M_DEVBUF);
|
||||
|
|
|
|||
|
|
@ -724,7 +724,7 @@ npx_intr(dummy)
|
|||
u_short control;
|
||||
struct intrframe *frame;
|
||||
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
if (PCPU_GET(npxproc) == NULL || !npx_exists) {
|
||||
printf("npxintr: npxproc = %p, curproc = %p, npx_exists = %d\n",
|
||||
PCPU_GET(npxproc), curproc, npx_exists);
|
||||
|
|
@ -783,7 +783,7 @@ npx_intr(dummy)
|
|||
*/
|
||||
psignal(curproc, SIGFPE);
|
||||
}
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ interrupt(u_int64_t vector, struct trapframe *framep)
|
|||
case 240: /* clock interrupt */
|
||||
CTR0(KTR_INTR, "clock interrupt");
|
||||
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
cnt.v_intr++;
|
||||
#ifdef EVCNT_COUNTERS
|
||||
clock_intr_evcnt.ev_count++;
|
||||
|
|
@ -98,11 +98,11 @@ interrupt(u_int64_t vector, struct trapframe *framep)
|
|||
/* divide hz (1024) by 8 to get stathz (128) */
|
||||
if((++schedclk2 & 0x7) == 0)
|
||||
statclock((struct clockframe *)framep);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
break;
|
||||
|
||||
default:
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
panic("unexpected interrupt: vec %ld\n", vector);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -597,7 +597,7 @@ ia64_init()
|
|||
*/
|
||||
mtx_init(&Giant, "Giant", MTX_DEF | MTX_RECURSE);
|
||||
mtx_init(&sched_lock, "sched lock", MTX_SPIN | MTX_RECURSE);
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
|
||||
#if 0
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -628,7 +628,7 @@ smp_rendezvous(void (* setup_func)(void *),
|
|||
{
|
||||
|
||||
/* obtain rendezvous lock */
|
||||
mtx_enter(&smp_rv_mtx, MTX_SPIN);
|
||||
mtx_lock_spin(&smp_rv_mtx);
|
||||
|
||||
/* set static function pointers */
|
||||
smp_rv_setup_func = setup_func;
|
||||
|
|
@ -645,7 +645,7 @@ smp_rendezvous(void (* setup_func)(void *),
|
|||
smp_rendezvous_action();
|
||||
|
||||
/* release lock */
|
||||
mtx_exit(&smp_rv_mtx, MTX_SPIN);
|
||||
mtx_unlock_spin(&smp_rv_mtx);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -86,12 +86,12 @@ procfs_read_regs(p, regs)
|
|||
struct reg *regs;
|
||||
{
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if ((p->p_sflag & PS_INMEM) == 0) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (EIO);
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (fill_regs(p, regs));
|
||||
}
|
||||
|
||||
|
|
@ -101,12 +101,12 @@ procfs_write_regs(p, regs)
|
|||
struct reg *regs;
|
||||
{
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if ((p->p_sflag & PS_INMEM) == 0) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (EIO);
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (set_regs(p, regs));
|
||||
}
|
||||
|
||||
|
|
@ -121,9 +121,9 @@ procfs_read_fpregs(p, fpregs)
|
|||
struct fpreg *fpregs;
|
||||
{
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if ((p->p_sflag & PS_INMEM) == 0) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (EIO);
|
||||
}
|
||||
return (fill_fpregs(p, fpregs));
|
||||
|
|
@ -135,12 +135,12 @@ procfs_write_fpregs(p, fpregs)
|
|||
struct fpreg *fpregs;
|
||||
{
|
||||
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if ((p->p_sflag & PS_INMEM) == 0) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (EIO);
|
||||
}
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
return (set_fpregs(p, fpregs));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,10 +90,10 @@ userret(register struct proc *p, struct trapframe *frame, u_quad_t oticks)
|
|||
/* take pending signals */
|
||||
while ((sig = CURSIG(p)) != 0) {
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
postsig(sig);
|
||||
}
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
p->p_priority = p->p_usrpri;
|
||||
if (want_resched) {
|
||||
/*
|
||||
|
|
@ -109,30 +109,30 @@ userret(register struct proc *p, struct trapframe *frame, u_quad_t oticks)
|
|||
setrunqueue(p);
|
||||
p->p_stats->p_ru.ru_nivcsw++;
|
||||
mi_switch();
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
PICKUP_GIANT();
|
||||
splx(s);
|
||||
while ((sig = CURSIG(p)) != 0) {
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
postsig(sig);
|
||||
}
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
* If profiling, charge recent system time to the trapped pc.
|
||||
*/
|
||||
if (p->p_sflag & PS_PROFIL) {
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock(&Giant);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
addupc_task(p, frame->tf_cr_iip,
|
||||
(int)(p->p_sticks - oticks) * psratio);
|
||||
}
|
||||
curpriority = p->p_priority;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
|
||||
static const char *ia64_vector_names[] = {
|
||||
|
|
@ -249,9 +249,9 @@ trap(int vector, int imm, struct trapframe *framep)
|
|||
|
||||
user = ((framep->tf_cr_ipsr & IA64_PSR_CPL) == IA64_PSR_CPL_USER);
|
||||
if (user) {
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
sticks = p->p_sticks;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
p->p_md.md_tf = framep;
|
||||
} else {
|
||||
sticks = 0; /* XXX bogus -Wuninitialized warning */
|
||||
|
|
@ -265,12 +265,12 @@ trap(int vector, int imm, struct trapframe *framep)
|
|||
* and per-process unaligned-access-handling flags).
|
||||
*/
|
||||
if (user) {
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
if ((i = unaligned_fixup(framep, p)) == 0) {
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
goto out;
|
||||
}
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
ucode = framep->tf_cr_ifa; /* VA */
|
||||
break;
|
||||
}
|
||||
|
|
@ -330,7 +330,7 @@ trap(int vector, int imm, struct trapframe *framep)
|
|||
vm_prot_t ftype = 0;
|
||||
int rv;
|
||||
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
/*
|
||||
* If it was caused by fuswintr or suswintr,
|
||||
* just punt. Note that we check the faulting
|
||||
|
|
@ -345,7 +345,7 @@ trap(int vector, int imm, struct trapframe *framep)
|
|||
p->p_addr->u_pcb.pcb_accessaddr == va) {
|
||||
framep->tf_cr_iip = p->p_addr->u_pcb.pcb_onfault;
|
||||
p->p_addr->u_pcb.pcb_onfault = 0;
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
@ -455,11 +455,11 @@ trap(int vector, int imm, struct trapframe *framep)
|
|||
rv = KERN_INVALID_ADDRESS;
|
||||
}
|
||||
if (rv == KERN_SUCCESS) {
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
goto out;
|
||||
}
|
||||
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
ucode = va;
|
||||
i = SIGSEGV;
|
||||
#ifdef DEBUG
|
||||
|
|
@ -480,7 +480,7 @@ out:
|
|||
if (user) {
|
||||
userret(p, framep, sticks);
|
||||
if (mtx_owned(&Giant))
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
return;
|
||||
|
||||
|
|
@ -521,11 +521,11 @@ syscall(int code, u_int64_t *args, struct trapframe *framep)
|
|||
cnt.v_syscall++;
|
||||
p = curproc;
|
||||
p->p_md.md_tf = framep;
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
sticks = p->p_sticks;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
/*
|
||||
* Skip past the break instruction. Remember old address in case
|
||||
* we have to restart.
|
||||
|
|
@ -618,7 +618,7 @@ syscall(int code, u_int64_t *args, struct trapframe *framep)
|
|||
* is not the case, this code will need to be revisited.
|
||||
*/
|
||||
STOPEVENT(p, S_SCX, code);
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
|
||||
#ifdef WITNESS
|
||||
if (witness_list(p)) {
|
||||
|
|
@ -646,13 +646,13 @@ child_return(p)
|
|||
#ifdef KTRACE
|
||||
if (KTRPOINT(p, KTR_SYSRET)) {
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
ktrsysret(p->p_tracep, SYS_fork, 0, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mtx_owned(&Giant))
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -667,9 +667,9 @@ ast(framep)
|
|||
u_quad_t sticks;
|
||||
|
||||
p = curproc;
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
sticks = p->p_sticks;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
p->p_md.md_tf = framep;
|
||||
|
||||
if ((framep->tf_cr_ipsr & IA64_PSR_CPL) != IA64_PSR_CPL_USER)
|
||||
|
|
@ -678,36 +678,36 @@ ast(framep)
|
|||
cnt.v_soft++;
|
||||
|
||||
PCPU_SET(astpending, 0);
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (p->p_sflag & PS_OWEUPC) {
|
||||
p->p_sflag &= ~PS_OWEUPC;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
mtx_lock(&Giant);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
addupc_task(p, p->p_stats->p_prof.pr_addr,
|
||||
p->p_stats->p_prof.pr_ticks);
|
||||
}
|
||||
if (p->p_sflag & PS_ALRMPEND) {
|
||||
p->p_sflag &= ~PS_ALRMPEND;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
psignal(p, SIGVTALRM);
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
}
|
||||
if (p->p_sflag & PS_PROFPEND) {
|
||||
p->p_sflag &= ~PS_PROFPEND;
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
if (!mtx_owned(&Giant))
|
||||
mtx_enter(&Giant, MTX_DEF);
|
||||
mtx_lock(&Giant);
|
||||
psignal(p, SIGPROF);
|
||||
} else
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
|
||||
userret(p, framep, sticks);
|
||||
|
||||
if (mtx_owned(&Giant))
|
||||
mtx_exit(&Giant, MTX_DEF);
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
|
||||
extern int ia64_unaligned_print, ia64_unaligned_fix;
|
||||
|
|
|
|||
|
|
@ -303,8 +303,8 @@ cpu_exit(p)
|
|||
ia64_fpstate_drop(p);
|
||||
|
||||
(void) splhigh();
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
mtx_exit(&Giant, MTX_DEF | MTX_NOSWITCH);
|
||||
mtx_lock_spin(&sched_lock);
|
||||
mtx_unlock_flags(&Giant, MTX_NOSWITCH);
|
||||
mtx_assert(&Giant, MA_NOTOWNED);
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -83,10 +83,10 @@ struct clockframe {
|
|||
* through trap, marking the proc as needing a profiling tick.
|
||||
*/
|
||||
#define need_proftick(p) do { \
|
||||
mtx_enter(&sched_lock, MTX_SPIN); \
|
||||
mtx_lock_spin(&sched_lock); \
|
||||
(p)->p_sflag |= PS_OWEUPC; \
|
||||
aston(); \
|
||||
mtx_exit(&sched_lock, MTX_SPIN); \
|
||||
mtx_unlock_spin(&sched_lock); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -42,22 +42,10 @@
|
|||
* Debugging
|
||||
*/
|
||||
#ifdef MUTEX_DEBUG
|
||||
|
||||
#ifdef _KERN_MUTEX_C_
|
||||
char STR_IEN[] = "psr.i";
|
||||
char STR_IDIS[] = "!psr.i";
|
||||
char STR_SIEN[] = "mpp->mtx_saveintr & IA64_PSR_I";
|
||||
#else /* _KERN_MUTEX_C_ */
|
||||
extern char STR_IEN[];
|
||||
extern char STR_IDIS[];
|
||||
extern char STR_SIEN[];
|
||||
#endif /* _KERN_MUTEX_C_ */
|
||||
|
||||
#endif /* MUTEX_DEBUG */
|
||||
|
||||
#define ASS_IEN MPASS2((save_intr() & IA64_PSR_I), STR_IEN)
|
||||
#define ASS_IDIS MPASS2(!(save_intr() & IA64_PSR_I), STR_IDIS)
|
||||
#define ASS_SIEN(mpp) MPASS2(((mpp)->mtx_saveintr & IA64_PSR_I), STR_SIEN)
|
||||
#define ASS_IEN MPASS2((save_intr() & IA64_PSR_I), "psr.i")
|
||||
#define ASS_IDIS MPASS2(!(save_intr() & IA64_PSR_I), "!psr.i")
|
||||
#define ASS_SIEN(mpp) MPASS2(((mpp)->mtx_saveintr & IA64_PSR_I), \
|
||||
"mpp->mtx_saveintr & IA64_PSR_I")
|
||||
|
||||
#define mtx_legal2block() (save_intr() & IA64_PSR_I)
|
||||
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ clkintr(struct clockframe frame)
|
|||
{
|
||||
|
||||
if (timecounter->tc_get_timecount == i8254_get_timecount) {
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
if (i8254_ticked)
|
||||
i8254_ticked = 0;
|
||||
else {
|
||||
|
|
@ -215,7 +215,7 @@ clkintr(struct clockframe frame)
|
|||
i8254_lastcount = 0;
|
||||
}
|
||||
clkintr_pending = 0;
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
}
|
||||
timer_func(&frame);
|
||||
switch (timer0_state) {
|
||||
|
|
@ -232,14 +232,14 @@ clkintr(struct clockframe frame)
|
|||
break;
|
||||
|
||||
case ACQUIRE_PENDING:
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
i8254_offset = i8254_get_timecount(NULL);
|
||||
i8254_lastcount = 0;
|
||||
timer0_max_count = TIMER_DIV(new_rate);
|
||||
outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
|
||||
outb(TIMER_CNTR0, timer0_max_count & 0xff);
|
||||
outb(TIMER_CNTR0, timer0_max_count >> 8);
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
timer_func = new_function;
|
||||
timer0_state = ACQUIRED;
|
||||
break;
|
||||
|
|
@ -247,7 +247,7 @@ clkintr(struct clockframe frame)
|
|||
case RELEASE_PENDING:
|
||||
if ((timer0_prescaler_count += timer0_max_count)
|
||||
>= hardclock_max_count) {
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
i8254_offset = i8254_get_timecount(NULL);
|
||||
i8254_lastcount = 0;
|
||||
timer0_max_count = hardclock_max_count;
|
||||
|
|
@ -255,7 +255,7 @@ clkintr(struct clockframe frame)
|
|||
TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
|
||||
outb(TIMER_CNTR0, timer0_max_count & 0xff);
|
||||
outb(TIMER_CNTR0, timer0_max_count >> 8);
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
timer0_prescaler_count = 0;
|
||||
timer_func = hardclock;
|
||||
timer0_state = RELEASED;
|
||||
|
|
@ -403,7 +403,7 @@ getit(void)
|
|||
{
|
||||
int high, low;
|
||||
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
|
||||
/* Select timer0 and latch counter value. */
|
||||
outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
|
||||
|
|
@ -411,7 +411,7 @@ getit(void)
|
|||
low = inb(TIMER_CNTR0);
|
||||
high = inb(TIMER_CNTR0);
|
||||
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
return ((high << 8) | low);
|
||||
}
|
||||
|
||||
|
|
@ -525,10 +525,10 @@ sysbeep(int pitch, int period)
|
|||
splx(x);
|
||||
return (-1); /* XXX Should be EBUSY, but nobody cares anyway. */
|
||||
}
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
outb(TIMER_CNTR2, pitch);
|
||||
outb(TIMER_CNTR2, (pitch>>8));
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
if (!beeping) {
|
||||
/* enable counter2 output to speaker */
|
||||
outb(IO_PPI, inb(IO_PPI) | 3);
|
||||
|
|
@ -679,7 +679,7 @@ set_timer_freq(u_int freq, int intr_freq)
|
|||
{
|
||||
int new_timer0_max_count;
|
||||
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
timer_freq = freq;
|
||||
new_timer0_max_count = hardclock_max_count = TIMER_DIV(intr_freq);
|
||||
if (new_timer0_max_count != timer0_max_count) {
|
||||
|
|
@ -688,7 +688,7 @@ set_timer_freq(u_int freq, int intr_freq)
|
|||
outb(TIMER_CNTR0, timer0_max_count & 0xff);
|
||||
outb(TIMER_CNTR0, timer0_max_count >> 8);
|
||||
}
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -703,11 +703,11 @@ void
|
|||
i8254_restore(void)
|
||||
{
|
||||
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
|
||||
outb(TIMER_CNTR0, timer0_max_count & 0xff);
|
||||
outb(TIMER_CNTR0, timer0_max_count >> 8);
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1194,7 +1194,7 @@ i8254_get_timecount(struct timecounter *tc)
|
|||
u_int eflags;
|
||||
|
||||
eflags = read_eflags();
|
||||
mtx_enter(&clock_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&clock_lock);
|
||||
|
||||
/* Select timer0 and latch counter value. */
|
||||
outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
|
||||
|
|
@ -1218,7 +1218,7 @@ i8254_get_timecount(struct timecounter *tc)
|
|||
}
|
||||
i8254_lastcount = count;
|
||||
count += i8254_offset;
|
||||
mtx_exit(&clock_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&clock_lock);
|
||||
return (count);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -856,7 +856,7 @@ sioprobe(dev, xrid)
|
|||
* but mask them in the processor as well in case there are some
|
||||
* (misconfigured) shared interrupts.
|
||||
*/
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
/* EXTRA DELAY? */
|
||||
|
||||
/*
|
||||
|
|
@ -953,7 +953,7 @@ sioprobe(dev, xrid)
|
|||
CLR_FLAG(dev, COM_C_IIR_TXRDYBUG);
|
||||
}
|
||||
sio_setreg(com, com_cfcr, CFCR_8BITS);
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
|
||||
return (iobase == siocniobase ? 0 : result);
|
||||
}
|
||||
|
|
@ -993,7 +993,7 @@ sioprobe(dev, xrid)
|
|||
irqmap[3] = isa_irq_pending();
|
||||
failures[9] = (sio_getreg(com, com_iir) & IIR_IMASK) - IIR_NOPEND;
|
||||
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
|
||||
irqs = irqmap[1] & ~irqmap[0];
|
||||
if (bus_get_resource(idev, SYS_RES_IRQ, 0, &xirq, NULL) == 0 &&
|
||||
|
|
@ -1181,7 +1181,7 @@ sioattach(dev, xrid)
|
|||
} else
|
||||
com->it_in.c_ispeed = com->it_in.c_ospeed = TTYDEF_SPEED;
|
||||
if (siosetwater(com, com->it_in.c_ispeed) != 0) {
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
/*
|
||||
* Leave i/o resources allocated if this is a `cn'-level
|
||||
* console, so that other devices can't snarf them.
|
||||
|
|
@ -1190,7 +1190,7 @@ sioattach(dev, xrid)
|
|||
bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
|
||||
return (ENOMEM);
|
||||
}
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
termioschars(&com->it_in);
|
||||
com->it_out = com->it_in;
|
||||
|
||||
|
|
@ -1485,7 +1485,7 @@ open_top:
|
|||
}
|
||||
}
|
||||
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
(void) inb(com->line_status_port);
|
||||
(void) inb(com->data_port);
|
||||
com->prev_modem_status = com->last_modem_status
|
||||
|
|
@ -1497,7 +1497,7 @@ open_top:
|
|||
outb(com->intr_ctl_port, IER_ERXRDY | IER_ETXRDY
|
||||
| IER_ERLS | IER_EMSC);
|
||||
}
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
/*
|
||||
* Handle initial DCD. Callout devices get a fake initial
|
||||
* DCD (trapdoor DCD). If we are callout, then any sleeping
|
||||
|
|
@ -1753,7 +1753,7 @@ sioinput(com)
|
|||
* semantics instead of the save-and-disable semantics
|
||||
* that are used everywhere else.
|
||||
*/
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
incc = com->iptr - buf;
|
||||
if (tp->t_rawq.c_cc + incc > tp->t_ihiwat
|
||||
&& (com->state & CS_RTS_IFLOW
|
||||
|
|
@ -1774,7 +1774,7 @@ sioinput(com)
|
|||
tp->t_lflag &= ~FLUSHO;
|
||||
comstart(tp);
|
||||
}
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
} while (buf < com->iptr);
|
||||
} else {
|
||||
do {
|
||||
|
|
@ -1783,7 +1783,7 @@ sioinput(com)
|
|||
* semantics instead of the save-and-disable semantics
|
||||
* that are used everywhere else.
|
||||
*/
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
line_status = buf[com->ierroff];
|
||||
recv_data = *buf++;
|
||||
if (line_status
|
||||
|
|
@ -1798,7 +1798,7 @@ sioinput(com)
|
|||
recv_data |= TTY_PE;
|
||||
}
|
||||
(*linesw[tp->t_line].l_rint)(recv_data, tp);
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
} while (buf < com->iptr);
|
||||
}
|
||||
com_events -= (com->iptr - com->ibuf);
|
||||
|
|
@ -1823,9 +1823,9 @@ siointr(arg)
|
|||
#ifndef COM_MULTIPORT
|
||||
com = (struct com_s *)arg;
|
||||
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
siointr1(com);
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
#else /* COM_MULTIPORT */
|
||||
bool_t possibly_more_intrs;
|
||||
int unit;
|
||||
|
|
@ -1837,7 +1837,7 @@ siointr(arg)
|
|||
* devices, then the edge from one may be lost because another is
|
||||
* on.
|
||||
*/
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
do {
|
||||
possibly_more_intrs = FALSE;
|
||||
for (unit = 0; unit < sio_numunits; ++unit) {
|
||||
|
|
@ -1856,7 +1856,7 @@ siointr(arg)
|
|||
/* XXX COM_UNLOCK(); */
|
||||
}
|
||||
} while (possibly_more_intrs);
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
#endif /* COM_MULTIPORT */
|
||||
}
|
||||
|
||||
|
|
@ -2264,7 +2264,7 @@ repeat:
|
|||
* Discard any events related to never-opened or
|
||||
* going-away devices.
|
||||
*/
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
incc = com->iptr - com->ibuf;
|
||||
com->iptr = com->ibuf;
|
||||
if (com->state & CS_CHECKMSR) {
|
||||
|
|
@ -2272,33 +2272,33 @@ repeat:
|
|||
com->state &= ~CS_CHECKMSR;
|
||||
}
|
||||
com_events -= incc;
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
continue;
|
||||
}
|
||||
if (com->iptr != com->ibuf) {
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
sioinput(com);
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
}
|
||||
if (com->state & CS_CHECKMSR) {
|
||||
u_char delta_modem_status;
|
||||
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
delta_modem_status = com->last_modem_status
|
||||
^ com->prev_modem_status;
|
||||
com->prev_modem_status = com->last_modem_status;
|
||||
com_events -= LOTS_OF_EVENTS;
|
||||
com->state &= ~CS_CHECKMSR;
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
if (delta_modem_status & MSR_DCD)
|
||||
(*linesw[tp->t_line].l_modem)
|
||||
(tp, com->prev_modem_status & MSR_DCD);
|
||||
}
|
||||
if (com->state & CS_ODONE) {
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
com_events -= LOTS_OF_EVENTS;
|
||||
com->state &= ~CS_ODONE;
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
if (!(com->state & CS_BUSY)
|
||||
&& !(com->extra_state & CSE_BUSYCHECK)) {
|
||||
timeout(siobusycheck, com, hz / 100);
|
||||
|
|
@ -2484,7 +2484,7 @@ comparam(tp, t)
|
|||
if (com->state >= (CS_BUSY | CS_TTGO))
|
||||
siointr1(com);
|
||||
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
splx(s);
|
||||
comstart(tp);
|
||||
if (com->ibufold != NULL) {
|
||||
|
|
@ -2518,7 +2518,7 @@ siosetwater(com, speed)
|
|||
for (ibufsize = 128; ibufsize < cp4ticks;)
|
||||
ibufsize <<= 1;
|
||||
if (ibufsize == com->ibufsize) {
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
@ -2528,7 +2528,7 @@ siosetwater(com, speed)
|
|||
*/
|
||||
ibuf = malloc(2 * ibufsize, M_DEVBUF, M_NOWAIT);
|
||||
if (ibuf == NULL) {
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
|
|
@ -2546,7 +2546,7 @@ siosetwater(com, speed)
|
|||
* Read current input buffer, if any. Continue with interrupts
|
||||
* disabled.
|
||||
*/
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
if (com->iptr != com->ibuf)
|
||||
sioinput(com);
|
||||
|
||||
|
|
@ -2581,7 +2581,7 @@ comstart(tp)
|
|||
if (com == NULL)
|
||||
return;
|
||||
s = spltty();
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
if (tp->t_state & TS_TTSTOP)
|
||||
com->state &= ~CS_TTGO;
|
||||
else
|
||||
|
|
@ -2594,7 +2594,7 @@ comstart(tp)
|
|||
&& com->state & CS_RTS_IFLOW)
|
||||
outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
|
||||
}
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
if (tp->t_state & (TS_TIMEOUT | TS_TTSTOP)) {
|
||||
ttwwakeup(tp);
|
||||
splx(s);
|
||||
|
|
@ -2610,7 +2610,7 @@ comstart(tp)
|
|||
sizeof com->obuf1);
|
||||
com->obufs[0].l_next = NULL;
|
||||
com->obufs[0].l_queued = TRUE;
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
if (com->state & CS_BUSY) {
|
||||
qp = com->obufq.l_next;
|
||||
while ((next = qp->l_next) != NULL)
|
||||
|
|
@ -2622,7 +2622,7 @@ comstart(tp)
|
|||
com->obufq.l_next = &com->obufs[0];
|
||||
com->state |= CS_BUSY;
|
||||
}
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
}
|
||||
if (tp->t_outq.c_cc != 0 && !com->obufs[1].l_queued) {
|
||||
com->obufs[1].l_tail
|
||||
|
|
@ -2630,7 +2630,7 @@ comstart(tp)
|
|||
sizeof com->obuf2);
|
||||
com->obufs[1].l_next = NULL;
|
||||
com->obufs[1].l_queued = TRUE;
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
if (com->state & CS_BUSY) {
|
||||
qp = com->obufq.l_next;
|
||||
while ((next = qp->l_next) != NULL)
|
||||
|
|
@ -2642,14 +2642,14 @@ comstart(tp)
|
|||
com->obufq.l_next = &com->obufs[1];
|
||||
com->state |= CS_BUSY;
|
||||
}
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
}
|
||||
tp->t_state |= TS_BUSY;
|
||||
}
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
if (com->state >= (CS_BUSY | CS_TTGO))
|
||||
siointr1(com); /* fake interrupt to start output */
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
ttwwakeup(tp);
|
||||
splx(s);
|
||||
}
|
||||
|
|
@ -2664,7 +2664,7 @@ comstop(tp, rw)
|
|||
com = com_addr(DEV_TO_UNIT(tp->t_dev));
|
||||
if (com == NULL || com->gone)
|
||||
return;
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
if (rw & FWRITE) {
|
||||
if (com->hasfifo)
|
||||
#ifdef COM_ESP
|
||||
|
|
@ -2691,7 +2691,7 @@ comstop(tp, rw)
|
|||
com_events -= (com->iptr - com->ibuf);
|
||||
com->iptr = com->ibuf;
|
||||
}
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
comstart(tp);
|
||||
}
|
||||
|
||||
|
|
@ -2734,7 +2734,7 @@ commctl(com, bits, how)
|
|||
mcr |= MCR_RTS;
|
||||
if (com->gone)
|
||||
return(0);
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
switch (how) {
|
||||
case DMSET:
|
||||
outb(com->modem_ctl_port,
|
||||
|
|
@ -2747,7 +2747,7 @@ commctl(com, bits, how)
|
|||
outb(com->modem_ctl_port, com->mcr_image &= ~mcr);
|
||||
break;
|
||||
}
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
@ -2806,9 +2806,9 @@ comwakeup(chan)
|
|||
com = com_addr(unit);
|
||||
if (com != NULL && !com->gone
|
||||
&& (com->state >= (CS_BUSY | CS_TTGO) || com->poll)) {
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
siointr1(com);
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2830,10 +2830,10 @@ comwakeup(chan)
|
|||
u_int delta;
|
||||
u_long total;
|
||||
|
||||
mtx_enter(&sio_lock, MTX_SPIN);
|
||||
mtx_lock_spin(&sio_lock);
|
||||
delta = com->delta_error_counts[errnum];
|
||||
com->delta_error_counts[errnum] = 0;
|
||||
mtx_exit(&sio_lock, MTX_SPIN);
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
if (delta == 0)
|
||||
continue;
|
||||
total = com->error_counts[errnum] += delta;
|
||||
|
|
|
|||
|
|
@ -102,18 +102,18 @@ cd9660_ihashget(dev, inum)
|
|||
struct vnode *vp;
|
||||
|
||||
loop:
|
||||
mtx_enter(&cd9660_ihash_mtx, MTX_DEF);
|
||||
mtx_lock(&cd9660_ihash_mtx);
|
||||
for (ip = isohashtbl[INOHASH(dev, inum)]; ip; ip = ip->i_next) {
|
||||
if (inum == ip->i_number && dev == ip->i_dev) {
|
||||
vp = ITOV(ip);
|
||||
mtx_enter(&vp->v_interlock, MTX_DEF);
|
||||
mtx_exit(&cd9660_ihash_mtx, MTX_DEF);
|
||||
mtx_lock(&vp->v_interlock);
|
||||
mtx_unlock(&cd9660_ihash_mtx);
|
||||
if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p))
|
||||
goto loop;
|
||||
return (vp);
|
||||
}
|
||||
}
|
||||
mtx_exit(&cd9660_ihash_mtx, MTX_DEF);
|
||||
mtx_unlock(&cd9660_ihash_mtx);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
|
@ -127,14 +127,14 @@ cd9660_ihashins(ip)
|
|||
struct proc *p = curproc; /* XXX */
|
||||
struct iso_node **ipp, *iq;
|
||||
|
||||
mtx_enter(&cd9660_ihash_mtx, MTX_DEF);
|
||||
mtx_lock(&cd9660_ihash_mtx);
|
||||
ipp = &isohashtbl[INOHASH(ip->i_dev, ip->i_number)];
|
||||
if ((iq = *ipp) != NULL)
|
||||
iq->i_prev = &ip->i_next;
|
||||
ip->i_next = iq;
|
||||
ip->i_prev = ipp;
|
||||
*ipp = ip;
|
||||
mtx_exit(&cd9660_ihash_mtx, MTX_DEF);
|
||||
mtx_unlock(&cd9660_ihash_mtx);
|
||||
|
||||
lockmgr(&ip->i_vnode->v_lock, LK_EXCLUSIVE, (struct mtx *)0, p);
|
||||
}
|
||||
|
|
@ -148,7 +148,7 @@ cd9660_ihashrem(ip)
|
|||
{
|
||||
register struct iso_node *iq;
|
||||
|
||||
mtx_enter(&cd9660_ihash_mtx, MTX_DEF);
|
||||
mtx_lock(&cd9660_ihash_mtx);
|
||||
if ((iq = ip->i_next) != NULL)
|
||||
iq->i_prev = ip->i_prev;
|
||||
*ip->i_prev = iq;
|
||||
|
|
@ -156,7 +156,7 @@ cd9660_ihashrem(ip)
|
|||
ip->i_next = NULL;
|
||||
ip->i_prev = NULL;
|
||||
#endif
|
||||
mtx_exit(&cd9660_ihash_mtx, MTX_DEF);
|
||||
mtx_unlock(&cd9660_ihash_mtx);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -485,9 +485,9 @@ exec_elf_imgact(struct image_params *imgp)
|
|||
* a context switch. Better safe than sorry; I really don't want
|
||||
* the file to change while it's being loaded.
|
||||
*/
|
||||
mtx_enter(&imgp->vp->v_interlock, MTX_DEF);
|
||||
mtx_lock(&imgp->vp->v_interlock);
|
||||
imgp->vp->v_flag |= VTEXT;
|
||||
mtx_exit(&imgp->vp->v_interlock, MTX_DEF);
|
||||
mtx_unlock(&imgp->vp->v_interlock);
|
||||
|
||||
if ((error = exec_extract_strings(imgp)) != 0)
|
||||
goto fail;
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue