Module Name:    src
Committed By:   jruoho
Date:           Sun Feb 27 17:10:34 UTC 2011

Modified Files:
        src/sys/arch/amd64/conf: GENERIC
        src/sys/arch/i386/conf: ALL GENERIC
        src/sys/arch/x86/conf: files.x86
        src/sys/dev/acpi: acpi.c acpi_cpu.c acpi_cpu_pstate.c files.acpi
        src/sys/modules/acpicpu: acpicpu.ioconf

Log Message:
Move acpicpu(4) from "acpinodebus" to "cpufeaturebus".


To generate a diff of this commit:
cvs rdiff -u -r1.314 -r1.315 src/sys/arch/amd64/conf/GENERIC
cvs rdiff -u -r1.298 -r1.299 src/sys/arch/i386/conf/ALL
cvs rdiff -u -r1.1023 -r1.1024 src/sys/arch/i386/conf/GENERIC
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/x86/conf/files.x86
cvs rdiff -u -r1.239 -r1.240 src/sys/dev/acpi/acpi.c
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/acpi/acpi_cpu.c
cvs rdiff -u -r1.40 -r1.41 src/sys/dev/acpi/acpi_cpu_pstate.c
cvs rdiff -u -r1.87 -r1.88 src/sys/dev/acpi/files.acpi
cvs rdiff -u -r1.1 -r1.2 src/sys/modules/acpicpu/acpicpu.ioconf

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.314 src/sys/arch/amd64/conf/GENERIC:1.315
--- src/sys/arch/amd64/conf/GENERIC:1.314	Thu Feb 24 10:56:00 2011
+++ src/sys/arch/amd64/conf/GENERIC	Sun Feb 27 17:10:33 2011
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.314 2011/02/24 10:56:00 jruoho Exp $
+# $NetBSD: GENERIC,v 1.315 2011/02/27 17:10:33 jruoho Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.314 $"
+#ident 		"GENERIC-$Revision: 1.315 $"
 
 maxusers	64		# estimated number of users
 
@@ -79,6 +79,7 @@
 options 	SYSCTL_INCLUDE_DESCR	# Include sysctl descriptions in kernel
 
 # CPU features
+#acpicpu*	at cpu?		# ACPI CPU (including frequency scaling)
 coretemp*	at cpu?		# Intel on-die thermal sensor
 est0		at cpu0		# Intel Enhanced SpeedStep (non-ACPI)
 powernow0	at cpu0		# AMD PowerNow! and Cool'n'Quiet (non-ACPI)
@@ -279,7 +280,6 @@
 acpiacad* 	at acpi?		# ACPI AC Adapter
 acpibat* 	at acpi?		# ACPI Battery
 acpibut* 	at acpi?		# ACPI Button
-#acpicpu*	at acpi?		# ACPI CPU
 acpidalb*	at acpi?		# Direct Application Launch Button
 acpiec* 	at acpi?		# ACPI Embedded Controller (late)
 acpiecdt* 	at acpi?		# ACPI Embedded Controller (early)

Index: src/sys/arch/i386/conf/ALL
diff -u src/sys/arch/i386/conf/ALL:1.298 src/sys/arch/i386/conf/ALL:1.299
--- src/sys/arch/i386/conf/ALL:1.298	Sat Feb 26 18:07:30 2011
+++ src/sys/arch/i386/conf/ALL	Sun Feb 27 17:10:33 2011
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.298 2011/02/26 18:07:30 ahoka Exp $
+# $NetBSD: ALL,v 1.299 2011/02/27 17:10:33 jruoho Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"ALL-$Revision: 1.298 $"
+#ident 		"ALL-$Revision: 1.299 $"
 
 maxusers	64		# estimated number of users
 
@@ -30,6 +30,7 @@
 options 	PAE		# PAE mode (36 bits physical addressing)
 
 # CPU features
+acpicpu*	at cpu?		# ACPI CPU (including frequency scaling)
 coretemp*	at cpu?		# Intel on-die thermal sensor
 est0		at cpu0		# Intel Enhanced SpeedStep (non-ACPI)
 padlock0	at cpu0		# VIA PadLock
