From owner-svn-src-all@freebsd.org Mon Jun 6 20:28:54 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DCC8BB6DD81; Mon, 6 Jun 2016 20:28:54 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B86291A52; Mon, 6 Jun 2016 20:28:54 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u56KSrFK003611; Mon, 6 Jun 2016 20:28:53 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u56KSrgM003610; Mon, 6 Jun 2016 20:28:53 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201606062028.u56KSrgM003610@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 6 Jun 2016 20:28:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r301518 - head/sys/dev/acpica X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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: Mon, 06 Jun 2016 20:28:55 -0000 Author: jhb Date: Mon Jun 6 20:28:53 2016 New Revision: 301518 URL: https://svnweb.freebsd.org/changeset/base/301518 Log: Defer the creation of ACPI thermal kthreads to a startup sysinit. The SYSINIT runs at SI_SUB_KICK_SCHEDULER after the scheduler is fully initialized and timers are working. This fixes booting in the EARLY_AP_STARTUP case. Modified: head/sys/dev/acpica/acpi_thermal.c Modified: head/sys/dev/acpica/acpi_thermal.c ============================================================================== --- head/sys/dev/acpica/acpi_thermal.c Mon Jun 6 20:00:13 2016 (r301517) +++ head/sys/dev/acpica/acpi_thermal.c Mon Jun 6 20:28:53 2016 (r301518) @@ -311,19 +311,40 @@ acpi_tz_attach(device_t dev) "thermal sampling period for passive cooling"); /* - * Create thread to service all of the thermal zones. Register - * our power profile event handler. + * Register our power profile event handler. */ sc->tz_event = EVENTHANDLER_REGISTER(power_profile_change, acpi_tz_power_profile, sc, 0); - if (acpi_tz_proc == NULL) { - error = kproc_create(acpi_tz_thread, NULL, &acpi_tz_proc, - RFHIGHPID, 0, "acpi_thermal"); - if (error != 0) { - device_printf(sc->tz_dev, "could not create thread - %d", error); - goto out; - } - } + + /* + * Flag the event handler for a manual invocation by our timeout. + * We defer it like this so that the rest of the subsystem has time + * to come up. Don't bother evaluating/printing the temperature at + * this point; on many systems it'll be bogus until the EC is running. + */ + sc->tz_flags |= TZ_FLAG_GETPROFILE; + + return_VALUE (0); +} + +static void +acpi_tz_startup(void *arg __unused) +{ + struct acpi_tz_softc *sc; + device_t *devs; + int devcount, error, i; + + devclass_get_devices(acpi_tz_devclass, &devs, &devcount); + if (devcount == 0) + return; + + /* + * Create thread to service all of the thermal zones. + */ + error = kproc_create(acpi_tz_thread, NULL, &acpi_tz_proc, RFHIGHPID, 0, + "acpi_thermal"); + if (error != 0) + printf("acpi_tz: could not create thread - %d", error); /* * Create a thread to handle passive cooling for 1st zone which @@ -335,34 +356,22 @@ acpi_tz_attach(device_t dev) * given frequency whereas it's possible for different thermal * zones to specify independent settings for multiple CPUs. */ - if (acpi_tz_cooling_unit < 0 && acpi_tz_cooling_is_available(sc)) - sc->tz_cooling_enabled = TRUE; - if (sc->tz_cooling_enabled) { - error = acpi_tz_cooling_thread_start(sc); - if (error != 0) { - sc->tz_cooling_enabled = FALSE; - goto out; + for (i = 0; i < devcount; i++) { + sc = device_get_softc(devs[i]); + if (acpi_tz_cooling_is_available(sc)) { + sc->tz_cooling_enabled = TRUE; + error = acpi_tz_cooling_thread_start(sc); + if (error != 0) { + sc->tz_cooling_enabled = FALSE; + break; + } + acpi_tz_cooling_unit = device_get_unit(devs[i]); + break; } - acpi_tz_cooling_unit = device_get_unit(dev); - } - - /* - * Flag the event handler for a manual invocation by our timeout. - * We defer it like this so that the rest of the subsystem has time - * to come up. Don't bother evaluating/printing the temperature at - * this point; on many systems it'll be bogus until the EC is running. - */ - sc->tz_flags |= TZ_FLAG_GETPROFILE; - -out: - if (error != 0) { - EVENTHANDLER_DEREGISTER(power_profile_change, sc->tz_event); - AcpiRemoveNotifyHandler(sc->tz_handle, ACPI_DEVICE_NOTIFY, - acpi_tz_notify_handler); - sysctl_ctx_free(&sc->tz_sysctl_ctx); } - return_VALUE (error); + free(devs, M_TEMP); } +SYSINIT(acpi_tz, SI_SUB_KICK_SCHEDULER, SI_ORDER_ANY, acpi_tz_startup, NULL); /* * Parse the current state of this thermal zone and set up to use it.