[Midnightbsd-cvs] src [6591] trunk/sys/dev/acpica: sync acpi with freebsd 9.2

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Mon Dec 30 13:11:21 EST 2013


Revision: 6591
          http://svnweb.midnightbsd.org/src/?rev=6591
Author:   laffer1
Date:     2013-12-30 13:11:21 -0500 (Mon, 30 Dec 2013)
Log Message:
-----------
sync acpi with freebsd 9.2

Modified Paths:
--------------
    trunk/sys/dev/acpica/Osd/OsdDebug.c
    trunk/sys/dev/acpica/Osd/OsdHardware.c
    trunk/sys/dev/acpica/Osd/OsdInterrupt.c
    trunk/sys/dev/acpica/Osd/OsdMemory.c
    trunk/sys/dev/acpica/Osd/OsdSchedule.c
    trunk/sys/dev/acpica/Osd/OsdStream.c
    trunk/sys/dev/acpica/Osd/OsdSynch.c
    trunk/sys/dev/acpica/Osd/OsdTable.c
    trunk/sys/dev/acpica/acpi.c
    trunk/sys/dev/acpica/acpi_acad.c
    trunk/sys/dev/acpica/acpi_battery.c
    trunk/sys/dev/acpica/acpi_button.c
    trunk/sys/dev/acpica/acpi_cmbat.c
    trunk/sys/dev/acpica/acpi_cpu.c
    trunk/sys/dev/acpica/acpi_dock.c
    trunk/sys/dev/acpica/acpi_ec.c
    trunk/sys/dev/acpica/acpi_hpet.c
    trunk/sys/dev/acpica/acpi_hpet.h
    trunk/sys/dev/acpica/acpi_if.m
    trunk/sys/dev/acpica/acpi_isab.c
    trunk/sys/dev/acpica/acpi_lid.c
    trunk/sys/dev/acpica/acpi_package.c
    trunk/sys/dev/acpica/acpi_pci.c
    trunk/sys/dev/acpica/acpi_pci_link.c
    trunk/sys/dev/acpica/acpi_pcib.c
    trunk/sys/dev/acpica/acpi_pcib_acpi.c
    trunk/sys/dev/acpica/acpi_pcib_pci.c
    trunk/sys/dev/acpica/acpi_pcibvar.h
    trunk/sys/dev/acpica/acpi_perf.c
    trunk/sys/dev/acpica/acpi_powerres.c
    trunk/sys/dev/acpica/acpi_quirk.c
    trunk/sys/dev/acpica/acpi_quirks
    trunk/sys/dev/acpica/acpi_resource.c
    trunk/sys/dev/acpica/acpi_smbat.c
    trunk/sys/dev/acpica/acpi_smbus.h
    trunk/sys/dev/acpica/acpi_thermal.c
    trunk/sys/dev/acpica/acpi_throttle.c
    trunk/sys/dev/acpica/acpi_timer.c
    trunk/sys/dev/acpica/acpi_video.c
    trunk/sys/dev/acpica/acpiio.h
    trunk/sys/dev/acpica/acpivar.h

Modified: trunk/sys/dev/acpica/Osd/OsdDebug.c
===================================================================
--- trunk/sys/dev/acpica/Osd/OsdDebug.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/Osd/OsdDebug.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Michael Smith
  * Copyright (c) 2000 BSDi
@@ -30,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/Osd/OsdDebug.c 222544 2011-05-31 19:45:58Z jkim $");
 
 #include "opt_ddb.h"
 #include <sys/param.h>

Modified: trunk/sys/dev/acpica/Osd/OsdHardware.c
===================================================================
--- trunk/sys/dev/acpica/Osd/OsdHardware.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/Osd/OsdHardware.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000, 2001 Michael Smith
  * Copyright (c) 2000 BSDi
@@ -30,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/Osd/OsdHardware.c 213787 2010-10-13 17:06:25Z jkim $");
 
 #include <contrib/dev/acpica/include/acpi.h>
 

Modified: trunk/sys/dev/acpica/Osd/OsdInterrupt.c
===================================================================
--- trunk/sys/dev/acpica/Osd/OsdInterrupt.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/Osd/OsdInterrupt.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Michael Smith
  * Copyright (c) 2000 BSDi
@@ -31,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/Osd/OsdInterrupt.c 249132 2013-04-05 08:22:11Z mav $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -51,7 +52,7 @@
 #define _COMPONENT	ACPI_OS_SERVICES
 ACPI_MODULE_NAME("INTERRUPT")
 
