From d940687d9bf0f6071270110efe4dacb3b31a677d Mon Sep 17 00:00:00 2001 From: macallan Date: Fri, 6 Aug 2010 00:07:05 +0000 Subject: [PATCH] do a better job synchronizing %tick across CPUs ok'ed by mrg --- sys/arch/sparc64/sparc64/cpu.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/sys/arch/sparc64/sparc64/cpu.c b/sys/arch/sparc64/sparc64/cpu.c index 9ce3b493fde3..ea861e56a2b1 100644 --- a/sys/arch/sparc64/sparc64/cpu.c +++ b/sys/arch/sparc64/sparc64/cpu.c @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.96 2010/07/28 21:34:57 macallan Exp $ */ +/* $NetBSD: cpu.c,v 1.97 2010/08/06 00:07:05 macallan Exp $ */ /* * Copyright (c) 1996 @@ -52,7 +52,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.96 2010/07/28 21:34:57 macallan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.97 2010/08/06 00:07:05 macallan Exp $"); #include "opt_multiprocessor.h" @@ -106,6 +106,8 @@ static const char *ipi_evcnt_names[IPI_EVCNT_NUM] = IPI_EVCNT_NAMES; static void cpu_reset_fpustate(void); +volatile int sync_tick = 0; + /* The CPU configuration driver. */ void cpu_attach(struct device *, struct device *, void *); int cpu_match(struct device *, struct cfdata *, void *); @@ -412,6 +414,8 @@ cpu_boot_secondary_processors(void) int i, pstate; struct cpu_info *ci; + sync_tick = 0; + sparc64_ipi_init(); if (boothowto & RB_MD1) { @@ -441,7 +445,13 @@ cpu_boot_secondary_processors(void) break; delay(10000); } + + /* synchronize %tick ( to some degree at least ) */ + delay(1000); + sync_tick = 1; + membar_sync(); settick(0); + setpstate(pstate); if (!CPUSET_HAS(cpus_active, ci->ci_index)) @@ -463,7 +473,13 @@ cpu_hatch(void) cpu_reset_fpustate(); curlwp = curcpu()->ci_data.cpu_idlelwp; membar_sync(); + + /* wait for the boot CPU to flip the switch */ + while (sync_tick == 0) { + /* we do nothing here */ + } settick(0); + tickintr_establish(PIL_CLOCK, tickintr); spl0(); }