Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Provide and use a sev() macro for the sev instruction.



details:   https://anonhg.NetBSD.org/src/rev/59488c0ae4b7
branches:  trunk
changeset: 957549:59488c0ae4b7
user:      skrll <skrll%NetBSD.org@localhost>
date:      Thu Dec 03 07:45:51 2020 +0000

description:
Provide and use a sev() macro for the sev instruction.

While here use the correct barrier to ensure completion of memory accesses
before a couple of the sev() calls.

diffstat:

 sys/arch/aarch64/aarch64/db_machdep.c     |  12 ++++++------
 sys/arch/arm/acpi/cpu_acpi.c              |   6 +++---
 sys/arch/arm/arm/cpu_subr.c               |   8 ++++----
 sys/arch/arm/arm32/db_interface.c         |  15 ++++++---------
 sys/arch/arm/cortex/gic.c                 |   6 +++---
 sys/arch/arm/fdt/cpu_fdt.c                |   6 +++---
 sys/arch/arm/include/cpufunc.h            |   2 ++
 sys/arch/evbarm/bcm53xx/bcm53xx_machdep.c |   6 +++---
 sys/arch/evbarm/beagle/beagle_machdep.c   |   6 +++---
 sys/arch/evbarm/gumstix/gumstix_machdep.c |   4 ++--
 sys/arch/evbarm/zynq/zynq_machdep.c       |   6 +++---
 11 files changed, 38 insertions(+), 39 deletions(-)

diffs (truncated from 318 to 300 lines):

diff -r 8d742d185b56 -r 59488c0ae4b7 sys/arch/aarch64/aarch64/db_machdep.c
--- a/sys/arch/aarch64/aarch64/db_machdep.c     Wed Dec 02 14:20:19 2020 +0000
+++ b/sys/arch/aarch64/aarch64/db_machdep.c     Thu Dec 03 07:45:51 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: db_machdep.c,v 1.28 2020/10/22 07:31:15 skrll Exp $ */
+/* $NetBSD: db_machdep.c,v 1.29 2020/12/03 07:45:51 skrll 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.28 2020/10/22 07:31:15 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.29 2020/12/03 07:45:51 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd32.h"
@@ -1050,8 +1050,8 @@
                if ((ncpu > 1) && (db_newcpu != NULL)) {
                        db_onproc = db_newcpu;
                        db_newcpu = NULL;
-                       membar_producer();
-                       __asm __volatile ("sev; sev; sev");
+                       dsb(ishst);
+                       sev();
                        continue;       /* redo DDB on new cpu */
                }
 #endif /* MULTIPROCESSOR */
@@ -1062,8 +1062,8 @@
 #ifdef MULTIPROCESSOR
        if (ncpu > 1) {
                db_onproc = NULL;
-               membar_producer();
-               __asm __volatile ("sev; sev; sev");
+               dsb(ishst);
+               sev();
        }
        db_trigger = NULL;
        db_readytoswitch[ci->ci_index] = NULL;
diff -r 8d742d185b56 -r 59488c0ae4b7 sys/arch/arm/acpi/cpu_acpi.c
--- a/sys/arch/arm/acpi/cpu_acpi.c      Wed Dec 02 14:20:19 2020 +0000
+++ b/sys/arch/arm/acpi/cpu_acpi.c      Thu Dec 03 07:45:51 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_acpi.c,v 1.8 2020/02/15 08:16:10 skrll Exp $ */
+/* $NetBSD: cpu_acpi.c,v 1.9 2020/12/03 07:45:51 skrll Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu_acpi.c,v 1.8 2020/02/15 08:16:10 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_acpi.c,v 1.9 2020/12/03 07:45:51 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -113,7 +113,7 @@
                        return;
                }
 
-               __asm __volatile("sev" ::: "memory");
+               sev();
 
                for (u_int i = 0x10000000; i > 0; i--) {
                        if (cpu_hatched_p(cpuindex))
diff -r 8d742d185b56 -r 59488c0ae4b7 sys/arch/arm/arm/cpu_subr.c
--- a/sys/arch/arm/arm/cpu_subr.c       Wed Dec 02 14:20:19 2020 +0000
+++ b/sys/arch/arm/arm/cpu_subr.c       Thu Dec 03 07:45:51 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu_subr.c,v 1.2 2020/11/30 21:06:56 skrll Exp $       */
+/*     $NetBSD: cpu_subr.c,v 1.3 2020/12/03 07:45:52 skrll Exp $       */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.2 2020/11/30 21:06:56 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.3 2020/12/03 07:45:52 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -89,7 +89,7 @@
                atomic_or_ulong(&arm_cpu_mbox[n], arm_cpu_hatched[n]);
 
        dsb(ishst);
