From owner-svn-src-stable-8@FreeBSD.ORG Fri Jun 1 13:21:33 2012 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5C7081065675; Fri, 1 Jun 2012 13:21:33 +0000 (UTC) (envelope-from iwasaki@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3D4148FC08; Fri, 1 Jun 2012 13:21:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q51DLXUA021365; Fri, 1 Jun 2012 13:21:33 GMT (envelope-from iwasaki@svn.freebsd.org) Received: (from iwasaki@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q51DLXZ7021363; Fri, 1 Jun 2012 13:21:33 GMT (envelope-from iwasaki@svn.freebsd.org) Message-Id: <201206011321.q51DLXZ7021363@svn.freebsd.org> From: Mitsuru IWASAKI Date: Fri, 1 Jun 2012 13:21:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236396 - stable/8/sys/dev/acpica X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Jun 2012 13:21:33 -0000 Author: iwasaki Date: Fri Jun 1 13:21:32 2012 New Revision: 236396 URL: http://svn.freebsd.org/changeset/base/236396 Log: MFC r235692,235772,236220,236221: - Don't start the sleep state transition procedure while sleep is disabled or the system is in shutdown procedure. - Ignore the power button press event for resuming rather than starting shutdown. - Fix the problem acpi_sleep_force() hang. - Reorder resume procedures to avoid hang during AcpiLeaveSleepState() execution. Modified: stable/8/sys/dev/acpica/acpi.c Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/dev/acpica/acpi.c ============================================================================== --- stable/8/sys/dev/acpica/acpi.c Fri Jun 1 12:47:13 2012 (r236395) +++ stable/8/sys/dev/acpica/acpi.c Fri Jun 1 13:21:32 2012 (r236396) @@ -2307,15 +2307,29 @@ acpi_SetSleepState(struct acpi_softc *sc #if defined(__amd64__) || defined(__i386__) static void +acpi_sleep_force_task(void *context) +{ + struct acpi_softc *sc = (struct acpi_softc *)context; + + if (ACPI_FAILURE(acpi_EnterSleepState(sc, sc->acpi_next_sstate))) + device_printf(sc->acpi_dev, "force sleep state S%d failed\n", + sc->acpi_next_sstate); +} + +static void acpi_sleep_force(void *arg) { struct acpi_softc *sc = (struct acpi_softc *)arg; device_printf(sc->acpi_dev, "suspend request timed out, forcing sleep now\n"); - if (ACPI_FAILURE(acpi_EnterSleepState(sc, sc->acpi_next_sstate))) - device_printf(sc->acpi_dev, "force sleep state S%d failed\n", - sc->acpi_next_sstate); + /* + * XXX Suspending from callout cause the freeze in DEVICE_SUSPEND(). + * Suspend from acpi_task thread in stead. + */ + if (ACPI_FAILURE(AcpiOsExecute(OSL_NOTIFY_HANDLER, + acpi_sleep_force_task, sc))) + device_printf(sc->acpi_dev, "AcpiOsExecute() for sleeping failed\n"); } #endif @@ -2339,14 +2353,20 @@ acpi_ReqSleepState(struct acpi_softc *sc if (!acpi_sleep_states[state]) return (EOPNOTSUPP); - ACPI_LOCK(acpi); - /* If a suspend request is already in progress, just return. */ if (sc->acpi_next_sstate != 0) { - ACPI_UNLOCK(acpi); return (0); } + /* Wait until sleep is enabled. */ + while (sc->acpi_sleep_disabled) { + AcpiOsSleep(1000); + } + + ACPI_LOCK(acpi); + + sc->acpi_next_sstate = state; + /* S5 (soft-off) should be entered directly with no waiting. */ if (state == ACPI_STATE_S5) { ACPI_UNLOCK(acpi); @@ -2355,7 +2375,6 @@ acpi_ReqSleepState(struct acpi_softc *sc } /* Record the pending state and notify all apm devices. */ - sc->acpi_next_sstate = state; #if defined(__i386__) STAILQ_FOREACH(clone, &sc->apm_cdevs, entries) { clone->notify_status = APM_EV_NONE; @@ -2615,10 +2634,10 @@ backout: acpi_wake_prep_walk(state); sc->acpi_sstate = ACPI_STATE_S0; } - if (slp_state >= ACPI_SS_SLP_PREP) - AcpiLeaveSleepState(state); if (slp_state >= ACPI_SS_DEV_SUSPEND) DEVICE_RESUME(root_bus); + if (slp_state >= ACPI_SS_SLP_PREP) + AcpiLeaveSleepState(state); if (slp_state >= ACPI_SS_SLEPT) acpi_enable_fixed_events(sc); sc->acpi_next_sstate = 0;