@@ -356,7 +357,6 @@
 acpiacad* 	at acpi?		# ACPI AC Adapter
 acpibat* 	at acpi?		# ACPI Battery
 acpibut* 	at acpi?		# ACPI Button
-acpicpu*	at acpi?		# ACPI CPU
 acpidalb*	at acpi?		# ACPI Direct Application Launch Button
 acpiec* 	at acpi?		# ACPI Embedded Controller (late)
 acpiecdt* 	at acpi?		# ACPI Embedded Controller (early)

Index: src/sys/arch/i386/conf/GENERIC
diff -u src/sys/arch/i386/conf/GENERIC:1.1023 src/sys/arch/i386/conf/GENERIC:1.1024
--- src/sys/arch/i386/conf/GENERIC:1.1023	Thu Feb 24 13:58:39 2011
+++ src/sys/arch/i386/conf/GENERIC	Sun Feb 27 17:10:34 2011
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.1023 2011/02/24 13:58:39 jruoho Exp $
+# $NetBSD: GENERIC,v 1.1024 2011/02/27 17:10:34 jruoho Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.1023 $"
+#ident 		"GENERIC-$Revision: 1.1024 $"
 
 maxusers	64		# estimated number of users
 
@@ -38,6 +38,7 @@
 #options 	PAE		# PAE mode (36 bits physical addressing)
 
 # CPU features
+#acpicpu*	at cpu?		# ACPI CPU (including frequency scaling)
 coretemp*	at cpu?		# Intel on-die thermal sensor
 est0		at cpu0		# Intel Enhanced SpeedStep (non-ACPI)
 #padlock0	at cpu0		# VIA PadLock
@@ -348,7 +349,6 @@
 acpiacad*	at acpi?		# ACPI AC Adapter
 acpibat*	at acpi?		# ACPI Battery
 acpibut*	at acpi?		# ACPI Button
-#acpicpu*	at acpi?		# ACPI CPU
 acpidalb*	at acpi?		# ACPI Direct Application Launch Button
 acpiec* 	at acpi?		# ACPI Embedded Controller (late)
 acpiecdt*	at acpi?		# ACPI Embedded Controller (early)

Index: src/sys/arch/x86/conf/files.x86
diff -u src/sys/arch/x86/conf/files.x86:1.62 src/sys/arch/x86/conf/files.x86:1.63
--- src/sys/arch/x86/conf/files.x86:1.62	Thu Feb 24 13:58:39 2011
+++ src/sys/arch/x86/conf/files.x86	Sun Feb 27 17:10:33 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: files.x86,v 1.62 2011/02/24 13:58:39 jruoho Exp $
+#	$NetBSD: files.x86,v 1.63 2011/02/27 17:10:33 jruoho Exp $
 
 # options for MP configuration through the MP spec
 defflag opt_mpbios.h MPBIOS MPVERBOSE MPDEBUG MPBIOS_SCANPCI
@@ -31,6 +31,14 @@
 attach	cpu at cpubus
 file 	arch/x86/x86/cpu.c 		cpu
 
+device	acpicpu
+attach	acpicpu at cpufeaturebus
+file	dev/acpi/acpi_cpu.c		acpi & acpicpu
+file	dev/acpi/acpi_cpu_cstate.c	acpi & acpicpu
+file	dev/acpi/acpi_cpu_pstate.c	acpi & acpicpu
+file	dev/acpi/acpi_cpu_tstate.c	acpi & acpicpu
+file	arch/x86/acpi/acpi_cpu_md.c	acpi & acpicpu
+
 device	coretemp: sysmon_envsys
 attach	coretemp at cpufeaturebus
 file	arch/x86/x86/coretemp.c		coretemp
@@ -96,7 +104,6 @@
 file	arch/x86/x86/acpi_machdep.c	acpi
 
 file	arch/x86/acpi/acpi_wakeup.c	acpi
-file	arch/x86/acpi/acpi_cpu_md.c	acpi & acpicpu
 
 file	arch/x86/isa/isa_machdep.c	isa
 

