From: Kirill A. Korinsky Subject: Re: gpiokeys: avoid repeated suspend on lid events To: Mark Kettenis Cc: tech@openbsd.org Date: Mon, 05 Oct 2026 22:23:29 +0200 On Mon, 05 Oct 2026 22:02:14 +0200, Mark Kettenis wrote: > > > 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? > Not sure. But suggested design at least consistent with that we have at acpibtn. Are you sure that it is good idea to make ignore button on resume at arm64 and amd64 at differences places? > > 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 > > > > -- wbr, Kirill