-MALLOC_DEFINE(M_ACPIINTR, "acpiintr", "ACPI interrupt");
+static MALLOC_DEFINE(M_ACPIINTR, "acpiintr", "ACPI interrupt");
 
 struct acpi_intr {
 	SLIST_ENTRY(acpi_intr)	ai_link;

Modified: trunk/sys/dev/acpica/Osd/OsdMemory.c
===================================================================
--- trunk/sys/dev/acpica/Osd/OsdMemory.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/Osd/OsdMemory.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Mitsaru Iwasaki
  * Copyright (c) 2000 Michael Smith
@@ -31,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/Osd/OsdMemory.c 249132 2013-04-05 08:22:11Z mav $");
 
 #include <contrib/dev/acpica/include/acpi.h>
 
@@ -40,7 +41,7 @@
 #include <vm/vm.h>
 #include <vm/pmap.h>
 
-MALLOC_DEFINE(M_ACPICA, "acpica", "ACPI CA memory pool");
+static MALLOC_DEFINE(M_ACPICA, "acpica", "ACPI CA memory pool");
 
 void *
 AcpiOsAllocate(ACPI_SIZE Size)

Modified: trunk/sys/dev/acpica/Osd/OsdSchedule.c
===================================================================
--- trunk/sys/dev/acpica/Osd/OsdSchedule.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/Osd/OsdSchedule.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Michael Smith
  * Copyright (c) 2000 BSDi
@@ -31,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/Osd/OsdSchedule.c 249132 2013-04-05 08:22:11Z mav $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -65,7 +66,7 @@
 static int acpi_max_threads = ACPI_MAX_THREADS;
 TUNABLE_INT("debug.acpi.max_threads", &acpi_max_threads);
 
-MALLOC_DEFINE(M_ACPITASK, "acpitask", "ACPI deferred task");
+static MALLOC_DEFINE(M_ACPITASK, "acpitask", "ACPI deferred task");
 
 struct acpi_task_ctx {
     struct task			at_task;

Modified: trunk/sys/dev/acpica/Osd/OsdStream.c
===================================================================
--- trunk/sys/dev/acpica/Osd/OsdStream.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/Osd/OsdStream.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Michael Smith
  * Copyright (c) 2000 BSDi
@@ -30,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/Osd/OsdStream.c 193530 2009-06-05 18:44:36Z jkim $");
 
 #include <contrib/dev/acpica/include/acpi.h>
 

Modified: trunk/sys/dev/acpica/Osd/OsdSynch.c
===================================================================
--- trunk/sys/dev/acpica/Osd/OsdSynch.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/Osd/OsdSynch.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Michael Smith
  * Copyright (c) 2000 BSDi
@@ -31,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/Osd/OsdSynch.c 249132 2013-04-05 08:22:11Z mav $");
 
 #include <contrib/dev/acpica/include/acpi.h>
 #include <contrib/dev/acpica/include/accommon.h>
@@ -45,7 +46,7 @@
 #define	_COMPONENT	ACPI_OS_SERVICES
 ACPI_MODULE_NAME("SYNCH")
 
-MALLOC_DEFINE(M_ACPISEM, "acpisem", "ACPI semaphore");
+static MALLOC_DEFINE(M_ACPISEM, "acpisem", "ACPI semaphore");
 
 /*
  * Convert milliseconds to ticks.

Modified: trunk/sys/dev/acpica/Osd/OsdTable.c
===================================================================
--- trunk/sys/dev/acpica/Osd/OsdTable.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/Osd/OsdTable.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2002 Mitsaru Iwasaki
  * All rights reserved.
@@ -29,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/Osd/OsdTable.c 218660 2011-02-13 19:24:04Z marcel $");
 
 #include <sys/param.h>
 #include <sys/endian.h>

Modified: trunk/sys/dev/acpica/acpi.c
===================================================================
--- trunk/sys/dev/acpica/acpi.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Takanori Watanabe <takawata at jp.freebsd.org>
  * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki at jp.freebsd.org>
@@ -28,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi.c 251754 2013-06-14 18:30:43Z jhb $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -68,7 +69,7 @@
 
 #include <vm/vm_param.h>
 
-MALLOC_DEFINE(M_ACPIDEV, "acpidev", "ACPI devices");
+static MALLOC_DEFINE(M_ACPIDEV, "acpidev", "ACPI devices");
 
 /* Hooks for the ACPI CA debugging infrastructure */
 #define _COMPONENT	ACPI_BUS
@@ -1960,6 +1961,7 @@
 acpi_shutdown_final(void *arg, int howto)
 {
     struct acpi_softc *sc = (struct acpi_softc *)arg;
+    register_t intr;
     ACPI_STATUS status;
 
     /*
@@ -1975,13 +1977,15 @@
 	    return;
 	}
 	device_printf(sc->acpi_dev, "Powering system off\n");
-	ACPI_DISABLE_IRQS();
+	intr = intr_disable();
 	status = AcpiEnterSleepState(ACPI_STATE_S5);
-	if (ACPI_FAILURE(status))
+	if (ACPI_FAILURE(status)) {
+	    intr_restore(intr);
 	    device_printf(sc->acpi_dev, "power-off failed - %s\n",
 		AcpiFormatException(status));
-	else {
+	} else {
 	    DELAY(1000000);
+	    intr_restore(intr);
 	    device_printf(sc->acpi_dev, "power-off failed - timeout\n");
 	}
     } else if ((howto & RB_HALT) == 0 && sc->acpi_handle_reboot) {
@@ -2329,7 +2333,7 @@
 	    return (AE_NO_MEMORY);
 	rp = (ACPI_RESOURCE *)buf->Pointer;
 	rp->Type = ACPI_RESOURCE_TYPE_END_TAG;
-	rp->Length = 0;
+	rp->Length = ACPI_RS_SIZE_MIN;
     }
     if (res == NULL)
 	return (AE_OK);
@@ -2379,7 +2383,7 @@
     /* And add the terminator. */
     rp = ACPI_NEXT_RESOURCE(rp);
     rp->Type = ACPI_RESOURCE_TYPE_END_TAG;
-    rp->Length = 0;
+    rp->Length = ACPI_RS_SIZE_MIN;
 
     return (AE_OK);
 }
@@ -2652,8 +2656,11 @@
 static ACPI_STATUS
 acpi_EnterSleepState(struct acpi_softc *sc, int state)
 {
-    ACPI_STATUS	status;
+    register_t intr;
+    ACPI_STATUS status;
+    ACPI_EVENT_STATUS power_button_status;
     enum acpi_sleep_state slp_state;
+    int sleep_result;
 
     ACPI_FUNCTION_TRACE_U32((char *)(uintptr_t)__func__, state);
 
@@ -2733,15 +2740,61 @@
     if (sc->acpi_sleep_delay > 0)
 	DELAY(sc->acpi_sleep_delay * 1000000);
 
+    intr = intr_disable();
     if (state != ACPI_STATE_S1) {
-	acpi_sleep_machdep(sc, state);
+	sleep_result = acpi_sleep_machdep(sc, state);
+	acpi_wakeup_machdep(sc, state, sleep_result, 0);
 
+	/*
+	 * XXX According to ACPI specification SCI_EN bit should be restored
+	 * by ACPI platform (BIOS, firmware) to its pre-sleep state.
+	 * Unfortunately some BIOSes fail to do that and that leads to
+	 * unexpected and serious consequences during wake up like a system
+	 * getting stuck in SMI handlers.
+	 * This hack is picked up from Linux, which claims that it follows
+	 * Windows behavior.
+	 */
+	if (sleep_result == 1 && state != ACPI_STATE_S4)
+	    AcpiWriteBitRegister(ACPI_BITREG_SCI_ENABLE, ACPI_ENABLE_EVENT);
+
+
+	if (sleep_result == 1 && state == ACPI_STATE_S3) {
+	    /*
+	     * Prevent mis-interpretation of the wakeup by power button
+	     * as a request for power off.
+	     * Ideally we should post an appropriate wakeup event,
+	     * perhaps using acpi_event_power_button_wake or alike.
+	     *
+	     * Clearing of power button status after wakeup is mandated
+	     * by ACPI specification in section "Fixed Power Button".
+	     *
+	     * XXX As of ACPICA 20121114 AcpiGetEventStatus provides
+	     * status as 0/1 corressponding to inactive/active despite
+	     * its type being ACPI_EVENT_STATUS.  In other words,
+	     * we should not test for ACPI_EVENT_FLAG_SET for time being.
+	     */
+	    if (ACPI_SUCCESS(AcpiGetEventStatus(ACPI_EVENT_POWER_BUTTON,
+		&power_button_status)) && power_button_status != 0) {
+		AcpiClearEvent(ACPI_EVENT_POWER_BUTTON);
+		device_printf(sc->acpi_dev,
+		    "cleared fixed power button status\n");
+	    }
+	}
+
+	intr_restore(intr);
+
+	/* call acpi_wakeup_machdep() again with interrupt enabled */
+	acpi_wakeup_machdep(sc, state, sleep_result, 1);
+
+	if (sleep_result == -1)
+		goto backout;
+
 	/* Re-enable ACPI hardware on wakeup from sleep state 4. */
 	if (state == ACPI_STATE_S4)
 	    AcpiEnable();
     } else {
-	ACPI_DISABLE_IRQS();
 	status = AcpiEnterSleepState(state);
+	intr_restore(intr);
 	if (ACPI_FAILURE(status)) {
 	    device_printf(sc->acpi_dev, "AcpiEnterSleepState failed - %s\n",
 			  AcpiFormatException(status));

Modified: trunk/sys/dev/acpica/acpi_acad.c
===================================================================
--- trunk/sys/dev/acpica/acpi_acad.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_acad.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Takanori Watanabe
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_acad.c 197649 2009-09-30 17:07:49Z jhb $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>

Modified: trunk/sys/dev/acpica/acpi_battery.c
===================================================================
--- trunk/sys/dev/acpica/acpi_battery.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_battery.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Nate Lawson
  * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki at jp.freebsd.org>
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_battery.c 253642 2013-07-25 08:05:25Z avg $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -360,6 +361,18 @@
     int error, unit;
     device_t dev;
 
+
+    /*
+     * Giant is acquired to work around a reference counting bug in ACPICA
+     * versions prior to 20130328.  If not for that bug this function could
+     * be executed concurrently without any problems.
+     * The bug is in acpi_BatteryIsPresent -> AcpiGetObjectInfo call tree,
+     * where AcpiUtExecute_HID, AcpiUtExecute_UID, etc are executed without
+     * protection of any ACPICA lock and may concurrently call
+     * AcpiUtRemoveReference on a battery object.
+     */
+    mtx_lock(&Giant);
+
     /* For commands that use the ioctl_arg struct, validate it first. */
     error = ENXIO;
     unit = 0;
@@ -417,6 +430,7 @@
 	error = EINVAL;
     }
 
+    mtx_unlock(&Giant);
     return (error);
 }
 

Modified: trunk/sys/dev/acpica/acpi_button.c
===================================================================
--- trunk/sys/dev/acpica/acpi_button.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_button.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Mitsaru IWASAKI <iwasaki at jp.freebsd.org>
  * Copyright (c) 2000 Michael Smith <msmith at freebsd.org>
@@ -27,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_button.c 216471 2010-12-15 23:48:45Z jkim $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>

Modified: trunk/sys/dev/acpica/acpi_cmbat.c
===================================================================
--- trunk/sys/dev/acpica/acpi_cmbat.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_cmbat.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Nate Lawson
  * Copyright (c) 2000 Munehiro Matsuda
@@ -28,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_cmbat.c 249132 2013-04-05 08:22:11Z mav $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -46,7 +47,8 @@
 #include <dev/acpica/acpivar.h>
 #include <dev/acpica/acpiio.h>
 
-MALLOC_DEFINE(M_ACPICMBAT, "acpicmbat", "ACPI control method battery data");
+static MALLOC_DEFINE(M_ACPICMBAT, "acpicmbat",
+    "ACPI control method battery data");
 
 /* Number of times to retry initialization before giving up. */
 #define ACPI_CMBAT_RETRY_MAX	6

Modified: trunk/sys/dev/acpica/acpi_cpu.c
===================================================================
--- trunk/sys/dev/acpica/acpi_cpu.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_cpu.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2003-2005 Nate Lawson (SDG)
  * Copyright (c) 2001 Michael Smith
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_cpu.c 244618 2012-12-23 12:09:41Z avg $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -38,6 +39,7 @@
 #include <sys/pcpu.h>
 #include <sys/power.h>
 #include <sys/proc.h>
+#include <sys/sched.h>
 #include <sys/sbuf.h>
 #include <sys/smp.h>
 
@@ -68,6 +70,7 @@
     uint32_t		 trans_lat;	/* Transition latency (usec). */
     uint32_t		 power;		/* Power consumed (mW). */
     int			 res_type;	/* Resource type for p_lvlx. */
+    int			 res_rid;	/* Resource ID for p_lvlx. */
 };
 #define MAX_CX_STATES	 8
 
@@ -89,8 +92,9 @@
     struct sysctl_ctx_list cpu_sysctl_ctx;
     struct sysctl_oid	*cpu_sysctl_tree;
     int			 cpu_cx_lowest;
+    int			 cpu_cx_lowest_lim;
+    int			 cpu_disable_idle; /* Disable entry to idle function */
     char 		 cpu_cx_supported[64];
-    int			 cpu_rid;
 };
 
 struct acpi_cpu_device {
@@ -136,15 +140,11 @@
 static uint8_t		 cpu_cst_cnt;	/* Indicate we are _CST aware. */
 static int		 cpu_quirks;	/* Indicate any hardware bugs. */
 
-/* Runtime state. */
-static int		 cpu_disable_idle; /* Disable entry to idle function */
-static int		 cpu_cx_count;	/* Number of valid Cx states */
-
 /* Values for sysctl. */
 static struct sysctl_ctx_list cpu_sysctl_ctx;
 static struct sysctl_oid *cpu_sysctl_tree;
 static int		 cpu_cx_generic;
-static int		 cpu_cx_lowest;
+static int		 cpu_cx_lowest_lim;
 
 static device_t		*cpu_devices;
 static int		 cpu_ndevices;
@@ -173,7 +173,7 @@
 static void	acpi_cpu_notify(ACPI_HANDLE h, UINT32 notify, void *context);
 static int	acpi_cpu_quirks(void);
 static int	acpi_cpu_usage_sysctl(SYSCTL_HANDLER_ARGS);
-static int	acpi_cpu_set_cx_lowest(struct acpi_cpu_softc *sc, int val);
+static int	acpi_cpu_set_cx_lowest(struct acpi_cpu_softc *sc);
 static int	acpi_cpu_cx_lowest_sysctl(SYSCTL_HANDLER_ARGS);
 static int	acpi_cpu_global_cx_lowest_sysctl(SYSCTL_HANDLER_ARGS);
 
@@ -418,6 +418,39 @@
 SYSINIT(acpi_cpu, SI_SUB_CONFIGURE, SI_ORDER_MIDDLE,
     acpi_cpu_postattach, NULL);
 
+static void
+disable_idle(struct acpi_cpu_softc *sc)
+{
+    cpuset_t cpuset;
+
+    CPU_SETOF(sc->cpu_pcpu->pc_cpuid, &cpuset);
+    sc->cpu_disable_idle = TRUE;
+
+    /*
+     * Ensure that the CPU is not in idle state or in acpi_cpu_idle().
+     * Note that this code depends on the fact that the rendezvous IPI
+     * can not penetrate context where interrupts are disabled and acpi_cpu_idle
+     * is called and executed in such a context with interrupts being re-enabled
+     * right before return.
+     */
+    smp_rendezvous_cpus(cpuset, smp_no_rendevous_barrier, NULL,
+	smp_no_rendevous_barrier, NULL);
+}
+
+static void
+enable_idle(struct acpi_cpu_softc *sc)
+{
+
+    sc->cpu_disable_idle = FALSE;
+}
+
+static int
+is_idle_disabled(struct acpi_cpu_softc *sc)
+{
+
+    return (sc->cpu_disable_idle);
+}
+
 /*
  * Disable any entry to the idle function during suspend and re-enable it
  * during resume.
@@ -430,7 +463,7 @@
     error = bus_generic_suspend(dev);
     if (error)
 	return (error);
-    cpu_disable_idle = TRUE;
+    disable_idle(device_get_softc(dev));
     return (0);
 }
 
@@ -438,7 +471,7 @@
 acpi_cpu_resume(device_t dev)
 {
 
-    cpu_disable_idle = FALSE;
+    enable_idle(device_get_softc(dev));
     return (bus_generic_resume(dev));
 }
 
@@ -572,13 +605,15 @@
     bus_generic_shutdown(dev);
 
     /*
-     * Disable any entry to the idle function.  There is a small race where
-     * an idle thread have passed this check but not gone to sleep.  This
-     * is ok since device_shutdown() does not free the softc, otherwise
-     * we'd have to be sure all threads were evicted before returning.
+     * Disable any entry to the idle function.
      */
-    cpu_disable_idle = TRUE;
+    disable_idle(device_get_softc(dev));
 
+    /*
+     * CPU devices are not truely detached and remain referenced,
+     * so their resources are not freed.
+     */
+
     return_VALUE (0);
 }
 
@@ -590,6 +625,7 @@
     /* Use initial sleep value of 1 sec. to start with lowest idle state. */
     sc->cpu_prev_sleep = 1000000;
     sc->cpu_cx_lowest = 0;
+    sc->cpu_cx_lowest_lim = 0;
 
     /*
      * Check for the ACPI 2.0 _CST sleep states object. If we can't find
@@ -629,6 +665,7 @@
     cx_ptr->type = ACPI_STATE_C1;
     cx_ptr->trans_lat = 0;
     cx_ptr++;
+    sc->cpu_non_c3 = sc->cpu_cx_count;
     sc->cpu_cx_count++;
 
     /* 
@@ -646,13 +683,14 @@
     gas.BitWidth = 8;
     if (AcpiGbl_FADT.C2Latency <= 100) {
 	gas.Address = sc->cpu_p_blk + 4;
-	acpi_bus_alloc_gas(sc->cpu_dev, &cx_ptr->res_type, &sc->cpu_rid,
+	cx_ptr->res_rid = 0;
+	acpi_bus_alloc_gas(sc->cpu_dev, &cx_ptr->res_type, &cx_ptr->res_rid,
 	    &gas, &cx_ptr->p_lvlx, RF_SHAREABLE);
 	if (cx_ptr->p_lvlx != NULL) {
-	    sc->cpu_rid++;
 	    cx_ptr->type = ACPI_STATE_C2;
 	    cx_ptr->trans_lat = AcpiGbl_FADT.C2Latency;
 	    cx_ptr++;
+	    sc->cpu_non_c3 = sc->cpu_cx_count;
 	    sc->cpu_cx_count++;
 	}
     }
@@ -662,14 +700,15 @@
     /* Validate and allocate resources for C3 (P_LVL3). */
     if (AcpiGbl_FADT.C3Latency <= 1000 && !(cpu_quirks & CPU_QUIRK_NO_C3)) {
 	gas.Address = sc->cpu_p_blk + 5;
-	acpi_bus_alloc_gas(sc->cpu_dev, &cx_ptr->res_type, &sc->cpu_rid, &gas,
-	    &cx_ptr->p_lvlx, RF_SHAREABLE);
+	cx_ptr->res_rid = 1;
+	acpi_bus_alloc_gas(sc->cpu_dev, &cx_ptr->res_type, &cx_ptr->res_rid,
+	    &gas, &cx_ptr->p_lvlx, RF_SHAREABLE);
 	if (cx_ptr->p_lvlx != NULL) {
-	    sc->cpu_rid++;
 	    cx_ptr->type = ACPI_STATE_C3;
 	    cx_ptr->trans_lat = AcpiGbl_FADT.C3Latency;
 	    cx_ptr++;
 	    sc->cpu_cx_count++;
+	    cpu_can_deep_sleep = 1;
 	}
     }
 }