Index: src/sys/dev/acpi/acpi.c
diff -u src/sys/dev/acpi/acpi.c:1.239 src/sys/dev/acpi/acpi.c:1.240
--- src/sys/dev/acpi/acpi.c:1.239	Sun Feb 20 16:24:54 2011
+++ src/sys/dev/acpi/acpi.c	Sun Feb 27 17:10:33 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpi.c,v 1.239 2011/02/20 16:24:54 jruoho Exp $	*/
+/*	$NetBSD: acpi.c,v 1.240 2011/02/27 17:10:33 jruoho Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -100,7 +100,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.239 2011/02/20 16:24:54 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.240 2011/02/27 17:10:33 jruoho Exp $");
 
 #include "opt_acpi.h"
 #include "opt_pcifixup.h"
@@ -134,7 +134,6 @@
  * Machine-dependent code may wish to skip other steps (such as attaching
  * subsystems that ACPI supercedes) when ACPI is active.
  */
-uint32_t	acpi_cpus = 0;
 int		acpi_active = 0;
 int		acpi_suspended = 0;
 int		acpi_force_load = 0;
@@ -161,6 +160,7 @@
  */
 static const char * const acpi_ignored_ids[] = {
 #if defined(i386) || defined(x86_64)
+	"ACPI0007",	/* ACPI CPUs do not attach to acpi(4) */
 	"PNP0000",	/* AT interrupt controller is handled internally */
 	"PNP0200",	/* AT DMA controller is handled internally */
 	"PNP0A??",	/* PCI Busses are handled internally */
@@ -804,7 +804,6 @@
 static void
 acpi_rescan_nodes(struct acpi_softc *sc)
 {
-	const uint32_t ncpus = acpi_md_ncpus();
 	struct acpi_attach_args aa;
 	struct acpi_devnode *ad;
 	ACPI_DEVICE_INFO *di;
@@ -841,7 +840,7 @@
 		if (di->Type == ACPI_TYPE_POWER)
 			continue;
 
-		if (di->Type == ACPI_TYPE_PROCESSOR && acpi_cpus >= ncpus)
+		if (di->Type == ACPI_TYPE_PROCESSOR)
 			continue;
 
 		if (acpi_match_hid(di, acpi_early_ids) != 0)

Index: src/sys/dev/acpi/acpi_cpu.c
diff -u src/sys/dev/acpi/acpi_cpu.c:1.29 src/sys/dev/acpi/acpi_cpu.c:1.30
--- src/sys/dev/acpi/acpi_cpu.c:1.29	Fri Feb 25 19:55:06 2011
+++ src/sys/dev/acpi/acpi_cpu.c	Sun Feb 27 17:10:33 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu.c,v 1.29 2011/02/25 19:55:06 jruoho Exp $ */
+/* $NetBSD: acpi_cpu.c,v 1.30 2011/02/27 17:10:33 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2010, 2011 Jukka Ruohonen <jruoho...@iki.fi>
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_cpu.c,v 1.29 2011/02/25 19:55:06 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu.c,v 1.30 2011/02/27 17:10:33 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -35,7 +35,6 @@
 #include <sys/kmem.h>
 #include <sys/module.h>
 #include <sys/mutex.h>
-#include <sys/once.h>
 #include <sys/sysctl.h>
 
 #include <dev/acpi/acpireg.h>
@@ -43,6 +42,7 @@
 #include <dev/acpi/acpi_cpu.h>
 
 #include <machine/acpi_machdep.h>
+#include <machine/cpuvar.h>
 
 #define _COMPONENT	  ACPI_BUS_COMPONENT
 ACPI_MODULE_NAME	  ("acpi_cpu")
@@ -52,14 +52,14 @@
 static int		  acpicpu_detach(device_t, int);
 static int		  acpicpu_once_attach(void);
 static int		  acpicpu_once_detach(void);
-static void		  acpicpu_prestart(device_t);
 static void		  acpicpu_start(device_t);
-static void		  acpicpu_debug_print(struct acpicpu_softc *);
+static void		  acpicpu_debug_print(device_t);
 static const char	 *acpicpu_debug_print_dep(uint32_t);
 static void		  acpicpu_sysctl(device_t);
 
-static int		  acpicpu_object(ACPI_HANDLE, struct acpicpu_object *);
-static struct cpu_info	 *acpicpu_ci(uint32_t);
+static ACPI_STATUS	  acpicpu_object(ACPI_HANDLE, struct acpicpu_object *);
+static int		  acpicpu_find(struct cpu_info *,
+				       struct acpi_devnode **);
 static uint32_t		  acpicpu_cap(struct acpicpu_softc *);
 static ACPI_STATUS	  acpicpu_cap_pdc(struct acpicpu_softc *, uint32_t);
 static ACPI_STATUS	  acpicpu_cap_osc(struct acpicpu_softc *,
@@ -68,7 +68,7 @@
 static bool		  acpicpu_suspend(device_t, const pmf_qual_t *);
 static bool		  acpicpu_resume(device_t, const pmf_qual_t *);
 
-extern uint32_t		  acpi_cpus;
+static uint32_t		  acpicpu_count = 0;
 struct acpicpu_softc	**acpicpu_sc = NULL;
 static struct sysctllog	 *acpicpu_log = NULL;
 static bool		  acpicpu_dynamic = true;
@@ -85,89 +85,90 @@
 static int
 acpicpu_match(device_t parent, cfdata_t match, void *aux)
 {
-	struct acpi_attach_args *aa = aux;
-	struct acpicpu_object ao;
-	int rv;
+	struct cpufeature_attach_args *cfaa = aux;
 
-	if (aa->aa_node->ad_type != ACPI_TYPE_PROCESSOR)
+	if (acpi_softc == NULL)
 		return 0;
 
-	if (acpi_match_hid(aa->aa_node->ad_devinfo, acpicpu_hid) != 0)
-		return 1;
-
-	rv = acpicpu_object(aa->aa_node->ad_handle, &ao);
-
-	if (rv != 0 || acpicpu_ci(ao.ao_procid) == NULL)
+	if (strcmp(cfaa->name, "frequency") != 0)
 		return 0;
 
-	return 1;
+	return acpicpu_find(cfaa->ci, NULL);
 }
 
 static void
 acpicpu_attach(device_t parent, device_t self, void *aux)
 {
 	struct acpicpu_softc *sc = device_private(self);
-	struct acpi_attach_args *aa = aux;
-	static ONCE_DECL(once_attach);
+	struct cpufeature_attach_args *cfaa = aux;
+	struct cpu_info *ci = cfaa->ci;
 	cpuid_t id;
 	int rv;
 
-	rv = acpicpu_object(aa->aa_node->ad_handle, &sc->sc_object);
-
-	if (rv != 0)
-		return;
-
-	rv = RUN_ONCE(&once_attach, acpicpu_once_attach);
-
-	if (rv != 0)
-		return;
-
+	sc->sc_ci = ci;
 	sc->sc_dev = self;
 	sc->sc_cold = true;
-	sc->sc_node = aa->aa_node;
+	sc->sc_node = NULL;
+
+	rv = acpicpu_find(ci, &sc->sc_node);
 
-	sc->sc_ci = acpicpu_ci(sc->sc_object.ao_procid);
+	if (rv == 0) {
+		aprint_normal(": failed to match processor\n");
+		return;
+	}
 
-	if (sc->sc_ci == NULL) {
-		aprint_error(": invalid CPU\n");
+	if (acpicpu_once_attach() != 0) {
+		aprint_normal(": failed to initialize\n");
 		return;
 	}
 
+	KASSERT(acpi_softc != NULL);
+	KASSERT(acpicpu_sc != NULL);
+	KASSERT(sc->sc_node != NULL);
+
 	id = sc->sc_ci->ci_acpiid;
 
 	if (acpicpu_sc[id] != NULL) {
-		aprint_error(": already attached\n");
+		aprint_normal(": already attached\n");
 		return;
 	}
 
 	aprint_naive("\n");
 	aprint_normal(": ACPI CPU\n");
 
-	acpi_cpus++;
+	rv = acpicpu_object(sc->sc_node->ad_handle, &sc->sc_object);
+
+	if (ACPI_FAILURE(rv))
+		aprint_verbose_dev(self, "failed to obtain CPU object\n");
+
+	acpicpu_count++;
 	acpicpu_sc[id] = sc;
 
 	sc->sc_cap = acpicpu_cap(sc);
 	sc->sc_ncpus = acpi_md_ncpus();
-	sc->sc_flags |= acpicpu_md_flags();
+	sc->sc_flags = acpicpu_md_flags();
 
+	KASSERT(acpicpu_count <= sc->sc_ncpus);
+	KASSERT(sc->sc_node->ad_device == NULL);
+
+	sc->sc_node->ad_device = self;
 	mutex_init(&sc->sc_mtx, MUTEX_DEFAULT, IPL_NONE);
 
 	acpicpu_cstate_attach(self);
 	acpicpu_pstate_attach(self);
 	acpicpu_tstate_attach(self);
 
-	(void)config_defer(self, acpicpu_prestart);
+	acpicpu_debug_print(self);
+
+	(void)config_interrupts(self, acpicpu_start);
 	(void)acpi_register_notify(sc->sc_node, acpicpu_notify);
 	(void)pmf_device_register(self, acpicpu_suspend, acpicpu_resume);
-
-	acpicpu_debug_print(sc);
 }
 
 static int
 acpicpu_detach(device_t self, int flags)
 {
 	struct acpicpu_softc *sc = device_private(self);
-	static ONCE_DECL(once_detach);
 	int rv = 0;
 
 	sc->sc_cold = true;
@@ -191,13 +192,11 @@
 	if (rv != 0)
 		return rv;
 
-	rv = RUN_ONCE(&once_detach, acpicpu_once_detach);
-
-	if (rv != 0)
-		return rv;
-
 	mutex_destroy(&sc->sc_mtx);
-	acpi_cpus--;
+	sc->sc_node->ad_device = NULL;
+
+	acpicpu_count--;
+	acpicpu_once_detach();
 
 	return 0;
 }
@@ -208,6 +207,12 @@
 	struct acpicpu_softc *sc;
 	unsigned int i;
 
+	if (acpicpu_count != 0)
+		return 0;
+
+	KASSERT(acpicpu_sc == NULL);
+	KASSERT(acpicpu_log == NULL);
+
 	acpicpu_sc = kmem_zalloc(maxcpus * sizeof(*sc), KM_SLEEP);
 
 	if (acpicpu_sc == NULL)
@@ -224,45 +229,43 @@
 {
 	struct acpicpu_softc *sc;
 
-	if (acpicpu_sc != NULL)
-		kmem_free(acpicpu_sc, maxcpus * sizeof(*sc));
+	if (acpicpu_count != 0)
+		return EDEADLK;
 
 	if (acpicpu_log != NULL)
 		sysctl_teardown(&acpicpu_log);
 
+	if (acpicpu_sc != NULL)
+		kmem_free(acpicpu_sc, maxcpus * sizeof(*sc));
+
 	return 0;
 }
 
 static void
-acpicpu_prestart(device_t self)
+acpicpu_start(device_t self)
 {
 	struct acpicpu_softc *sc = device_private(self);
-	static bool once = false;
+	static uint32_t count = 0;
 
-	if (once != false) {
+	/*
+	 * Run the state-specific initialization routines. These
+	 * must run only once, after interrupts have been enabled,
+	 * all CPUs are running, and all ACPI CPUs have attached.
+	 */
+	if (++count != acpicpu_count || acpicpu_count != sc->sc_ncpus) {
 		sc->sc_cold = false;
 		return;
 	}
 
-	once = true;
-
-	(void)config_interrupts(self, acpicpu_start);
-}
-
-static void
-acpicpu_start(device_t self)
-{
-	struct acpicpu_softc *sc = device_private(self);
-
 	/*
-	 * Run the state-specific initialization
-	 * routines. These should be called only
-	 * once, after interrupts are enabled and
-	 * all ACPI CPUs have attached.
+	 * Set the last ACPI CPU as non-cold
+	 * only after C-states are enabled.
 	 */
 	if ((sc->sc_flags & ACPICPU_FLAG_C) != 0)
 		acpicpu_cstate_start(self);
 
+	sc->sc_cold = false;
+
 	if ((sc->sc_flags & ACPICPU_FLAG_P) != 0)
 		acpicpu_pstate_start(self);
 
@@ -270,11 +273,7 @@
 		acpicpu_tstate_start(self);
 
 	acpicpu_sysctl(self);
-
-	aprint_debug_dev(sc->sc_dev, "ACPI CPUs started (cap "
-	    "0x%02x, flags 0x%06x)\n", sc->sc_cap, sc->sc_flags);
-
-	sc->sc_cold = false;
+	aprint_debug_dev(self, "ACPI CPUs started\n");
 }
 
 static void
@@ -283,6 +282,8 @@
 	const struct sysctlnode *node;
 	int err;
 
+	KASSERT(acpicpu_log == NULL);
+
 	err = sysctl_createv(&acpicpu_log, 0, NULL, &node,
 	    CTLFLAG_PERMANENT, CTLTYPE_NODE, "hw", NULL,
 	    NULL, 0, NULL, 0, CTL_HW, CTL_EOL);
@@ -326,7 +327,7 @@
 	aprint_error_dev(self, "failed to initialize sysctl (err %d)\n", err);
 }
 
