Index | Thread | Search

From:
Kirill A. Korinsky <kirill@korins.ky>
Subject:
gpiokeys: avoid repeated suspend on lid events
To:
OpenBSD tech <tech@openbsd.org>
Date:
Mon, 05 Oct 2026 02:56:35 +0200

Download raw body.

Thread
tech@,

A lid close during suspend or resume can queue a second sleep cycle, putting
the machine back to sleep after the lid opens. Accept lid suspend requests
only while sleep_mode is SLEEP_RESUME and the existing ten second resume
grace period has elapsed.

Ok?

Index: sys/dev/fdt/gpiokeys.c
===================================================================
RCS file: /home/cvs/src/sys/dev/fdt/gpiokeys.c,v
diff -u -p -r1.7 gpiokeys.c
--- sys/dev/fdt/gpiokeys.c	8 Sep 2025 19:32:57 -0000	1.7
+++ sys/dev/fdt/gpiokeys.c	5 Oct 2026 00:50:24 -0000
@@ -244,7 +244,8 @@ gpiokeys_update_key(void *arg)
 				break;
 			case 1:
 #ifdef SUSPEND
-				if (val)
+				if (val && sleep_mode == SLEEP_RESUME &&
+				    !resuming())
 					request_sleep(SLEEP_SUSPEND);
 #endif
 				break;


-- 
wbr, Kirill