Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/aarch64/aarch64 prevent switching to CPUs that are ...



details:   https://anonhg.NetBSD.org/src/rev/a28efa0c971e
branches:  trunk
changeset: 454152:a28efa0c971e
user:      ryo <ryo%NetBSD.org@localhost>
date:      Sat Sep 07 09:27:25 2019 +0000

description:
prevent switching to CPUs that are not responding to IPI_DDB.

diffstat:

 sys/arch/aarch64/aarch64/db_machdep.c |  29 ++++++++++++++++++++++++-----
 1 files changed, 24 insertions(+), 5 deletions(-)

diffs (79 lines):

diff -r 63031f4d6564 -r a28efa0c971e sys/arch/aarch64/aarch64/db_machdep.c
--- a/sys/arch/aarch64/aarch64/db_machdep.c     Sat Sep 07 09:21:17 2019 +0000
+++ b/sys/arch/aarch64/aarch64/db_machdep.c     Sat Sep 07 09:27:25 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: db_machdep.c,v 1.18 2019/09/07 09:21:17 ryo Exp $ */
+/* $NetBSD: db_machdep.c,v 1.19 2019/09/07 09:27:25 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.18 2019/09/07 09:21:17 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.19 2019/09/07 09:27:25 ryo Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd32.h"
@@ -868,24 +868,39 @@
 volatile struct cpu_info *db_trigger;
 volatile struct cpu_info *db_onproc;
 volatile struct cpu_info *db_newcpu;
+volatile int db_readytoswitch[MAXCPUS];
 
 #ifdef _KERNEL
 void
 db_md_switch_cpu_cmd(db_expr_t addr, bool have_addr, db_expr_t count,
     const char *modif)
 {
+       struct cpu_info *new_ci = NULL;
        u_int cpuno = (u_int)addr;
+       int i;
+
+       membar_consumer();
 
-       if (!have_addr || (cpuno >= ncpu)) {
-               db_printf("cpu: 0..%d\n", ncpu - 1);
+       if (!have_addr) {
+               for (i = 0; i < ncpu; i++) {
+                       if (db_readytoswitch[i] != 0)
+                               db_printf("cpu%d: ready\n", i);
+                       else
+                               db_printf("cpu%d: not responding\n", i);
+               }
                return;
        }
 
-       struct cpu_info *new_ci = cpu_lookup(cpuno);
+       if (cpuno < ncpu)
+               new_ci = cpu_lookup(cpuno);
        if (new_ci == NULL) {
                db_printf("cpu %u does not exist", cpuno);
                return;
        }
+       if (db_readytoswitch[new_ci->ci_index] == 0) {
+               db_printf("cpu %u is not responding", cpuno);
+               return;
+       }
 
        if (new_ci == curcpu())
                return;
@@ -940,6 +955,8 @@
                db_trigger = ci;
                membar_producer();
        }
+       db_readytoswitch[ci->ci_index] = 1;
+       membar_producer();
 #endif
 
        for (;;) {
@@ -993,6 +1010,8 @@
                __asm __volatile ("sev; sev; sev");
        }
        db_trigger = NULL;
+       db_readytoswitch[ci->ci_index] = 0;
+       membar_producer();
 #endif
 
        return 1;



Home | Main Index | Thread Index | Old Index