[Midnightbsd-cvs] src [10113] trunk/sys/dev/acpica: update acpi support
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun May 27 19:55:56 EDT 2018
Revision: 10113
http://svnweb.midnightbsd.org/src/?rev=10113
Author: laffer1
Date: 2018-05-27 19:55:56 -0400 (Sun, 27 May 2018)
Log Message:
-----------
update acpi support
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
Property Changed:
----------------
trunk/sys/dev/acpica/acpi_if.m
trunk/sys/dev/acpica/acpi_quirks
Modified: trunk/sys/dev/acpica/Osd/OsdDebug.c
===================================================================
--- trunk/sys/dev/acpica/Osd/OsdDebug.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/Osd/OsdDebug.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/Osd/OsdDebug.c 222544 2011-05-31 19:45:58Z jkim $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/Osd/OsdDebug.c 306536 2016-09-30 22:40:58Z jkim $");
#include "opt_ddb.h"
#include <sys/param.h>
@@ -105,7 +105,7 @@
if (!initted) {
printf("Initialising ACPICA debugger...\n");
- AcpiDbInitialize();
+ AcpiInitializeDebugger();
initted = 1;
}
Modified: trunk/sys/dev/acpica/Osd/OsdHardware.c
===================================================================
--- trunk/sys/dev/acpica/Osd/OsdHardware.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/Osd/OsdHardware.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/Osd/OsdHardware.c 213787 2010-10-13 17:06:25Z jkim $");
+__FBSDID("$FreeBSD: stable/10/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 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/Osd/OsdInterrupt.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/Osd/OsdInterrupt.c 249132 2013-04-05 08:22:11Z mav $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/Osd/OsdInterrupt.c 227293 2011-11-07 06:44:47Z ed $");
#include <sys/param.h>
#include <sys/kernel.h>
Modified: trunk/sys/dev/acpica/Osd/OsdMemory.c
===================================================================
--- trunk/sys/dev/acpica/Osd/OsdMemory.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/Osd/OsdMemory.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/Osd/OsdMemory.c 249132 2013-04-05 08:22:11Z mav $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/Osd/OsdMemory.c 231844 2012-02-16 22:59:29Z jkim $");
#include <contrib/dev/acpica/include/acpi.h>
@@ -88,7 +88,7 @@
}
ACPI_STATUS
-AcpiOsReadMemory(ACPI_PHYSICAL_ADDRESS Address, UINT32 *Value, UINT32 Width)
+AcpiOsReadMemory(ACPI_PHYSICAL_ADDRESS Address, UINT64 *Value, UINT32 Width)
{
void *LogicalAddress;
@@ -106,6 +106,9 @@
case 32:
*Value = *(volatile uint32_t *)LogicalAddress;
break;
+ case 64:
+ *Value = *(volatile uint64_t *)LogicalAddress;
+ break;
}
pmap_unmapdev((vm_offset_t)LogicalAddress, Width / 8);
@@ -114,7 +117,7 @@
}
ACPI_STATUS
-AcpiOsWriteMemory(ACPI_PHYSICAL_ADDRESS Address, UINT32 Value, UINT32 Width)
+AcpiOsWriteMemory(ACPI_PHYSICAL_ADDRESS Address, UINT64 Value, UINT32 Width)
{
void *LogicalAddress;
@@ -132,6 +135,9 @@
case 32:
*(volatile uint32_t *)LogicalAddress = Value;
break;
+ case 64:
+ *(volatile uint64_t *)LogicalAddress = Value;
+ break;
}
pmap_unmapdev((vm_offset_t)LogicalAddress, Width / 8);
Modified: trunk/sys/dev/acpica/Osd/OsdSchedule.c
===================================================================
--- trunk/sys/dev/acpica/Osd/OsdSchedule.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/Osd/OsdSchedule.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -2,7 +2,7 @@
/*-
* Copyright (c) 2000 Michael Smith
* Copyright (c) 2000 BSDi
- * Copyright (c) 2007-2009 Jung-uk Kim <jkim at FreeBSD.org>
+ * Copyright (c) 2007-2012 Jung-uk Kim <jkim at FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/Osd/OsdSchedule.c 249132 2013-04-05 08:22:11Z mav $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/Osd/OsdSchedule.c 306536 2016-09-30 22:40:58Z jkim $");
#include "opt_acpi.h"
#include <sys/param.h>
@@ -58,6 +58,8 @@
*/
static int acpi_max_tasks = ACPI_MAX_TASKS;
TUNABLE_INT("debug.acpi.max_tasks", &acpi_max_tasks);
+SYSCTL_INT(_debug_acpi, OID_AUTO, max_tasks, CTLFLAG_RDTUN, &acpi_max_tasks,
+ 0, "Maximum acpi tasks");
/*
* Allow the user to tune the number of task threads we start. It seems
@@ -65,6 +67,8 @@
*/
static int acpi_max_threads = ACPI_MAX_THREADS;
TUNABLE_INT("debug.acpi.max_threads", &acpi_max_threads);
+SYSCTL_INT(_debug_acpi, OID_AUTO, max_threads, CTLFLAG_RDTUN, &acpi_max_threads,
+ 0, "Maximum acpi threads");
static MALLOC_DEFINE(M_ACPITASK, "acpitask", "ACPI deferred task");
@@ -182,12 +186,13 @@
AcpiOsExecute(ACPI_EXECUTE_TYPE Type, ACPI_OSD_EXEC_CALLBACK Function,
void *Context)
{
+ ACPI_STATUS status;
int pri;
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
if (Function == NULL)
- return_ACPI_STATUS (AE_BAD_PARAMETER);
+ return_ACPI_STATUS(AE_BAD_PARAMETER);
switch (Type) {
case OSL_GPE_HANDLER:
@@ -205,17 +210,33 @@
case OSL_EC_BURST_HANDLER:
pri = 5;
break;
- case OSL_DEBUGGER_THREAD:
+ case OSL_DEBUGGER_MAIN_THREAD:
+ case OSL_DEBUGGER_EXEC_THREAD:
pri = 0;
break;
default:
- return_ACPI_STATUS (AE_BAD_PARAMETER);
+ return_ACPI_STATUS(AE_BAD_PARAMETER);
}
- return_ACPI_STATUS (acpi_task_enqueue(pri, Function, Context));
+ status = acpi_task_enqueue(pri, Function, Context);
+ return_ACPI_STATUS(status);
}
void
+AcpiOsWaitEventsComplete(void)
+{
+ int i;
+
+ ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
+
+ for (i = 0; i < acpi_max_tasks; i++)
+ if ((atomic_load_acq_int(&acpi_tasks[i].at_flag) &
+ ACPI_TASK_ENQUEUED) != 0)
+ taskqueue_drain(acpi_taskq, &acpi_tasks[i].at_task);
+ return_VOID;
+}
+
+void
AcpiOsSleep(UINT64 Milliseconds)
{
int timo;
@@ -249,8 +270,8 @@
KASSERT(cold == 0, ("acpi: timer op not yet supported during boot"));
binuptime(&bt);
- t = ((UINT64)10000000 * (uint32_t)(bt.frac >> 32)) >> 32;
- t += bt.sec * 10000000;
+ t = (uint64_t)bt.sec * 10000000;
+ t += ((uint64_t)10000000 * (uint32_t)(bt.frac >> 32)) >> 32;
return (t);
}
Modified: trunk/sys/dev/acpica/Osd/OsdStream.c
===================================================================
--- trunk/sys/dev/acpica/Osd/OsdStream.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/Osd/OsdStream.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/Osd/OsdStream.c 193530 2009-06-05 18:44:36Z jkim $");
+__FBSDID("$FreeBSD: stable/10/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 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/Osd/OsdSynch.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/Osd/OsdSynch.c 249132 2013-04-05 08:22:11Z mav $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/Osd/OsdSynch.c 303252 2016-07-23 22:50:59Z jhb $");
#include <contrib/dev/acpica/include/acpi.h>
#include <contrib/dev/acpica/include/accommon.h>
@@ -189,6 +189,23 @@
}
break;
default:
+ if (cold) {
+ /*
+ * Just spin polling the semaphore once a
+ * millisecond.
+ */
+ while (!ACPISEM_AVAIL(as, Units)) {
+ if (Timeout == 0) {
+ status = AE_TIME;
+ break;
+ }
+ Timeout--;
+ mtx_unlock(&as->as_lock);
+ DELAY(1000);
+ mtx_lock(&as->as_lock);
+ }
+ break;
+ }
tmo = timeout2hz(Timeout);
while (!ACPISEM_AVAIL(as, Units)) {
prevtick = ticks;
@@ -209,7 +226,7 @@
tmo -= slptick;
}
}
- if (status == AE_OK)
+ if (ACPI_SUCCESS(status))
as->as_units -= Units;
mtx_unlock(&as->as_lock);
@@ -382,6 +399,23 @@
}
break;
default:
+ if (cold) {
+ /*
+ * Just spin polling the mutex once a
+ * millisecond.
+ */
+ while (!ACPIMTX_AVAIL(am)) {
+ if (Timeout == 0) {
+ status = AE_TIME;
+ break;
+ }
+ Timeout--;
+ mtx_unlock(&am->am_lock);
+ DELAY(1000);
+ mtx_lock(&am->am_lock);
+ }
+ break;
+ }
tmo = timeout2hz(Timeout);
while (!ACPIMTX_AVAIL(am)) {
prevtick = ticks;
@@ -403,7 +437,7 @@
tmo -= slptick;
}
}
- if (status == AE_OK)
+ if (ACPI_SUCCESS(status))
am->am_owner = curthread;
mtx_unlock(&am->am_lock);
@@ -567,8 +601,6 @@
}
/* Section 5.2.10.1: global lock acquire/release functions */
-#define GL_BIT_PENDING 0x01
-#define GL_BIT_OWNED 0x02
/*
* Acquire the global lock. If busy, set the pending bit. The caller
@@ -576,18 +608,18 @@
* and then attempt to acquire it again.
*/
int
-acpi_acquire_global_lock(uint32_t *lock)
+acpi_acquire_global_lock(volatile uint32_t *lock)
{
uint32_t new, old;
do {
old = *lock;
- new = (old & ~GL_BIT_PENDING) | GL_BIT_OWNED;
- if ((old & GL_BIT_OWNED) != 0)
- new |= GL_BIT_PENDING;
- } while (atomic_cmpset_acq_int(lock, old, new) == 0);
+ new = (old & ~ACPI_GLOCK_PENDING) | ACPI_GLOCK_OWNED;
+ if ((old & ACPI_GLOCK_OWNED) != 0)
+ new |= ACPI_GLOCK_PENDING;
+ } while (atomic_cmpset_32(lock, old, new) == 0);
- return ((new & GL_BIT_PENDING) == 0);
+ return ((new & ACPI_GLOCK_PENDING) == 0);
}
/*
@@ -596,14 +628,14 @@
* releases the lock.
*/
int
-acpi_release_global_lock(uint32_t *lock)
+acpi_release_global_lock(volatile uint32_t *lock)
{
uint32_t new, old;
do {
old = *lock;
- new = old & ~(GL_BIT_PENDING | GL_BIT_OWNED);
- } while (atomic_cmpset_rel_int(lock, old, new) == 0);
+ new = old & ~(ACPI_GLOCK_PENDING | ACPI_GLOCK_OWNED);
+ } while (atomic_cmpset_32(lock, old, new) == 0);
- return ((old & GL_BIT_PENDING) != 0);
+ return ((old & ACPI_GLOCK_PENDING) != 0);
}
Modified: trunk/sys/dev/acpica/Osd/OsdTable.c
===================================================================
--- trunk/sys/dev/acpica/Osd/OsdTable.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/Osd/OsdTable.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/Osd/OsdTable.c 218660 2011-02-13 19:24:04Z marcel $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/Osd/OsdTable.c 281075 2015-04-04 10:17:51Z dim $");
#include <sys/param.h>
#include <sys/endian.h>
@@ -51,17 +51,17 @@
ACPI_STRING *NewVal)
{
- if (InitVal == NULL || NewVal == NULL)
- return (AE_BAD_PARAMETER);
+ if (InitVal == NULL || NewVal == NULL)
+ return (AE_BAD_PARAMETER);
- *NewVal = NULL;
- if (strncmp(InitVal->Name, "_OS_", ACPI_NAME_SIZE) == 0 &&
- strlen(acpi_osname) > 0) {
- printf("ACPI: Overriding _OS definition with \"%s\"\n", acpi_osname);
- *NewVal = acpi_osname;
- }
-
- return (AE_OK);
+ *NewVal = NULL;
+ if (ACPI_COMPARE_NAME(InitVal->Name, "_OS_") &&
+ InitVal->Type == ACPI_TYPE_STRING && strlen(acpi_osname) > 0) {
+ printf("ACPI: Overriding _OS definition with \"%s\"\n",
+ acpi_osname);
+ *NewVal = acpi_osname;
+ }
+ return (AE_OK);
}
ACPI_STATUS
@@ -68,32 +68,41 @@
AcpiOsTableOverride(ACPI_TABLE_HEADER *ExistingTable,
ACPI_TABLE_HEADER **NewTable)
{
- char modname[] = "acpi_dsdt";
- caddr_t acpi_table;
- ACPI_TABLE_HEADER *hdr;
- size_t sz;
+ char modname[] = "acpi_dsdt";
+ caddr_t acpi_table;
+ ACPI_TABLE_HEADER *hdr;
+ size_t sz;
- if (ExistingTable == NULL || NewTable == NULL)
- return (AE_BAD_PARAMETER);
+ if (ExistingTable == NULL || NewTable == NULL)
+ return (AE_BAD_PARAMETER);
- *NewTable = NULL;
+ *NewTable = NULL;
+ if (!ACPI_COMPARE_NAME(ExistingTable->Signature, ACPI_SIG_DSDT))
#ifdef notyet
- for (int i = 0; i < ACPI_NAME_SIZE; i++)
- modname[i + 5] = tolower(ExistingTable->Signature[i]);
+ for (int i = 0; i < ACPI_NAME_SIZE; i++)
+ modname[i + 5] = tolower(ExistingTable->Signature[i]);
#else
- /* If we're not overriding the DSDT, just return. */
- if (strncmp(ExistingTable->Signature, ACPI_SIG_DSDT, ACPI_NAME_SIZE) != 0)
- return (AE_OK);
+ return (AE_SUPPORT);
#endif
-
- acpi_table = preload_search_by_type(modname);
- if (acpi_table == NULL)
+ acpi_table = preload_search_by_type(modname);
+ if (acpi_table == NULL)
+ return (AE_NOT_FOUND);
+ hdr = preload_fetch_addr(acpi_table);
+ sz = preload_fetch_size(acpi_table);
+ if (hdr == NULL || sz == 0)
+ return (AE_ERROR);
+#ifndef notyet
+ /* Assume SSDT is installed with DSDT. */
+ AcpiGbl_DisableSsdtTableInstall = TRUE;
+#endif
+ *NewTable = hdr;
return (AE_OK);
+}
- hdr = preload_fetch_addr(acpi_table);
- sz = preload_fetch_size(acpi_table);
- if (hdr != NULL && sz != 0)
- *NewTable = hdr;
+ACPI_STATUS
+AcpiOsPhysicalTableOverride(ACPI_TABLE_HEADER *ExistingTable,
+ ACPI_PHYSICAL_ADDRESS *NewAddress, UINT32 *NewTableLength)
+{
- return (AE_OK);
+ return (AE_SUPPORT);
}
Modified: trunk/sys/dev/acpica/acpi.c
===================================================================
--- trunk/sys/dev/acpica/acpi.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi.c 251754 2013-06-14 18:30:43Z jhb $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/acpi.c 306536 2016-09-30 22:40:58Z jkim $");
#include "opt_acpi.h"
#include <sys/param.h>
@@ -101,6 +101,7 @@
/* Supported sleep states. */
static BOOLEAN acpi_sleep_states[ACPI_S_STATE_COUNT];
+static void acpi_lookup(void *arg, const char *name, device_t *dev);
static int acpi_modevent(struct module *mod, int event, void *junk);
static int acpi_probe(device_t dev);
static int acpi_attach(device_t dev);
@@ -208,6 +209,7 @@
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
DEVMETHOD(bus_hint_device_unit, acpi_hint_device_unit),
+ DEVMETHOD(bus_get_domain, acpi_get_domain),
/* ACPI bus */
DEVMETHOD(acpi_id_probe, acpi_device_id_probe),
@@ -218,7 +220,7 @@
/* ISA emulation */
DEVMETHOD(isa_pnp_probe, acpi_isa_pnp_probe),
- {0, 0}
+ DEVMETHOD_END
};
static driver_t acpi_driver = {
@@ -256,16 +258,6 @@
TUNABLE_STR("hw.acpi.remove_interface", acpi_remove_interface,
sizeof(acpi_remove_interface));
-/*
- * Allow override of whether methods execute in parallel or not.
- * Enable this for serial behavior, which fixes "AE_ALREADY_EXISTS"
- * errors for AML that really can't handle parallel method execution.
- * It is off by default since this breaks recursive methods and
- * some IBMs use such code.
- */
-static int acpi_serialize_methods;
-TUNABLE_INT("hw.acpi.serialize_methods", &acpi_serialize_methods);
-
/* Allow users to dump Debug objects without ACPI debugger. */
static int acpi_debug_objects;
TUNABLE_INT("debug.acpi.enable_debug_objects", &acpi_debug_objects);
@@ -279,6 +271,12 @@
SYSCTL_INT(_debug_acpi, OID_AUTO, interpreter_slack, CTLFLAG_RDTUN,
&acpi_interpreter_slack, 1, "Turn on interpreter slack mode.");
+/* Ignore register widths set by FADT and use default widths instead. */
+static int acpi_ignore_reg_width = 1;
+TUNABLE_INT("debug.acpi.default_register_width", &acpi_ignore_reg_width);
+SYSCTL_INT(_debug_acpi, OID_AUTO, default_register_width, CTLFLAG_RDTUN,
+ &acpi_ignore_reg_width, 1, "Ignore register widths set by FADT");
+
#ifdef __amd64__
/* Reset system clock while resuming. XXX Remove once tested. */
static int acpi_reset_clock = 1;
@@ -432,7 +430,7 @@
device_set_desc(dev, acpi_desc);
- return_VALUE (0);
+ return_VALUE (BUS_PROBE_NOWILDCARD);
}
static int
@@ -474,9 +472,9 @@
* Set the globals from our tunables. This is needed because ACPI-CA
* uses UINT8 for some values and we have no tunable_byte.
*/
- AcpiGbl_AllMethodsSerialized = acpi_serialize_methods ? TRUE : FALSE;
AcpiGbl_EnableInterpreterSlack = acpi_interpreter_slack ? TRUE : FALSE;
AcpiGbl_EnableAmlDebugObject = acpi_debug_objects ? TRUE : FALSE;
+ AcpiGbl_UseDefaultRegisterWidths = acpi_ignore_reg_width ? TRUE : FALSE;
#ifndef ACPI_DEBUG
/*
@@ -614,7 +612,9 @@
/* Probe all supported sleep states. */
acpi_sleep_states[ACPI_STATE_S0] = TRUE;
for (state = ACPI_STATE_S1; state < ACPI_S_STATE_COUNT; state++)
- if (ACPI_SUCCESS(AcpiGetSleepTypeData(state, &TypeA, &TypeB)))
+ if (ACPI_SUCCESS(AcpiEvaluateObject(ACPI_ROOT_OBJECT,
+ __DECONST(char *, AcpiGbl_SleepStateNames[state]), NULL, NULL)) &&
+ ACPI_SUCCESS(AcpiGetSleepTypeData(state, &TypeA, &TypeB)))
acpi_sleep_states[state] = TRUE;
/*
@@ -672,8 +672,10 @@
/* Register ACPI again to pass the correct argument of pm_func. */
power_pm_register(POWER_PM_TYPE_ACPI, acpi_pm_func, sc);
- if (!acpi_disabled("bus"))
+ if (!acpi_disabled("bus")) {
+ EVENTHANDLER_REGISTER(dev_lookup, acpi_lookup, NULL, 1000);
acpi_probe_children(dev);
+ }
/* Update all GPEs and enable runtime GPEs. */
status = AcpiUpdateAllGpes();
@@ -796,6 +798,7 @@
retval += resource_list_print_type(rl, "drq", SYS_RES_DRQ, "%ld");
if (device_get_flags(child))
retval += printf(" flags %#x", device_get_flags(child));
+ retval += bus_print_child_domain(bus, child);
retval += bus_print_child_footer(bus, child);
return (retval);
@@ -852,11 +855,18 @@
size_t buflen)
{
struct acpi_device *dinfo = device_get_ivars(child);
+ char buf2[32];
+ int pxm;
- if (dinfo->ad_handle)
- snprintf(buf, buflen, "handle=%s", acpi_name(dinfo->ad_handle));
- else
- snprintf(buf, buflen, "unknown");
+ if (dinfo->ad_handle) {
+ snprintf(buf, buflen, "handle=%s", acpi_name(dinfo->ad_handle));
+ if (ACPI_SUCCESS(acpi_GetInteger(dinfo->ad_handle, "_PXM", &pxm))) {
+ snprintf(buf2, 32, " _PXM=%d", pxm);
+ strlcat(buf, buf2, buflen);
+ }
+ } else {
+ snprintf(buf, buflen, "unknown");
+ }
return (0);
}
@@ -1062,6 +1072,35 @@
}
/*
+ * Fech the NUMA domain for the given device.
+ *
+ * If a device has a _PXM method, map that to a NUMA domain.
+ *
+ * If none is found, then it'll call the parent method.
+ * If there's no domain, return ENOENT.
+ */
+int
+acpi_get_domain(device_t dev, device_t child, int *domain)
+{
+#if MAXMEMDOM > 1
+ ACPI_HANDLE h;
+ int d, pxm;
+
+ h = acpi_get_handle(child);
+ if ((h != NULL) &&
+ ACPI_SUCCESS(acpi_GetInteger(h, "_PXM", &pxm))) {
+ d = acpi_map_pxm_to_vm_domainid(pxm);
+ if (d < 0)
+ return (ENOENT);
+ *domain = d;
+ return (0);
+ }
+#endif
+ /* No _PXM node; go up a level */
+ return (bus_generic_get_domain(dev, child, domain));
+}
+
+/*
* Pre-allocate/manage all memory and IO resources. Since rman can't handle
* duplicates, we merge any in the sysresource attach routine.
*/
@@ -1505,7 +1544,7 @@
acpi_isa_get_compatid(device_t dev, uint32_t *cids, int count)
{
ACPI_DEVICE_INFO *devinfo;
- ACPI_DEVICE_ID *ids;
+ ACPI_PNP_DEVICE_ID *ids;
ACPI_HANDLE h;
uint32_t *pnpid;
int i, valid;
@@ -2413,6 +2452,46 @@
return (AE_OK);
}
+ACPI_STATUS
+acpi_EvaluateOSC(ACPI_HANDLE handle, uint8_t *uuid, int revision, int count,
+ uint32_t *caps_in, uint32_t *caps_out, bool query)
+{
+ ACPI_OBJECT arg[4], *ret;
+ ACPI_OBJECT_LIST arglist;
+ ACPI_BUFFER buf;
+ ACPI_STATUS status;
+
+ arglist.Pointer = arg;
+ arglist.Count = 4;
+ arg[0].Type = ACPI_TYPE_BUFFER;
+ arg[0].Buffer.Length = ACPI_UUID_LENGTH;
+ arg[0].Buffer.Pointer = uuid;
+ arg[1].Type = ACPI_TYPE_INTEGER;
+ arg[1].Integer.Value = revision;
+ arg[2].Type = ACPI_TYPE_INTEGER;
+ arg[2].Integer.Value = count;
+ arg[3].Type = ACPI_TYPE_BUFFER;
+ arg[3].Buffer.Length = count * sizeof(*caps_in);
+ arg[3].Buffer.Pointer = (uint8_t *)caps_in;
+ caps_in[0] = query ? 1 : 0;
+ buf.Pointer = NULL;
+ buf.Length = ACPI_ALLOCATE_BUFFER;
+ status = AcpiEvaluateObjectTyped(handle, "_OSC", &arglist, &buf,
+ ACPI_TYPE_BUFFER);
+ if (ACPI_FAILURE(status))
+ return (status);
+ if (caps_out != NULL) {
+ ret = buf.Pointer;
+ if (ret->Buffer.Length != count * sizeof(*caps_out)) {
+ AcpiOsFree(buf.Pointer);
+ return (AE_BUFFER_OVERFLOW);
+ }
+ bcopy(ret->Buffer.Pointer, caps_out, ret->Buffer.Length);
+ }
+ AcpiOsFree(buf.Pointer);
+ return (status);
+}
+
/*
* Set interrupt model.
*/
@@ -2511,8 +2590,11 @@
if (!acpi_sleep_states[state])
return (EOPNOTSUPP);
- /* If a suspend request is already in progress, just return. */
- if (sc->acpi_next_sstate != 0) {
+ /*
+ * If a reboot/shutdown/suspend request is already in progress or
+ * suspend is blocked due to an upcoming shutdown, just return.
+ */
+ if (rebooting || sc->acpi_next_sstate != 0 || suspend_blocked) {
return (0);
}
@@ -2714,6 +2796,8 @@
return_ACPI_STATUS (AE_OK);
}
+ EVENTHANDLER_INVOKE(power_suspend_early);
+ stop_all_proc();
EVENTHANDLER_INVOKE(power_suspend);
if (smp_started) {
@@ -2782,6 +2866,7 @@
if (sleep_result == 1 && state != ACPI_STATE_S4)
AcpiWriteBitRegister(ACPI_BITREG_SCI_ENABLE, ACPI_ENABLE_EVENT);
+ AcpiLeaveSleepStatePrep(state);
if (sleep_result == 1 && state == ACPI_STATE_S3) {
/*
@@ -2819,6 +2904,7 @@
AcpiEnable();
} else {
status = AcpiEnterSleepState(state);
+ AcpiLeaveSleepStatePrep(state);
intr_restore(intr);
if (ACPI_FAILURE(status)) {
device_printf(sc->acpi_dev, "AcpiEnterSleepState failed - %s\n",
@@ -2855,6 +2941,8 @@
thread_unlock(curthread);
}
+ resume_all_proc();
+
EVENTHANDLER_INVOKE(power_resume);
/* Allow another sleep request after a while. */
@@ -3360,6 +3448,31 @@
return (0);
}
+static void
+acpi_lookup(void *arg, const char *name, device_t *dev)
+{
+ ACPI_HANDLE handle;
+
+ if (*dev != NULL)
+ return;
+
+ /*
+ * Allow any handle name that is specified as an absolute path and
+ * starts with '\'. We could restrict this to \_SB and friends,
+ * but see acpi_probe_children() for notes on why we scan the entire
+ * namespace for devices.
+ *
+ * XXX: The pathname argument to AcpiGetHandle() should be fixed to
+ * be const.
+ */
+ if (name[0] != '\\')
+ return;
+ if (ACPI_FAILURE(AcpiGetHandle(ACPI_ROOT_OBJECT, __DECONST(char *, name),
+ &handle)))
+ return;
+ *dev = acpi_get_device(handle);
+}
+
/*
* Control interface.
*
@@ -3570,7 +3683,7 @@
handle_buf.Pointer = NULL;
handle_buf.Length = ACPI_ALLOCATE_BUFFER;
- status = AcpiNsHandleToPathname(h, &handle_buf);
+ status = AcpiNsHandleToPathname(h, &handle_buf, FALSE);
if (ACPI_FAILURE(status))
return;
snprintf(notify_buf, sizeof(notify_buf), "notify=0x%02x", notify);
Modified: trunk/sys/dev/acpica/acpi_acad.c
===================================================================
--- trunk/sys/dev/acpica/acpi_acad.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_acad.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_acad.c 197649 2009-09-30 17:07:49Z jhb $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/acpi_acad.c 246128 2013-01-30 18:01:20Z sbz $");
#include "opt_acpi.h"
#include <sys/param.h>
@@ -75,7 +75,7 @@
DEVMETHOD(device_probe, acpi_acad_probe),
DEVMETHOD(device_attach, acpi_acad_attach),
- {0, 0}
+ DEVMETHOD_END
};
static driver_t acpi_acad_driver = {
Modified: trunk/sys/dev/acpica/acpi_battery.c
===================================================================
--- trunk/sys/dev/acpica/acpi_battery.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_battery.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_battery.c 253642 2013-07-25 08:05:25Z avg $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/acpi_battery.c 227992 2011-11-26 13:43:50Z dumbbell $");
#include "opt_acpi.h"
#include <sys/param.h>
@@ -361,18 +361,6 @@
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;
@@ -430,7 +418,6 @@
error = EINVAL;
}
- mtx_unlock(&Giant);
return (error);
}
Modified: trunk/sys/dev/acpica/acpi_button.c
===================================================================
--- trunk/sys/dev/acpica/acpi_button.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_button.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_button.c 216471 2010-12-15 23:48:45Z jkim $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/acpi_button.c 246128 2013-01-30 18:01:20Z sbz $");
#include "opt_acpi.h"
#include <sys/param.h>
@@ -80,8 +80,7 @@
DEVMETHOD(device_suspend, acpi_button_suspend),
DEVMETHOD(device_shutdown, acpi_button_suspend),
DEVMETHOD(device_resume, acpi_button_resume),
-
- {0, 0}
+ DEVMETHOD_END
};
static driver_t acpi_button_driver = {
Modified: trunk/sys/dev/acpica/acpi_cmbat.c
===================================================================
--- trunk/sys/dev/acpica/acpi_cmbat.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_cmbat.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_cmbat.c 249132 2013-04-05 08:22:11Z mav $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/acpi_cmbat.c 315264 2017-03-14 15:56:19Z hselasky $");
#include "opt_acpi.h"
#include <sys/param.h>
@@ -100,7 +100,7 @@
DEVMETHOD(acpi_batt_get_info, acpi_cmbat_bif),
DEVMETHOD(acpi_batt_get_status, acpi_cmbat_bst),
- {0, 0}
+ DEVMETHOD_END
};
static driver_t acpi_cmbat_driver = {
@@ -165,6 +165,16 @@
handle = acpi_get_handle(dev);
AcpiRemoveNotifyHandler(handle, ACPI_ALL_NOTIFY, acpi_cmbat_notify_handler);
acpi_battery_remove(dev);
+
+ /*
+ * Force any pending notification handler calls to complete by
+ * requesting cmbat serialisation while freeing and clearing the
+ * softc pointer:
+ */
+ ACPI_SERIAL_BEGIN(cmbat);
+ device_set_softc(dev, NULL);
+ ACPI_SERIAL_END(cmbat);
+
return (0);
}
@@ -437,7 +447,6 @@
device_t dev;
dev = (device_t)arg;
- sc = device_get_softc(dev);
ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev),
"battery initialization start\n");
@@ -447,18 +456,33 @@
* to wait a while.
*/
for (retry = 0; retry < ACPI_CMBAT_RETRY_MAX; retry++, AcpiOsSleep(10000)) {
- /* batteries on DOCK can be ejected w/ DOCK during retrying */
- if (!device_is_attached(dev))
+ /*
+ * Batteries on DOCK can be ejected w/ DOCK during retrying.
+ *
+ * If there is a valid softc pointer the device may be in
+ * attaching, attached or detaching state. If the state is
+ * different from attached retry getting the device state
+ * until it becomes stable. This solves a race if the ACPI
+ * notification handler is called during attach, because
+ * device_is_attached() doesn't return non-zero until after
+ * the attach code has been executed.
+ */
+ ACPI_SERIAL_BEGIN(cmbat);
+ sc = device_get_softc(dev);
+ if (sc == NULL) {
+ ACPI_SERIAL_END(cmbat);
return;
+ }
- if (!acpi_BatteryIsPresent(dev))
+ if (!acpi_BatteryIsPresent(dev) || !device_is_attached(dev)) {
+ ACPI_SERIAL_END(cmbat);
continue;
+ }
/*
* Only query the battery if this is the first try or the specific
* type of info is still invalid.
*/
- ACPI_SERIAL_BEGIN(cmbat);
if (retry == 0 || !acpi_battery_bst_valid(&sc->bst)) {
timespecclear(&sc->bst_lastupdated);
acpi_cmbat_get_bst(dev);
Modified: trunk/sys/dev/acpica/acpi_cpu.c
===================================================================
--- trunk/sys/dev/acpica/acpi_cpu.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_cpu.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -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: release/9.2.0/sys/dev/acpica/acpi_cpu.c 244618 2012-12-23 12:09:41Z avg $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/acpi_cpu.c 303229 2016-07-23 17:41:47Z jhb $");
#include "opt_acpi.h"
#include <sys/param.h>
@@ -85,6 +86,7 @@
int cpu_prev_sleep;/* Last idle sleep duration. */
int cpu_features; /* Child driver supported features. */
/* Runtime state. */
+ int cpu_non_c2; /* Index of lowest non-C2 state. */
int cpu_non_c3; /* Index of lowest non-C3 state. */
u_int cpu_cx_stats[MAX_CX_STATES];/* Cx usage history. */
/* Values for sysctl. */
@@ -168,9 +170,10 @@
static void acpi_cpu_startup(void *arg);
static void acpi_cpu_startup_cx(struct acpi_cpu_softc *sc);
static void acpi_cpu_cx_list(struct acpi_cpu_softc *sc);
-static void acpi_cpu_idle(void);
+static void acpi_cpu_idle(sbintime_t sbt);
static void acpi_cpu_notify(ACPI_HANDLE h, UINT32 notify, void *context);
-static int acpi_cpu_quirks(void);
+static void acpi_cpu_quirks(void);
+static void acpi_cpu_quirks_piix4(void);
static int acpi_cpu_usage_sysctl(SYSCTL_HANDLER_ARGS);
static int acpi_cpu_set_cx_lowest(struct acpi_cpu_softc *sc);
static int acpi_cpu_cx_lowest_sysctl(SYSCTL_HANDLER_ARGS);
@@ -273,7 +276,7 @@
acpi_cpu_attach(device_t dev)
{
ACPI_BUFFER buf;
- ACPI_OBJECT arg[4], *obj;
+ ACPI_OBJECT arg, *obj;
ACPI_OBJECT_LIST arglist;
struct pcpu *pcpu_data;
struct acpi_cpu_softc *sc;
@@ -357,31 +360,19 @@
* Intel Processor Vendor-Specific ACPI Interface Specification.
*/
if (sc->cpu_features) {
- arglist.Pointer = arg;
- arglist.Count = 4;
- arg[0].Type = ACPI_TYPE_BUFFER;
- arg[0].Buffer.Length = sizeof(cpu_oscuuid);
- arg[0].Buffer.Pointer = cpu_oscuuid; /* UUID */
- arg[1].Type = ACPI_TYPE_INTEGER;
- arg[1].Integer.Value = 1; /* revision */
- arg[2].Type = ACPI_TYPE_INTEGER;
- arg[2].Integer.Value = 1; /* count */
- arg[3].Type = ACPI_TYPE_BUFFER;
- arg[3].Buffer.Length = sizeof(cap_set); /* Capabilities buffer */
- arg[3].Buffer.Pointer = (uint8_t *)cap_set;
- cap_set[0] = 0; /* status */
cap_set[1] = sc->cpu_features;
- status = AcpiEvaluateObject(sc->cpu_handle, "_OSC", &arglist, NULL);
+ status = acpi_EvaluateOSC(sc->cpu_handle, cpu_oscuuid, 1, 2, cap_set,
+ cap_set, false);
if (ACPI_SUCCESS(status)) {
if (cap_set[0] != 0)
device_printf(dev, "_OSC returned status %#x\n", cap_set[0]);
}
else {
- arglist.Pointer = arg;
+ arglist.Pointer = &arg;
arglist.Count = 1;
- arg[0].Type = ACPI_TYPE_BUFFER;
- arg[0].Buffer.Length = sizeof(cap_set);
- arg[0].Buffer.Pointer = (uint8_t *)cap_set;
+ arg.Type = ACPI_TYPE_BUFFER;
+ arg.Buffer.Length = sizeof(cap_set);
+ arg.Buffer.Pointer = (uint8_t *)cap_set;
cap_set[0] = 1; /* revision */
cap_set[1] = 1; /* number of capabilities integers */
cap_set[2] = sc->cpu_features;
@@ -664,8 +655,10 @@
cx_ptr->type = ACPI_STATE_C1;
cx_ptr->trans_lat = 0;
cx_ptr++;
+ sc->cpu_non_c2 = sc->cpu_cx_count;
sc->cpu_non_c3 = sc->cpu_cx_count;
sc->cpu_cx_count++;
+ cpu_deepest_sleep = 1;
/*
* The spec says P_BLK must be 6 bytes long. However, some systems
@@ -691,6 +684,7 @@
cx_ptr++;
sc->cpu_non_c3 = sc->cpu_cx_count;
sc->cpu_cx_count++;
+ cpu_deepest_sleep = 2;
}
}
if (sc->cpu_p_blk_len < 6)
@@ -707,7 +701,7 @@
cx_ptr->trans_lat = AcpiGbl_FADT.C3Latency;
cx_ptr++;
sc->cpu_cx_count++;
- cpu_can_deep_sleep = 1;
+ cpu_deepest_sleep = 3;
}
}
}
@@ -753,6 +747,7 @@
count = MAX_CX_STATES;
}
+ sc->cpu_non_c2 = 0;
sc->cpu_non_c3 = 0;
sc->cpu_cx_count = 0;
cx_ptr = sc->cpu_cx_states;
@@ -764,6 +759,7 @@
cx_ptr->type = ACPI_STATE_C0;
cx_ptr++;
sc->cpu_cx_count++;
+ cpu_deepest_sleep = 1;
/* Set up all valid states. */
for (i = 0; i < count; i++) {
@@ -784,6 +780,7 @@
/* This is the first C1 state. Use the reserved slot. */
sc->cpu_cx_states[0] = *cx_ptr;
} else {
+ sc->cpu_non_c2 = sc->cpu_cx_count;
sc->cpu_non_c3 = sc->cpu_cx_count;
cx_ptr++;
sc->cpu_cx_count++;
@@ -791,6 +788,8 @@
continue;
case ACPI_STATE_C2:
sc->cpu_non_c3 = sc->cpu_cx_count;
+ if (cpu_deepest_sleep < 2)
+ cpu_deepest_sleep = 2;
break;
case ACPI_STATE_C3:
default:
@@ -800,7 +799,7 @@
device_get_unit(sc->cpu_dev), i));
continue;
} else
- cpu_can_deep_sleep = 1;
+ cpu_deepest_sleep = 3;
break;
}
@@ -872,7 +871,7 @@
for (i = 0; i < cpu_ndevices; i++) {
sc = device_get_softc(cpu_devices[i]);
if (cpu_quirks & CPU_QUIRK_NO_C3) {
- sc->cpu_cx_count = sc->cpu_non_c3 + 1;
+ sc->cpu_cx_count = min(sc->cpu_cx_count, sc->cpu_non_c3 + 1);
}
AcpiInstallNotifyHandler(sc->cpu_handle, ACPI_DEVICE_NOTIFY,
acpi_cpu_notify, sc);
@@ -954,13 +953,13 @@
* interrupts are re-enabled.
*/
static void
-acpi_cpu_idle()
+acpi_cpu_idle(sbintime_t sbt)
{
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;
+ int bm_active, cx_next_idx, i, us;
/*
* Look up our CPU id to get our softc. If it's NULL, we'll use C1
@@ -980,13 +979,18 @@
}
/* Find the lowest state that has small enough latency. */
+ us = sc->cpu_prev_sleep;
+ if (sbt >= 0 && us > (sbt >> 12))
+ us = (sbt >> 12);
cx_next_idx = 0;
- if (cpu_disable_deep_sleep)
+ if (cpu_disable_c2_sleep)
+ i = min(sc->cpu_cx_lowest, sc->cpu_non_c2);
+ else if (cpu_disable_c3_sleep)
i = min(sc->cpu_cx_lowest, sc->cpu_non_c3);
else
i = sc->cpu_cx_lowest;
for (; i >= 0; i--) {
- if (sc->cpu_cx_states[i].trans_lat * 3 <= sc->cpu_prev_sleep) {
+ if (sc->cpu_cx_states[i].trans_lat * 3 <= us) {
cx_next_idx = i;
break;
}
@@ -1111,12 +1115,9 @@
acpi_UserNotify("PROCESSOR", sc->cpu_handle, notify);
}
-static int
+static void
acpi_cpu_quirks(void)
{
- device_t acpi_dev;
- uint32_t val;
-
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
/*
@@ -1150,6 +1151,16 @@
}
/* Look for various quirks of the PIIX4 part. */
+ acpi_cpu_quirks_piix4();
+}
+
+static void
+acpi_cpu_quirks_piix4(void)
+{
+#ifdef __i386__
+ device_t acpi_dev;
+ uint32_t val;
+
acpi_dev = pci_find_device(PCI_VENDOR_INTEL, PCI_DEVICE_82371AB_3);
if (acpi_dev != NULL) {
switch (pci_get_revid(acpi_dev)) {
@@ -1198,8 +1209,7 @@
break;
}
}
-
- return (0);
+#endif
}
static int
Modified: trunk/sys/dev/acpica/acpi_dock.c
===================================================================
--- trunk/sys/dev/acpica/acpi_dock.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_dock.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: release/9.2.0/sys/dev/acpica/acpi_dock.c 209064 2010-06-11 19:53:42Z jkim $
+ * $FreeBSD: stable/10/sys/dev/acpica/acpi_dock.c 246128 2013-01-30 18:01:20Z sbz $
*/
#include "opt_acpi.h"
@@ -522,7 +522,7 @@
DEVMETHOD(device_probe, acpi_dock_probe),
DEVMETHOD(device_attach, acpi_dock_attach),
- {0, 0}
+ DEVMETHOD_END
};
static driver_t acpi_dock_driver = {
Modified: trunk/sys/dev/acpica/acpi_ec.c
===================================================================
--- trunk/sys/dev/acpica/acpi_ec.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_ec.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_ec.c 248085 2013-03-09 02:36:32Z marius $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/acpi_ec.c 310254 2016-12-19 09:52:32Z hselasky $");
#include "opt_acpi.h"
#include <sys/param.h>
@@ -254,7 +254,7 @@
DEVMETHOD(acpi_ec_read, acpi_ec_read_method),
DEVMETHOD(acpi_ec_write, acpi_ec_write_method),
- {0, 0}
+ DEVMETHOD_END
};
static driver_t acpi_ec_driver = {
@@ -619,16 +619,14 @@
}
static void
-EcGpeQueryHandler(void *Context)
+EcGpeQueryHandlerSub(struct acpi_ec_softc *sc)
{
- struct acpi_ec_softc *sc = (struct acpi_ec_softc *)Context;
UINT8 Data;
ACPI_STATUS Status;
- int retry, sci_enqueued;
+ int retry;
char qxx[5];
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
- KASSERT(Context != NULL, ("EcGpeQueryHandler called with NULL"));
/* Serialize user access with EcSpaceHandler(). */
Status = EcLock(sc);
@@ -645,18 +643,14 @@
* that may arise from running the query from causing another query
* to be queued, we clear the pending flag only after running it.
*/
- sci_enqueued = sc->ec_sci_pend;
for (retry = 0; retry < 2; retry++) {
Status = EcCommand(sc, EC_COMMAND_QUERY);
if (ACPI_SUCCESS(Status))
break;
- if (EcCheckStatus(sc, "retr_check",
- EC_EVENT_INPUT_BUFFER_EMPTY) == AE_OK)
- continue;
- else
+ if (ACPI_FAILURE(EcCheckStatus(sc, "retr_check",
+ EC_EVENT_INPUT_BUFFER_EMPTY)))
break;
}
- sc->ec_sci_pend = FALSE;
if (ACPI_FAILURE(Status)) {
EcUnlock(sc);
device_printf(sc->ec_dev, "GPE query failed: %s\n",
@@ -685,14 +679,29 @@
device_printf(sc->ec_dev, "evaluation of query method %s failed: %s\n",
qxx, AcpiFormatException(Status));
}
+}
- /* Reenable runtime GPE if its execution was deferred. */
- if (sci_enqueued) {
- Status = AcpiFinishGpe(sc->ec_gpehandle, sc->ec_gpebit);
- if (ACPI_FAILURE(Status))
- device_printf(sc->ec_dev, "reenabling runtime GPE failed: %s\n",
- AcpiFormatException(Status));
- }
+static void
+EcGpeQueryHandler(void *Context)
+{
+ struct acpi_ec_softc *sc = (struct acpi_ec_softc *)Context;
+ int pending;
+
+ KASSERT(Context != NULL, ("EcGpeQueryHandler called with NULL"));
+
+ do {
+ /* Read the current pending count */
+ pending = atomic_load_acq_int(&sc->ec_sci_pend);
+
+ /* Call GPE handler function */
+ EcGpeQueryHandlerSub(sc);
+
+ /*
+ * Try to reset the pending count to zero. If this fails we
+ * know another GPE event has occurred while handling the
+ * current GPE event and need to loop.
+ */
+ } while (!atomic_cmpset_int(&sc->ec_sci_pend, pending, 0));
}
/*
@@ -723,14 +732,14 @@
* It will run the query and _Qxx method later, under the lock.
*/
EcStatus = EC_GET_CSR(sc);
- if ((EcStatus & EC_EVENT_SCI) && !sc->ec_sci_pend) {
+ if ((EcStatus & EC_EVENT_SCI) &&
+ atomic_fetchadd_int(&sc->ec_sci_pend, 1) == 0) {
CTR0(KTR_ACPI, "ec gpe queueing query handler");
Status = AcpiOsExecute(OSL_GPE_HANDLER, EcGpeQueryHandler, Context);
- if (ACPI_SUCCESS(Status)) {
- sc->ec_sci_pend = TRUE;
- return (0);
- } else
+ if (ACPI_FAILURE(Status)) {
printf("EcGpeHandler: queuing GPE query handler failed\n");
+ atomic_store_rel_int(&sc->ec_sci_pend, 0);
+ }
}
return (ACPI_REENABLE_GPE);
}
@@ -777,7 +786,8 @@
* we call it directly here since our thread taskq is not active yet.
*/
if (cold || rebooting || sc->ec_suspending) {
- if ((EC_GET_CSR(sc) & EC_EVENT_SCI)) {
+ if ((EC_GET_CSR(sc) & EC_EVENT_SCI) &&
+ atomic_fetchadd_int(&sc->ec_sci_pend, 1) == 0) {
CTR0(KTR_ACPI, "ec running gpe handler directly");
EcGpeQueryHandler(sc);
}
@@ -846,7 +856,7 @@
DELAY(10);
for (i = 0; i < count; i++) {
Status = EcCheckStatus(sc, "poll", Event);
- if (Status == AE_OK)
+ if (ACPI_SUCCESS(Status))
break;
DELAY(EC_POLL_DELAY);
}
@@ -876,7 +886,7 @@
* event we are actually waiting for.
*/
Status = EcCheckStatus(sc, "sleep", Event);
- if (Status == AE_OK) {
+ if (ACPI_SUCCESS(Status)) {
if (gen_count == sc->ec_gencount)
no_intr++;
else
@@ -891,7 +901,7 @@
* read the register once and trust whatever value we got. This is
* the best we can do at this point.
*/
- if (Status != AE_OK)
+ if (ACPI_FAILURE(Status))
Status = EcCheckStatus(sc, "sleep_end", Event);
}
if (!need_poll && no_intr > 10) {
@@ -899,7 +909,7 @@
"not getting interrupts, switched to polled mode\n");
ec_polled_mode = 1;
}
- if (Status != AE_OK)
+ if (ACPI_FAILURE(Status))
CTR0(KTR_ACPI, "error: ec wait timed out");
return (Status);
}
@@ -977,15 +987,13 @@
gen_count = sc->ec_gencount;
EC_SET_DATA(sc, Address);
status = EcWaitEvent(sc, EC_EVENT_OUTPUT_BUFFER_FULL, gen_count);
- if (ACPI_FAILURE(status)) {
- if (EcCheckStatus(sc, "retr_check",
- EC_EVENT_INPUT_BUFFER_EMPTY) == AE_OK)
- continue;
- else
- break;
+ if (ACPI_SUCCESS(status)) {
+ *Data = EC_GET_DATA(sc);
+ return (AE_OK);
}
- *Data = EC_GET_DATA(sc);
- return (AE_OK);
+ if (ACPI_FAILURE(EcCheckStatus(sc, "retr_check",
+ EC_EVENT_INPUT_BUFFER_EMPTY)))
+ break;
}
device_printf(sc->ec_dev, "EcRead: failed waiting to get data\n");
return (status);
Modified: trunk/sys/dev/acpica/acpi_hpet.c
===================================================================
--- trunk/sys/dev/acpica/acpi_hpet.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_hpet.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_hpet.c 240384 2012-09-12 09:29:22Z mav $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/acpi_hpet.c 274001 2014-11-03 03:17:58Z rpaulo $");
#include "opt_acpi.h"
#if defined(__amd64__) || defined(__ia64__)
@@ -36,11 +36,13 @@
#include "opt_apic.h"
#endif
#include <sys/param.h>
+#include <sys/conf.h>
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/proc.h>
#include <sys/rman.h>
+#include <sys/mman.h>
#include <sys/time.h>
#include <sys/smp.h>
#include <sys/sysctl.h>
@@ -107,8 +109,21 @@
char name[8];
} t[32];
int num_timers;
+ struct cdev *pdev;
+ int mmap_allow;
+ int mmap_allow_write;
};
+static d_open_t hpet_open;
+static d_mmap_t hpet_mmap;
+
+static struct cdevsw hpet_cdevsw = {
+ .d_version = D_VERSION,
+ .d_name = "hpet",
+ .d_open = hpet_open,
+ .d_mmap = hpet_mmap,
+};
+
static u_int hpet_get_timecount(struct timecounter *tc);
static void hpet_test(struct hpet_softc *sc);
@@ -148,8 +163,7 @@
}
static int
-hpet_start(struct eventtimer *et,
- struct bintime *first, struct bintime *period)
+hpet_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
{
struct hpet_timer *mt = (struct hpet_timer *)et->et_priv;
struct hpet_timer *t;
@@ -157,20 +171,16 @@
uint32_t fdiv, now;
t = (mt->pcpu_master < 0) ? mt : &sc->t[mt->pcpu_slaves[curcpu]];
- if (period != NULL) {
+ if (period != 0) {
t->mode = 1;
- t->div = (sc->freq * (period->frac >> 32)) >> 32;
- if (period->sec != 0)
- t->div += sc->freq * period->sec;
+ t->div = (sc->freq * period) >> 32;
} else {
t->mode = 2;
t->div = 0;
}
- if (first != NULL) {
- fdiv = (sc->freq * (first->frac >> 32)) >> 32;
- if (first->sec != 0)
- fdiv += sc->freq * first->sec;
- } else
+ if (first != 0)
+ fdiv = (sc->freq * first) >> 32;
+ else
fdiv = t->div;
if (t->irq < 0)
bus_write_4(sc->mem_res, HPET_ISR, 1 << t->num);
@@ -299,7 +309,7 @@
return (AE_OK);
if (ACPI_FAILURE(acpi_GetInteger(handle, "_UID", &uid)) ||
id == uid)
- *((int *)status) = 1;
+ *status = acpi_get_device(handle);
return (AE_OK);
}
@@ -320,14 +330,43 @@
}
}
+static int
+hpet_open(struct cdev *cdev, int oflags, int devtype, struct thread *td)
+{
+ struct hpet_softc *sc;
+
+ sc = cdev->si_drv1;
+ if (!sc->mmap_allow)
+ return (EPERM);
+ else
+ return (0);
+}
+
+static int
+hpet_mmap(struct cdev *cdev, vm_ooffset_t offset, vm_paddr_t *paddr,
+ int nprot, vm_memattr_t *memattr)
+{
+ struct hpet_softc *sc;
+
+ sc = cdev->si_drv1;
+ if (offset > rman_get_size(sc->mem_res))
+ return (EINVAL);
+ if (!sc->mmap_allow_write && (nprot & PROT_WRITE))
+ return (EPERM);
+ *paddr = rman_get_start(sc->mem_res) + offset;
+ *memattr = VM_MEMATTR_UNCACHEABLE;
+
+ return (0);
+}
+
/* Discover the HPET via the ACPI table of the same name. */
-static void
+static void
hpet_identify(driver_t *driver, device_t parent)
{
ACPI_TABLE_HPET *hpet;
ACPI_STATUS status;
device_t child;
- int i, found;
+ int i;
/* Only one HPET device can be added. */
if (devclass_get_device(hpet_devclass, 0))
@@ -338,12 +377,18 @@
if (ACPI_FAILURE(status))
return;
/* Search for HPET device with same ID. */
- found = 0;
+ child = NULL;
AcpiWalkNamespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
- 100, hpet_find, NULL, (void *)(uintptr_t)hpet->Sequence, (void *)&found);
+ 100, hpet_find, NULL, (void *)(uintptr_t)hpet->Sequence,
+ (void *)&child);
/* If found - let it be probed in normal way. */
- if (found)
+ if (child) {
+ if (bus_get_resource(child, SYS_RES_MEMORY, 0,
+ NULL, NULL) != 0)
+ bus_set_resource(child, SYS_RES_MEMORY, 0,
+ hpet->Address.Address, HPET_MEM_WIDTH);
continue;
+ }
/* If not - create it from table info. */
child = BUS_ADD_CHILD(parent, 2, "hpet", 0);
if (child == NULL) {
@@ -646,8 +691,8 @@
#ifdef DEV_APIC
if ((t->caps & HPET_TCAP_FSB_INT_DEL) && t->irq >= 0) {
uint64_t addr;
- uint32_t data;
-
+ uint32_t data;
+
if (PCIB_MAP_MSI(
device_get_parent(device_get_parent(dev)), dev,
t->irq, &addr, &data) == 0) {
@@ -681,16 +726,14 @@
if (t->pcpu_master >= 0) {
t->et.et_flags |= ET_FLAGS_PERCPU;
t->et.et_quality += 100;
- }
+ } else if (mp_ncpus >= 8)
+ t->et.et_quality -= 100;
if ((t->caps & HPET_TCAP_PER_INT) == 0)
t->et.et_quality -= 10;
t->et.et_frequency = sc->freq;
- t->et.et_min_period.sec = 0;
- t->et.et_min_period.frac =
- (((uint64_t)(HPET_MIN_CYCLES * 2) << 32) / sc->freq) << 32;
- t->et.et_max_period.sec = 0xfffffffeLLU / sc->freq;
- t->et.et_max_period.frac =
- ((0xfffffffeLLU << 32) / sc->freq) << 32;
+ t->et.et_min_period =
+ ((uint64_t)(HPET_MIN_CYCLES * 2) << 32) / sc->freq;
+ t->et.et_max_period = (0xfffffffeLLU << 32) / sc->freq;
t->et.et_start = hpet_start;
t->et.et_stop = hpet_stop;
t->et.et_priv = &sc->t[i];
@@ -699,6 +742,31 @@
maxhpetet++;
}
}
+
+ sc->pdev = make_dev(&hpet_cdevsw, 0, UID_ROOT, GID_WHEEL,
+ 0600, "hpet%d", device_get_unit(dev));
+ if (sc->pdev) {
+ sc->pdev->si_drv1 = sc;
+ sc->mmap_allow = 1;
+ TUNABLE_INT_FETCH("hw.acpi.hpet.mmap_allow",
+ &sc->mmap_allow);
+ sc->mmap_allow_write = 1;
+ TUNABLE_INT_FETCH("hw.acpi.hpet.mmap_allow_write",
+ &sc->mmap_allow_write);
+ SYSCTL_ADD_INT(device_get_sysctl_ctx(dev),
+ SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
+ OID_AUTO, "mmap_allow",
+ CTLFLAG_RW, &sc->mmap_allow, 0,
+ "Allow userland to memory map HPET");
+ SYSCTL_ADD_INT(device_get_sysctl_ctx(dev),
+ SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
+ OID_AUTO, "mmap_allow_write",
+ CTLFLAG_RW, &sc->mmap_allow_write, 0,
+ "Allow userland write to the HPET register space");
+ } else
+ device_printf(dev, "could not create /dev/hpet%d\n",
+ device_get_unit(dev));
+
return (0);
}
@@ -743,8 +811,8 @@
#ifdef DEV_APIC
if (t->irq >= 0 && (sc->legacy_route == 0 || i >= 2)) {
uint64_t addr;
- uint32_t data;
-
+ uint32_t data;
+
if (PCIB_MAP_MSI(
device_get_parent(device_get_parent(dev)), dev,
t->irq, &addr, &data) == 0) {
@@ -815,7 +883,7 @@
struct hpet_softc *sc = device_get_softc(dev);
struct hpet_timer *t;
uint64_t addr;
- uint32_t data;
+ uint32_t data;
int error, i;
for (i = 0; i < sc->num_timers; i++) {
@@ -850,7 +918,7 @@
DEVMETHOD(bus_remap_intr, hpet_remap_intr),
#endif
- {0, 0}
+ DEVMETHOD_END
};
static driver_t hpet_driver = {
Modified: trunk/sys/dev/acpica/acpi_hpet.h
===================================================================
--- trunk/sys/dev/acpica/acpi_hpet.h 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_hpet.h 2018-05-27 23:55:56 UTC (rev 10113)
@@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: release/9.2.0/sys/dev/acpica/acpi_hpet.h 224919 2011-08-16 21:51:29Z mav $
+ * $FreeBSD: stable/10/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 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_if.m 2018-05-27 23:55:56 UTC (rev 10113)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
#-
# Copyright (c) 2004 Nate Lawson
# All rights reserved.
@@ -23,7 +24,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: release/9.2.0/sys/dev/acpica/acpi_if.m 214072 2010-10-19 19:53:06Z jkim $
+# $FreeBSD: stable/10/sys/dev/acpica/acpi_if.m 214072 2010-10-19 19:53:06Z jkim $
#
#include <sys/bus.h>
Property changes on: trunk/sys/dev/acpica/acpi_if.m
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/dev/acpica/acpi_isab.c
===================================================================
--- trunk/sys/dev/acpica/acpi_isab.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_isab.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_isab.c 229093 2011-12-31 14:12:12Z hselasky $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/acpi_isab.c 227843 2011-11-22 21:28:20Z marius $");
/*
* 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 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_lid.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_lid.c 209746 2010-07-06 20:57:28Z jkim $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/acpi_lid.c 246128 2013-01-30 18:01:20Z sbz $");
#include "opt_acpi.h"
#include <sys/param.h>
@@ -70,7 +70,7 @@
DEVMETHOD(device_suspend, acpi_lid_suspend),
DEVMETHOD(device_resume, acpi_lid_resume),
- {0, 0}
+ DEVMETHOD_END
};
static driver_t acpi_lid_driver = {
Modified: trunk/sys/dev/acpica/acpi_package.c
===================================================================
--- trunk/sys/dev/acpica/acpi_package.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_package.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_package.c 202771 2010-01-21 21:14:28Z jkim $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/acpi_package.c 315021 2017-03-10 19:34:14Z vangyzen $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -51,7 +51,7 @@
ACPI_OBJECT *obj;
obj = &res->Package.Elements[idx];
- if (obj == NULL || obj->Type != ACPI_TYPE_INTEGER)
+ if (obj->Type != ACPI_TYPE_INTEGER)
return (EINVAL);
*dst = obj->Integer.Value;
Modified: trunk/sys/dev/acpica/acpi_pci.c
===================================================================
--- trunk/sys/dev/acpica/acpi_pci.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_pci.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -28,8 +28,10 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_pci.c 233393 2012-03-23 20:47:25Z jhb $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/acpi_pci.c 330938 2018-03-14 19:04:40Z jhb $");
+#include "opt_acpi.h"
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
@@ -69,6 +71,7 @@
CTASSERT(ACPI_STATE_D3 == PCI_POWERSTATE_D3);
static int acpi_pci_attach(device_t dev);
+static void acpi_pci_child_deleted(device_t dev, device_t child);
static int acpi_pci_child_location_str_method(device_t cbdev,
device_t child, char *buf, size_t buflen);
static int acpi_pci_probe(device_t dev);
@@ -81,6 +84,7 @@
static int acpi_pci_set_powerstate_method(device_t dev, device_t child,
int state);
static void acpi_pci_update_device(ACPI_HANDLE handle, device_t pci_child);
+static bus_dma_tag_t acpi_pci_get_dma_tag(device_t bus, device_t child);
static device_method_t acpi_pci_methods[] = {
/* Device interface */
@@ -90,12 +94,15 @@
/* Bus interface */
DEVMETHOD(bus_read_ivar, acpi_pci_read_ivar),
DEVMETHOD(bus_write_ivar, acpi_pci_write_ivar),
+ DEVMETHOD(bus_child_deleted, acpi_pci_child_deleted),
DEVMETHOD(bus_child_location_str, acpi_pci_child_location_str_method),
+ DEVMETHOD(bus_get_dma_tag, acpi_pci_get_dma_tag),
+ DEVMETHOD(bus_get_domain, acpi_get_domain),
/* PCI interface */
DEVMETHOD(pci_set_powerstate, acpi_pci_set_powerstate_method),
- { 0, 0 }
+ DEVMETHOD_END
};
static devclass_t pci_devclass;
@@ -141,17 +148,34 @@
return (pci_write_ivar(dev, child, which, value));
}
+static void
+acpi_pci_child_deleted(device_t dev, device_t child)
+{
+ struct acpi_pci_devinfo *dinfo = device_get_ivars(child);
+
+ if (acpi_get_device(dinfo->ap_handle) == child)
+ AcpiDetachData(dinfo->ap_handle, acpi_fake_objhandler);
+ pci_child_deleted(dev, child);
+}
+
static int
acpi_pci_child_location_str_method(device_t cbdev, device_t child, char *buf,
size_t buflen)
{
struct acpi_pci_devinfo *dinfo = device_get_ivars(child);
+ int pxm;
+ char buf2[32];
pci_child_location_str_method(cbdev, child, buf, buflen);
-
+
if (dinfo->ap_handle) {
- strlcat(buf, " handle=", buflen);
- strlcat(buf, acpi_name(dinfo->ap_handle), buflen);
+ strlcat(buf, " handle=", buflen);
+ strlcat(buf, acpi_name(dinfo->ap_handle), buflen);
+
+ if (ACPI_SUCCESS(acpi_GetInteger(dinfo->ap_handle, "_PXM", &pxm))) {
+ snprintf(buf2, 32, " _PXM=%d", pxm);
+ strlcat(buf, buf2, buflen);
+ }
}
return (0);
}
@@ -309,3 +333,28 @@
return (bus_generic_attach(dev));
}
+
+#ifdef ACPI_DMAR
+bus_dma_tag_t dmar_get_dma_tag(device_t dev, device_t child);
+static bus_dma_tag_t
+acpi_pci_get_dma_tag(device_t bus, device_t child)
+{
+ bus_dma_tag_t tag;
+
+ if (device_get_parent(child) == bus) {
+ /* try dmar and return if it works */
+ tag = dmar_get_dma_tag(bus, child);
+ } else
+ tag = NULL;
+ if (tag == NULL)
+ tag = pci_get_dma_tag(bus, child);
+ return (tag);
+}
+#else
+static bus_dma_tag_t
+acpi_pci_get_dma_tag(device_t bus, device_t child)
+{
+
+ return (pci_get_dma_tag(bus, child));
+}
+#endif
Modified: trunk/sys/dev/acpica/acpi_pci_link.c
===================================================================
--- trunk/sys/dev/acpica/acpi_pci_link.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_pci_link.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_pci_link.c 251754 2013-06-14 18:30:43Z jhb $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/acpi_pci_link.c 249767 2013-04-22 15:51:06Z jhb $");
#include "opt_acpi.h"
#include <sys/param.h>
@@ -1108,7 +1108,7 @@
DEVMETHOD(device_attach, acpi_pci_link_attach),
DEVMETHOD(device_resume, acpi_pci_link_resume),
- {0, 0}
+ DEVMETHOD_END
};
static driver_t acpi_pci_link_driver = {
Modified: trunk/sys/dev/acpica/acpi_pcib.c
===================================================================
--- trunk/sys/dev/acpica/acpi_pcib.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_pcib.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_pcib.c 253426 2013-07-17 14:04:18Z jhb $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/acpi_pcib.c 279195 2015-02-23 01:17:45Z kib $");
#include "opt_acpi.h"
#include <sys/param.h>
@@ -96,7 +96,7 @@
int error;
/* We only care about entries that reference a link device. */
- if (entry->Source == NULL || entry->Source[0] == '\0')
+ if (entry->Source[0] == '\0')
return;
/*
@@ -130,7 +130,8 @@
int
acpi_pcib_attach(device_t dev, ACPI_BUFFER *prt, int busno)
{
- ACPI_STATUS status;
+ ACPI_STATUS status;
+ int error;
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
@@ -160,7 +161,8 @@
*/
prt_walk_table(prt, prt_attach_devices, dev);
- return_VALUE (bus_generic_attach(dev));
+ error = bus_generic_attach(dev);
+ return_VALUE(error);
}
static void
@@ -221,7 +223,7 @@
if (bootverbose) {
device_printf(pcib, "matched entry for %d.%d.INT%c",
pci_get_bus(dev), pci_get_slot(dev), 'A' + pin);
- if (prt->Source != NULL && prt->Source[0] != '\0')
+ if (prt->Source[0] != '\0')
printf(" (src %s:%u)", prt->Source, prt->SourceIndex);
printf("\n");
}
@@ -233,8 +235,7 @@
* XXX: If the source index is non-zero, ignore the source device and
* assume that this is a hard-wired entry.
*/
- if (prt->Source == NULL || prt->Source[0] == '\0' ||
- prt->SourceIndex != 0) {
+ if (prt->Source[0] == '\0' || prt->SourceIndex != 0) {
if (bootverbose)
device_printf(pcib, "slot %d INT%c hardwired to IRQ %d\n",
pci_get_slot(dev), 'A' + pin, prt->SourceIndex);
@@ -265,7 +266,7 @@
out:
ACPI_SERIAL_END(pcib);
- return_VALUE (interrupt);
+ return_VALUE(interrupt);
}
int
@@ -277,4 +278,3 @@
acpi_device_pwr_for_sleep(acpi_dev, dev, pstate);
return (0);
}
-
Modified: trunk/sys/dev/acpica/acpi_pcib_acpi.c
===================================================================
--- trunk/sys/dev/acpica/acpi_pcib_acpi.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_pcib_acpi.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_pcib_acpi.c 253426 2013-07-17 14:04:18Z jhb $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/acpi_pcib_acpi.c 318393 2017-05-17 02:40:06Z sephe $");
#include "opt_acpi.h"
#include <sys/param.h>
@@ -45,6 +45,7 @@
#include <dev/acpica/acpivar.h>
#include <machine/pci_cfgreg.h>
+#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcib_private.h>
#include "pcib_if.h"
@@ -97,7 +98,12 @@
static int acpi_pcib_acpi_adjust_resource(device_t dev,
device_t child, int type, struct resource *r,
u_long start, u_long end);
+#ifdef PCI_RES_BUS
+static int acpi_pcib_acpi_release_resource(device_t dev,
+ device_t child, int type, int rid,
+ struct resource *r);
#endif
+#endif
static device_method_t acpi_pcib_acpi_methods[] = {
/* Device interface */
@@ -116,7 +122,11 @@
#else
DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource),
#endif
+#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
+ DEVMETHOD(bus_release_resource, acpi_pcib_acpi_release_resource),
+#else
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
+#endif
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
@@ -185,27 +195,27 @@
break;
switch (res->Type) {
case ACPI_RESOURCE_TYPE_ADDRESS16:
- min = res->Data.Address16.Minimum;
- max = res->Data.Address16.Maximum;
- length = res->Data.Address16.AddressLength;
+ min = res->Data.Address16.Address.Minimum;
+ max = res->Data.Address16.Address.Maximum;
+ length = res->Data.Address16.Address.AddressLength;
break;
case ACPI_RESOURCE_TYPE_ADDRESS32:
- min = res->Data.Address32.Minimum;
- max = res->Data.Address32.Maximum;
- length = res->Data.Address32.AddressLength;
+ min = res->Data.Address32.Address.Minimum;
+ max = res->Data.Address32.Address.Maximum;
+ length = res->Data.Address32.Address.AddressLength;
break;
case ACPI_RESOURCE_TYPE_ADDRESS64:
- min = res->Data.Address64.Minimum;
- max = res->Data.Address64.Maximum;
- length = res->Data.Address64.AddressLength;
+ min = res->Data.Address64.Address.Minimum;
+ max = res->Data.Address64.Address.Maximum;
+ length = res->Data.Address64.Address.AddressLength;
break;
default:
KASSERT(res->Type ==
ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64,
("should never happen"));
- min = res->Data.ExtAddress64.Minimum;
- max = res->Data.ExtAddress64.Maximum;
- length = res->Data.ExtAddress64.AddressLength;
+ min = res->Data.ExtAddress64.Address.Minimum;
+ max = res->Data.ExtAddress64.Address.Maximum;
+ length = res->Data.ExtAddress64.Address.AddressLength;
break;
}
if (length == 0)
@@ -244,7 +254,7 @@
if (min + length - 1 != max)
device_printf(sc->ap_dev,
"Length mismatch for %d range: %jx vs %jx\n", type,
- (uintmax_t)max - min + 1, (uintmax_t)length);
+ (uintmax_t)(max - min + 1), (uintmax_t)length);
#ifdef __i386__
if (min > ULONG_MAX) {
device_printf(sc->ap_dev,
@@ -272,7 +282,54 @@
}
#endif
+#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
static int
+first_decoded_bus(struct acpi_hpcib_softc *sc, u_long *startp)
+{
+ struct resource_list_entry *rle;
+
+ rle = resource_list_find(&sc->ap_host_res.hr_rl, PCI_RES_BUS, 0);
+ if (rle == NULL)
+ return (ENXIO);
+ *startp = rle->start;
+ return (0);
+}
+#endif
+
+static void
+acpi_pcib_osc(struct acpi_hpcib_softc *sc)
+{
+ ACPI_STATUS status;
+ uint32_t cap_set[3];
+
+ static uint8_t pci_host_bridge_uuid[ACPI_UUID_LENGTH] = {
+ 0x5b, 0x4d, 0xdb, 0x33, 0xf7, 0x1f, 0x1c, 0x40,
+ 0x96, 0x57, 0x74, 0x41, 0xc0, 0x3d, 0xd7, 0x66
+ };
+
+ /* Support Field: Extended PCI Config Space, MSI */
+ cap_set[1] = 0x11;
+
+ /* Control Field */
+ cap_set[2] = 0;
+
+ status = acpi_EvaluateOSC(sc->ap_handle, pci_host_bridge_uuid, 1,
+ nitems(cap_set), cap_set, cap_set, false);
+ if (ACPI_FAILURE(status)) {
+ if (status == AE_NOT_FOUND)
+ return;
+ device_printf(sc->ap_dev, "_OSC failed: %s\n",
+ AcpiFormatException(status));
+ return;
+ }
+
+ if (cap_set[0] != 0) {
+ device_printf(sc->ap_dev, "_OSC returned error %#x\n",
+ cap_set[0]);
+ }
+}
+
+static int
acpi_pcib_acpi_attach(device_t dev)
{
struct acpi_hpcib_softc *sc;
@@ -279,6 +336,11 @@
ACPI_STATUS status;
static int bus0_seen = 0;
u_int slot, func, busok;
+#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
+ struct resource *bus_res;
+ u_long start;
+ int rid;
+#endif
uint8_t busno;
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
@@ -293,6 +355,8 @@
if (!acpi_DeviceIsPresent(dev))
return (ENXIO);
+ acpi_pcib_osc(sc);
+
/*
* Get our segment number by evaluating _SEG.
* It's OK for this to not exist.
@@ -390,8 +454,48 @@
}
}
+#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
/*
* If nothing else worked, hope that ACPI at least lays out the
+ * Host-PCI bridges in order and that as a result the next free
+ * bus number is our bus number.
+ */
+ if (busok == 0) {
+ /*
+ * If we have a region of bus numbers, use the first
+ * number for our bus.
+ */
+ if (first_decoded_bus(sc, &start) == 0)
+ sc->ap_bus = start;
+ else {
+ rid = 0;
+ bus_res = pci_domain_alloc_bus(sc->ap_segment, dev, &rid, 0,
+ PCI_BUSMAX, 1, 0);
+ if (bus_res == NULL) {
+ device_printf(dev,
+ "could not allocate bus number\n");
+ pcib_host_res_free(dev, &sc->ap_host_res);
+ return (ENXIO);
+ }
+ sc->ap_bus = rman_get_start(bus_res);
+ pci_domain_release_bus(sc->ap_segment, dev, rid, bus_res);
+ }
+ } else {
+ /*
+ * Require the bus number from _BBN to match the start of any
+ * decoded range.
+ */
+ if (first_decoded_bus(sc, &start) == 0 && sc->ap_bus != start) {
+ device_printf(dev,
+ "bus number %d does not match start of decoded range %ju\n",
+ sc->ap_bus, (uintmax_t)start);
+ pcib_host_res_free(dev, &sc->ap_host_res);
+ return (ENXIO);
+ }
+ }
+#else
+ /*
+ * If nothing else worked, hope that ACPI at least lays out the
* host-PCI bridges in order and that as a result our unit number
* is actually our bus number. There are several reasons this
* might not be true.
@@ -400,11 +504,13 @@
sc->ap_bus = device_get_unit(dev);
device_printf(dev, "trying bus number %d\n", sc->ap_bus);
}
+#endif
/* If this is bus 0 on segment 0, note that it has been seen already. */
if (sc->ap_segment == 0 && sc->ap_bus == 0)
bus0_seen = 1;
+ bus_generic_probe(dev);
return (acpi_pcib_attach(dev, &sc->ap_prt, sc->ap_bus));
}
@@ -509,7 +615,7 @@
if (error)
return (error);
- sc = device_get_softc(dev);
+ sc = device_get_softc(pcib);
if (sc->ap_addr == -1)
return (0);
/* XXX: Assumes all bridges are on bus 0. */
@@ -535,6 +641,11 @@
#ifdef NEW_PCIB
sc = device_get_softc(dev);
+#ifdef PCI_RES_BUS
+ if (type == PCI_RES_BUS)
+ return (pci_domain_alloc_bus(sc->ap_segment, child, rid, start, end,
+ count, flags));
+#endif
res = pcib_host_res_alloc(&sc->ap_host_res, child, type, rid, start, end,
count, flags);
@@ -563,7 +674,26 @@
struct acpi_hpcib_softc *sc;
sc = device_get_softc(dev);
+#ifdef PCI_RES_BUS
+ if (type == PCI_RES_BUS)
+ return (pci_domain_adjust_bus(sc->ap_segment, child, r, start,
+ end));
+#endif
return (pcib_host_res_adjust(&sc->ap_host_res, child, type, r, start,
end));
}
+
+#ifdef PCI_RES_BUS
+int
+acpi_pcib_acpi_release_resource(device_t dev, device_t child, int type, int rid,
+ struct resource *r)
+{
+ struct acpi_hpcib_softc *sc;
+
+ sc = device_get_softc(dev);
+ if (type == PCI_RES_BUS)
+ return (pci_domain_release_bus(sc->ap_segment, child, rid, r));
+ return (bus_generic_release_resource(dev, child, type, rid, r));
+}
#endif
+#endif
Modified: trunk/sys/dev/acpica/acpi_pcib_pci.c
===================================================================
--- trunk/sys/dev/acpica/acpi_pcib_pci.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_pcib_pci.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_pcib_pci.c 221393 2011-05-03 17:37:24Z jhb $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/acpi_pcib_pci.c 280970 2015-04-01 21:48:54Z jhb $");
#include "opt_acpi.h"
@@ -84,7 +84,7 @@
DEVMETHOD(pcib_route_interrupt, acpi_pcib_pci_route_interrupt),
DEVMETHOD(pcib_power_for_sleep, acpi_pcib_power_for_sleep),
- {0, 0}
+ DEVMETHOD_END
};
static devclass_t pcib_devclass;
@@ -121,7 +121,7 @@
pcib_attach_common(dev);
sc = device_get_softc(dev);
sc->ap_handle = acpi_get_handle(dev);
- return (acpi_pcib_attach(dev, &sc->ap_prt, sc->ap_pcibsc.secbus));
+ return (acpi_pcib_attach(dev, &sc->ap_prt, sc->ap_pcibsc.bus.sec));
}
static int
Modified: trunk/sys/dev/acpica/acpi_pcibvar.h
===================================================================
--- trunk/sys/dev/acpica/acpi_pcibvar.h 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_pcibvar.h 2018-05-27 23:55:56 UTC (rev 10113)
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: release/9.2.0/sys/dev/acpica/acpi_pcibvar.h 211430 2010-08-17 15:44:52Z jhb $
+ * $FreeBSD: stable/10/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 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_perf.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_perf.c 249132 2013-04-05 08:22:11Z mav $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/acpi_perf.c 246128 2013-01-30 18:01:20Z sbz $");
#include "opt_acpi.h"
#include <sys/param.h>
@@ -123,7 +123,8 @@
DEVMETHOD(cpufreq_drv_get, acpi_px_get),
DEVMETHOD(cpufreq_drv_type, acpi_px_type),
DEVMETHOD(cpufreq_drv_settings, acpi_px_settings),
- {0, 0}
+
+ DEVMETHOD_END
};
static driver_t acpi_perf_driver = {
Modified: trunk/sys/dev/acpica/acpi_powerres.c
===================================================================
--- trunk/sys/dev/acpica/acpi_powerres.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_powerres.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: stable/9/sys/dev/acpica/acpi_powerres.c 267983 2014-06-27 20:57:12Z jhb $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/acpi_powerres.c 267983 2014-06-27 20:57:12Z jhb $");
#include "opt_acpi.h"
#include <sys/param.h>
@@ -48,7 +48,7 @@
* resource, and only deactivate it when there are no powered devices.
*
* Note that this only manages resources for known devices. There is an
- * ugly case where we may turn of power to a device which is in use because
+ * ugly case where we may turn off power to a device which is in use because
* we don't know that it depends on a given resource. We should perhaps
* try to be smarter about this, but a more complete solution would involve
* scanning all of the ACPI namespace to find devices we're not currently
Modified: trunk/sys/dev/acpica/acpi_quirk.c
===================================================================
--- trunk/sys/dev/acpica/acpi_quirk.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_quirk.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_quirk.c 193530 2009-06-05 18:44:36Z jkim $");
+__FBSDID("$FreeBSD: stable/10/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 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_quirks 2018-05-27 23:55:56 UTC (rev 10113)
@@ -1,4 +1,4 @@
-# $FreeBSD: release/9.2.0/sys/dev/acpica/acpi_quirks 147612 2005-06-26 18:19:14Z dwmalone $
+# $FreeBSD: stable/10/sys/dev/acpica/acpi_quirks 147612 2005-06-26 18:19:14Z dwmalone $
#
# Quirks for ACPI tables can be added here.
#
Property changes on: trunk/sys/dev/acpica/acpi_quirks
___________________________________________________________________
Added: mnbsd:nokeywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/dev/acpica/acpi_resource.c
===================================================================
--- trunk/sys/dev/acpica/acpi_resource.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_resource.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: stable/9/sys/dev/acpica/acpi_resource.c 267835 2014-06-24 19:58:18Z jhb $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/acpi_resource.c 333080 2018-04-28 00:16:54Z jhb $");
#include "opt_acpi.h"
#include <sys/param.h>
@@ -297,33 +297,33 @@
case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
switch (res->Type) {
case ACPI_RESOURCE_TYPE_ADDRESS16:
- gran = res->Data.Address16.Granularity;
- min = res->Data.Address16.Minimum;
- max = res->Data.Address16.Maximum;
- length = res->Data.Address16.AddressLength;
+ gran = res->Data.Address16.Address.Granularity;
+ min = res->Data.Address16.Address.Minimum;
+ max = res->Data.Address16.Address.Maximum;
+ length = res->Data.Address16.Address.AddressLength;
name = "Address16";
break;
case ACPI_RESOURCE_TYPE_ADDRESS32:
- gran = res->Data.Address32.Granularity;
- min = res->Data.Address32.Minimum;
- max = res->Data.Address32.Maximum;
- length = res->Data.Address32.AddressLength;
+ gran = res->Data.Address32.Address.Granularity;
+ min = res->Data.Address32.Address.Minimum;
+ max = res->Data.Address32.Address.Maximum;
+ length = res->Data.Address32.Address.AddressLength;
name = "Address32";
break;
case ACPI_RESOURCE_TYPE_ADDRESS64:
- gran = res->Data.Address64.Granularity;
- min = res->Data.Address64.Minimum;
- max = res->Data.Address64.Maximum;
- length = res->Data.Address64.AddressLength;
+ gran = res->Data.Address64.Address.Granularity;
+ min = res->Data.Address64.Address.Minimum;
+ max = res->Data.Address64.Address.Maximum;
+ length = res->Data.Address64.Address.AddressLength;
name = "Address64";
break;
default:
KASSERT(res->Type == ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64,
("should never happen"));
- gran = res->Data.ExtAddress64.Granularity;
- min = res->Data.ExtAddress64.Minimum;
- max = res->Data.ExtAddress64.Maximum;
- length = res->Data.ExtAddress64.AddressLength;
+ gran = res->Data.ExtAddress64.Address.Granularity;
+ min = res->Data.ExtAddress64.Address.Minimum;
+ max = res->Data.ExtAddress64.Address.Maximum;
+ length = res->Data.ExtAddress64.Address.AddressLength;
name = "ExtAddress64";
break;
}
@@ -516,6 +516,24 @@
if (cp == NULL)
return;
+
+ /*
+ * XXX: Some BIOSes contain buggy _CRS entries where fixed I/O
+ * ranges have the maximum base address (_MAX) to the end of the
+ * I/O range instead of the start. These are then treated as a
+ * relocatable I/O range rather than a fixed I/O resource. As a
+ * workaround, treat I/O resources encoded this way as fixed I/O
+ * ports.
+ */
+ if (high == (low + length)) {
+ if (bootverbose)
+ device_printf(dev,
+ "_CRS has fixed I/O port range defined as relocatable\n");
+
+ bus_set_resource(dev, SYS_RES_IOPORT, cp->ar_nio++, low, length);
+ return;
+ }
+
device_printf(dev, "I/O range not supported\n");
}
@@ -627,7 +645,7 @@
DEVMETHOD(device_probe, acpi_sysres_probe),
DEVMETHOD(device_attach, acpi_sysres_attach),
- {0, 0}
+ DEVMETHOD_END
};
static driver_t acpi_sysres_driver = {
Modified: trunk/sys/dev/acpica/acpi_smbat.c
===================================================================
--- trunk/sys/dev/acpica/acpi_smbat.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_smbat.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_smbat.c 248085 2013-03-09 02:36:32Z marius $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/acpi_smbat.c 246128 2013-01-30 18:01:20Z sbz $");
#include "opt_acpi.h"
#include <sys/param.h>
@@ -90,7 +90,7 @@
DEVMETHOD(acpi_batt_get_status, acpi_smbat_get_bst),
DEVMETHOD(acpi_batt_get_info, acpi_smbat_get_bif),
- {0, 0}
+ DEVMETHOD_END
};
static driver_t acpi_smbat_driver = {
Modified: trunk/sys/dev/acpica/acpi_smbus.h
===================================================================
--- trunk/sys/dev/acpica/acpi_smbus.h 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_smbus.h 2018-05-27 23:55:56 UTC (rev 10113)
@@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: release/9.2.0/sys/dev/acpica/acpi_smbus.h 151564 2005-10-23 00:20:13Z njl $
+ * $FreeBSD: stable/10/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 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_thermal.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: stable/9/sys/dev/acpica/acpi_thermal.c 260881 2014-01-19 13:51:46Z dumbbell $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/acpi_thermal.c 255077 2013-08-30 19:21:12Z dumbbell $");
#include "opt_acpi.h"
#include <sys/param.h>
@@ -154,7 +154,7 @@
DEVMETHOD(device_probe, acpi_tz_probe),
DEVMETHOD(device_attach, acpi_tz_attach),
- {0, 0}
+ DEVMETHOD_END
};
static driver_t acpi_tz_driver = {
Modified: trunk/sys/dev/acpica/acpi_throttle.c
===================================================================
--- trunk/sys/dev/acpica/acpi_throttle.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_throttle.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_throttle.c 193530 2009-06-05 18:44:36Z jkim $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/acpi_throttle.c 283892 2015-06-01 19:26:24Z jkim $");
#include "opt_acpi.h"
#include <sys/param.h>
@@ -97,7 +97,7 @@
static int acpi_throttle_probe(device_t dev);
static int acpi_throttle_attach(device_t dev);
static int acpi_throttle_evaluate(struct acpi_throttle_softc *sc);
-static int acpi_throttle_quirks(struct acpi_throttle_softc *sc);
+static void acpi_throttle_quirks(struct acpi_throttle_softc *sc);
static int acpi_thr_settings(device_t dev, struct cf_setting *sets,
int *count);
static int acpi_thr_set(device_t dev, const struct cf_setting *set);
@@ -115,7 +115,7 @@
DEVMETHOD(cpufreq_drv_get, acpi_thr_get),
DEVMETHOD(cpufreq_drv_type, acpi_thr_type),
DEVMETHOD(cpufreq_drv_settings, acpi_thr_settings),
- {0, 0}
+ DEVMETHOD_END
};
static driver_t acpi_throttle_driver = {
@@ -315,9 +315,10 @@
return (0);
}
-static int
+static void
acpi_throttle_quirks(struct acpi_throttle_softc *sc)
{
+#ifdef __i386__
device_t acpi_dev;
/* Look for various quirks of the PIIX4 part. */
@@ -340,8 +341,7 @@
break;
}
}
-
- return (0);
+#endif
}
static int
Modified: trunk/sys/dev/acpica/acpi_timer.c
===================================================================
--- trunk/sys/dev/acpica/acpi_timer.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_timer.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_timer.c 232086 2012-02-23 22:26:14Z jkim $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/acpi_timer.c 255726 2013-09-20 05:06:03Z gibbs $");
#include "opt_acpi.h"
#include <sys/param.h>
@@ -83,7 +83,7 @@
DEVMETHOD(device_probe, acpi_timer_probe),
DEVMETHOD(device_attach, acpi_timer_attach),
- {0, 0}
+ DEVMETHOD_END
};
static driver_t acpi_timer_driver = {
@@ -190,6 +190,7 @@
else
acpi_timer_timecounter.tc_counter_mask = 0x00ffffff;
acpi_timer_timecounter.tc_frequency = acpi_timer_frequency;
+ acpi_timer_timecounter.tc_flags = TC_FLAGS_SUSPEND_SAFE;
if (testenv("debug.acpi.timer_test"))
acpi_timer_boot_test();
@@ -286,6 +287,14 @@
acpi_timer_eh = NULL;
}
+ if ((timecounter->tc_flags & TC_FLAGS_SUSPEND_SAFE) != 0) {
+ /*
+ * If we are using a suspend safe timecounter, don't
+ * save/restore it across suspend/resume.
+ */
+ return;
+ }
+
KASSERT(newtc == &acpi_timer_timecounter,
("acpi_timer_suspend_handler: wrong timecounter"));
Modified: trunk/sys/dev/acpica/acpi_video.c
===================================================================
--- trunk/sys/dev/acpica/acpi_video.c 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpi_video.c 2018-05-27 23:55:56 UTC (rev 10113)
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/sys/dev/acpica/acpi_video.c 249132 2013-04-05 08:22:11Z mav $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/acpica/acpi_video.c 261455 2014-02-04 03:36:42Z eadler $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -133,7 +133,7 @@
#define DOD_HEAD_ID_BITS 3
#define DOD_HEAD_ID_MASK \
(((1 << DOD_HEAD_ID_BITS) - 1) << DOD_HEAD_ID_SHIFT)
-#define DOD_DEVID_SCHEME_STD (1 << 31)
+#define DOD_DEVID_SCHEME_STD (1U << 31)
/* _BCL related constants */
#define BCL_FULLPOWER 0
@@ -150,7 +150,7 @@
#define DSS_INACTIVE 0
#define DSS_ACTIVE (1 << 0)
#define DSS_SETNEXT (1 << 30)
-#define DSS_COMMIT (1 << 31)
+#define DSS_COMMIT (1U << 31)
static device_method_t acpi_video_methods[] = {
DEVMETHOD(device_identify, acpi_video_identify),
Modified: trunk/sys/dev/acpica/acpiio.h
===================================================================
--- trunk/sys/dev/acpica/acpiio.h 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpiio.h 2018-05-27 23:55:56 UTC (rev 10113)
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: release/9.2.0/sys/dev/acpica/acpiio.h 216503 2010-12-17 16:21:30Z avg $
+ * $FreeBSD: stable/10/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 2018-05-27 23:55:14 UTC (rev 10112)
+++ trunk/sys/dev/acpica/acpivar.h 2018-05-27 23:55:56 UTC (rev 10113)
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: release/9.2.0/sys/dev/acpica/acpivar.h 247881 2013-03-06 10:23:56Z avg $
+ * $FreeBSD: stable/10/sys/dev/acpica/acpivar.h 303229 2016-07-23 17:41:47Z jhb $
*/
#ifndef _ACPIVAR_H_
@@ -72,8 +72,6 @@
int acpi_verbose;
int acpi_handle_reboot;
- bus_dma_tag_t acpi_waketag;
- bus_dmamap_t acpi_wakemap;
vm_offset_t acpi_wakeaddr;
vm_paddr_t acpi_wakephys;
@@ -188,7 +186,7 @@
* Various features and capabilities for the acpi_get_features() method.
* In particular, these are used for the ACPI 3.0 _PDC and _OSC methods.
* See the Intel document titled "Intel Processor Vendor-Specific ACPI",
- * number 302223-005.
+ * number 302223-007.
*/
#define ACPI_CAP_PERF_MSRS (1 << 0) /* Intel SpeedStep PERF_CTL MSRs */
#define ACPI_CAP_C1_IO_HALT (1 << 1) /* Intel C1 "IO then halt" sequence */
@@ -201,6 +199,9 @@
#define ACPI_CAP_SMP_C1_NATIVE (1 << 8) /* MP C1 support other than halt */
#define ACPI_CAP_SMP_C3_NATIVE (1 << 9) /* MP C2 and C3 support */
#define ACPI_CAP_PX_HW_COORD (1 << 11) /* Intel P-state HW coordination */
+#define ACPI_CAP_INTR_CPPC (1 << 12) /* Native Interrupt Handling for
+ Collaborative Processor Performance Control notifications */
+#define ACPI_CAP_HW_DUTY_C (1 << 13) /* Hardware Duty Cycling */
/*
* Quirk flags.
@@ -269,7 +270,7 @@
if ((h = acpi_get_handle(dev)) == NULL)
return (ACPI_TYPE_NOT_FOUND);
- if (AcpiGetType(h, &t) != AE_OK)
+ if (ACPI_FAILURE(AcpiGetType(h, &t)))
return (ACPI_TYPE_NOT_FOUND);
return (t);
}
@@ -335,6 +336,9 @@
ACPI_RESOURCE **resp);
ACPI_STATUS acpi_AppendBufferResource(ACPI_BUFFER *buf,
ACPI_RESOURCE *res);
+ACPI_STATUS acpi_EvaluateOSC(ACPI_HANDLE handle, uint8_t *uuid,
+ int revision, int count, uint32_t *caps_in,
+ uint32_t *caps_out, bool query);
ACPI_STATUS acpi_OverrideInterruptLevel(UINT32 InterruptNumber);
ACPI_STATUS acpi_SetIntrModel(int model);
int acpi_ReqSleepState(struct acpi_softc *sc, int state);
@@ -492,5 +496,16 @@
SYSCTL_DECL(_debug_acpi);
+/*
+ * Map a PXM to a VM domain.
+ *
+ * Returns the VM domain ID if found, or -1 if not found / invalid.
+ */
+#if MAXMEMDOM > 1
+extern int acpi_map_pxm_to_vm_domainid(int pxm);
+#endif
+
+extern int acpi_get_domain(device_t dev, device_t child, int *domain);
+
#endif /* _KERNEL */
#endif /* !_ACPIVAR_H_ */
More information about the Midnightbsd-cvs
mailing list