-static int
+static ACPI_STATUS
 acpicpu_object(ACPI_HANDLE hdl, struct acpicpu_object *ao)
 {
 	ACPI_OBJECT *obj;
@@ -336,7 +337,7 @@
 	rv = acpi_eval_struct(hdl, NULL, &buf);
 
 	if (ACPI_FAILURE(rv))
-		return 1;
+		goto out;
 
 	obj = buf.Pointer;
 
@@ -362,22 +363,53 @@
 	if (buf.Pointer != NULL)
 		ACPI_FREE(buf.Pointer);
 
-	return ACPI_FAILURE(rv) ? 1 : 0;
+	return rv;
 }
 
-static struct cpu_info *
-acpicpu_ci(uint32_t id)
+static int
+acpicpu_find(struct cpu_info *ci, struct acpi_devnode **ptr)
 {
-	CPU_INFO_ITERATOR cii;
-	struct cpu_info *ci;
+	struct acpi_softc *sc = acpi_softc;
+	struct acpicpu_object ao;
+	struct acpi_devnode *ad;
+	ACPI_INTEGER val;
+	ACPI_STATUS rv;
+
+	if (sc == NULL || acpi_active == 0)
+		return 0;
+
+	/*
+	 * CPUs are declared in the ACPI namespace
+	 * either as a Processor() or as a Device().
+	 * In both cases the MADT entries are used
+	 * for the match (see ACPI 4.0, section 8.4).
+	 */
+	SIMPLEQ_FOREACH(ad, &sc->ad_head, ad_list) {
+
+		if (ad->ad_type == ACPI_TYPE_PROCESSOR) {
 
-	for (CPU_INFO_FOREACH(cii, ci)) {
+			rv = acpicpu_object(ad->ad_handle, &ao);
 
-		if (id == ci->ci_acpiid)
-			return ci;
+			if (ACPI_SUCCESS(rv) && ci->ci_acpiid == ao.ao_procid)
+				goto out;
+		}
+
+		if (acpi_match_hid(ad->ad_devinfo, acpicpu_hid) != 0) {
+
+			rv = acpi_eval_integer(ad->ad_handle, "_UID", &val);
+
+			if (ACPI_SUCCESS(rv) && ci->ci_acpiid == val)
+				goto out;
+		}
 	}
 
-	return NULL;
+	return 0;
+
+out:
+	if (ptr != NULL)
+		*ptr = ad;
+
+	return 10;		/* Beat est(4) and powernow(4). */
 }
 
 static uint32_t
@@ -638,10 +670,16 @@
 }
 
 static void
