From owner-svn-src-all@FreeBSD.ORG Thu Jul 15 23:24:07 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 5071B1065676; Thu, 15 Jul 2010 23:24:07 +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 26A828FC13; Thu, 15 Jul 2010 23:24:07 +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 o6FNO73b032590; Thu, 15 Jul 2010 23:24:07 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o6FNO7gd032588; Thu, 15 Jul 2010 23:24:07 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201007152324.o6FNO7gd032588@svn.freebsd.org> From: Jung-uk Kim Date: Thu, 15 Jul 2010 23:24:07 +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: r210150 - 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, 15 Jul 2010 23:24:07 -0000 Author: jkim Date: Thu Jul 15 23:24:06 2010 New Revision: 210150 URL: http://svn.freebsd.org/changeset/base/210150 Log: If there is any pending sleep request, disallow entering S5 state. Otherwise, bad things may happen. ;-) Modified: head/sys/dev/acpica/acpi.c Modified: head/sys/dev/acpica/acpi.c ============================================================================== --- head/sys/dev/acpica/acpi.c Thu Jul 15 23:11:51 2010 (r210149) +++ head/sys/dev/acpica/acpi.c Thu Jul 15 23:24:06 2010 (r210150) @@ -2317,27 +2317,28 @@ acpi_ReqSleepState(struct acpi_softc *sc { #if defined(__amd64__) || defined(__i386__) struct apm_clone_data *clone; + ACPI_STATUS status; if (state < ACPI_STATE_S1 || state > ACPI_S_STATES_MAX) return (EINVAL); if (!acpi_sleep_states[state]) return (EOPNOTSUPP); - /* S5 (soft-off) should be entered directly with no waiting. */ - if (state == ACPI_STATE_S5) { - if (ACPI_SUCCESS(acpi_EnterSleepState(sc, state))) - return (0); - else - return (ENXIO); - } + ACPI_LOCK(acpi); /* If a suspend request is already in progress, just return. */ - ACPI_LOCK(acpi); if (sc->acpi_next_sstate != 0) { ACPI_UNLOCK(acpi); return (0); } + /* S5 (soft-off) should be entered directly with no waiting. */ + if (state == ACPI_STATE_S5) { + ACPI_UNLOCK(acpi); + status = acpi_EnterSleepState(sc, state); + return (ACPI_SUCCESS(status) ? 0 : ENXIO); + } + /* Record the pending state and notify all apm devices. */ sc->acpi_next_sstate = state; STAILQ_FOREACH(clone, &sc->apm_cdevs, entries) { @@ -2351,11 +2352,8 @@ acpi_ReqSleepState(struct acpi_softc *sc /* If devd(8) is not running, immediately enter the sleep state. */ if (!devctl_process_running()) { ACPI_UNLOCK(acpi); - if (ACPI_SUCCESS(acpi_EnterSleepState(sc, sc->acpi_next_sstate))) { - return (0); - } else { - return (ENXIO); - } + status = acpi_EnterSleepState(sc, state); + return (ACPI_SUCCESS(status) ? 0 : ENXIO); } /* @@ -2592,7 +2590,6 @@ acpi_EnterSleepState(struct acpi_softc * * process. This handles both the error and success cases. */ backout: - sc->acpi_next_sstate = 0; if (slp_state >= ACPI_SS_GPE_SET) { acpi_wake_prep_walk(state); sc->acpi_sstate = ACPI_STATE_S0; @@ -2603,6 +2600,7 @@ backout: DEVICE_RESUME(root_bus); if (slp_state >= ACPI_SS_SLEPT) acpi_enable_fixed_events(sc); + sc->acpi_next_sstate = 0; mtx_unlock(&Giant);