Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch MULTIPROCESSOR fixes
details: https://anonhg.NetBSD.org/src/rev/291ae6cfa719
branches: trunk
changeset: 755449:291ae6cfa719
user: skrll <skrll%NetBSD.org@localhost>
date: Sun Jun 06 12:13:35 2010 +0000
description:
MULTIPROCESSOR fixes
- provide curcpu in a control register instead of curlwp
- define {GET,SET}_CURLWP and GET_CURCPU and use whereever possible.
- define a cpu count and use it in CPU_INFO_FOREACH
XXX hppa_ncpus isn't valid yet.
diffstat:
sys/arch/hp700/dev/cpu.c | 8 ++++++--
sys/arch/hp700/hp700/locore.S | 30 ++++++++++++++++--------------
sys/arch/hp700/hp700/machdep.c | 15 +++++++++++----
sys/arch/hp700/include/cpu.h | 24 +++++++++++++++++++++---
sys/arch/hppa/hppa/copy.S | 10 +++++-----
sys/arch/hppa/hppa/trap.S | 22 ++++++++++++----------
sys/arch/hppa/include/reg.h | 6 +++++-
7 files changed, 76 insertions(+), 39 deletions(-)
diffs (truncated from 354 to 300 lines):
diff -r 03a465414c3b -r 291ae6cfa719 sys/arch/hp700/dev/cpu.c
--- a/sys/arch/hp700/dev/cpu.c Sun Jun 06 11:41:06 2010 +0000
+++ b/sys/arch/hp700/dev/cpu.c Sun Jun 06 12:13:35 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.14 2010/03/30 07:58:02 skrll Exp $ */
+/* $NetBSD: cpu.c,v 1.15 2010/06/06 12:13:35 skrll Exp $ */
/* $OpenBSD: cpu.c,v 1.28 2004/12/28 05:18:25 mickey Exp $ */
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.14 2010/03/30 07:58:02 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.15 2010/06/06 12:13:35 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -51,6 +51,10 @@
void *sc_ih;
};
+#ifdef MULTIPROCESSOR
+int hppa_ncpus;
+#endif
+
int cpumatch(device_t, cfdata_t, void *);
void cpuattach(device_t, device_t, void *);
diff -r 03a465414c3b -r 291ae6cfa719 sys/arch/hp700/hp700/locore.S
--- a/sys/arch/hp700/hp700/locore.S Sun Jun 06 11:41:06 2010 +0000
+++ b/sys/arch/hp700/hp700/locore.S Sun Jun 06 12:13:35 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.46 2010/04/05 12:56:51 skrll Exp $ */
+/* $NetBSD: locore.S,v 1.47 2010/06/06 12:13:35 skrll Exp $ */
/* $OpenBSD: locore.S,v 1.158 2008/07/28 19:08:46 miod Exp $ */
/*
@@ -142,6 +142,16 @@
#define MTCPU_U(x,r) .word 0x14001840 | ((r) << 21) | ((x) << 16)
#endif
+#ifdef MULTIPROCESSOR
+#define GET_CURCPU(r) mfctl CR_CURCPU, r
+#define GET_CURLWP(r) mfctl CR_CURCPU, r ! ldw CI_CURLWP(r), r
+#define SET_CURLWP(r,s) mfctl CR_CURCPU, s ! stw r, CI_CURLWP(s)
+#else
+#define GET_CURCPU(r) mfctl CR_CURLWP, r ! ldw L_CPU(r), r
+#define GET_CURLWP(r) mfctl CR_CURLWP, r
+#define SET_CURLWP(r,s) mtctl r, CR_CURLWP
+#endif
+
.import $global$, data
.import pdc, data
.import boothowto, data
@@ -537,8 +547,7 @@
* int splraise(int ncpl);
*/
LEAF_ENTRY(splraise)
- mfctl CR_CURLWP, %t1
- ldw L_CPU(%t1),%t1
+ GET_CURCPU(%t1)
ldw CI_CPL(%t1), %ret0
or %ret0, %arg0, %arg0
bv %r0(%rp)
@@ -549,8 +558,7 @@
* int spllower(int ncpl);
*/
ENTRY(spllower,HPPA_FRAME_SIZE)
- mfctl CR_CURLWP, %t1
- ldw L_CPU(%t1),%t1
+ GET_CURCPU(%t1)
ldw CI_IPENDING(%t1), %r1 ; load ipending
andcm,<> %r1, %arg0, %r1 ; and with complement of new cpl
@@ -615,8 +623,7 @@
* void hp700_intr_schedule(int mask);
*/
ENTRY(hp700_intr_schedule,0)
- mfctl CR_CURLWP, %t1
- ldw L_CPU(%t1),%t2
+ GET_CURCPU(%t2)
mfctl %eiem, %arg1
mtctl %r0, %eiem ; disable interrupts
ldw CI_IPENDING(%t2), %r1 ; load ipending
@@ -870,12 +877,7 @@
ldw TF_CR30(%t1), %t2 /* pmap_activate? */
mtctl %t2, CR_FPPADDR /* pmap_activate? */
- mtctl %arg1, CR_CURLWP
-
-#ifdef MULTIPROCESSOR
- ldw L_CPU(%arg1),%t2 ; %t2 = curcpu()
- stw %arg1, CI_CURLWP(%t2)
-#endif
+ SET_CURLWP(%arg1, %t2)
ldo -(HPPA_FRAME_SIZE+16*4)(%sp), %r3
@@ -991,7 +993,7 @@
* this LWP was created by the fork()
* syscall, which we now return from.
*/
- mfctl CR_CURLWP, %t2
+ GET_CURLWP(%t2)
.call
b syscall_return
ldw L_MD(%t2), %t3
diff -r 03a465414c3b -r 291ae6cfa719 sys/arch/hp700/hp700/machdep.c
--- a/sys/arch/hp700/hp700/machdep.c Sun Jun 06 11:41:06 2010 +0000
+++ b/sys/arch/hp700/hp700/machdep.c Sun Jun 06 12:13:35 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.87 2010/06/06 10:15:51 skrll Exp $ */
+/* $NetBSD: machdep.c,v 1.88 2010/06/06 12:13:35 skrll Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.87 2010/06/06 10:15:51 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.88 2010/06/06 12:13:35 skrll Exp $");
#include "opt_cputype.h"
#include "opt_ddb.h"
@@ -256,10 +256,13 @@
/* Virtual page frame for /dev/mem (see mem.c) */
vaddr_t vmmap;
+/* Our exported CPU info */
struct cpu_info cpus[HPPA_MAXCPUS] = {
+ {
#ifdef MULTIPROCESSOR
- .ci_curlwp = &lwp0
+ .ci_curlwp = &lwp0,
#endif
+ },
};
struct vm_map *phys_map = NULL;
@@ -426,8 +429,12 @@
#ifdef KGDB
boothowto |= RB_KDB; /* go to kgdb early if compiled in. */
#endif
- /* Setup curlwp early for LOCKDEBUG */
+ /* Setup curlwp/curcpu early for LOCKDEBUG */
+#ifdef MULTIPROCESSOR
+ mtctl(&cpus[0], CR_CURCPU);
+#else
mtctl(&lwp0, CR_CURLWP);
+#endif
/* Copy bootinfo */
if (bi != NULL)
diff -r 03a465414c3b -r 291ae6cfa719 sys/arch/hp700/include/cpu.h
--- a/sys/arch/hp700/include/cpu.h Sun Jun 06 11:41:06 2010 +0000
+++ b/sys/arch/hp700/include/cpu.h Sun Jun 06 12:13:35 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.51 2010/06/06 10:22:43 skrll Exp $ */
+/* $NetBSD: cpu.h,v 1.52 2010/06/06 12:13:36 skrll Exp $ */
/* $OpenBSD: cpu.h,v 1.55 2008/07/23 17:39:35 kettenis Exp $ */
@@ -231,7 +231,9 @@
struct cpu_data ci_data; /* MI per-cpu data */
+#ifdef MULTIPROCESSOR
struct lwp *ci_curlwp; /* CPU owner */
+#endif
int ci_cpuid; /* CPU index (see cpus[] array) */
int ci_mtx_count;
int ci_mtx_oldspl;
@@ -252,15 +254,31 @@
#ifdef MULTIPROCESSOR
+/* Number of CPUs in the system */
+extern int hppa_ncpus;
+
#define HPPA_MAXCPUS 4
#define cpu_number() (curcpu()->ci_cpuid)
#define CPU_IS_PRIMARY(ci) ((ci)->ci_cpuid == 0)
#define CPU_INFO_ITERATOR int
-#define CPU_INFO_FOREACH(cii, ci) cii = 0; ci = &cpus[0], cii < ncpus; cii++, ci++
+#define CPU_INFO_FOREACH(cii, ci) cii = 0; ci = &cpus[0], cii < hppa_ncpus; cii++, ci++
void cpu_boot_secondary_processors(void);
-#else /* MULTIPROCESSOR */
+
+static __inline struct cpu_info *
+hppa_curcpu(void)
+{
+ struct cpu_info *ci;
+
+ __asm volatile("mfctl %1, %0" : "=r" (ci): "i" (CR_CURCPU));
+
+ return ci;
+}
+
+#define curcpu() hppa_curcpu()
+
+#else /* MULTIPROCESSOR */
#define HPPA_MAXCPUS 1
#define curcpu() (&cpus[0])
diff -r 03a465414c3b -r 291ae6cfa719 sys/arch/hppa/hppa/copy.S
--- a/sys/arch/hppa/hppa/copy.S Sun Jun 06 11:41:06 2010 +0000
+++ b/sys/arch/hppa/hppa/copy.S Sun Jun 06 12:13:35 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: copy.S,v 1.16 2010/03/20 23:31:27 chs Exp $ */
+/* $NetBSD: copy.S,v 1.17 2010/06/06 12:13:36 skrll Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -98,7 +98,7 @@
LEAF_ENTRY_NOPROFILE(name) ! \
ldil L%VM_MAXUSER_ADDRESS, %t1 ! \
comb,>>= %arg0, %t1, fusubadaddr ! \
- mfctl CR_CURLWP, %t1 ! \
+ GET_CURLWP(%t1) ! \
ldw L_PCB(%t1), %t1 ! \
ldil L%fusufault, %t2 ! \
ldo R%fusufault(%t2), %t2 ! \
@@ -149,7 +149,7 @@
*/
LEAF_ENTRY(spstrcpy)
/* setup fault handler */
- mfctl CR_CURLWP, %r31
+ GET_CURLWP(%r31)
ldw L_PCB(%r31), %r31
ldil L%L$spstrcpy_fault, %t2
ldo R%L$spstrcpy_fault(%t2), %t2
@@ -222,7 +222,7 @@
/* This loads curlwp's space into the given register. */
#define SPACE_CURLWP(reg) \
- mfctl CR_CURLWP, reg ! \
+ GET_CURLWP(reg) ! \
ldw L_PCB(reg), reg ! \
ldw PCB_SPACE(reg), reg
@@ -352,7 +352,7 @@
comb,>>= %arg0, %t1, 1f
/* setup fault handler */
- mfctl CR_CURLWP, %r31
+ GET_CURLWP(%r31)
ldw L_PCB(%r31), %r31
ldil L%L$ucas_32_fault, %t2
ldo R%L$ucas_32_fault(%t2), %t2
diff -r 03a465414c3b -r 291ae6cfa719 sys/arch/hppa/hppa/trap.S
--- a/sys/arch/hppa/hppa/trap.S Sun Jun 06 11:41:06 2010 +0000
+++ b/sys/arch/hppa/hppa/trap.S Sun Jun 06 12:13:35 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.S,v 1.49 2010/04/26 12:10:51 skrll Exp $ */
+/* $NetBSD: trap.S,v 1.50 2010/06/06 12:13:36 skrll Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -203,7 +203,7 @@
*/
/* t2 = curlwp PCB */
- mfctl CR_CURLWP, %t3
+ GET_CURLWP(%t3)
ldw L_PCB(%sr1, %t3), %t2 /* XXX can use ,sl */
/*
@@ -399,7 +399,7 @@
CALL(syscall, %r1)
/* load curlwp's trapframe pointer */
- mfctl CR_CURLWP, %r1
+ GET_CURLWP(%r1)
ldw L_MD(%r1), %t3
.exit
@@ -421,8 +421,7 @@
* a note for trapall). Hopefully no page fault would happen on or after
* the copy, and interrupts are disabled.
*/
- mfctl CR_CURLWP, %t2
- ldw L_CPU(%t2), %t2
+ GET_CURCPU(%t2)
ldo CI_TRAPSAVE(%t2), %t2
ldw 0(%t3), %r1 ! ldw 4(%t3), %t1 ! stw %r1, 0(%t2) ! stw %t1, 4(%t2)
@@ -508,8 +507,13 @@
ldw TF_CR30(%sr3, %t3), %t1
mtctl %t1, CR_FPPADDR
+#ifdef MULTIPROCESSOR
+ mfctl CR_CURCPU, %t3
+#else
mfctl CR_CURLWP, %t3
ldw L_CPU(%sr3, %t3), %t3
+#endif
Home |
Main Index |
Thread Index |
Old Index