-acpicpu_debug_print(struct acpicpu_softc *sc)
+acpicpu_debug_print(device_t self)
 {
+	struct acpicpu_softc *sc = device_private(self);
+	struct cpu_info *ci = sc->sc_ci;
 	struct acpicpu_dep *dep;
 
+	aprint_debug_dev(sc->sc_dev, "id %u, lapic id %u, "
+	    "cap 0x%04x, flags 0x%08x\n", ci->ci_acpiid,
+	    (uint32_t)ci->ci_cpuid, sc->sc_cap, sc->sc_flags);
+
 	if ((sc->sc_flags & ACPICPU_FLAG_C_DEP) != 0) {
 
 		dep = &sc->sc_cstate_dep;

Index: src/sys/dev/acpi/acpi_cpu_pstate.c
diff -u src/sys/dev/acpi/acpi_cpu_pstate.c:1.40 src/sys/dev/acpi/acpi_cpu_pstate.c:1.41
--- src/sys/dev/acpi/acpi_cpu_pstate.c:1.40	Fri Feb 25 19:55:06 2011
+++ src/sys/dev/acpi/acpi_cpu_pstate.c	Sun Feb 27 17:10:33 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu_pstate.c,v 1.40 2011/02/25 19:55:06 jruoho Exp $ */
+/* $NetBSD: acpi_cpu_pstate.c,v 1.41 2011/02/27 17:10:33 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2010, 2011 Jukka Ruohonen <jruoho...@iki.fi>
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_pstate.c,v 1.40 2011/02/25 19:55:06 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_pstate.c,v 1.41 2011/02/27 17:10:33 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/evcnt.h>
@@ -271,7 +271,6 @@
 		ps = &sc->sc_pstate[i];
 
 		if (ps->ps_freq != 0) {
-			sc->sc_cold = false;
 			rv = acpicpu_pstate_set(sc, ps->ps_freq);
 			break;
 		}

Index: src/sys/dev/acpi/files.acpi
diff -u src/sys/dev/acpi/files.acpi:1.87 src/sys/dev/acpi/files.acpi:1.88
--- src/sys/dev/acpi/files.acpi:1.87	Sun Feb 20 08:31:46 2011
+++ src/sys/dev/acpi/files.acpi	Sun Feb 27 17:10:33 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: files.acpi,v 1.87 2011/02/20 08:31:46 jruoho Exp $
+#	$NetBSD: files.acpi,v 1.88 2011/02/27 17:10:33 jruoho Exp $
 
 include "dev/acpi/acpica/files.acpica"
 
@@ -59,14 +59,6 @@
 attach	acpibat at acpinodebus
 file	dev/acpi/acpi_bat.c		acpibat
 
-# ACPI CPU
-device	acpicpu
-attach	acpicpu at acpinodebus
-file	dev/acpi/acpi_cpu.c		acpicpu
-file	dev/acpi/acpi_cpu_cstate.c	acpicpu
-file	dev/acpi/acpi_cpu_pstate.c	acpicpu
-file	dev/acpi/acpi_cpu_tstate.c	acpicpu
-
 # ACPI Display
 device	acpivga {}
 attach	acpivga at acpinodebus

Index: src/sys/modules/acpicpu/acpicpu.ioconf
diff -u src/sys/modules/acpicpu/acpicpu.ioconf:1.1 src/sys/modules/acpicpu/acpicpu.ioconf:1.2
--- src/sys/modules/acpicpu/acpicpu.ioconf:1.1	Wed Feb 16 08:35:52 2011
+++ src/sys/modules/acpicpu/acpicpu.ioconf	Sun Feb 27 17:10:33 2011
@@ -1,10 +1,10 @@
-# $NetBSD: acpicpu.ioconf,v 1.1 2011/02/16 08:35:52 jruoho Exp $
+# $NetBSD: acpicpu.ioconf,v 1.2 2011/02/27 17:10:33 jruoho Exp $
 
 ioconf acpicpu
 
 include "conf/files"
-include "dev/acpi/files.acpi"
+include "arch/x86/conf/files.x86"
 
-pseudo-root acpi*
+pseudo-root cpufeaturebus*
 
-acpicpu* at acpi?
+acpicpu* at cpufeaturebus?

Reply via email to