Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch ddb MP support



details:   https://anonhg.NetBSD.org/src/rev/80ce6e634350
branches:  trunk
changeset: 805918:80ce6e634350
user:      nonaka <nonaka%NetBSD.org@localhost>
date:      Fri Jan 23 07:27:05 2015 +0000

description:
ddb MP support

diffstat:

 sys/arch/evbppc/mpc85xx/machdep.c          |   10 +-
 sys/arch/powerpc/booke/booke_machdep.c     |    6 +-
 sys/arch/powerpc/booke/e500_intr.c         |   16 +-
 sys/arch/powerpc/include/booke/intr.h      |    3 +-
 sys/arch/powerpc/include/cpu.h             |   10 +-
 sys/arch/powerpc/include/db_machdep.h      |    6 +-
 sys/arch/powerpc/pic/ipi.c                 |    9 +-
 sys/arch/powerpc/pic/ipivar.h              |    5 +-
 sys/arch/powerpc/powerpc/db_interface.c    |  123 +++++++++++++-
 sys/arch/powerpc/powerpc/powerpc_machdep.c |  260 ++++++++++++++++++++++++++++-
 10 files changed, 428 insertions(+), 20 deletions(-)

diffs (truncated from 725 to 300 lines):

diff -r 2574659fe136 -r 80ce6e634350 sys/arch/evbppc/mpc85xx/machdep.c
--- a/sys/arch/evbppc/mpc85xx/machdep.c Fri Jan 23 06:58:32 2015 +0000
+++ b/sys/arch/evbppc/mpc85xx/machdep.c Fri Jan 23 07:27:05 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.39 2015/01/06 01:23:24 nonaka Exp $      */
+/*     $NetBSD: machdep.c,v 1.40 2015/01/23 07:27:05 nonaka Exp $      */
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -41,6 +41,7 @@
 #include "opt_altivec.h"
 #include "opt_ddb.h"
 #include "opt_mpc85xx.h"
+#include "opt_multiprocessor.h"
 #include "opt_pci.h"
 #include "gpio.h"
 #include "pci.h"
@@ -1054,6 +1055,13 @@
 void
 e500_ipi_halt(void)
 {
+#ifdef MULTIPROCESSOR
+       struct cpuset_info * const csi = &cpuset_info;
+       const cpuid_t index = cpu_index(curcpu());
+
+       printf("cpu%lu: shutting down\n", index);
+       kcpuset_set(csi->cpus_halted, index);
+#endif
        register_t msr, hid0;
 
        msr = wrtee(0);
diff -r 2574659fe136 -r 80ce6e634350 sys/arch/powerpc/booke/booke_machdep.c
--- a/sys/arch/powerpc/booke/booke_machdep.c    Fri Jan 23 06:58:32 2015 +0000
+++ b/sys/arch/powerpc/booke/booke_machdep.c    Fri Jan 23 07:27:05 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: booke_machdep.c,v 1.22 2015/01/23 06:39:41 nonaka Exp $        */
+/*     $NetBSD: booke_machdep.c,v 1.23 2015/01/23 07:27:05 nonaka Exp $        */
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 #define        _POWERPC_BUS_DMA_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: booke_machdep.c,v 1.22 2015/01/23 06:39:41 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: booke_machdep.c,v 1.23 2015/01/23 07:27:05 nonaka Exp $");
 
 #include "opt_modular.h"
 
@@ -230,6 +230,8 @@
        kcpuset_create(&cpuset_info.cpus_paused, true);
        kcpuset_create(&cpuset_info.cpus_resumed, true);
        kcpuset_create(&cpuset_info.cpus_halted, true);
+
+       kcpuset_set(cpuset_info.cpus_running, cpu_number());
 #endif /* MULTIPROCESSOR */
 }
 
diff -r 2574659fe136 -r 80ce6e634350 sys/arch/powerpc/booke/e500_intr.c
--- a/sys/arch/powerpc/booke/e500_intr.c        Fri Jan 23 06:58:32 2015 +0000
+++ b/sys/arch/powerpc/booke/e500_intr.c        Fri Jan 23 07:27:05 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: e500_intr.c,v 1.30 2015/01/23 06:16:23 nonaka Exp $    */
+/*     $NetBSD: e500_intr.c,v 1.31 2015/01/23 07:27:05 nonaka Exp $    */
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -35,11 +35,13 @@
  */
 
 #include "opt_mpc85xx.h"
+#include "opt_multiprocessor.h"
+#include "opt_ddb.h"
 
 #define __INTR_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.30 2015/01/23 06:16:23 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.31 2015/01/23 07:27:05 nonaka Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -1268,6 +1270,15 @@
 }
 #endif
 
