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.
This commit is contained in:
skrll 2020-12-03 07:45:51 +00:00
parent 0fff63c9f6
commit 69120ac14e
11 changed files with 38 additions and 39 deletions

View File

@ -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 @@ kdb_trap(int type, struct trapframe *tf)
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 @@ kdb_trap(int type, struct trapframe *tf)
#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;

View File

@ -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 @@ cpu_acpi_attach(device_t parent, device_t self, void *aux)
return;
}
__asm __volatile("sev" ::: "memory");
sev();
for (u_int i = 0x10000000; i > 0; i--) {
if (cpu_hatched_p(cpuindex))

View File

@ -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 @@ cpu_boot_secondary_processors(void)
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 @@ cpu_clr_mbox(int cpuindex)
atomic_and_ulong(&arm_cpu_mbox[off], ~bit);
membar_producer();
dsb(ishst);
__asm __volatile("sev");
sev();
}
#endif

View File

@ -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 @@ kdb_trap(int type, db_regs_t *regs)
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 @@ kdb_trap(int type, db_regs_t *regs)
* the other CPUs to exit.
*/
db_onproc = NULL;
#ifdef _ARM_ARCH_6
__asm __volatile("sev; sev");
#endif
dsb(ishst);
sev();
}
#endif

View File

@ -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 @@ armgic_ipi_send(struct pic_softc *pic, const kcpuset_t *kcp, u_long ipi)
#if 0
if (ipi == IPI_NOP) {
__asm __volatile("sev");
sev();
return;
}
#endif

View File

@ -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>
@ -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 @@ arm_fdt_cpu_mpstart(void)
}
/* 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--) {

View File

@ -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

View File

@ -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 @@ bcm53xx_mpstart(void)
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++) {

View File

@ -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 @@ beagle_mpstart(void)
dsb(sy);
__asm __volatile("sev" ::: "memory");
sev();
u_int hatched = 0;
for (u_int cpuindex = 1; cpuindex < arm_cpu_max; cpuindex++) {

View File

@ -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 @@ gumstix_mpstart(void)
}
dsb(sy);
__asm __volatile("sev" ::: "memory");
sev();
u_int i;
for (i = 0x10000000; i > 0; i--) {

View File

@ -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.
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: zynq_machdep.c,v 1.15 2020/11/28 14:33:57 skrll Exp $");
__KERNEL_RCSID(0, "$NetBSD: zynq_machdep.c,v 1.16 2020/12/03 07:45:53 skrll Exp $");
#include "opt_evbarm_boardtype.h"
#include "opt_arm_debug.h"
@ -221,7 +221,7 @@ zynq_mpstart(void)
bus_space_unmap(bst, bsh, ZYNQ7000_CPU1_ENTRY_SZ);
dsb(sy);
__asm __volatile("sev" ::: "memory");
sev();
u_int cpuindex = 1;
u_int i;