Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/acpi Make a two-pass scan for acpinodebus. This shou...



details:   https://anonhg.NetBSD.org/src/rev/9e934d9f2371
branches:  trunk
changeset: 760445:9e934d9f2371
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Wed Jan 05 07:58:04 2011 +0000

description:
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.

diffstat:

 sys/dev/acpi/acpi.c |  55 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 52 insertions(+), 3 deletions(-)

diffs (98 lines):

diff -r 7435b1ffcaab -r 9e934d9f2371 sys/dev/acpi/acpi.c
--- a/sys/dev/acpi/acpi.c       Wed Jan 05 07:40:16 2011 +0000
+++ b/sys/dev/acpi/acpi.c       Wed Jan 05 07:58:04 2011 +0000
@@ -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;



Home | Main Index | Thread Index | Old Index