+static void
+e500_ipi_suspend(void)
+{
+
+#ifdef MULTIPROCESSOR
+       cpu_pause(NULL);
+#endif /* MULTIPROCESSOR */
+}
+
 static const ipifunc_t e500_ipifuncs[] = {
        [ilog2(IPI_XCALL)] =    xc_ipi_handler,
        [ilog2(IPI_GENERIC)] =  ipi_cpu_handler,
@@ -1276,6 +1287,7 @@
        [ilog2(IPI_KPREEMPT)] = e500_ipi_kpreempt,
 #endif
        [ilog2(IPI_TLB1SYNC)] = e500_tlb1_sync,
+       [ilog2(IPI_SUSPEND)] =  e500_ipi_suspend,
 };
 
 static int
diff -r 2574659fe136 -r 80ce6e634350 sys/arch/powerpc/include/booke/intr.h
--- a/sys/arch/powerpc/include/booke/intr.h     Fri Jan 23 06:58:32 2015 +0000
+++ b/sys/arch/powerpc/include/booke/intr.h     Fri Jan 23 07:27:05 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr.h,v 1.8 2014/05/19 22:47:53 rmind Exp $   */
+/*     $NetBSD: intr.h,v 1.9 2015/01/23 07:27:05 nonaka Exp $  */
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -74,6 +74,7 @@
 #define        IPI_KPREEMPT    0x0004
 #define IPI_TLB1SYNC   0x0008
 #define IPI_GENERIC    0x0010
+#define IPI_SUSPEND    0x0020
 
 #define        __HAVE_FAST_SOFTINTS    1
 #define        SOFTINT_KPREEMPT        SOFTINT_COUNT
diff -r 2574659fe136 -r 80ce6e634350 sys/arch/powerpc/include/cpu.h
--- a/sys/arch/powerpc/include/cpu.h    Fri Jan 23 06:58:32 2015 +0000
+++ b/sys/arch/powerpc/include/cpu.h    Fri Jan 23 07:27:05 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.100 2014/03/24 19:29:59 christos Exp $       */
+/*     $NetBSD: cpu.h,v 1.101 2015/01/23 07:27:05 nonaka Exp $ */
 
 /*
  * Copyright (C) 1999 Wolfgang Solfrank.
@@ -393,6 +393,14 @@
        cpu_hatch(void);
 void   cpu_spinup_trampoline(void);
 void   cpu_boot_secondary_processors(void);
+void   cpu_halt(void);
+void   cpu_halt_others(void);
+void   cpu_pause(struct trapframe *);
+void   cpu_pause_others(void);
+void   cpu_resume(cpuid_t);
+void   cpu_resume_others(void);
+int    cpu_is_paused(int);
+void   cpu_debug_dump(void);
 #endif /* MULTIPROCESSOR */
 #endif /* !_MODULE */
 
diff -r 2574659fe136 -r 80ce6e634350 sys/arch/powerpc/include/db_machdep.h
--- a/sys/arch/powerpc/include/db_machdep.h     Fri Jan 23 06:58:32 2015 +0000
+++ b/sys/arch/powerpc/include/db_machdep.h     Fri Jan 23 07:27:05 2015 +0000
@@ -1,5 +1,5 @@
 /*     $OpenBSD: db_machdep.h,v 1.2 1997/03/21 00:48:48 niklas Exp $   */
-/*     $NetBSD: db_machdep.h,v 1.24 2011/06/14 03:28:32 matt Exp $     */
+/*     $NetBSD: db_machdep.h,v 1.25 2015/01/23 07:27:05 nonaka Exp $   */
 
 /* 
  * Mach Operating System
@@ -163,6 +163,10 @@
 void   kdb_kintr(void *);
 int    kdb_trap(int, void *);
 
+bool   ddb_running_on_this_cpu_p(void);
+bool   ddb_running_on_any_cpu_p(void);
+void   db_resume_others(void);
+
 /*
  * We have machine-dependent commands.
  */
diff -r 2574659fe136 -r 80ce6e634350 sys/arch/powerpc/pic/ipi.c
--- a/sys/arch/powerpc/pic/ipi.c        Fri Jan 23 06:58:32 2015 +0000
+++ b/sys/arch/powerpc/pic/ipi.c        Fri Jan 23 07:27:05 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ipi.c,v 1.11 2014/05/19 22:47:53 rmind Exp $ */
+/* $NetBSD: ipi.c,v 1.12 2015/01/23 07:27:05 nonaka Exp $ */
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ipi.c,v 1.11 2014/05/19 22:47:53 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipi.c,v 1.12 2015/01/23 07:27:05 nonaka Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_pic.h"
@@ -75,8 +75,13 @@
        if (ipi & IPI_GENERIC)
                ipi_cpu_handler();
 