@@ -746,13 +785,13 @@
 		/* This is the first C1 state.  Use the reserved slot. */
 		sc->cpu_cx_states[0] = *cx_ptr;
 	    } else {
-		sc->cpu_non_c3 = i;
+		sc->cpu_non_c3 = sc->cpu_cx_count;
 		cx_ptr++;
 		sc->cpu_cx_count++;
 	    }
 	    continue;
 	case ACPI_STATE_C2:
-	    sc->cpu_non_c3 = i;
+	    sc->cpu_non_c3 = sc->cpu_cx_count;
 	    break;
 	case ACPI_STATE_C3:
 	default:
@@ -761,23 +800,23 @@
 				 "acpi_cpu%d: C3[%d] not available.\n",
 				 device_get_unit(sc->cpu_dev), i));
 		continue;
-	    }
+	    } else
+		cpu_can_deep_sleep = 1;
 	    break;
 	}
 
-#ifdef notyet
 	/* Free up any previous register. */
 	if (cx_ptr->p_lvlx != NULL) {
-	    bus_release_resource(sc->cpu_dev, 0, 0, cx_ptr->p_lvlx);
+	    bus_release_resource(sc->cpu_dev, cx_ptr->res_type, cx_ptr->res_rid,
+	        cx_ptr->p_lvlx);
 	    cx_ptr->p_lvlx = NULL;
 	}
