From: Mark Kettenis Subject: Re: gpiokeys: avoid repeated suspend on lid events To: Kirill A. Korinsky Cc: tech@openbsd.org Date: Mon, 05 Oct 2026 22:02:14 +0200 > Date: Mon, 05 Oct 2026 02:56:35 +0200 > From: Kirill A. Korinsky > > 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? I'm not sure this is the right place to fix this. Although ACPI does something similar in acpibtn(4). I wonder if it would it make sense to check in request_sleep() instead? > 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 > >