-       __asm __volatile ("sev");
+       sev();
 
        /* wait all cpus have done cpu_hatch() */
        for (cpuno = 1; cpuno < ncpu; cpuno++) {
@@ -140,7 +140,7 @@
        atomic_and_ulong(&arm_cpu_mbox[off], ~bit);
        membar_producer();
        dsb(ishst);
-       __asm __volatile("sev");
+       sev();
 }
 
 #endif
diff -r 8d742d185b56 -r 59488c0ae4b7 sys/arch/arm/arm32/db_interface.c
--- a/sys/arch/arm/arm32/db_interface.c Wed Dec 02 14:20:19 2020 +0000
+++ b/sys/arch/arm/arm32/db_interface.c Thu Dec 03 07:45:51 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_interface.c,v 1.62 2020/12/01 02:48:29 rin Exp $    */
+/*     $NetBSD: db_interface.c,v 1.63 2020/12/03 07:45:52 skrll Exp $  */
 
 /*
  * Copyright (c) 1996 Scott K. Stevens
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.62 2020/12/01 02:48:29 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.63 2020/12/03 07:45:52 skrll Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -172,10 +172,8 @@
                if (is_mp_p && db_newcpu != NULL) {
                        db_onproc = db_newcpu;
                        db_newcpu = NULL;
-#ifdef _ARM_ARCH_6
-                       membar_producer();
-                       __asm __volatile("sev; sev");
-#endif
+                       dsb(ishst);
+                       sev();
                        continue;
                }
                break;
@@ -187,9 +185,8 @@
                 * the other CPUs to exit.
                 */
                db_onproc = NULL;
-#ifdef _ARM_ARCH_6
-               __asm __volatile("sev; sev");
-#endif
+               dsb(ishst);
+               sev();
        }
 #endif
 
diff -r 8d742d185b56 -r 59488c0ae4b7 sys/arch/arm/cortex/gic.c
--- a/sys/arch/arm/cortex/gic.c Wed Dec 02 14:20:19 2020 +0000
+++ b/sys/arch/arm/cortex/gic.c Thu Dec 03 07:45:51 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gic.c,v 1.42 2020/09/26 10:06:25 skrll Exp $   */
+/*     $NetBSD: gic.c,v 1.43 2020/12/03 07:45:52 skrll Exp $   */
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -34,7 +34,7 @@
 #define _INTR_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gic.c,v 1.42 2020/09/26 10:06:25 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic.c,v 1.43 2020/12/03 07:45:52 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -539,7 +539,7 @@
 
 #if 0
        if (ipi == IPI_NOP) {
-               __asm __volatile("sev");
+               sev();
                return;
        }
 #endif
diff -r 8d742d185b56 -r 59488c0ae4b7 sys/arch/arm/fdt/cpu_fdt.c
--- a/sys/arch/arm/fdt/cpu_fdt.c        Wed Dec 02 14:20:19 2020 +0000
+++ b/sys/arch/arm/fdt/cpu_fdt.c        Thu Dec 03 07:45:51 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_fdt.c,v 1.37 2020/11/25 19:50:06 skrll Exp $ */
+/* $NetBSD: cpu_fdt.c,v 1.38 2020/12/03 07:45:52 skrll Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -30,7 +30,7 @@
 #include "psci_fdt.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.37 2020/11/25 19:50:06 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.38 2020/12/03 07:45:52 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -270,7 +270,7 @@
                }
 
                /* Wake up AP in case firmware has placed it in WFE state */
