Get rid of RUN_ONCE(9). Should fix PR # kern/44043.
This commit is contained in:
parent
796e6c822e
commit
4fb79b4e25
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: acpi_cpu_md.c,v 1.61 2011/06/12 10:11:52 jruoho Exp $ */
|
||||
/* $NetBSD: acpi_cpu_md.c,v 1.62 2011/06/22 08:49:54 jruoho Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010, 2011 Jukka Ruohonen <jruohonen@iki.fi>
|
||||
|
@ -27,7 +27,7 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.61 2011/06/12 10:11:52 jruoho Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.62 2011/06/22 08:49:54 jruoho Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/bus.h>
|
||||
|
@ -373,9 +373,16 @@ acpicpu_md_cstate_start(struct acpicpu_softc *sc)
|
|||
int
|
||||
acpicpu_md_cstate_stop(void)
|
||||
{
|
||||
static char text[16];
|
||||
void (*func)(void);
|
||||
uint64_t xc;
|
||||
bool ipi;
|
||||
|
||||
x86_cpu_idle_get(&func, text, sizeof(text));
|
||||
|
||||
if (func == native_idle)
|
||||
return EALREADY;
|
||||
|
||||
ipi = (native_idle != x86_cpu_idle_halt) ? false : true;
|
||||
x86_cpu_idle_set(native_idle, native_idle_text, ipi);
|
||||
|
||||
|
@ -424,7 +431,25 @@ acpicpu_md_cstate_enter(int method, int state)
|
|||
int
|
||||
acpicpu_md_pstate_start(struct acpicpu_softc *sc)
|
||||
{
|
||||
uint64_t xc;
|
||||
uint64_t xc, val;
|
||||
|
||||
/*
|
||||
* Make sure EST is enabled.
|
||||
*/
|
||||
if ((sc->sc_flags & ACPICPU_FLAG_P_FFH) != 0) {
|
||||
|
||||
val = rdmsr(MSR_MISC_ENABLE);
|
||||
|
||||
if ((val & MSR_MISC_ENABLE_EST) == 0) {
|
||||
|
||||
val |= MSR_MISC_ENABLE_EST;
|
||||
wrmsr(MSR_MISC_ENABLE, val);
|
||||
val = rdmsr(MSR_MISC_ENABLE);
|
||||
|
||||
if ((val & MSR_MISC_ENABLE_EST) == 0)
|
||||
return ENOTTY;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset the APERF and MPERF counters.
|
||||
|
@ -440,8 +465,12 @@ acpicpu_md_pstate_start(struct acpicpu_softc *sc)
|
|||
int
|
||||
acpicpu_md_pstate_stop(void)
|
||||
{
|
||||
if (acpicpu_log != NULL)
|
||||
sysctl_teardown(&acpicpu_log);
|
||||
|
||||
if (acpicpu_log == NULL)
|
||||
return EALREADY;
|
||||
|
||||
sysctl_teardown(&acpicpu_log);
|
||||
acpicpu_log = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -452,7 +481,6 @@ acpicpu_md_pstate_init(struct acpicpu_softc *sc)
|
|||
struct cpu_info *ci = sc->sc_ci;
|
||||
struct acpicpu_pstate *ps, msr;
|
||||
uint32_t family, i = 0;
|
||||
uint64_t val;
|
||||
|
||||
(void)memset(&msr, 0, sizeof(struct acpicpu_pstate));
|
||||
|
||||
|
@ -461,24 +489,6 @@ acpicpu_md_pstate_init(struct acpicpu_softc *sc)
|
|||
case CPUVENDOR_IDT:
|
||||
case CPUVENDOR_INTEL:
|
||||
|
||||
/*
|
||||
* Make sure EST is enabled.
|
||||
*/
|
||||
if ((sc->sc_flags & ACPICPU_FLAG_P_FFH) != 0) {
|
||||
|
||||
val = rdmsr(MSR_MISC_ENABLE);
|
||||
|
||||
if ((val & MSR_MISC_ENABLE_EST) == 0) {
|
||||
|
||||
val |= MSR_MISC_ENABLE_EST;
|
||||
wrmsr(MSR_MISC_ENABLE, val);
|
||||
val = rdmsr(MSR_MISC_ENABLE);
|
||||
|
||||
if ((val & MSR_MISC_ENABLE_EST) == 0)
|
||||
return ENOTTY;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If the so-called Turbo Boost is present,
|
||||
* the P0-state is always the "turbo state".
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: acpi_cpu.c,v 1.43 2011/06/21 03:37:21 jruoho Exp $ */
|
||||
/* $NetBSD: acpi_cpu.c,v 1.44 2011/06/22 08:49:54 jruoho Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010, 2011 Jukka Ruohonen <jruohonen@iki.fi>
|
||||
|
@ -27,7 +27,7 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi_cpu.c,v 1.43 2011/06/21 03:37:21 jruoho Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi_cpu.c,v 1.44 2011/06/22 08:49:54 jruoho Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/cpu.h>
|
||||
|
@ -202,33 +202,17 @@ static int
|
|||
acpicpu_detach(device_t self, int flags)
|
||||
{
|
||||
struct acpicpu_softc *sc = device_private(self);
|
||||
int rv = 0;
|
||||
|
||||
sc->sc_cold = true;
|
||||
|
||||
acpicpu_evcnt_detach(self);
|
||||
acpi_deregister_notify(sc->sc_node);
|
||||
|
||||
if ((sc->sc_flags & ACPICPU_FLAG_C) != 0)
|
||||
rv = acpicpu_cstate_detach(self);
|
||||
|
||||
if (rv != 0)
|
||||
return rv;
|
||||
|
||||
if ((sc->sc_flags & ACPICPU_FLAG_P) != 0)
|
||||
rv = acpicpu_pstate_detach(self);
|
||||
|
||||
if (rv != 0)
|
||||
return rv;
|
||||
|
||||
if ((sc->sc_flags & ACPICPU_FLAG_T) != 0)
|
||||
rv = acpicpu_tstate_detach(self);
|
||||
|
||||
if (rv != 0)
|
||||
return rv;
|
||||
acpicpu_cstate_detach(self);
|
||||
acpicpu_pstate_detach(self);
|
||||
acpicpu_tstate_detach(self);
|
||||
|
||||
mutex_destroy(&sc->sc_mtx);
|
||||
|
||||
sc->sc_node->ad_device = NULL;
|
||||
|
||||
acpicpu_count--;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: acpi_cpu.h,v 1.41 2011/06/12 10:11:52 jruoho Exp $ */
|
||||
/* $NetBSD: acpi_cpu.h,v 1.42 2011/06/22 08:49:54 jruoho Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010, 2011 Jukka Ruohonen <jruohonen@iki.fi>
|
||||
|
@ -232,7 +232,7 @@ struct acpicpu_softc {
|
|||
};
|
||||
|
||||
void acpicpu_cstate_attach(device_t);
|
||||
int acpicpu_cstate_detach(device_t);
|
||||
void acpicpu_cstate_detach(device_t);
|
||||
void acpicpu_cstate_start(device_t);
|
||||
void acpicpu_cstate_suspend(void *);
|
||||
void acpicpu_cstate_resume(void *);
|
||||
|
@ -240,7 +240,7 @@ void acpicpu_cstate_callback(void *);
|
|||
void acpicpu_cstate_idle(void);
|
||||
|
||||
void acpicpu_pstate_attach(device_t);
|
||||
int acpicpu_pstate_detach(device_t);
|
||||
void acpicpu_pstate_detach(device_t);
|
||||
void acpicpu_pstate_start(device_t);
|
||||
void acpicpu_pstate_suspend(void *);
|
||||
void acpicpu_pstate_resume(void *);
|
||||
|
@ -249,7 +249,7 @@ int acpicpu_pstate_get(struct cpu_info *, uint32_t *);
|
|||
void acpicpu_pstate_set(struct cpu_info *, uint32_t);
|
||||
|
||||
void acpicpu_tstate_attach(device_t);
|
||||
int acpicpu_tstate_detach(device_t);
|
||||
void acpicpu_tstate_detach(device_t);
|
||||
void acpicpu_tstate_start(device_t);
|
||||
void acpicpu_tstate_suspend(void *);
|
||||
void acpicpu_tstate_resume(void *);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: acpi_cpu_cstate.c,v 1.52 2011/03/19 12:57:31 jruoho Exp $ */
|
||||
/* $NetBSD: acpi_cpu_cstate.c,v 1.53 2011/06/22 08:49:54 jruoho Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010, 2011 Jukka Ruohonen <jruohonen@iki.fi>
|
||||
|
@ -27,13 +27,12 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_cstate.c,v 1.52 2011/03/19 12:57:31 jruoho Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_cstate.c,v 1.53 2011/06/22 08:49:54 jruoho Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/cpu.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/once.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/timetc.h>
|
||||
|
||||
|
@ -109,21 +108,17 @@ acpicpu_cstate_attach(device_t self)
|
|||
acpicpu_cstate_quirks(sc);
|
||||
}
|
||||
|
||||
int
|
||||
void
|
||||
acpicpu_cstate_detach(device_t self)
|
||||
{
|
||||
struct acpicpu_softc *sc = device_private(self);
|
||||
static ONCE_DECL(once_detach);
|
||||
int rv;
|
||||
|
||||
rv = RUN_ONCE(&once_detach, acpicpu_md_cstate_stop);
|
||||
if ((sc->sc_flags & ACPICPU_FLAG_C) == 0)
|
||||
return;
|
||||
|
||||
if (rv != 0)
|
||||
return rv;
|
||||
(void)acpicpu_md_cstate_stop();
|
||||
|
||||
sc->sc_flags &= ~ACPICPU_FLAG_C;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: acpi_cpu_pstate.c,v 1.50 2011/06/22 08:05:10 jruoho Exp $ */
|
||||
/* $NetBSD: acpi_cpu_pstate.c,v 1.51 2011/06/22 08:49:54 jruoho Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010, 2011 Jukka Ruohonen <jruohonen@iki.fi>
|
||||
|
@ -27,11 +27,10 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_pstate.c,v 1.50 2011/06/22 08:05:10 jruoho Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_pstate.c,v 1.51 2011/06/22 08:49:54 jruoho Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kmem.h>
|
||||
#include <sys/once.h>
|
||||
#include <sys/xcall.h>
|
||||
|
||||
#include <dev/acpi/acpireg.h>
|
||||
|
@ -153,21 +152,16 @@ fail:
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
void
|
||||
acpicpu_pstate_detach(device_t self)
|
||||
{
|
||||
struct acpicpu_softc *sc = device_private(self);
|
||||
static ONCE_DECL(once_detach);
|
||||
size_t size;
|
||||
int rv;
|
||||
|
||||
if ((sc->sc_flags & ACPICPU_FLAG_P) == 0)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
rv = RUN_ONCE(&once_detach, acpicpu_md_pstate_stop);
|
||||
|
||||
if (rv != 0)
|
||||
return rv;
|
||||
(void)acpicpu_md_pstate_stop();
|
||||
|
||||
size = sc->sc_pstate_count * sizeof(*sc->sc_pstate);
|
||||
|
||||
|
@ -175,8 +169,6 @@ acpicpu_pstate_detach(device_t self)
|
|||
kmem_free(sc->sc_pstate, size);
|
||||
|
||||
sc->sc_flags &= ~ACPICPU_FLAG_P;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: acpi_cpu_tstate.c,v 1.29 2011/06/22 08:05:10 jruoho Exp $ */
|
||||
/* $NetBSD: acpi_cpu_tstate.c,v 1.30 2011/06/22 08:49:54 jruoho Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010 Jukka Ruohonen <jruohonen@iki.fi>
|
||||
|
@ -27,7 +27,7 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_tstate.c,v 1.29 2011/06/22 08:05:10 jruoho Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_tstate.c,v 1.30 2011/06/22 08:49:54 jruoho Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kmem.h>
|
||||
|
@ -120,14 +120,14 @@ out:
|
|||
acpicpu_tstate_reset(sc);
|
||||
}
|
||||
|
||||
int
|
||||
void
|
||||
acpicpu_tstate_detach(device_t self)
|
||||
{
|
||||
struct acpicpu_softc *sc = device_private(self);
|
||||
size_t size;
|
||||
|
||||
if ((sc->sc_flags & ACPICPU_FLAG_T) == 0)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
size = sc->sc_tstate_count * sizeof(*sc->sc_tstate);
|
||||
|
||||
|
@ -135,8 +135,6 @@ acpicpu_tstate_detach(device_t self)
|
|||
kmem_free(sc->sc_tstate, size);
|
||||
|
||||
sc->sc_flags &= ~ACPICPU_FLAG_T;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue