From owner-svn-src-all@FreeBSD.ORG Thu Feb 11 08:50:21 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 86279106566B; Thu, 11 Feb 2010 08:50:21 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 749438FC15; Thu, 11 Feb 2010 08:50:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1B8oL2G024284; Thu, 11 Feb 2010 08:50:21 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1B8oLeQ024281; Thu, 11 Feb 2010 08:50:21 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201002110850.o1B8oLeQ024281@svn.freebsd.org> From: Andriy Gapon Date: Thu, 11 Feb 2010 08:50:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203776 - head/sys/dev/acpica X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Feb 2010 08:50:21 -0000 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.