Get rid of the IPI simple_lock.

This commit is contained in:
martin 2008-02-22 10:55:00 +00:00
parent 49ffaced1c
commit 1fc8a17916
6 changed files with 36 additions and 86 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu.h,v 1.71 2008/02/18 21:08:42 martin Exp $ */
/* $NetBSD: cpu.h,v 1.72 2008/02/22 10:55:00 martin Exp $ */
/*
* Copyright (c) 1992, 1993
@ -210,9 +210,9 @@ void cpu_boot_secondary_processors(void);
*/
typedef void (* ipifunc_t)(void *);
void sparc64_multicast_ipi (sparc64_cpuset_t, ipifunc_t);
void sparc64_broadcast_ipi (ipifunc_t);
void sparc64_send_ipi (int, ipifunc_t);
void sparc64_multicast_ipi (sparc64_cpuset_t, ipifunc_t, uint64_t);
void sparc64_broadcast_ipi (ipifunc_t, uint64_t);
void sparc64_send_ipi (int, ipifunc_t, uint64_t);
#endif
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: pte.h,v 1.18 2006/09/08 23:08:05 mrg Exp $ */
/* $NetBSD: pte.h,v 1.19 2008/02/22 10:55:00 martin Exp $ */
/*
* Copyright (c) 1996-1999 Eduardo Horvath
@ -130,12 +130,6 @@ struct sun4u_tte {
#endif
typedef struct sun4u_tte pte_t;
/* TLB shootdown handler arguments. */
struct ipi_tlb_args {
vaddr_t ita_vaddr;
int ita_ctx;
};
/* Assembly routines to flush TLB mappings */
void sp_tlb_flush_pte(vaddr_t, int);
void sp_tlb_flush_ctx(int);

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.50 2007/12/09 20:12:54 martin Exp $
# $NetBSD: genassym.cf,v 1.51 2008/02/22 10:55:00 martin Exp $
#
# Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -293,10 +293,6 @@ define DBR_LOCAL offsetof(struct db_regs, dbr_local)
define DBR_IN offsetof(struct db_regs, dbr_in)
endif
# TLB IPI handler arguments.
define ITA_VADDR offsetof(struct ipi_tlb_args, ita_vaddr)
define ITA_CTX offsetof(struct ipi_tlb_args, ita_ctx)
# pte_t structure.
define TTE_VPN offsetof(pte_t, tag)
define TTE_DATA offsetof(pte_t, data)

View File

