Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Feb 2010 08:50:21 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r203776 - head/sys/dev/acpica
Message-ID:  <201002110850.o1B8oLeQ024281@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Thu Feb 11 08:50:21 2010
New Revision: 203776
URL: http://svn.freebsd.org/changeset/base/203776

Log:
  acpi cpu: probe+attach before all other enumerated children on acpi bus
  
  Some current systems dynamically load SSDT(s) when _PDC/_OSC method
  of Processor is evaluated.  Other devices in ACPI namespace may access
  objects defined in the dynamic SSDT.  Drivers for such devices might
  have to have a rather high priority, because of other dependencies.
  Good example is acpi_ec driver for EC.
  Thus we attach to Processors as early as possible to load the SSDTs
  before any other drivers may try to evaluate control methods.
  It also seems to be a natural order for a processor in a device
  hierarchy.
  
  On the other hand, some child devices on acpi cpu bus need to access
  other system resources like PCI configuration space of chipset devices,
  so they need to be probed and attached rather late.
  For this reason we probe and attach the cpu bus at
  SI_SUB_CONFIGURE:SI_ORDER_MIDDLE SYSINIT level.
  In the future this could be done more elegantly via multipass.
  
  Please note that acpi drivers that might access ACPI namespace from
  device_identify will do that before _PDC/_OSC of Processors are evaluated.
  
  Legacy cpu driver is not affected by this change.
  
  PR:		kern/142561 (in part)
  Reviewed by:	jhb
  Silence from:	acpi@
  MFC after:	5 weeks

Modified:
  head/sys/dev/acpica/acpi.c
  head/sys/dev/acpica/acpi_cpu.c

Modified: head/sys/dev/acpica/acpi.c
==============================================================================
--- head/sys/dev/acpica/acpi.c	Thu Feb 11 08:34:41 2010	(r203775)
+++ head/sys/dev/acpica/acpi.c	Thu Feb 11 08:50:21 2010	(r203776)
@@ -1685,14 +1685,14 @@ acpi_probe_order(ACPI_HANDLE handle, int
      * 100000. CPUs
      */
     AcpiGetType(handle, &type);
-    if (acpi_MatchHid(handle, "PNP0C01") || acpi_MatchHid(handle, "PNP0C02"))
+    if (type == ACPI_TYPE_PROCESSOR)
 	*order = 1;
-    else if (acpi_MatchHid(handle, "PNP0C09"))
+    else if (acpi_MatchHid(handle, "PNP0C01") || acpi_MatchHid(handle, "PNP0C02"))
 	*order = 2;
-    else if (acpi_MatchHid(handle, "PNP0C0F"))
+    else if (acpi_MatchHid(handle, "PNP0C09"))
 	*order = 3;
-    else if (type == ACPI_TYPE_PROCESSOR)
-	*order = 100000;
+    else if (acpi_MatchHid(handle, "PNP0C0F"))
+	*order = 4;
 }
 
 /*

Modified: head/sys/dev/acpica/acpi_cpu.c
==============================================================================
--- head/sys/dev/acpica/acpi_cpu.c	Thu Feb 11 08:34:41 2010	(r203775)
+++ head/sys/dev/acpica/acpi_cpu.c	Thu Feb 11 08:50:21 2010	(r203776)
@@ -384,13 +384,31 @@ acpi_cpu_attach(device_t dev)
     /* Probe for Cx state support. */
     acpi_cpu_cx_probe(sc);
 
-    /* Finally,  call identify and probe/attach for child devices. */
-    bus_generic_probe(dev);
-    bus_generic_attach(dev);
-
     return (0);
 }
 
+static void
+acpi_cpu_postattach(void *unused __unused)
+{
+    device_t *devices;
+    int err;
+    int i, n;
+
+    err = devclass_get_devices(acpi_cpu_devclass, &devices, &n);
+    if (err != 0) {
+	printf("devclass_get_devices(acpi_cpu_devclass) failed\n");
+	return;
+    }
+    for (i = 0; i < n; i++)
+	bus_generic_probe(devices[i]);
+    for (i = 0; i < n; i++)
+	bus_generic_attach(devices[i]);
+    free(devices, M_TEMP);
+}
+
+SYSINIT(acpi_cpu, SI_SUB_CONFIGURE, SI_ORDER_MIDDLE,
+    acpi_cpu_postattach, NULL);
+
 /*
  * Disable any entry to the idle function during suspend and re-enable it
  * during resume.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201002110850.o1B8oLeQ024281>