From owner-svn-src-all@FreeBSD.ORG Mon Mar 23 22:06:10 2009 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 4A606106568C; Mon, 23 Mar 2009 22:06:10 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 38DEF8FC29; Mon, 23 Mar 2009 22:06:10 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2NM6AJs022947; Mon, 23 Mar 2009 22:06:10 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2NM6Agr022946; Mon, 23 Mar 2009 22:06:10 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <200903232206.n2NM6Agr022946@svn.freebsd.org> From: Jung-uk Kim Date: Mon, 23 Mar 2009 22:06:10 +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: r190339 - 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: Mon, 23 Mar 2009 22:06:11 -0000 Author: jkim Date: Mon Mar 23 22:06:09 2009 New Revision: 190339 URL: http://svn.freebsd.org/changeset/base/190339 Log: Check whether devd is running before calling resume notifier and reshuffle code to reduce unnecessary locking coverage. Modified: head/sys/dev/acpica/acpi.c Modified: head/sys/dev/acpica/acpi.c ============================================================================== --- head/sys/dev/acpica/acpi.c Mon Mar 23 21:32:03 2009 (r190338) +++ head/sys/dev/acpica/acpi.c Mon Mar 23 22:06:09 2009 (r190339) @@ -2336,7 +2336,7 @@ acpi_ReqSleepState(struct acpi_softc *sc #endif /* If devd(8) is not running, immediately enter the sleep state. */ - if (devctl_process_running() == FALSE) { + if (!devctl_process_running()) { ACPI_UNLOCK(acpi); if (ACPI_SUCCESS(acpi_EnterSleepState(sc, sc->acpi_next_sstate))) { return (0); @@ -2345,9 +2345,6 @@ acpi_ReqSleepState(struct acpi_softc *sc } } - /* Now notify devd(8) also. */ - acpi_UserNotify("Suspend", ACPI_ROOT_OBJECT, state); - /* * Set a timeout to fire if userland doesn't ack the suspend request * in time. This way we still eventually go to sleep if we were @@ -2357,6 +2354,10 @@ acpi_ReqSleepState(struct acpi_softc *sc */ callout_reset(&sc->susp_force_to, 10 * hz, acpi_sleep_force, sc); ACPI_UNLOCK(acpi); + + /* Now notify devd(8) also. */ + acpi_UserNotify("Suspend", ACPI_ROOT_OBJECT, state); + return (0); #else /* This platform does not support acpi suspend/resume. */ @@ -2432,8 +2433,24 @@ acpi_AckSleepState(struct apm_clone_data static void acpi_sleep_enable(void *arg) { + struct acpi_softc *sc = (struct acpi_softc *)arg; - ((struct acpi_softc *)arg)->acpi_sleep_disabled = 0; + ACPI_LOCK(acpi); + sc->acpi_sleep_disabled = 0; + ACPI_UNLOCK(acpi); +} + +static ACPI_STATUS +acpi_sleep_disable(struct acpi_softc *sc) +{ + ACPI_STATUS status; + + ACPI_LOCK(acpi); + status = sc->acpi_sleep_disabled ? AE_ERROR : AE_OK; + sc->acpi_sleep_disabled = 1; + ACPI_UNLOCK(acpi); + + return (status); } enum acpi_sleep_state { @@ -2460,15 +2477,11 @@ acpi_EnterSleepState(struct acpi_softc * ACPI_FUNCTION_TRACE_U32((char *)(uintptr_t)__func__, state); /* Re-entry once we're suspending is not allowed. */ - status = AE_OK; - ACPI_LOCK(acpi); - if (sc->acpi_sleep_disabled) { - ACPI_UNLOCK(acpi); + status = acpi_sleep_disable(sc); + if (ACPI_FAILURE(status)) { printf("acpi: suspend request ignored (not ready yet)\n"); - return (AE_ERROR); + return (status); } - sc->acpi_sleep_disabled = 1; - ACPI_UNLOCK(acpi); #ifdef SMP thread_lock(curthread); @@ -2557,6 +2570,7 @@ acpi_EnterSleepState(struct acpi_softc * * shutdown handlers. */ shutdown_nice(RB_POWEROFF); + status = AE_OK; break; case ACPI_STATE_S0: default: @@ -2580,13 +2594,6 @@ acpi_EnterSleepState(struct acpi_softc * if (slp_state >= ACPI_SS_SLEPT) acpi_enable_fixed_events(sc); - /* Allow another sleep request after a while. */ - if (state != ACPI_STATE_S5) - timeout(acpi_sleep_enable, sc, hz * ACPI_MINIMUM_AWAKETIME); - - /* Run /etc/rc.resume after we are back. */ - acpi_UserNotify("Resume", ACPI_ROOT_OBJECT, state); - mtx_unlock(&Giant); /* Warm up timecounter again */ @@ -2599,6 +2606,14 @@ acpi_EnterSleepState(struct acpi_softc * thread_unlock(curthread); #endif + /* Allow another sleep request after a while. */ + if (state != ACPI_STATE_S5) + timeout(acpi_sleep_enable, sc, hz * ACPI_MINIMUM_AWAKETIME); + + /* Run /etc/rc.resume after we are back. */ + if (devctl_process_running()) + acpi_UserNotify("Resume", ACPI_ROOT_OBJECT, state); + return_ACPI_STATUS (status); }