@ -1,4 +1,4 @@
/* $NetBSD: ipifuncs.c,v 1.12 2008/01/26 11:42:45 nakayama Exp $ */
/* $NetBSD: ipifuncs.c,v 1.13 2008/02/22 10:55:00 martin Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ipifuncs.c,v 1.12 2008/01/26 11:42:45 nakayama Exp $");
__KERNEL_RCSID(0, "$NetBSD: ipifuncs.c,v 1.13 2008/02/22 10:55:00 martin Exp $");
#include "opt_ddb.h"
@ -63,19 +63,10 @@ static volatile sparc64_cpuset_t cpus_halted;
static volatile sparc64_cpuset_t cpus_paused;
static volatile sparc64_cpuset_t cpus_resumed;
volatile struct ipi_tlb_args ipi_tlb_args;
/* IPI handlers. */
static int sparc64_ipi_wait(sparc64_cpuset_t volatile *, sparc64_cpuset_t);
static void sparc64_ipi_error(const char *, sparc64_cpuset_t, sparc64_cpuset_t);
/*
* This must be locked around all message transactions to ensure only
* one CPU is generating them.
* XXX this is from sparc, but it isn't necessary here, but we'll do
* XXX it anyway for now, just to keep some things known.
*/
static struct simplelock sparc64_ipi_lock = SIMPLELOCK_INITIALIZER;
/*
* These are the "function" entry points in locore.s to handle IPI's.
@ -161,7 +152,7 @@ sparc64_ipi_init()
* Send an IPI to all in the list but ourselves.
*/
void
sparc64_multicast_ipi(sparc64_cpuset_t cpuset, ipifunc_t func)
sparc64_multicast_ipi(sparc64_cpuset_t cpuset, ipifunc_t func, uint64_t arg1)
{
struct cpu_info *ci;
@ -172,7 +163,7 @@ sparc64_multicast_ipi(sparc64_cpuset_t cpuset, ipifunc_t func)
for (ci = cpus; ci != NULL; ci = ci->ci_next) {
if (CPUSET_HAS(cpuset, ci->ci_index)) {
CPUSET_DEL(cpuset, ci->ci_index);
sparc64_send_ipi(ci->ci_cpuid, func);
sparc64_send_ipi(ci->ci_cpuid, func, arg1);
}
}
}
@ -181,37 +172,34 @@ sparc64_multicast_ipi(sparc64_cpuset_t cpuset, ipifunc_t func)
* Broadcast an IPI to all but ourselves.
*/
void
sparc64_broadcast_ipi(ipifunc_t func)
sparc64_broadcast_ipi(ipifunc_t func, uint64_t arg1)
{
sparc64_multicast_ipi(CPUSET_EXCEPT(cpus_active, cpu_number()), func);
sparc64_multicast_ipi(CPUSET_EXCEPT(cpus_active, cpu_number()), func,
arg1);
}
/*
* Send an interprocessor interrupt.
*/
void
sparc64_send_ipi(int upaid, ipifunc_t func)
sparc64_send_ipi(int upaid, ipifunc_t func, uint64_t arg1)
{
int i, ik;
uint64_t intr_number, intr_func, intr_arg;
uint64_t intr_func;
if (ldxa(0, ASR_IDSR) & IDSR_BUSY) {
__asm __volatile("ta 1; nop");
}
if (ldxa(0, ASR_IDSR) & IDSR_BUSY)
panic("recursive IPI?");
/* Setup interrupt data. */
intr_number = 0;
intr_func = (uint64_t)(u_long)func;
intr_arg = (uint64_t)(u_long)&ipi_tlb_args;
/* Schedule an interrupt. */
for (i = 0; i < SPARC64_IPI_RETRIES; i++) {
int s = intr_disable();
stxa(IDDR_0H, ASI_INTERRUPT_DISPATCH, intr_number);
stxa(IDDR_0H, ASI_INTERRUPT_DISPATCH, 0);
stxa(IDDR_1H, ASI_INTERRUPT_DISPATCH, intr_func);
stxa(IDDR_2H, ASI_INTERRUPT_DISPATCH, intr_arg);
stxa(IDDR_2H, ASI_INTERRUPT_DISPATCH, arg1);
stxa(IDCR(upaid), ASI_INTERRUPT_DISPATCH, 0);
membar_sync();
@ -230,14 +218,12 @@ sparc64_send_ipi(int upaid, ipifunc_t func)
return;
}
#if 0
if (db_active || panicstr != NULL)
printf("ipi_send: couldn't send ipi to module %u\n", upaid);
if (!db_active && panicstr == NULL)
panic("cpu%d: ipi_send: couldn't send ipi to UPAID %u",
cpu_number(), upaid);
else
panic("ipi_send: couldn't send ipi");
#else
__asm __volatile("ta 1; nop" : :);
#endif
printf("\noops, can't send IPI from cpu%d to UPAID %u\n",
cpu_number(), upaid);
}
/*
@ -273,13 +259,9 @@ mp_halt_cpus()
if (CPUSET_EMPTY(cpuset))
return;
simple_lock(&sparc64_ipi_lock);
sparc64_multicast_ipi(cpuset, sparc64_ipi_halt);
sparc64_multicast_ipi(cpuset, sparc64_ipi_halt, 0);
if (sparc64_ipi_wait(&cpus_halted, cpumask))
sparc64_ipi_error("halt", cpumask, cpus_halted);
simple_unlock(&sparc64_ipi_lock);
}
/*
@ -296,13 +278,9 @@ mp_pause_cpus()
if (CPUSET_EMPTY(cpuset))
return;
simple_lock(&sparc64_ipi_lock);
sparc64_multicast_ipi(cpuset, sparc64_ipi_pause);
sparc64_multicast_ipi(cpuset, sparc64_ipi_pause, 0);
if (sparc64_ipi_wait(&cpus_paused, cpuset))
sparc64_ipi_error("pause", cpus_paused, cpuset);
simple_unlock(&sparc64_ipi_lock);
}
/*
@ -339,15 +317,8 @@ smp_tlb_flush_pte(vaddr_t va, int ctx)
/* Flush our own TLB */
sp_tlb_flush_pte(va, ctx);
simple_lock(&sparc64_ipi_lock);
/* Flush others */
ipi_tlb_args.ita_vaddr = va;
ipi_tlb_args.ita_ctx = ctx;
sparc64_broadcast_ipi(sparc64_ipi_flush_pte);
simple_unlock(&sparc64_ipi_lock);
/* sparc64_broadcast_ipi(sparc64_ipi_flush_ctx, ctx); */
}
/*
@ -359,15 +330,8 @@ smp_tlb_flush_ctx(int ctx)
/* Flush our own TLB */
sp_tlb_flush_ctx(ctx);
simple_lock(&sparc64_ipi_lock);
/* Flush others */
ipi_tlb_args.ita_vaddr = (vaddr_t)0;
ipi_tlb_args.ita_ctx = ctx;
sparc64_broadcast_ipi(sparc64_ipi_flush_ctx);
simple_unlock(&sparc64_ipi_lock);
sparc64_broadcast_ipi(sparc64_ipi_flush_ctx, ctx);
}
/*
@ -379,12 +343,8 @@ smp_tlb_flush_all()
/* Flush our own TLB */
sp_tlb_flush_all();
simple_lock(&sparc64_ipi_lock);
/* Flush others */
sparc64_broadcast_ipi(sparc64_ipi_flush_all);
simple_unlock(&sparc64_ipi_lock);
sparc64_broadcast_ipi(sparc64_ipi_flush_all, 0);
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.215 2008/01/16 08:00:29 skrll Exp $ */
/* $NetBSD: machdep.c,v 1.216 2008/02/22 10:55:00 martin Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -78,7 +78,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.215 2008/01/16 08:00:29 skrll Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.216 2008/02/22 10:55:00 martin Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@ -1970,7 +1970,7 @@ cpu_need_resched(struct cpu_info *ci, int flags)
#if defined(MULTIPROCESSOR)
/* Just interrupt the target CPU, so it can notice its AST */
if ((flags & RESCHED_IMMED) || ci->ci_index != cpu_number())
sparc64_send_ipi(ci->ci_cpuid, sparc64_ipi_nop);
sparc64_send_ipi(ci->ci_cpuid, sparc64_ipi_nop, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: vm_machdep.c,v 1.77 2007/10/17 19:57:32 garbled Exp $ */
/* $NetBSD: vm_machdep.c,v 1.78 2008/02/22 10:55:00 martin Exp $ */
/*
* Copyright (c) 1996-2002 Eduardo Horvath. All rights reserved.
@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.77 2007/10/17 19:57:32 garbled Exp $");
__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.78 2008/02/22 10:55:00 martin Exp $");
#include "opt_coredump.h"
@ -313,7 +313,7 @@ save_and_clear_fpstate(struct lwp *l)
continue;
if (ci->ci_fplwp != l)
continue;
sparc64_send_ipi(ci->ci_cpuid, sparc64_ipi_save_fpstate);
sparc64_send_ipi(ci->ci_cpuid, sparc64_ipi_save_fpstate, 0);
break;
}
#endif
@ -352,7 +352,7 @@ cpu_lwp_free(l, proc)
if (l == ci->ci_fplwp) {
/* drop the fplwp from the other fpu */
sparc64_send_ipi(ci->ci_cpuid,
sparc64_ipi_drop_fpstate);
sparc64_ipi_drop_fpstate, 0);
break;
}
}