Port-amd64 archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
ACPI call for testing (take two)
Hello.
Please try the attached patch on as many x86 systems as is possible.
This follows the same ideas presented earlier by Joerg, but with some
additional important changes.[1] Like with the earlier patch, it has been
already verified that this fixes numerous problems related to the acpi(4)
subsystem initialization and the x86 interrupt routing. (Thanks to all who
pretested this.) The earlier discussion however indicated that some systems
experienced problems. Thus, please at least report all regressions.
I am currently working with the x86 interrupt management and this (or
comparable) change must be made before more substantial changes can be
tested.
- Jukka.
[1] http://mail-index.netbsd.org/port-amd64/2009/11/09/msg000991.html
Index: acpi.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpi.c,v
retrieving revision 1.229
diff -u -p -r1.229 acpi.c
--- acpi.c 6 Jan 2011 07:05:00 -0000 1.229
+++ acpi.c 7 Jan 2011 09:52:38 -0000
@@ -138,22 +138,12 @@ MALLOC_DECLARE(M_ACPI);
#include <machine/acpi_machdep.h>
-#ifdef ACPI_DEBUGGER
-#define ACPI_DBGR_INIT 0x01
-#define ACPI_DBGR_TABLES 0x02
-#define ACPI_DBGR_ENABLE 0x04
-#define ACPI_DBGR_PROBE 0x08
-#define ACPI_DBGR_RUNNING 0x10
-
-static int acpi_dbgr = 0x00;
-#endif
-
/*
* This is a flag we set when the ACPI subsystem is active. Machine
* dependent code may wish to skip other steps (such as attaching
* subsystems that ACPI supercedes) when ACPI is active.
*/
-int acpi_active;
+int acpi_active = 0;
int acpi_force_load = 0;
int acpi_suspended = 0;
@@ -216,7 +206,8 @@ static ACPI_STATUS acpi_make_devnode_pos
static void acpi_make_name(struct acpi_devnode *, uint32_t);
static int acpi_rescan(device_t, const char *, const int *);
-static void acpi_rescan_early(struct acpi_softc *);
+static int acpi_rescan_early(device_t, const char *, const int *);
+static void acpi_rescan_early_nodes(struct acpi_softc *);
static void acpi_rescan_nodes(struct acpi_softc *);
static void acpi_rescan_capabilities(device_t);
static int acpi_print(void *aux, const char *);
@@ -278,14 +269,6 @@ acpi_probe(void)
/*
* Start up ACPICA.
*/
-#ifdef ACPI_DEBUGGER
- if (acpi_dbgr & ACPI_DBGR_INIT)
- acpi_osd_debugger();
-#endif
-
- CTASSERT(TRUE == true);
- CTASSERT(FALSE == false);
-
AcpiGbl_AllMethodsSerialized = false;
AcpiGbl_EnableInterpreterSlack = true;
@@ -309,11 +292,6 @@ acpi_probe(void)
goto fail;
}
-#ifdef ACPI_DEBUGGER
- if (acpi_dbgr & ACPI_DBGR_TABLES)
- acpi_osd_debugger();
-#endif
-
rv = AcpiLoadTables();
if (ACPI_FAILURE(rv)) {
@@ -421,6 +399,7 @@ acpi_submatch(device_t parent, cfdata_t
static void
acpi_attach(device_t parent, device_t self, void *aux)
{
+ const uint16_t sci = AcpiGbl_FADT.SciInterrupt;
struct acpi_softc *sc = device_private(self);
struct acpibus_attach_args *aa = aux;
ACPI_TABLE_HEADER *rsdt;
@@ -468,40 +447,67 @@ acpi_attach(device_t parent, device_t se
aprint_error_dev(self, "couldn't establish power handler\n");
/*
- * Bring ACPI on-line.
+ * Partial system initialization.
*/
-#ifdef ACPI_DEBUGGER
- if (acpi_dbgr & ACPI_DBGR_ENABLE)
- acpi_osd_debugger();
-#endif
-
-#define ACPI_ENABLE_PHASE1 \
- (ACPI_NO_HANDLER_INIT | ACPI_NO_EVENT_INIT)
-#define ACPI_ENABLE_PHASE2 \
- (ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE | \
- ACPI_NO_ADDRESS_SPACE_INIT)
-
- rv = AcpiEnableSubsystem(ACPI_ENABLE_PHASE1);
+ rv = AcpiEnableSubsystem(ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE);
if (ACPI_FAILURE(rv))
goto fail;
- acpi_md_callback();
+ /*
+ * Early acpiecdt(4) attachment.
+ */
+ config_found_ia(self, "acpiecdtbus", aa, NULL);
- rv = AcpiEnableSubsystem(ACPI_ENABLE_PHASE2);
+ /*
+ * Full system initialization.
+ */
+ rv = AcpiInitializeObjects(ACPI_FULL_INITIALIZATION);
if (ACPI_FAILURE(rv))
goto fail;
/*
- * Early EC handler initialization if ECDT table is available.
+ * Build device tree.
*/
- config_found_ia(self, "acpiecdtbus", aa, NULL);
+ acpi_build_tree(sc);
- rv = AcpiInitializeObjects(ACPI_FULL_INITIALIZATION);
+ /*
+ * Attach early devices.
+ */
+ (void)acpi_rescan_early(sc->sc_dev, NULL, NULL);
- if (ACPI_FAILURE(rv))
- goto fail;
+ /*
+ * After this we are fully functional.
+ */
+ acpi_active = 1;
+
+ /*
+ * Call MD initialization routines.
+ */
+ acpi_md_callback();
+
+ /*
+ * Attach PM timer.
+ */
+ acpitimer_init(sc);
+
+ /*
+ * Initialize sleep.
+ */
+ acpi_sleep_init(sc);
+
+ /*
+ * Attach devices. Note that the calling
+ * order of these two functions is important.
+ */
+ (void)acpi_pcidev_scan(sc->sc_root);
+ (void)acpi_rescan(sc->sc_dev, NULL, NULL);
+
+ /*
+ * Defer rest of the autoconfiguration.
+ */
+ (void)config_defer(sc->sc_dev, acpi_rescan_capabilities);
/*
* Install global notify handlers.
@@ -518,45 +524,22 @@ acpi_attach(device_t parent, device_t se
if (ACPI_FAILURE(rv))
goto fail;
- acpi_active = 1;
-
- /* Show SCI interrupt. */
- aprint_verbose_dev(self, "SCI interrupting at int %u\n",
- AcpiGbl_FADT.SciInterrupt);
-
/*
* Install fixed-event handlers.
*/
acpi_register_fixed_button(sc, ACPI_EVENT_POWER_BUTTON);
acpi_register_fixed_button(sc, ACPI_EVENT_SLEEP_BUTTON);
- acpitimer_init(sc);
-
-#ifdef ACPI_DEBUGGER
- if (acpi_dbgr & ACPI_DBGR_PROBE)
- acpi_osd_debugger();
-#endif
-
/*
- * Scan the namespace and build our device tree.
+ * Print debug information.
*/
- acpi_build_tree(sc);
- acpi_sleep_init(sc);
-
-#ifdef ACPI_DEBUGGER
- if (acpi_dbgr & ACPI_DBGR_RUNNING)
- acpi_osd_debugger();
-#endif
+ acpi_print_verbose(sc);
+ aprint_debug_dev(self, "SCI interrupting at int %u\n", sci);
#ifdef ACPI_DEBUG
acpi_debug_init();
#endif
- /*
- * Print debug information.
- */
- acpi_print_verbose(sc);
-
return;
fail:
@@ -675,17 +658,6 @@ acpi_build_tree(struct acpi_softc *sc)
*/
(void)AcpiWalkNamespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, UINT32_MAX,
acpi_make_devnode, acpi_make_devnode_post, &awc, NULL);
-
- /*
- * Scan the internal namespace.
- */
- (void)acpi_pcidev_scan(sc->sc_root);
- (void)acpi_rescan(sc->sc_dev, NULL, NULL);
-
- /*
- * Defer rest of the configuration.
- */
- (void)config_defer(sc->sc_dev, acpi_rescan_capabilities);
}
static ACPI_STATUS
@@ -790,27 +762,18 @@ acpi_make_name(struct acpi_devnode *ad,
* Device attachment.
*/
static int
-acpi_rescan(device_t self, const char *ifattr, const int *locators)
+acpi_rescan_early(device_t self, const char *ifattr, const int *locators)
{
struct acpi_softc *sc = device_private(self);
- /*
- * A two-pass scan for acpinodebus.
- */
- if (ifattr_match(ifattr, "acpinodebus")) {
- acpi_rescan_early(sc);
- acpi_rescan_nodes(sc);
- }
-
- if (ifattr_match(ifattr, "acpiapmbus") && sc->sc_apmbus == NULL)
- sc->sc_apmbus = config_found_ia(sc->sc_dev,
- "acpiapmbus", NULL, NULL);
+ if (ifattr_match(ifattr, "acpinodebus"))
+ acpi_rescan_early_nodes(sc);
return 0;
}
static void
-acpi_rescan_early(struct acpi_softc *sc)
+acpi_rescan_early_nodes(struct acpi_softc *sc)
{
struct acpi_attach_args aa;
struct acpi_devnode *ad;
@@ -844,6 +807,24 @@ acpi_rescan_early(struct acpi_softc *sc)
}
}
+static int
+acpi_rescan(device_t self, const char *ifattr, const int *locators)
+{
+ struct acpi_softc *sc = device_private(self);
+
+ /*
+ * Attach rest of the devices.
+ */
+ if (ifattr_match(ifattr, "acpinodebus"))
+ acpi_rescan_nodes(sc);
+
+ if (ifattr_match(ifattr, "acpiapmbus") && sc->sc_apmbus == NULL)
+ sc->sc_apmbus = config_found_ia(sc->sc_dev,
+ "acpiapmbus", NULL, NULL);
+
+ return 0;
+}
+
static void
acpi_rescan_nodes(struct acpi_softc *sc)
{
Home |
Main Index |
Thread Index |
Old Index