-#endif
 
 	/* Allocate the control register for C2 or C3. */
-	acpi_PkgGas(sc->cpu_dev, pkg, 0, &cx_ptr->res_type, &sc->cpu_rid,
+	cx_ptr->res_rid = sc->cpu_cx_count;
+	acpi_PkgGas(sc->cpu_dev, pkg, 0, &cx_ptr->res_type, &cx_ptr->res_rid,
 	    &cx_ptr->p_lvlx, RF_SHAREABLE);
 	if (cx_ptr->p_lvlx) {
-	    sc->cpu_rid++;
 	    ACPI_DEBUG_PRINT((ACPI_DB_INFO,
 			     "acpi_cpu%d: Got C%d - %d latency\n",
 			     device_get_unit(sc->cpu_dev), cx_ptr->type,
@@ -816,7 +855,6 @@
      */
     acpi_cpu_quirks();
 
-    cpu_cx_count = 0;
     if (cpu_cx_generic) {
 	/*
 	 * We are using generic Cx mode, probe for available Cx states
@@ -825,24 +863,10 @@
 	for (i = 0; i < cpu_ndevices; i++) {
 	    sc = device_get_softc(cpu_devices[i]);
 	    acpi_cpu_generic_cx_probe(sc);
-	    if (sc->cpu_cx_count > cpu_cx_count)
-		    cpu_cx_count = sc->cpu_cx_count;
 	}
-
-	/*
-	 * Find the highest Cx state common to all CPUs
-	 * in the system, taking quirks into account.
-	 */
-	for (i = 0; i < cpu_ndevices; i++) {
-	    sc = device_get_softc(cpu_devices[i]);
-	    if (sc->cpu_cx_count < cpu_cx_count)
-		cpu_cx_count = sc->cpu_cx_count;
-	}
     } else {
 	/*
 	 * We are using _CST mode, remove C3 state if necessary.
-	 * Update the largest Cx state supported in the global cpu_cx_count.
-	 * It will be used in the global Cx sysctl handler.
 	 * As we now know for sure that we will be using _CST mode
 	 * install our notify handler.
 	 */
@@ -851,8 +875,6 @@
 	    if (cpu_quirks & CPU_QUIRK_NO_C3) {
 		sc->cpu_cx_count = sc->cpu_non_c3 + 1;
 	    }
-	    if (sc->cpu_cx_count > cpu_cx_count)
-		cpu_cx_count = sc->cpu_cx_count;
 	    AcpiInstallNotifyHandler(sc->cpu_handle, ACPI_DEVICE_NOTIFY,
 		acpi_cpu_notify, sc);
 	}
@@ -871,8 +893,11 @@
 	"Global lowest Cx sleep state to use");
 
     /* Take over idling from cpu_idle_default(). */
-    cpu_cx_lowest = 0;
-    cpu_disable_idle = FALSE;
+    cpu_cx_lowest_lim = 0;
+    for (i = 0; i < cpu_ndevices; i++) {
+	sc = device_get_softc(cpu_devices[i]);
+	enable_idle(sc);
+    }
     cpu_idle_hook = acpi_cpu_idle;
 }
 
@@ -885,16 +910,11 @@
     /*
      * Set up the list of Cx states
      */
-    sc->cpu_non_c3 = 0;
     sbuf_new(&sb, sc->cpu_cx_supported, sizeof(sc->cpu_cx_supported),
 	SBUF_FIXEDLEN);
-    for (i = 0; i < sc->cpu_cx_count; i++) {
-	sbuf_printf(&sb, "C%d/%d ", i + 1, sc->cpu_cx_states[i].trans_lat);
-	if (sc->cpu_cx_states[i].type < ACPI_STATE_C3)
-	    sc->cpu_non_c3 = i;
-	else
-	    cpu_can_deep_sleep = 1;
-    }
+    for (i = 0; i < sc->cpu_cx_count; i++)
+	sbuf_printf(&sb, "C%d/%d/%d ", i + 1, sc->cpu_cx_states[i].type,
+	    sc->cpu_cx_states[i].trans_lat);
     sbuf_trim(&sb);
     sbuf_finish(&sb);
 }	
@@ -920,7 +940,6 @@
 		    (void *)sc, 0, acpi_cpu_usage_sysctl, "A",
 		    "percent usage for each Cx state");
 
-#ifdef notyet
     /* Signal platform that we can handle _CST notification. */
     if (!cpu_cx_generic && cpu_cst_cnt != 0) {
 	ACPI_LOCK(acpi);
@@ -927,7 +946,6 @@
 	AcpiOsWritePort(cpu_smi_cmd, cpu_cst_cnt, 8);
 	ACPI_UNLOCK(acpi);
     }