+       if (ipi & IPI_SUSPEND)
+               cpu_pause(NULL);
+
        if (ipi & IPI_HALT) {
+               struct cpuset_info * const csi = &cpuset_info;
                aprint_normal("halting CPU %d\n", cpu_id);
+               kcpuset_set(csi->cpus_halted, cpu_id);
                msr = (mfmsr() & ~PSL_EE) | PSL_POW;
                for (;;) {
                        __asm volatile ("sync; isync");
diff -r 2574659fe136 -r 80ce6e634350 sys/arch/powerpc/pic/ipivar.h
--- a/sys/arch/powerpc/pic/ipivar.h     Fri Jan 23 06:58:32 2015 +0000
+++ b/sys/arch/powerpc/pic/ipivar.h     Fri Jan 23 07:27:05 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ipivar.h,v 1.7 2014/05/19 22:47:53 rmind Exp $ */
+/* $NetBSD: ipivar.h,v 1.8 2015/01/23 07:27:05 nonaka Exp $ */
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ipivar.h,v 1.7 2014/05/19 22:47:53 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipivar.h,v 1.8 2015/01/23 07:27:05 nonaka Exp $");
 
 #ifndef _IPI_VAR_H_
 #define _IPI_VAR_H_
@@ -55,6 +55,7 @@
 #define IPI_XCALL              0x0002
 #define IPI_KPREEMPT           0x0004
 #define IPI_GENERIC            0x0008
+#define IPI_SUSPEND            0x0010
 
 /* OpenPIC */
 void setup_openpic_ipi(void);
diff -r 2574659fe136 -r 80ce6e634350 sys/arch/powerpc/powerpc/db_interface.c
--- a/sys/arch/powerpc/powerpc/db_interface.c   Fri Jan 23 06:58:32 2015 +0000
+++ b/sys/arch/powerpc/powerpc/db_interface.c   Fri Jan 23 07:27:05 2015 +0000
@@ -1,19 +1,21 @@
-/*     $NetBSD: db_interface.c,v 1.52 2013/07/04 22:59:58 joerg Exp $ */
+/*     $NetBSD: db_interface.c,v 1.53 2015/01/23 07:27:05 nonaka Exp $ */
 /*     $OpenBSD: db_interface.c,v 1.2 1996/12/28 06:21:50 rahnds Exp $ */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.52 2013/07/04 22:59:58 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.53 2015/01/23 07:27:05 nonaka Exp $");
 
 #define USERACC
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
+#include "opt_multiprocessor.h"
 #include "opt_ppcarch.h"
 
 #include <sys/param.h>
 #include <sys/proc.h>
 #include <sys/systm.h>
 #include <sys/cpu.h>
+#include <sys/atomic.h>
 
 #include <dev/cons.h>
 
@@ -48,6 +50,7 @@
 #include <ddb/db_access.h>
 #include <ddb/db_lex.h>
 #include <ddb/db_output.h>
+#include <ddb/db_run.h>        /* for db_continue_cmd() proto */
 #include <ddb/ddbvar.h>
 #endif
 
@@ -58,6 +61,9 @@
 
 #include <dev/ofw/openfirm.h>
 
+#define NOCPU   ~0
+volatile u_int ddb_cpu = NOCPU;
+
 int    db_active = 0;
 
 db_regs_t ddb_regs;
@@ -89,6 +95,10 @@
 static void db_ppcbooke_dumptlb(db_expr_t, bool, db_expr_t, const char *);
 #endif
 
+#ifdef MULTIPROCESSOR
+static void db_mach_cpu(db_expr_t, bool, db_expr_t, const char *);
+#endif /* MULTIPROCESSOR */
+
 #ifdef DDB
 const struct db_command db_machine_command_table[] = {
 #if defined (PPC_OEA) || defined(PPC_OEA64) || defined (PPC_OEA64_BRIDGE)
@@ -138,6 +148,12 @@
          "Display instruction translation storage buffer information.",
          NULL,NULL) },
 #endif /* PPC_BOOKE */
+
+#ifdef MULTIPROCESSOR
+       { DDB_ADD_CMD("cpu",    db_mach_cpu,    0,
+         "switch to another cpu", "cpu-no", NULL) },
+#endif /* MULTIPROCESSOR */
+
        { DDB_ADD_CMD(NULL,     NULL,                   0,
          NULL,NULL,NULL) }
 };
@@ -183,6 +199,8 @@
 kdb_trap(int type, void *v)
 {
        struct trapframe *tf = v;
+       int rv = 1;



Home | Main Index | Thread Index | Old Index