Module Name: src Committed By: jruoho Date: Wed Jan 5 07:58:04 UTC 2011
Modified Files: src/sys/dev/acpi: acpi.c Log Message: Make a two-pass scan for acpinodebus. This should ensure that devices such as acpiec(4) are attached before anything else. Numerous bugs are expected to be fixed with this change. To generate a diff of this commit: cvs rdiff -u -r1.225 -r1.226 src/sys/dev/acpi/acpi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/acpi/acpi.c diff -u src/sys/dev/acpi/acpi.c:1.225 src/sys/dev/acpi/acpi.c:1.226 --- src/sys/dev/acpi/acpi.c:1.225 Mon Jan 3 08:50:23 2011 +++ src/sys/dev/acpi/acpi.c Wed Jan 5 07:58:04 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi.c,v 1.225 2011/01/03 08:50:23 jruoho Exp $ */ +/* $NetBSD: acpi.c,v 1.226 2011/01/05 07:58:04 jruoho Exp $ */ /*- * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc. @@ -100,7 +100,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.225 2011/01/03 08:50:23 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.226 2011/01/05 07:58:04 jruoho Exp $"); #include "opt_acpi.h" #include "opt_pcifixup.h" @@ -192,6 +192,14 @@ NULL }; +/* + * Devices that should be attached early. + */ +static const char * const acpi_early_ids[] = { + "PNP0C09", /* acpiec(4) */ + NULL +}; + static int acpi_match(device_t, cfdata_t, void *); static int acpi_submatch(device_t, cfdata_t, const int *, void *); static void acpi_attach(device_t, device_t, void *); @@ -212,6 +220,7 @@ #endif static int acpi_rescan(device_t, const char *, const int *); +static void acpi_rescan_early(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 *); @@ -940,8 +949,13 @@ { struct acpi_softc *sc = device_private(self); - if (ifattr_match(ifattr, "acpinodebus")) + /* + * 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, @@ -951,6 +965,41 @@ } static void +acpi_rescan_early(struct acpi_softc *sc) +{ + struct acpi_attach_args aa; + struct acpi_devnode *ad; + + /* + * First scan for devices such as acpiec(4) that + * should be always attached before anything else. + * We want these devices to attach regardless of + * the device status and other restrictions. + */ + SIMPLEQ_FOREACH(ad, &sc->ad_head, ad_list) { + + if (ad->ad_device != NULL) + continue; + + if (ad->ad_devinfo->Type != ACPI_TYPE_DEVICE) + continue; + + if (acpi_match_hid(ad->ad_devinfo, acpi_early_ids) == 0) + continue; + + aa.aa_node = ad; + aa.aa_iot = sc->sc_iot; + aa.aa_memt = sc->sc_memt; + aa.aa_pc = sc->sc_pc; + aa.aa_pciflags = sc->sc_pciflags; + aa.aa_ic = sc->sc_ic; + + ad->ad_device = config_found_ia(sc->sc_dev, + "acpinodebus", &aa, acpi_print); + } +} + +static void acpi_rescan_nodes(struct acpi_softc *sc) { struct acpi_attach_args aa;