Fri Jul 29 21:21:43 2011 UTC ()
Don't shutdown the boostrap processor (BSP) because we may have to run
BIOS methods on it.  For example, ACPI requires that we execute the code
for changing sleep state on the BSP.

This may help the problem where folks' machines would hang instead of
powering off when they entered ACPI sleep state 5.

XXX If the BSP is already shut down, we should start it back up.


(dyoung)
diff -r1.89 -r1.90 src/sys/arch/x86/x86/cpu.c

cvs diff -r1.89 -r1.90 src/sys/arch/x86/x86/cpu.c (expand / switch to unified diff)

--- src/sys/arch/x86/x86/cpu.c 2011/06/22 09:28:08 1.89
+++ src/sys/arch/x86/x86/cpu.c 2011/07/29 21:21:43 1.90
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: cpu.c,v 1.89 2011/06/22 09:28:08 jruoho Exp $ */ 1/* $NetBSD: cpu.c,v 1.90 2011/07/29 21:21:43 dyoung Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2000, 2006, 2007, 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2000, 2006, 2007, 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Bill Sommerfeld of RedBack Networks Inc, and by Andrew Doran. 8 * by Bill Sommerfeld of RedBack Networks Inc, and by Andrew Doran.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -52,27 +52,27 @@ @@ -52,27 +52,27 @@
52 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 52 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
53 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 53 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
54 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR AND CONTRIBUTORS BE LIABLE 54 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR AND CONTRIBUTORS BE LIABLE
55 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 55 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
56 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 56 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
57 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 57 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 58 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
59 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 59 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
60 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 60 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
61 * SUCH DAMAGE. 61 * SUCH DAMAGE.
62 */ 62 */
63 63
64#include <sys/cdefs.h> 64#include <sys/cdefs.h>
65__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.89 2011/06/22 09:28:08 jruoho Exp $"); 65__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.90 2011/07/29 21:21:43 dyoung Exp $");
66 66
67#include "opt_ddb.h" 67#include "opt_ddb.h"
68#include "opt_mpbios.h" /* for MPDEBUG */ 68#include "opt_mpbios.h" /* for MPDEBUG */
69#include "opt_mtrr.h" 69#include "opt_mtrr.h"
70 70
71#include "lapic.h" 71#include "lapic.h"
72#include "ioapic.h" 72#include "ioapic.h"
73 73
74#ifdef i386 74#ifdef i386
75#include "npx.h" 75#include "npx.h"
76#endif 76#endif
77 77
78#include <sys/param.h> 78#include <sys/param.h>
@@ -1127,26 +1127,32 @@ cpu_resume(device_t dv, const pmf_qual_t @@ -1127,26 +1127,32 @@ cpu_resume(device_t dv, const pmf_qual_t
1127 1127
1128 if (sc->sc_wasonline) { 1128 if (sc->sc_wasonline) {
1129 mutex_enter(&cpu_lock); 1129 mutex_enter(&cpu_lock);
1130 err = cpu_setstate(ci, true); 1130 err = cpu_setstate(ci, true);
1131 mutex_exit(&cpu_lock); 1131 mutex_exit(&cpu_lock);
1132 } 1132 }
1133 1133
1134 return err == 0; 1134 return err == 0;
1135} 1135}
1136 1136
1137static bool 1137static bool
1138cpu_shutdown(device_t dv, int how) 1138cpu_shutdown(device_t dv, int how)
1139{ 1139{
 1140 struct cpu_softc *sc = device_private(dv);
 1141 struct cpu_info *ci = sc->sc_info;
 1142
 1143 if (ci->ci_flags & CPUF_BSP)
 1144 return false;
 1145
1140 return cpu_suspend(dv, NULL); 1146 return cpu_suspend(dv, NULL);
1141} 1147}
1142 1148
1143void 1149void
1144cpu_get_tsc_freq(struct cpu_info *ci) 1150cpu_get_tsc_freq(struct cpu_info *ci)
1145{ 1151{
1146 uint64_t last_tsc; 1152 uint64_t last_tsc;
1147 1153
1148 if (cpu_hascounter()) { 1154 if (cpu_hascounter()) {
1149 last_tsc = cpu_counter_serializing(); 1155 last_tsc = cpu_counter_serializing();
1150 i8254_delay(100000); 1156 i8254_delay(100000);
1151 ci->ci_data.cpu_cc_freq = 1157 ci->ci_data.cpu_cc_freq =
1152 (cpu_counter_serializing() - last_tsc) * 10; 1158 (cpu_counter_serializing() - last_tsc) * 10;