-               __asm __volatile("sev" ::: "memory");
+               sev();
 
                /* Wait for AP to start */
                for (i = 0x10000000; i > 0; i--) {
diff -r 8d742d185b56 -r 59488c0ae4b7 sys/arch/arm/include/cpufunc.h
--- a/sys/arch/arm/include/cpufunc.h    Wed Dec 02 14:20:19 2020 +0000
+++ b/sys/arch/arm/include/cpufunc.h    Thu Dec 03 07:45:51 2020 +0000
@@ -61,6 +61,7 @@
 #define        dsb(opt)        __asm __volatile("dsb " __STRING(opt) : : : "memory")
 #define        dmb(opt)        __asm __volatile("dmb " __STRING(opt) : : : "memory")
 #define        isb()           __asm __volatile("isb" : : : "memory")
+#define        sev()           __asm __volatile("sev" : : : "memory")
 
 #else
 
@@ -70,6 +71,7 @@
        __asm __volatile("mcr p15, 0, %0, c7, c10, 5" :: "r" (0) : "memory")
 #define isb()          \
        __asm __volatile("mcr p15, 0, %0, c7, c5, 4" :: "r" (0) : "memory")
+#define sev()          __nothing
 
 #endif
 
diff -r 8d742d185b56 -r 59488c0ae4b7 sys/arch/evbarm/bcm53xx/bcm53xx_machdep.c
--- a/sys/arch/evbarm/bcm53xx/bcm53xx_machdep.c Wed Dec 02 14:20:19 2020 +0000
+++ b/sys/arch/evbarm/bcm53xx/bcm53xx_machdep.c Thu Dec 03 07:45:51 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bcm53xx_machdep.c,v 1.25 2020/11/28 14:33:56 skrll Exp $       */
+/*     $NetBSD: bcm53xx_machdep.c,v 1.26 2020/12/03 07:45:52 skrll Exp $       */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #define IDM_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcm53xx_machdep.c,v 1.25 2020/11/28 14:33:56 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm53xx_machdep.c,v 1.26 2020/12/03 07:45:52 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_console.h"
@@ -243,7 +243,7 @@
        bus_space_write_4(bcm53xx_rom_bst, bcm53xx_rom_entry_bsh, mpstart);
 
        dsb(sy);
-       __asm __volatile("sev" ::: "memory");
+       sev();
 
        /* Bitmask of CPUs (non-BP) to start */
        for (u_int cpuindex = 1; cpuindex < arm_cpu_max; cpuindex++) {
diff -r 8d742d185b56 -r 59488c0ae4b7 sys/arch/evbarm/beagle/beagle_machdep.c
--- a/sys/arch/evbarm/beagle/beagle_machdep.c   Wed Dec 02 14:20:19 2020 +0000
+++ b/sys/arch/evbarm/beagle/beagle_machdep.c   Thu Dec 03 07:45:51 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: beagle_machdep.c,v 1.85 2020/10/30 18:54:37 skrll Exp $ */
+/*     $NetBSD: beagle_machdep.c,v 1.86 2020/12/03 07:45:52 skrll Exp $ */
 
 /*
  * Machine dependent functions for kernel setup for TI OSK5912 board.
@@ -125,7 +125,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: beagle_machdep.c,v 1.85 2020/10/30 18:54:37 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: beagle_machdep.c,v 1.86 2020/12/03 07:45:52 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_console.h"
@@ -488,7 +488,7 @@
 
 
        dsb(sy);
-       __asm __volatile("sev" ::: "memory");
+       sev();
 
        u_int hatched = 0;
        for (u_int cpuindex = 1; cpuindex < arm_cpu_max; cpuindex++) {
diff -r 8d742d185b56 -r 59488c0ae4b7 sys/arch/evbarm/gumstix/gumstix_machdep.c
--- a/sys/arch/evbarm/gumstix/gumstix_machdep.c Wed Dec 02 14:20:19 2020 +0000
+++ b/sys/arch/evbarm/gumstix/gumstix_machdep.c Thu Dec 03 07:45:51 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gumstix_machdep.c,v 1.70 2020/11/28 14:33:56 skrll Exp $ */
+/*     $NetBSD: gumstix_machdep.c,v 1.71 2020/12/03 07:45:53 skrll Exp $ */
 /*
  * Copyright (C) 2005, 2006, 2007  WIDE Project and SOUM Corporation.
  * All rights reserved.
@@ -538,7 +538,7 @@
        }
 
        dsb(sy);
-       __asm __volatile("sev" ::: "memory");
+       sev();
 
        u_int i;
        for (i = 0x10000000; i > 0; i--) {
diff -r 8d742d185b56 -r 59488c0ae4b7 sys/arch/evbarm/zynq/zynq_machdep.c
--- a/sys/arch/evbarm/zynq/zynq_machdep.c       Wed Dec 02 14:20:19 2020 +0000
+++ b/sys/arch/evbarm/zynq/zynq_machdep.c       Thu Dec 03 07:45:51 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: zynq_machdep.c,v 1.15 2020/11/28 14:33:57 skrll Exp $  */
+/*     $NetBSD: zynq_machdep.c,v 1.16 2020/12/03 07:45:53 skrll Exp $  */
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.



Home | Main Index | Thread Index | Old Index