diff options
author | jhb <jhb@FreeBSD.org> | 2001-12-18 00:27:18 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2001-12-18 00:27:18 +0000 |
commit | a3b98398cbfb4b809f8577b6a95aabb2c30a1aeb (patch) | |
tree | bd1f842c61588e8478e798dece6dff8b2be41310 /sys/alpha | |
parent | 090c933e94e7345e9c9e9a9fbe29ea6c8397a662 (diff) | |
download | FreeBSD-src-a3b98398cbfb4b809f8577b6a95aabb2c30a1aeb.zip FreeBSD-src-a3b98398cbfb4b809f8577b6a95aabb2c30a1aeb.tar.gz |
Modify the critical section API as follows:
- The MD functions critical_enter/exit are renamed to start with a cpu_
prefix.
- MI wrapper functions critical_enter/exit maintain a per-thread nesting
count and a per-thread critical section saved state set when entering
a critical section while at nesting level 0 and restored when exiting
to nesting level 0. This moves the saved state out of spin mutexes so
that interlocking spin mutexes works properly.
- Most low-level MD code that used critical_enter/exit now use
cpu_critical_enter/exit. MI code such as device drivers and spin
mutexes use the MI wrappers. Note that since the MI wrappers store
the state in the current thread, they do not have any return values or
arguments.
- mtx_intr_enable() is replaced with a constant CRITICAL_FORK which is
assigned to curthread->td_savecrit during fork_exit().
Tested on: i386, alpha
Diffstat (limited to 'sys/alpha')
-rw-r--r-- | sys/alpha/alpha/db_interface.c | 4 | ||||
-rw-r--r-- | sys/alpha/alpha/genassym.c | 1 | ||||
-rw-r--r-- | sys/alpha/alpha/interrupt.c | 4 | ||||
-rw-r--r-- | sys/alpha/alpha/machdep.c | 16 | ||||
-rw-r--r-- | sys/alpha/alpha/prom.c | 6 | ||||
-rw-r--r-- | sys/alpha/alpha/trap.c | 8 | ||||
-rw-r--r-- | sys/alpha/include/cpufunc.h | 6 | ||||
-rw-r--r-- | sys/alpha/include/mutex.h | 2 | ||||
-rw-r--r-- | sys/alpha/pci/cia.c | 8 | ||||
-rw-r--r-- | sys/alpha/pci/t2.c | 4 | ||||
-rw-r--r-- | sys/alpha/pci/t2_pci.c | 4 |
11 files changed, 31 insertions, 32 deletions
diff --git a/sys/alpha/alpha/db_interface.c b/sys/alpha/alpha/db_interface.c index fea763d..041b0b9 100644 --- a/sys/alpha/alpha/db_interface.c +++ b/sys/alpha/alpha/db_interface.c @@ -192,7 +192,7 @@ kdb_trap(a0, a1, a2, entry, regs) ddb_regs = *regs; - s = critical_enter(); + s = cpu_critical_enter(); #ifdef SMP #ifdef DIAGNOSTIC @@ -219,7 +219,7 @@ kdb_trap(a0, a1, a2, entry, regs) restart_cpus(stopped_cpus); #endif - critical_exit(s); + cpu_critical_exit(s); *regs = ddb_regs; diff --git a/sys/alpha/alpha/genassym.c b/sys/alpha/alpha/genassym.c index 8d68d73..e989675 100644 --- a/sys/alpha/alpha/genassym.c +++ b/sys/alpha/alpha/genassym.c @@ -76,7 +76,6 @@ ASSYM(PC_IDLEPCBPHYS, offsetof(struct pcpu, pc_idlepcbphys)); ASSYM(MTX_LOCK, offsetof(struct mtx, mtx_lock)); ASSYM(MTX_RECURSE, offsetof(struct mtx, mtx_recurse)); -ASSYM(MTX_SAVECRIT, offsetof(struct mtx, mtx_savecrit)); ASSYM(MTX_UNOWNED, MTX_UNOWNED); ASSYM(TD_PCB, offsetof(struct thread, td_pcb)); diff --git a/sys/alpha/alpha/interrupt.c b/sys/alpha/alpha/interrupt.c index 29bb74f..3143856 100644 --- a/sys/alpha/alpha/interrupt.c +++ b/sys/alpha/alpha/interrupt.c @@ -99,13 +99,13 @@ interrupt(a0, a1, a2, framep) * Find our per-cpu globals. */ #ifdef SMP - s = critical_enter(); + s = cpu_critical_enter(); #endif pcpup = (struct pcpu *) alpha_pal_rdval(); td = curthread; #ifdef SMP td->td_md.md_kernnest++; - critical_exit(s); + cpu_critical_exit(s); #endif atomic_add_int(&td->td_intr_nesting_level, 1); #ifndef KSTACK_GUARD diff --git a/sys/alpha/alpha/machdep.c b/sys/alpha/alpha/machdep.c index ef763a9..a6f181c 100644 --- a/sys/alpha/alpha/machdep.c +++ b/sys/alpha/alpha/machdep.c @@ -2007,11 +2007,11 @@ alpha_fpstate_check(struct thread *td) #ifndef SMP critical_t s; - s = critical_enter(); + s = cpu_critical_enter(); if (td->td_pcb->pcb_hw.apcb_flags & ALPHA_PCB_FLAGS_FEN) if (td != PCPU_GET(fpcurthread)) panic("alpha_check_fpcurthread: bogus"); - critical_exit(s); + cpu_critical_exit(s); #endif } @@ -2033,7 +2033,7 @@ alpha_fpstate_save(struct thread *td, int write) { critical_t s; - s = critical_enter(); + s = cpu_critical_enter(); if (td != NULL && td == PCPU_GET(fpcurthread)) { /* * If curthread != fpcurthread, then we need to enable FEN @@ -2068,7 +2068,7 @@ alpha_fpstate_save(struct thread *td, int write) alpha_pal_wrfen(0); } } - critical_exit(s); + cpu_critical_exit(s); } /* @@ -2081,7 +2081,7 @@ alpha_fpstate_drop(struct thread *td) { critical_t s; - s = critical_enter(); + s = cpu_critical_enter(); if (td == PCPU_GET(fpcurthread)) { if (td == curthread) { /* @@ -2097,7 +2097,7 @@ alpha_fpstate_drop(struct thread *td) } PCPU_SET(fpcurthread, NULL); } - critical_exit(s); + cpu_critical_exit(s); } /* @@ -2112,7 +2112,7 @@ alpha_fpstate_switch(struct thread *td) /* * Enable FEN so that we can access the fp registers. */ - s = critical_enter(); + s = cpu_critical_enter(); alpha_pal_wrfen(1); if (PCPU_GET(fpcurthread)) { /* @@ -2139,7 +2139,7 @@ alpha_fpstate_switch(struct thread *td) } td->td_md.md_flags |= MDP_FPUSED; - critical_exit(s); + cpu_critical_exit(s); } /* diff --git a/sys/alpha/alpha/prom.c b/sys/alpha/alpha/prom.c index 54d913a..d4dd267 100644 --- a/sys/alpha/alpha/prom.c +++ b/sys/alpha/alpha/prom.c @@ -193,7 +193,7 @@ enter_prom() pt_entry_t *lev1map; critical_t s; - s = critical_enter(); + s = cpu_critical_enter(); if (!prom_mapped) { #ifdef SIMOS @@ -232,7 +232,7 @@ leave_prom(s) lev1map[0] = saved_pte[0]; /* XXX */ prom_cache_sync(); /* XXX */ } - critical_exit(s); + cpu_critical_exit(s); } static void @@ -272,7 +272,7 @@ prom_halt(halt) /* * Turn off interrupts, for sanity. */ - critical_enter(); + cpu_critical_enter(); /* * Set "boot request" part of the CPU state depending on what diff --git a/sys/alpha/alpha/trap.c b/sys/alpha/alpha/trap.c index 4c7694d..99278fa 100644 --- a/sys/alpha/alpha/trap.c +++ b/sys/alpha/alpha/trap.c @@ -270,13 +270,13 @@ trap(a0, a1, a2, entry, framep) * Find our per-cpu globals. */ #ifdef SMP - s = critical_enter(); + s = cpu_critical_enter(); #endif pcpup = (struct pcpu *) alpha_pal_rdval(); td = curthread; #ifdef SMP td->td_md.md_kernnest++; - critical_exit(s); + cpu_critical_exit(s); #endif p = td->td_proc; @@ -672,13 +672,13 @@ syscall(code, framep) * Find our per-cpu globals. */ #ifdef SMP - s = critical_enter(); + s = cpu_critical_enter(); #endif pcpup = (struct pcpu *) alpha_pal_rdval(); td = curthread; #ifdef SMP td->td_md.md_kernnest++; - critical_exit(s); + cpu_critical_exit(s); #endif p = td->td_proc; diff --git a/sys/alpha/include/cpufunc.h b/sys/alpha/include/cpufunc.h index 51a1fdc..dbee911 100644 --- a/sys/alpha/include/cpufunc.h +++ b/sys/alpha/include/cpufunc.h @@ -35,6 +35,8 @@ #include <machine/chipset.h> #include <machine/alpha_cpu.h> +#define CRITICAL_FORK (ALPHA_PSL_IPL_0) + #ifdef __GNUC__ static __inline void @@ -46,13 +48,13 @@ breakpoint(void) #endif static __inline critical_t -critical_enter(void) +cpu_critical_enter(void) { return (alpha_pal_swpipl(ALPHA_PSL_IPL_MCES)); } static __inline void -critical_exit(critical_t ipl) +cpu_critical_exit(critical_t ipl) { alpha_pal_swpipl(ipl); } diff --git a/sys/alpha/include/mutex.h b/sys/alpha/include/mutex.h index 970049b..7300c08 100644 --- a/sys/alpha/include/mutex.h +++ b/sys/alpha/include/mutex.h @@ -39,8 +39,6 @@ /* Global locks */ extern struct mtx clock_lock; -#define mtx_intr_enable(mutex) do (mutex)->mtx_savecrit = ALPHA_PSL_IPL_0; while (0) - #endif /* _KERNEL */ #else /* !LOCORE */ diff --git a/sys/alpha/pci/cia.c b/sys/alpha/pci/cia.c index c2bcafc..09436e3 100644 --- a/sys/alpha/pci/cia.c +++ b/sys/alpha/pci/cia.c @@ -156,12 +156,12 @@ cia_swiz_set_hae_mem(void *arg, u_int32_t pa) u_int32_t msb = pa & REG1; critical_t s; - s = critical_enter(); + s = cpu_critical_enter(); cia_hae_mem = (cia_hae_mem & ~REG1) | msb; REGVAL(CIA_CSR_HAE_MEM) = cia_hae_mem; alpha_mb(); cia_hae_mem = REGVAL(CIA_CSR_HAE_MEM); - critical_exit(s); + cpu_critical_exit(s); } return pa & ~REG1; } @@ -226,7 +226,7 @@ cia_sgmap_invalidate_pyxis(void) int i; critical_t s; - s = critical_enter(); + s = cpu_critical_enter(); /* * Put the Pyxis into PCI loopback mode. @@ -257,7 +257,7 @@ cia_sgmap_invalidate_pyxis(void) REGVAL(CIA_CSR_CTRL) = ctrl; alpha_mb(); - critical_exit(s); + cpu_critical_exit(s); } static void diff --git a/sys/alpha/pci/t2.c b/sys/alpha/pci/t2.c index c8ade0c..d9d0b9d 100644 --- a/sys/alpha/pci/t2.c +++ b/sys/alpha/pci/t2.c @@ -118,14 +118,14 @@ t2_set_hae_mem(void *arg, u_int32_t pa) msb = pa & 0xf8000000; pa -= msb; msb >>= 27; /* t2 puts high bits in the bottom of the register */ - s = critical_enter(); + s = cpu_critical_enter(); if (msb != t2_hae_mem[hose]) { t2_hae_mem[hose] = msb; t2_csr[hose]->hae0_1 = t2_hae_mem[hose]; alpha_mb(); t2_hae_mem[hose] = t2_csr[hose]->hae0_1; } - critical_exit(s); + cpu_critical_exit(s); } return pa; } diff --git a/sys/alpha/pci/t2_pci.c b/sys/alpha/pci/t2_pci.c index 87a3dca..b50555f 100644 --- a/sys/alpha/pci/t2_pci.c +++ b/sys/alpha/pci/t2_pci.c @@ -92,7 +92,7 @@ t2_pcib_maxslots(device_t dev) #define T2_TYPE1_SETUP(b,s,old_hae3) if((b)) { \ do { \ - (s) = critical_enter(); \ + (s) = cpu_critical_enter(); \ (old_hae3) = REGVAL(T2_HAE0_3); \ alpha_mb(); \ REGVAL(T2_HAE0_3) = (old_hae3) | (1<<30); \ @@ -105,7 +105,7 @@ t2_pcib_maxslots(device_t dev) alpha_mb(); \ REGVAL(T2_HAE0_3) = (old_hae3); \ alpha_mb(); \ - critical_exit((s)); \ + cpu_critical_exit((s)); \ } while(0); \ } |