-#endif
 }
 
 /*
@@ -941,15 +959,10 @@
 {
     struct	acpi_cpu_softc *sc;
     struct	acpi_cx *cx_next;
+    uint64_t	cputicks;
     uint32_t	start_time, end_time;
     int		bm_active, cx_next_idx, i;
 
-    /* If disabled, return immediately. */
-    if (cpu_disable_idle) {
-	ACPI_ENABLE_IRQS();
-	return;
-    }
-
     /*
      * Look up our CPU id to get our softc.  If it's NULL, we'll use C1
      * since there is no ACPI processor object for this CPU.  This occurs
@@ -961,6 +974,12 @@
 	return;
     }
 
+    /* If disabled, take the safe path. */
+    if (is_idle_disabled(sc)) {
+	acpi_cpu_c1();
+	return;
+    }
+
     /* Find the lowest state that has small enough latency. */
     cx_next_idx = 0;
     if (cpu_disable_deep_sleep)
@@ -980,11 +999,12 @@
      * driver polling for new devices keeps this bit set all the
      * time if USB is loaded.
      */
-    if ((cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) {
+    if ((cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0 &&
+	cx_next_idx > sc->cpu_non_c3) {
 	AcpiReadBitRegister(ACPI_BITREG_BUS_MASTER_STATUS, &bm_active);
 	if (bm_active != 0) {
 	    AcpiWriteBitRegister(ACPI_BITREG_BUS_MASTER_STATUS, 1);
-	    cx_next_idx = min(cx_next_idx, sc->cpu_non_c3);
+	    cx_next_idx = sc->cpu_non_c3;
 	}
     }
 
@@ -1000,11 +1020,10 @@
      * we are called inside critical section, delaying context switch.
      */
     if (cx_next->type == ACPI_STATE_C1) {
-	AcpiHwRead(&start_time, &AcpiGbl_FADT.XPmTimerBlock);
+	cputicks = cpu_ticks();
 	acpi_cpu_c1();
-	AcpiHwRead(&end_time, &AcpiGbl_FADT.XPmTimerBlock);
-        end_time = PM_USEC(acpi_TimerDelta(end_time, start_time));
-        if (curthread->td_critnest == 0)
+	end_time = ((cpu_ticks() - cputicks) << 20) / cpu_tickrate();
+	if (curthread->td_critnest == 0)
 		end_time = min(end_time, 500000 / hz);
 	sc->cpu_prev_sleep = (sc->cpu_prev_sleep * 3 + end_time) / 4;
 	return;
@@ -1028,7 +1047,13 @@
      * get the time very close to the CPU start/stop clock logic, this
      * is the only reliable time source.
      */
-    AcpiHwRead(&start_time, &AcpiGbl_FADT.XPmTimerBlock);
+    if (cx_next->type == ACPI_STATE_C3) {
+	AcpiHwRead(&start_time, &AcpiGbl_FADT.XPmTimerBlock);
+	cputicks = 0;
+    } else {
+	start_time = 0;
+	cputicks = cpu_ticks();
+    }
     CPU_GET_REG(cx_next->p_lvlx, 1);
 
     /*
@@ -1038,7 +1063,11 @@
      * margin that we are certain to have a correct value.
      */
     AcpiHwRead(&end_time, &AcpiGbl_FADT.XPmTimerBlock);
-    AcpiHwRead(&end_time, &AcpiGbl_FADT.XPmTimerBlock);
+    if (cx_next->type == ACPI_STATE_C3) {
+	AcpiHwRead(&end_time, &AcpiGbl_FADT.XPmTimerBlock);
+	end_time = acpi_TimerDelta(end_time, start_time);
+    } else
+	end_time = ((cpu_ticks() - cputicks) << 20) / cpu_tickrate();
 
     /* Enable bus master arbitration and disable bus master wakeup. */
     if (cx_next->type == ACPI_STATE_C3 &&
@@ -1048,41 +1077,39 @@
     }
     ACPI_ENABLE_IRQS();
 
-    /* Find the actual time asleep in microseconds. */
-    end_time = acpi_TimerDelta(end_time, start_time);
     sc->cpu_prev_sleep = (sc->cpu_prev_sleep * 3 + PM_USEC(end_time)) / 4;
 }
 
 /*
  * Re-evaluate the _CST object when we are notified that it changed.
- *
- * XXX Re-evaluation disabled until locking is done.
  */
 static void
 acpi_cpu_notify(ACPI_HANDLE h, UINT32 notify, void *context)
 {
     struct acpi_cpu_softc *sc = (struct acpi_cpu_softc *)context;
-    struct acpi_cpu_softc *isc;
-    int i;
-    
+
     if (notify != ACPI_NOTIFY_CX_STATES)
 	return;
 
+    /*
+     * C-state data for target CPU is going to be in flux while we execute
+     * acpi_cpu_cx_cst, so disable entering acpi_cpu_idle.
+     * Also, it may happen that multiple ACPI taskqueues may concurrently
+     * execute notifications for the same CPU.  ACPI_SERIAL is used to
+     * protect against that.
+     */
+    ACPI_SERIAL_BEGIN(cpu);
+    disable_idle(sc);
+
     /* Update the list of Cx states. */
     acpi_cpu_cx_cst(sc);
     acpi_cpu_cx_list(sc);
+    acpi_cpu_set_cx_lowest(sc);
 
-    /* Update the new lowest useable Cx state for all CPUs. */
-    ACPI_SERIAL_BEGIN(cpu);
-    cpu_cx_count = 0;
-    for (i = 0; i < cpu_ndevices; i++) {
-	isc = device_get_softc(cpu_devices[i]);
-	if (isc->cpu_cx_count > cpu_cx_count)
-	    cpu_cx_count = isc->cpu_cx_count;
-    }
-    if (sc->cpu_cx_lowest < cpu_cx_lowest)
-	acpi_cpu_set_cx_lowest(sc, min(cpu_cx_lowest, sc->cpu_cx_count - 1));
+    enable_idle(sc);
     ACPI_SERIAL_END(cpu);
+
+    acpi_UserNotify("PROCESSOR", sc->cpu_handle, notify);
 }
 
 static int
@@ -1209,12 +1236,12 @@
 }
 
 static int
-acpi_cpu_set_cx_lowest(struct acpi_cpu_softc *sc, int val)
+acpi_cpu_set_cx_lowest(struct acpi_cpu_softc *sc)
 {
     int i;
 
     ACPI_SERIAL_ASSERT(cpu);
-    sc->cpu_cx_lowest = val;
+    sc->cpu_cx_lowest = min(sc->cpu_cx_lowest_lim, sc->cpu_cx_count - 1);
 
     /* If not disabling, cache the new lowest non-C3 state. */
     sc->cpu_non_c3 = 0;
@@ -1238,18 +1265,23 @@
     int		 val, error;
 
     sc = (struct acpi_cpu_softc *) arg1;
-    snprintf(state, sizeof(state), "C%d", sc->cpu_cx_lowest + 1);
+    snprintf(state, sizeof(state), "C%d", sc->cpu_cx_lowest_lim + 1);
     error = sysctl_handle_string(oidp, state, sizeof(state), req);
     if (error != 0 || req->newptr == NULL)
 	return (error);
     if (strlen(state) < 2 || toupper(state[0]) != 'C')
 	return (EINVAL);
-    val = (int) strtol(state + 1, NULL, 10) - 1;
-    if (val < 0 || val > sc->cpu_cx_count - 1)
-	return (EINVAL);
+    if (strcasecmp(state, "Cmax") == 0)
+	val = MAX_CX_STATES;
+    else {
+	val = (int) strtol(state + 1, NULL, 10);
+	if (val < 1 || val > MAX_CX_STATES)
+	    return (EINVAL);
+    }
 
     ACPI_SERIAL_BEGIN(cpu);
-    acpi_cpu_set_cx_lowest(sc, val);
+    sc->cpu_cx_lowest_lim = val - 1;
+    acpi_cpu_set_cx_lowest(sc);
     ACPI_SERIAL_END(cpu);
 
     return (0);
@@ -1262,22 +1294,27 @@
     char	state[8];
     int		val, error, i;
 
-    snprintf(state, sizeof(state), "C%d", cpu_cx_lowest + 1);
+    snprintf(state, sizeof(state), "C%d", cpu_cx_lowest_lim + 1);
     error = sysctl_handle_string(oidp, state, sizeof(state), req);
     if (error != 0 || req->newptr == NULL)
 	return (error);
     if (strlen(state) < 2 || toupper(state[0]) != 'C')
 	return (EINVAL);
-    val = (int) strtol(state + 1, NULL, 10) - 1;
-    if (val < 0 || val > cpu_cx_count - 1)
-	return (EINVAL);
-    cpu_cx_lowest = val;
+    if (strcasecmp(state, "Cmax") == 0)
+	val = MAX_CX_STATES;
+    else {
+	val = (int) strtol(state + 1, NULL, 10);
+	if (val < 1 || val > MAX_CX_STATES)
+	    return (EINVAL);
+    }
 
     /* Update the new lowest useable Cx state for all CPUs. */
     ACPI_SERIAL_BEGIN(cpu);
+    cpu_cx_lowest_lim = val - 1;
     for (i = 0; i < cpu_ndevices; i++) {
 	sc = device_get_softc(cpu_devices[i]);
-	acpi_cpu_set_cx_lowest(sc, min(val, sc->cpu_cx_count - 1));
+	sc->cpu_cx_lowest_lim = cpu_cx_lowest_lim;
+	acpi_cpu_set_cx_lowest(sc);
     }
     ACPI_SERIAL_END(cpu);
 

Modified: trunk/sys/dev/acpica/acpi_dock.c
===================================================================
--- trunk/sys/dev/acpica/acpi_dock.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_dock.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005-2006 Mitsuru IWASAKI <iwasaki at FreeBSD.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD$
+ * $FreeBSD: release/9.2.0/sys/dev/acpica/acpi_dock.c 209064 2010-06-11 19:53:42Z jkim $
  */
 
 #include "opt_acpi.h"

Modified: trunk/sys/dev/acpica/acpi_ec.c
===================================================================
--- trunk/sys/dev/acpica/acpi_ec.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_ec.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2003-2007 Nate Lawson
  * Copyright (c) 2000 Michael Smith
@@ -27,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_ec.c 248085 2013-03-09 02:36:32Z marius $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -178,7 +179,7 @@
 
 ACPI_SERIAL_DECL(ec, "ACPI embedded controller");
 
-SYSCTL_NODE(_debug_acpi, OID_AUTO, ec, CTLFLAG_RD, NULL, "EC debugging");
+static SYSCTL_NODE(_debug_acpi, OID_AUTO, ec, CTLFLAG_RD, NULL, "EC debugging");
 
 static int	ec_burst_mode;
 TUNABLE_INT("debug.acpi.ec.burst", &ec_burst_mode);

Modified: trunk/sys/dev/acpica/acpi_hpet.c
===================================================================
--- trunk/sys/dev/acpica/acpi_hpet.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_hpet.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Poul-Henning Kamp
  * Copyright (c) 2010 Alexander Motin <mav at FreeBSD.org>
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_hpet.c 240384 2012-09-12 09:29:22Z mav $");
 
 #include "opt_acpi.h"
 #if defined(__amd64__) || defined(__ia64__)
@@ -57,6 +58,7 @@
 #endif
 
 #define HPET_VENDID_AMD		0x4353
+#define HPET_VENDID_AMD2	0x1022
 #define HPET_VENDID_INTEL	0x8086
 #define HPET_VENDID_NVIDIA	0x10de
 #define HPET_VENDID_SW		0x1166
@@ -505,7 +507,7 @@
 	 * properly, that makes it very unreliable - it freezes after any
 	 * interrupt loss. Avoid legacy IRQs for AMD.
 	 */
-	if (vendor == HPET_VENDID_AMD)
+	if (vendor == HPET_VENDID_AMD || vendor == HPET_VENDID_AMD2)
 		sc->allowed_irqs = 0x00000000;
 	/*
 	 * NVidia MCP5x chipsets have number of unexplained interrupt

Modified: trunk/sys/dev/acpica/acpi_hpet.h
===================================================================
--- trunk/sys/dev/acpica/acpi_hpet.h	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_hpet.h	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Poul-Henning Kamp
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD$
+ * $FreeBSD: release/9.2.0/sys/dev/acpica/acpi_hpet.h 224919 2011-08-16 21:51:29Z mav $
  */
 
 #ifndef __ACPI_HPET_H__

Modified: trunk/sys/dev/acpica/acpi_if.m
===================================================================
--- trunk/sys/dev/acpica/acpi_if.m	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_if.m	2013-12-30 18:11:21 UTC (rev 6591)
@@ -23,7 +23,7 @@
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 #
-# $FreeBSD$
+# $FreeBSD: release/9.2.0/sys/dev/acpica/acpi_if.m 214072 2010-10-19 19:53:06Z jkim $
 #
 
 #include <sys/bus.h>

Modified: trunk/sys/dev/acpica/acpi_isab.c
===================================================================
--- trunk/sys/dev/acpica/acpi_isab.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_isab.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2003 John Baldwin <jhb at FreeBSD.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_isab.c 229093 2011-12-31 14:12:12Z hselasky $");
 
 /*
  * ISA Bridge driver for Generic ISA Bus Devices.  See section 10.7 of the

Modified: trunk/sys/dev/acpica/acpi_lid.c
===================================================================
--- trunk/sys/dev/acpica/acpi_lid.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_lid.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Takanori Watanabe <takawata at jp.freebsd.org>
  * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki at jp.freebsd.org>
@@ -28,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_lid.c 209746 2010-07-06 20:57:28Z jkim $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>

Modified: trunk/sys/dev/acpica/acpi_package.c
===================================================================
--- trunk/sys/dev/acpica/acpi_package.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_package.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2003 Nate Lawson
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_package.c 202771 2010-01-21 21:14:28Z jkim $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>

Modified: trunk/sys/dev/acpica/acpi_pci.c
===================================================================
--- trunk/sys/dev/acpica/acpi_pci.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_pci.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1997, Stefan Esser <se at freebsd.org>
  * Copyright (c) 2000, Michael Smith <msmith at freebsd.org>
@@ -27,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_pci.c 233393 2012-03-23 20:47:25Z jhb $");
 
 #include <sys/param.h>
 #include <sys/systm.h>

Modified: trunk/sys/dev/acpica/acpi_pci_link.c
===================================================================
--- trunk/sys/dev/acpica/acpi_pci_link.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_pci_link.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2002 Mitsuru IWASAKI <iwasaki at jp.freebsd.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_pci_link.c 251754 2013-06-14 18:30:43Z jhb $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -99,6 +100,7 @@
 	uint8_t	l_bios_irq;
 	uint8_t	l_irq;
 	uint8_t	l_initial_irq;
+	UINT32	l_crs_type;
 	int	l_res_index;
 	int	l_num_irqs;
 	int	*l_irqs;
@@ -120,7 +122,7 @@
 	int	link_index;
 };
 
-MALLOC_DEFINE(M_PCI_LINK, "pci_link", "ACPI PCI Link structures");
+static MALLOC_DEFINE(M_PCI_LINK, "pci_link", "ACPI PCI Link structures");
 
 static int pci_link_interrupt_weights[NUM_ACPI_INTERRUPTS];
 static int pci_link_bios_isa_irqs;
@@ -236,6 +238,7 @@
 		    ("%s: array boundary violation", __func__));
 		link = &req->sc->pl_links[req->link_index];
 		link->l_res_index = req->res_index;
+		link->l_crs_type = res->Type;
 		req->link_index++;
 		req->res_index++;
 
@@ -364,6 +367,14 @@
 					link->l_isa_irq = FALSE;
 			}
 		}
+
+		/*
+		 * If this is not an ISA IRQ but _CRS used a non-extended
+		 * IRQ descriptor, don't use _CRS as a template for _SRS.
+		 */
+		if (!req->sc->pl_crs_bad && !link->l_isa_irq &&
+		    link->l_crs_type == ACPI_RESOURCE_TYPE_IRQ)
+			req->sc->pl_crs_bad = TRUE;
 		break;
 	default:
 		if (req->in_dpf == DPF_IGNORE)

Modified: trunk/sys/dev/acpica/acpi_pcib.c
===================================================================
--- trunk/sys/dev/acpica/acpi_pcib.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_pcib.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Michael Smith
  * Copyright (c) 2000 BSDi
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_pcib.c 253426 2013-07-17 14:04:18Z jhb $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -134,15 +135,6 @@
     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
 
     /*
-     * Don't attach if we're not really there.
-     *
-     * XXX: This isn't entirely correct since we may be a PCI bus
-     * on a hot-plug docking station, etc.
-     */
-    if (!acpi_DeviceIsPresent(dev))
-	return_VALUE(ENXIO);
-
-    /*
      * Get the PCI interrupt routing table for this bus.  If we can't
      * get it, this is not an error but may reduce functionality.  There
      * are several valid bridges in the field that do not have a _PRT, so

Modified: trunk/sys/dev/acpica/acpi_pcib_acpi.c
===================================================================
--- trunk/sys/dev/acpica/acpi_pcib_acpi.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_pcib_acpi.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Michael Smith
  * Copyright (c) 2000 BSDi
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_pcib_acpi.c 253426 2013-07-17 14:04:18Z jhb $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -287,6 +288,12 @@
     sc->ap_handle = acpi_get_handle(dev);
 
     /*
+     * Don't attach if we're not really there.
+     */
+    if (!acpi_DeviceIsPresent(dev))
+	return (ENXIO);
+
+    /*
      * Get our segment number by evaluating _SEG.
      * It's OK for this to not exist.
      */
@@ -353,7 +360,7 @@
 	if (status != AE_NOT_FOUND) {
 	    device_printf(dev, "could not evaluate _BBN - %s\n",
 		AcpiFormatException(status));
-	    return_VALUE (ENXIO);
+	    return (ENXIO);
 	} else {
 	    /* If it's not found, assume 0. */
 	    sc->ap_bus = 0;

Modified: trunk/sys/dev/acpica/acpi_pcib_pci.c
===================================================================
--- trunk/sys/dev/acpica/acpi_pcib_pci.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_pcib_pci.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Michael Smith
  * Copyright (c) 2000 BSDi
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_pcib_pci.c 221393 2011-05-03 17:37:24Z jhb $");
 
 #include "opt_acpi.h"
 

Modified: trunk/sys/dev/acpica/acpi_pcibvar.h
===================================================================
--- trunk/sys/dev/acpica/acpi_pcibvar.h	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_pcibvar.h	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Michael Smith
  * Copyright (c) 2000 BSDi
@@ -24,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD$
+ * $FreeBSD: release/9.2.0/sys/dev/acpica/acpi_pcibvar.h 211430 2010-08-17 15:44:52Z jhb $
  */
 
 #ifndef	_ACPI_PCIBVAR_H_

Modified: trunk/sys/dev/acpica/acpi_perf.c
===================================================================
--- trunk/sys/dev/acpica/acpi_perf.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_perf.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2003-2005 Nate Lawson (SDG)
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_perf.c 249132 2013-04-05 08:22:11Z mav $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -135,7 +136,7 @@
 DRIVER_MODULE(acpi_perf, cpu, acpi_perf_driver, acpi_perf_devclass, 0, 0);
 MODULE_DEPEND(acpi_perf, acpi, 1, 1, 1);
 
-MALLOC_DEFINE(M_ACPIPERF, "acpi_perf", "ACPI Performance states");
+static MALLOC_DEFINE(M_ACPIPERF, "acpi_perf", "ACPI Performance states");
 
 static void
 acpi_perf_identify(driver_t *driver, device_t parent)

Modified: trunk/sys/dev/acpica/acpi_powerres.c
===================================================================
--- trunk/sys/dev/acpica/acpi_powerres.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_powerres.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2001 Michael Smith
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_powerres.c 249132 2013-04-05 08:22:11Z mav $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -55,7 +56,7 @@
  * on, turned off, etc.
  */
 
-MALLOC_DEFINE(M_ACPIPWR, "acpipwr", "ACPI power resources");
+static MALLOC_DEFINE(M_ACPIPWR, "acpipwr", "ACPI power resources");
 
 /* Hooks for the ACPI CA debugging infrastructure */
 #define _COMPONENT	ACPI_POWERRES
@@ -314,7 +315,6 @@
     ACPI_OBJECT			*reslist_object;
     ACPI_STATUS			status;
     char			*method_name, *reslist_name;
-    int				res_changed;
 
     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
 
@@ -445,7 +445,7 @@
      * Now we are ready to switch, so kill off any current power
      * resource references.
      */
-    res_changed = acpi_pwr_dereference_resource(pc);
+    acpi_pwr_dereference_resource(pc);
 
     /*
      * Add new power resource references, if we have any.  Traverse the
@@ -457,7 +457,6 @@
 			  reslist_object->Package.Count));
 	acpi_ForeachPackageObject(reslist_object, acpi_pwr_reference_resource,
 				  pc);
-	res_changed = 1;
     }
 
     /*

Modified: trunk/sys/dev/acpica/acpi_quirk.c
===================================================================
--- trunk/sys/dev/acpica/acpi_quirk.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_quirk.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2004 Nate Lawson (SDG)
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_quirk.c 193530 2009-06-05 18:44:36Z jkim $");
 
 #include <sys/param.h>
 #include <sys/bus.h>

Modified: trunk/sys/dev/acpica/acpi_quirks
===================================================================
--- trunk/sys/dev/acpica/acpi_quirks	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_quirks	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: release/9.2.0/sys/dev/acpica/acpi_quirks 147612 2005-06-26 18:19:14Z dwmalone $
 #
 # Quirks for ACPI tables can be added here.
 #

Modified: trunk/sys/dev/acpica/acpi_resource.c
===================================================================
--- trunk/sys/dev/acpica/acpi_resource.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_resource.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Michael Smith
  * Copyright (c) 2000 BSDi
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_resource.c 223383 2011-06-21 21:30:20Z jhb $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>

Modified: trunk/sys/dev/acpica/acpi_smbat.c
===================================================================
--- trunk/sys/dev/acpica/acpi_smbat.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_smbat.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Hans Petter Selasky
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_smbat.c 248085 2013-03-09 02:36:32Z marius $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -62,7 +63,8 @@
 
 ACPI_SERIAL_DECL(smbat, "ACPI Smart Battery");
 
-SYSCTL_NODE(_debug_acpi, OID_AUTO, batt, CTLFLAG_RD, NULL, "Battery debugging");
+static SYSCTL_NODE(_debug_acpi, OID_AUTO, batt, CTLFLAG_RD, NULL,
+    "Battery debugging");
 
 /* On some laptops with smart batteries, enabling battery monitoring
  * software causes keystrokes from atkbd to be lost.  This has also been

Modified: trunk/sys/dev/acpica/acpi_smbus.h
===================================================================
--- trunk/sys/dev/acpica/acpi_smbus.h	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_smbus.h	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Hans Petter Selasky
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	$FreeBSD$
+ *	$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_smbus.h 151564 2005-10-23 00:20:13Z njl $
  */
 
 #ifndef _ACPI_SMBUS_H_

Modified: trunk/sys/dev/acpica/acpi_thermal.c
===================================================================
--- trunk/sys/dev/acpica/acpi_thermal.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_thermal.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000, 2001 Michael Smith
  * Copyright (c) 2000 BSDi
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_thermal.c 248796 2013-03-27 14:23:50Z mav $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -121,6 +122,8 @@
     int				tz_cooling_saved_freq;
 };
 
+#define	TZ_ACTIVE_LEVEL(act)	((act) >= 0 ? (act) : TZ_NUMLEVELS)
+
 #define CPUFREQ_MAX_LEVELS	64 /* XXX cpufreq should export this */
 
 static int	acpi_tz_probe(device_t dev);
@@ -507,15 +510,8 @@
      */
     newactive = TZ_ACTIVE_NONE;
     for (i = TZ_NUMLEVELS - 1; i >= 0; i--) {
-	if (sc->tz_zone.ac[i] != -1 && temp >= sc->tz_zone.ac[i]) {
+	if (sc->tz_zone.ac[i] != -1 && temp >= sc->tz_zone.ac[i])
 	    newactive = i;
-	    if (sc->tz_active != newactive) {
-		ACPI_VPRINT(sc->tz_dev,
-			    acpi_device_get_parent_softc(sc->tz_dev),
-			    "_AC%d: temperature %d.%d >= setpoint %d.%d\n", i,
-			    TZ_KELVTOC(temp), TZ_KELVTOC(sc->tz_zone.ac[i]));
-	    }
-	}
     }
 
     /*
@@ -565,18 +561,21 @@
     }
 
     if (newactive != sc->tz_active) {
-	/* Turn off the cooling devices that are on, if any are */
-	if (sc->tz_active != TZ_ACTIVE_NONE)
+	/* Turn off unneeded cooling devices that are on, if any are */
+	for (i = TZ_ACTIVE_LEVEL(sc->tz_active);
+	     i < TZ_ACTIVE_LEVEL(newactive); i++) {
 	    acpi_ForeachPackageObject(
-		(ACPI_OBJECT *)sc->tz_zone.al[sc->tz_active].Pointer,
+		(ACPI_OBJECT *)sc->tz_zone.al[i].Pointer,
 		acpi_tz_switch_cooler_off, sc);
-
+	}
 	/* Turn on cooling devices that are required, if any are */
-	if (newactive != TZ_ACTIVE_NONE) {
+	for (i = TZ_ACTIVE_LEVEL(sc->tz_active) - 1;
+	     i >= TZ_ACTIVE_LEVEL(newactive); i--) {
 	    acpi_ForeachPackageObject(
-		(ACPI_OBJECT *)sc->tz_zone.al[newactive].Pointer,
+		(ACPI_OBJECT *)sc->tz_zone.al[i].Pointer,
 		acpi_tz_switch_cooler_on, sc);
 	}
+
 	ACPI_VPRINT(sc->tz_dev, acpi_device_get_parent_softc(sc->tz_dev),
 		    "switched from %s to %s: %d.%dC\n",
 		    acpi_tz_aclevel_string(sc->tz_active),

Modified: trunk/sys/dev/acpica/acpi_throttle.c
===================================================================
--- trunk/sys/dev/acpica/acpi_throttle.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_throttle.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2003-2005 Nate Lawson (SDG)
  * Copyright (c) 2001 Michael Smith
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_throttle.c 193530 2009-06-05 18:44:36Z jkim $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>

Modified: trunk/sys/dev/acpica/acpi_timer.c
===================================================================
--- trunk/sys/dev/acpica/acpi_timer.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_timer.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000, 2001 Michael Smith
  * Copyright (c) 2000 BSDi
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_timer.c 232086 2012-02-23 22:26:14Z jkim $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>

Modified: trunk/sys/dev/acpica/acpi_video.c
===================================================================
--- trunk/sys/dev/acpica/acpi_video.c	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpi_video.c	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2002-2003 Taku YAMAMOTO <taku at cent.saitama-u.ac.jp>
  * All rights reserved.
@@ -23,11 +24,11 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	$Id: acpi_video.c,v 1.5 2012-10-09 04:08:08 laffer1 Exp $
+ *	$Id: acpi_vid.c,v 1.4 2003/10/13 10:07:36 taku Exp $
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_video.c 249132 2013-04-05 08:22:11Z mav $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -185,7 +186,7 @@
  */
 ACPI_SERIAL_DECL(video, "ACPI video");
 ACPI_SERIAL_DECL(video_output, "ACPI video output");
-MALLOC_DEFINE(M_ACPIVIDEO, "acpivideo", "ACPI video extension");
+static MALLOC_DEFINE(M_ACPIVIDEO, "acpivideo", "ACPI video extension");
 
 static int
 acpi_video_modevent(struct module *mod __unused, int evt, void *cookie __unused)
@@ -906,7 +907,8 @@
 
 	for (i = 0; i < argset->dod_pkg->Package.Count; i++) {
 		if (acpi_PkgInt32(argset->dod_pkg, i, &val) == 0 &&
-		    (val & DOD_DEVID_MASK_FULL) == adr) {
+		    (val & DOD_DEVID_MASK_FULL) ==
+		    (adr & DOD_DEVID_MASK_FULL)) {
 			argset->callback(handle, val, argset->context);
 			argset->count++;
 		}

Modified: trunk/sys/dev/acpica/acpiio.h
===================================================================
--- trunk/sys/dev/acpica/acpiio.h	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpiio.h	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Takanori Watanabe <takawata at jp.freebsd.org>
  * Copyright (c) 1999 Mitsuru IWASAKI <iwasaki at FreeBSD.org>
@@ -24,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD$
+ * $FreeBSD: release/9.2.0/sys/dev/acpica/acpiio.h 216503 2010-12-17 16:21:30Z avg $
  */
 
 #ifndef _ACPIIO_H_

Modified: trunk/sys/dev/acpica/acpivar.h
===================================================================
--- trunk/sys/dev/acpica/acpivar.h	2013-12-30 18:11:10 UTC (rev 6590)
+++ trunk/sys/dev/acpica/acpivar.h	2013-12-30 18:11:21 UTC (rev 6591)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki at jp.freebsd.org>
  * Copyright (c) 2000 Michael Smith <msmith at freebsd.org>
@@ -25,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD$
+ * $FreeBSD: release/9.2.0/sys/dev/acpica/acpivar.h 247881 2013-03-06 10:23:56Z avg $
  */
 
 #ifndef _ACPIVAR_H_
@@ -434,6 +435,8 @@
 int		acpi_machdep_init(device_t dev);
 void		acpi_install_wakeup_handler(struct acpi_softc *sc);
 int		acpi_sleep_machdep(struct acpi_softc *sc, int state);
+int		acpi_wakeup_machdep(struct acpi_softc *sc, int state,
+		    int sleep_result, int intr_enabled);
 int		acpi_table_quirks(int *quirks);
 int		acpi_machdep_quirks(int *quirks);
 
@@ -476,7 +479,7 @@
 
 /* Default maximum number of tasks to enqueue. */
 #ifndef ACPI_MAX_TASKS
-#define	ACPI_MAX_TASKS		32
+#define	ACPI_MAX_TASKS		MAX(32, MAXCPU * 2)
 #endif
 
 /* Default number of task queue threads to start. */



More information about the Midnightbsd-cvs mailing list