Now that the deferred configuration actually works as expected and documented,
use config_defer(9) instead of config_finalize_register(9), and simplify the code paths around the initialization.
This commit is contained in:
parent
1108237392
commit
2510a0e220
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: acpi_cpu.c,v 1.16 2010/08/14 11:16:14 jruoho Exp $ */
|
||||
/* $NetBSD: acpi_cpu.c,v 1.17 2010/08/16 17:58:42 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.c,v 1.16 2010/08/14 11:16:14 jruoho Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi_cpu.c,v 1.17 2010/08/16 17:58:42 jruoho Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/cpu.h>
|
||||
@ -51,6 +51,7 @@ static void acpicpu_attach(device_t, device_t, void *);
|
||||
static int acpicpu_detach(device_t, int);
|
||||
static int acpicpu_once_attach(void);
|
||||
static int acpicpu_once_detach(void);
|
||||
static void acpicpu_start(device_t);
|
||||
|
||||
static int acpicpu_object(ACPI_HANDLE, struct acpicpu_object *);
|
||||
static cpuid_t acpicpu_id(uint32_t);
|
||||
@ -112,10 +113,8 @@ acpicpu_attach(device_t parent, device_t self, void *aux)
|
||||
if (rv != 0)
|
||||
return;
|
||||
|
||||
KASSERT(acpicpu_sc != NULL);
|
||||
|
||||
sc->sc_dev = self;
|
||||
sc->sc_cold = false;
|
||||
sc->sc_cold = true;
|
||||
sc->sc_mapped = false;
|
||||
sc->sc_iot = aa->aa_iot;
|
||||
sc->sc_node = aa->aa_node;
|
||||
@ -159,15 +158,9 @@ acpicpu_attach(device_t parent, device_t self, void *aux)
|
||||
acpicpu_pstate_attach(self);
|
||||
acpicpu_tstate_attach(self);
|
||||
|
||||
(void)config_finalize_register(self, acpicpu_cstate_start);
|
||||
(void)config_finalize_register(self, acpicpu_pstate_start);
|
||||
(void)config_finalize_register(self, acpicpu_tstate_start);
|
||||
|
||||
(void)config_defer(self, acpicpu_start);
|
||||
(void)acpi_register_notify(sc->sc_node, acpicpu_notify);
|
||||
(void)pmf_device_register(self, acpicpu_suspend, acpicpu_resume);
|
||||
|
||||
aprint_debug_dev(sc->sc_dev, "cap 0x%02x, "
|
||||
"flags 0x%06x\n", sc->sc_cap, sc->sc_flags);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -234,14 +227,44 @@ acpicpu_once_detach(void)
|
||||
{
|
||||
struct acpicpu_softc *sc;
|
||||
|
||||
KASSERT(acpicpu_sc != NULL);
|
||||
|
||||
kmem_free(acpicpu_sc, maxcpus * sizeof(*sc));
|
||||
acpicpu_sc = NULL;
|
||||
if (acpicpu_sc != NULL)
|
||||
kmem_free(acpicpu_sc, maxcpus * sizeof(*sc));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
acpicpu_start(device_t self)
|
||||
{
|
||||
struct acpicpu_softc *sc = device_private(self);
|
||||
static bool once = false;
|
||||
|
||||
if (once != false) {
|
||||
sc->sc_cold = false;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Run the state-specific initialization
|
||||
* routines. These should be called only
|
||||
* once, after all ACPI CPUs have attached.
|
||||
*/
|
||||
if ((sc->sc_flags & ACPICPU_FLAG_C) != 0)
|
||||
acpicpu_cstate_start(self);
|
||||
|
||||
if ((sc->sc_flags & ACPICPU_FLAG_P) != 0)
|
||||
acpicpu_pstate_start(self);
|
||||
|
||||
if ((sc->sc_flags & ACPICPU_FLAG_T) != 0)
|
||||
acpicpu_tstate_start(self);
|
||||
|
||||
aprint_debug_dev(sc->sc_dev, "ACPI CPUs started (cap "
|
||||
"0x%02x, flags 0x%06x)\n", sc->sc_cap, sc->sc_flags);
|
||||
|
||||
once = true;
|
||||
sc->sc_cold = false;
|
||||
}
|
||||
|
||||
static int
|
||||
acpicpu_object(ACPI_HANDLE hdl, struct acpicpu_object *ao)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: acpi_cpu.h,v 1.16 2010/08/16 07:38:38 jruoho Exp $ */
|
||||
/* $NetBSD: acpi_cpu.h,v 1.17 2010/08/16 17:58:42 jruoho Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010 Jukka Ruohonen <jruohonen@iki.fi>
|
||||
@ -207,7 +207,7 @@ struct acpicpu_softc {
|
||||
|
||||
void acpicpu_cstate_attach(device_t);
|
||||
int acpicpu_cstate_detach(device_t);
|
||||
int acpicpu_cstate_start(device_t);
|
||||
void acpicpu_cstate_start(device_t);
|
||||
bool acpicpu_cstate_suspend(device_t);
|
||||
bool acpicpu_cstate_resume(device_t);
|
||||
void acpicpu_cstate_callback(void *);
|
||||
@ -215,7 +215,7 @@ void acpicpu_cstate_idle(void);
|
||||
|
||||
void acpicpu_pstate_attach(device_t);
|
||||
int acpicpu_pstate_detach(device_t);
|
||||
int acpicpu_pstate_start(device_t);
|
||||
void acpicpu_pstate_start(device_t);
|
||||
bool acpicpu_pstate_suspend(device_t);
|
||||
bool acpicpu_pstate_resume(device_t);
|
||||
void acpicpu_pstate_callback(void *);
|
||||
@ -224,7 +224,7 @@ int acpicpu_pstate_set(struct acpicpu_softc *, uint32_t);
|
||||
|
||||
void acpicpu_tstate_attach(device_t);
|
||||
int acpicpu_tstate_detach(device_t);
|
||||
int acpicpu_tstate_start(device_t);
|
||||
void acpicpu_tstate_start(device_t);
|
||||
bool acpicpu_tstate_suspend(device_t);
|
||||
bool acpicpu_tstate_resume(device_t);
|
||||
void acpicpu_tstate_callback(void *);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: acpi_cpu_cstate.c,v 1.28 2010/08/15 08:53:19 jruoho Exp $ */
|
||||
/* $NetBSD: acpi_cpu_cstate.c,v 1.29 2010/08/16 17:58:42 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_cstate.c,v 1.28 2010/08/15 08:53:19 jruoho Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_cstate.c,v 1.29 2010/08/16 17:58:42 jruoho Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/cpu.h>
|
||||
@ -99,6 +99,8 @@ acpicpu_cstate_attach(device_t self)
|
||||
break;
|
||||
}
|
||||
|
||||
sc->sc_flags |= ACPICPU_FLAG_C;
|
||||
|
||||
acpicpu_cstate_quirks(sc);
|
||||
acpicpu_cstate_attach_evcnt(sc);
|
||||
acpicpu_cstate_attach_print(sc);
|
||||
@ -211,23 +213,11 @@ acpicpu_cstate_detach_evcnt(struct acpicpu_softc *sc)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
void
|
||||
acpicpu_cstate_start(device_t self)
|
||||
{
|
||||
struct acpicpu_softc *sc = device_private(self);
|
||||
static ONCE_DECL(once_start);
|
||||
int rv;
|
||||
|
||||
/*
|
||||
* Save the existing idle-mechanism and claim the cpu_idle(9).
|
||||
* This should be called after all ACPI CPUs have been attached.
|
||||
*/
|
||||
rv = RUN_ONCE(&once_start, acpicpu_md_idle_start);
|
||||
|
||||
if (rv == 0)
|
||||
sc->sc_flags |= ACPICPU_FLAG_C;
|
||||
|
||||
return rv;
|
||||
(void)acpicpu_md_idle_start();
|
||||
}
|
||||
|
||||
bool
|
||||
@ -675,6 +665,7 @@ acpicpu_cstate_idle(void)
|
||||
KASSERT(acpicpu_sc != NULL);
|
||||
KASSERT(ci->ci_acpiid < maxcpus);
|
||||
KASSERT(ci->ci_ilevel == IPL_NONE);
|
||||
KASSERT((sc->sc_flags & ACPICPU_FLAG_C) != 0);
|
||||
|
||||
sc = acpicpu_sc[ci->ci_acpiid];
|
||||
|
||||
@ -684,9 +675,6 @@ acpicpu_cstate_idle(void)
|
||||
if (__predict_false(sc->sc_cold != false))
|
||||
goto halt;
|
||||
|
||||
if (__predict_false((sc->sc_flags & ACPICPU_FLAG_C) == 0))
|
||||
goto halt;
|
||||
|
||||
if (__predict_false(mutex_tryenter(&sc->sc_mtx) == 0))
|
||||
goto halt;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: acpi_cpu_pstate.c,v 1.23 2010/08/16 10:23:25 jmcneill Exp $ */
|
||||
/* $NetBSD: acpi_cpu_pstate.c,v 1.24 2010/08/16 17:58:42 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_pstate.c,v 1.23 2010/08/16 10:23:25 jmcneill Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_pstate.c,v 1.24 2010/08/16 17:58:42 jruoho Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/evcnt.h>
|
||||
@ -62,13 +62,6 @@ acpicpu_pstate_attach(device_t self)
|
||||
const char *str;
|
||||
ACPI_STATUS rv;
|
||||
|
||||
/*
|
||||
* The ACPI 3.0 and 4.0 specifications mandate three
|
||||
* objects for P-states: _PSS, _PCT, and _PPC. A less
|
||||
* strict wording is however used in the earlier 2.0
|
||||
* standard, and some systems conforming to ACPI 2.0
|
||||
* do not have _PPC, the method for dynamic maximum.
|
||||
*/
|
||||
rv = acpicpu_pstate_pss(sc);
|
||||
|
||||
if (ACPI_FAILURE(rv)) {
|
||||
@ -102,6 +95,13 @@ acpicpu_pstate_attach(device_t self)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/*
|
||||
* The ACPI 3.0 and 4.0 specifications mandate three
|
||||
* objects for P-states: _PSS, _PCT, and _PPC. A less
|
||||
* strict wording is however used in the earlier 2.0
|
||||
* standard, and some systems conforming to ACPI 2.0
|
||||
* do not have _PPC, the method for dynamic maximum.
|
||||
*/
|
||||
(void)acpicpu_pstate_max(sc);
|
||||
|
||||
sc->sc_flags |= ACPICPU_FLAG_P;
|
||||
@ -221,16 +221,19 @@ acpicpu_pstate_detach_evcnt(struct acpicpu_softc *sc)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
void
|
||||
acpicpu_pstate_start(device_t self)
|
||||
{
|
||||
struct acpicpu_softc *sc = device_private(self);
|
||||
static ONCE_DECL(once_start);
|
||||
int rv;
|
||||
|
||||
if ((sc->sc_flags & ACPICPU_FLAG_P) == 0)
|
||||
return 0;
|
||||
rv = acpicpu_md_pstate_start();
|
||||
|
||||
return RUN_ONCE(&once_start, acpicpu_md_pstate_start);
|
||||
if (rv == 0)
|
||||
return;
|
||||
|
||||
sc->sc_flags &= ~ACPICPU_FLAG_P;
|
||||
aprint_error_dev(self, "failed to start P-states (err %d)\n", rv);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: acpi_cpu_tstate.c,v 1.10 2010/08/16 04:31:21 jruoho Exp $ */
|
||||
/* $NetBSD: acpi_cpu_tstate.c,v 1.11 2010/08/16 17:58:42 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.10 2010/08/16 04:31:21 jruoho Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_tstate.c,v 1.11 2010/08/16 17:58:42 jruoho Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/evcnt.h>
|
||||
@ -190,11 +190,10 @@ acpicpu_tstate_detach_evcnt(struct acpicpu_softc *sc)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
void
|
||||
acpicpu_tstate_start(device_t self)
|
||||
{
|
||||
|
||||
return 0;
|
||||
/* Nothing. */
|
||||
}
|
||||
|
||||
bool
|
||||
|
Loading…
Reference in New Issue
Block a user