From owner-acpi-jp@jp.freebsd.org  Sun Nov 25 23:14:48 2001
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id XAA15836;
	Sun, 25 Nov 2001 23:14:48 +0900 (JST)
	(envelope-from owner-acpi-jp@jp.FreeBSD.org)
Received: from tasogare.imasy.or.jp (root@tasogare.imasy.or.jp [202.227.24.5])
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) with ESMTP id XAA15829
	for <acpi-jp@jp.freebsd.org>; Sun, 25 Nov 2001 23:14:48 +0900 (JST)
	(envelope-from iwasaki@jp.FreeBSD.org)
Received: from localhost (iwasaki.imasy.or.jp [202.227.24.92])
	(authenticated as iwa with CRAM-MD5)
	by tasogare.imasy.or.jp (8.11.6+3.4W/8.11.6/tasogare) with ESMTP/inet id fAPEEjW28778
	for <acpi-jp@jp.freebsd.org>; Sun, 25 Nov 2001 23:14:45 +0900 (JST)
	(envelope-from iwasaki@jp.FreeBSD.org)
Date: Sun, 25 Nov 2001 23:14:28 +0900 (JST)
Message-Id: <20011125.231428.74756526.iwasaki@jp.FreeBSD.org>
To: acpi-jp@jp.freebsd.org
From: Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
In-Reply-To: <200111242008.fAOK8Ok00753@grimreaper.grondar.org>
References: <20011123.145100.97299406.iwasaki@jp.FreeBSD.org>
	<200111242008.fAOK8Ok00753@grimreaper.grondar.org>
X-Mailer: Mew version 2.0 on Emacs 20.7 / Mule 4.0 (HANANOEN)
Mime-Version: 1.0
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Reply-To: acpi-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+010328
X-Sequence: acpi-jp 1504
Subject: [acpi-jp 1504] Re: Toshiba Libretto 110CT ACPI funnies 
Errors-To: owner-acpi-jp@jp.freebsd.org
Sender: owner-acpi-jp@jp.freebsd.org
X-Originator: iwasaki@jp.freebsd.org

Hi,

> > I revised the patch, please try this instead.
> > Also, I'll commit this soon because this is very general validation.
> 
> Nope :-(.
> 
> I got the commit via cvsup, and I see the same behaviour. (Recover
> from suspend, followed by clean shutdown).

OK, then please try this.

Thanks

Index: acpi.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpica/acpi.c,v
retrieving revision 1.50
diff -u -r1.50 acpi.c
--- acpi.c	23 Nov 2001 05:57:03 -0000	1.50
+++ acpi.c	25 Nov 2001 13:48:08 -0000
@@ -457,6 +457,7 @@
      */
     sc->acpi_enabled = 1;
     sc->acpi_sstate = ACPI_STATE_S0;
+    sc->acpi_sleep_disabled = 0;
 
     /*
      * Create the control device
@@ -1289,6 +1290,13 @@
     return(AE_OK);
 }
 
+#define ACPI_MINIMUM_AWAKETIME	5
+
+static void
+acpi_sleep_enable(void *arg)
+{
+    ((struct acpi_softc *)arg)->acpi_sleep_disabled = 0;
+}
 
 /*
  * Set the system sleep state
@@ -1308,6 +1316,9 @@
     if (sc->acpi_sstate != ACPI_STATE_S0)
 	return_ACPI_STATUS(AE_BAD_PARAMETER);	/* avoid reentry */
 
+    if (sc->acpi_sleep_disabled)
+	return_ACPI_STATUS(AE_OK);
+
     switch (state) {
     case ACPI_STATE_S0:	/* XXX only for testing */
 	status = AcpiEnterSleepState((UINT8)state);
@@ -1341,6 +1352,7 @@
 	    return_ACPI_STATUS(AE_ERROR);
 	}
 	sc->acpi_sstate = state;
+	sc->acpi_sleep_disabled = 1;
 
 	if (state != ACPI_STATE_S1) {
 	    acpi_sleep_machdep(sc, state);
@@ -1377,6 +1389,10 @@
 	status = AE_BAD_PARAMETER;
 	break;
     }
+
+    if (sc->acpi_sleep_disabled)
+	timeout(acpi_sleep_enable, (caddr_t)sc, hz * ACPI_MINIMUM_AWAKETIME);
+
     return_ACPI_STATUS(status);
 }
 
Index: acpivar.h
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpica/acpivar.h,v
retrieving revision 1.23
diff -u -r1.23 acpivar.h
--- acpivar.h	18 Nov 2001 18:12:07 -0000	1.23
+++ acpivar.h	25 Nov 2001 13:44:17 -0000
@@ -47,6 +47,7 @@
 
     int			acpi_enabled;
     int			acpi_sstate;
+    int			acpi_sleep_disabled;
 
     struct sysctl_ctx_list acpi_sysctl_ctx;
     struct sysctl_oid	*acpi_sysctl_tree;
