diff options
-rw-r--r-- | etc/etc.amd64/sysctl.conf | 2 | ||||
-rw-r--r-- | etc/etc.i386/sysctl.conf | 2 | ||||
-rw-r--r-- | etc/etc.loongson/sysctl.conf | 2 | ||||
-rw-r--r-- | sbin/init/init.c | 12 | ||||
-rw-r--r-- | sbin/reboot/reboot.c | 12 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/machdep.c | 9 | ||||
-rw-r--r-- | sys/arch/amd64/include/cpu.h | 6 | ||||
-rw-r--r-- | sys/arch/arm/include/cpu.h | 6 | ||||
-rw-r--r-- | sys/arch/i386/i386/machdep.c | 9 | ||||
-rw-r--r-- | sys/arch/i386/include/cpu.h | 6 | ||||
-rw-r--r-- | sys/arch/loongson/loongson/machdep.c | 7 | ||||
-rw-r--r-- | sys/arch/mips64/include/cpu.h | 6 | ||||
-rw-r--r-- | sys/dev/acpi/acpi.c | 6 | ||||
-rw-r--r-- | sys/dev/acpi/acpibtn.c | 22 | ||||
-rw-r--r-- | sys/dev/isa/aps.c | 6 |
15 files changed, 68 insertions, 45 deletions
diff --git a/etc/etc.amd64/sysctl.conf b/etc/etc.amd64/sysctl.conf index ba90bf714f0..b1b64952365 100644 --- a/etc/etc.amd64/sysctl.conf +++ b/etc/etc.amd64/sysctl.conf @@ -1,3 +1,3 @@ #machdep.allowaperture=2 # See xf86(4) #machdep.kbdreset=1 # permit console CTRL-ALT-DEL to do a nice halt -#machdep.lidsuspend=0 # do not suspend laptop upon lid closing +#machdep.lidaction=0 # 1=suspend, 2=hibernate laptop upon lid closing diff --git a/etc/etc.i386/sysctl.conf b/etc/etc.i386/sysctl.conf index 48f492dc82d..9e8d3252d85 100644 --- a/etc/etc.i386/sysctl.conf +++ b/etc/etc.i386/sysctl.conf @@ -1,4 +1,4 @@ #machdep.allowaperture=2 # See xf86(4) #machdep.apmhalt=1 # 1=powerdown hack, try if halt -p doesn't work #machdep.kbdreset=1 # permit console CTRL-ALT-DEL to do a nice halt -#machdep.lidsuspend=0 # do not suspend laptop upon lid closing +#machdep.lidaction=0 # 1=suspend, 2=hibernate laptop upon lid closing diff --git a/etc/etc.loongson/sysctl.conf b/etc/etc.loongson/sysctl.conf index e6491005aa6..a3f6e594cad 100644 --- a/etc/etc.loongson/sysctl.conf +++ b/etc/etc.loongson/sysctl.conf @@ -1 +1 @@ -#machdep.lidsuspend=0 # do not suspend laptop upon lid closing +#machdep.lidaction=0 # 1=suspend, 2=hibernate laptop upon lid closing diff --git a/sbin/init/init.c b/sbin/init/init.c index 208db53d438..a2dff9bfafa 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.62 2016/09/05 10:20:40 gsoares Exp $ */ +/* $OpenBSD: init.c,v 1.63 2017/03/02 10:38:09 natano Exp $ */ /* $NetBSD: init.c,v 1.22 1996/05/15 23:29:33 jtc Exp $ */ /*- @@ -1325,13 +1325,13 @@ f_nice_death(void) int status; #ifdef CPU_LIDSUSPEND - int lidsuspend_mib[] = {CTL_MACHDEP, CPU_LIDSUSPEND}; - int dontsuspend = 0; + int mib[] = {CTL_MACHDEP, CPU_LIDACTION}; + int lidaction = 0; if ((death_howto & RB_POWERDOWN) && - (sysctl(lidsuspend_mib, 2, NULL, NULL, &dontsuspend, - sizeof(dontsuspend)) == -1) && (errno != EOPNOTSUPP)) - warning("cannot disable lid suspend"); + (sysctl(mib, 2, NULL, NULL, &lidaction, + sizeof(lidaction)) == -1) && (errno != EOPNOTSUPP)) + warning("cannot disable lid action"); #endif for (sp = sessions; sp; sp = sp->se_next) { diff --git a/sbin/reboot/reboot.c b/sbin/reboot/reboot.c index 266e6df9927..8f1f524d72c 100644 --- a/sbin/reboot/reboot.c +++ b/sbin/reboot/reboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: reboot.c,v 1.35 2016/08/27 01:56:07 guenther Exp $ */ +/* $OpenBSD: reboot.c,v 1.36 2017/03/02 10:38:09 natano Exp $ */ /* $NetBSD: reboot.c,v 1.8 1995/10/05 05:36:22 mycroft Exp $ */ /* @@ -115,13 +115,11 @@ main(int argc, char *argv[]) #ifdef CPU_LIDSUSPEND if (howto & RB_POWERDOWN) { /* Disable suspending on laptop lid close */ - int mib[2]; - int lidsuspend = 0; + int mib[] = {CTL_MACHDEP, CPU_LIDACTION}; + int lidaction = 0; - mib[0] = CTL_MACHDEP; - mib[1] = CPU_LIDSUSPEND; - if (sysctl(mib, 2, NULL, NULL, &lidsuspend, - sizeof(lidsuspend)) == -1 && errno != EOPNOTSUPP) + if (sysctl(mib, 2, NULL, NULL, &lidaction, + sizeof(lidaction)) == -1 && errno != EOPNOTSUPP) warn("sysctl"); } #endif /* CPU_LIDSUSPEND */ diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index 45e44274833..653d636df9f 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.223 2016/10/09 11:25:39 tom Exp $ */ +/* $OpenBSD: machdep.c,v 1.224 2017/03/02 10:38:09 natano Exp $ */ /* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */ /*- @@ -188,7 +188,7 @@ paddr_t lo32_paddr; paddr_t tramp_pdirpa; int kbd_reset; -int lid_suspend = 1; +int lid_action = 1; /* * safepri is a safe priority for sleep to set for a spin-wait @@ -495,7 +495,8 @@ cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, case CPU_XCRYPT: return (sysctl_rdint(oldp, oldlenp, newp, amd64_has_xcrypt)); case CPU_LIDSUSPEND: - return (sysctl_int(oldp, oldlenp, newp, newlen, &lid_suspend)); + case CPU_LIDACTION: + return (sysctl_int(oldp, oldlenp, newp, newlen, &lid_action)); default: return (EOPNOTSUPP); } @@ -715,7 +716,7 @@ __dead void boot(int howto) { if ((howto & RB_POWERDOWN) != 0) - lid_suspend = 0; + lid_action = 0; if (cold) { if ((howto & RB_USERREQ) == 0) diff --git a/sys/arch/amd64/include/cpu.h b/sys/arch/amd64/include/cpu.h index 09ce08cc938..4b51f80e0fe 100644 --- a/sys/arch/amd64/include/cpu.h +++ b/sys/arch/amd64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.107 2016/12/14 10:30:59 reyk Exp $ */ +/* $OpenBSD: cpu.h,v 1.108 2017/03/02 10:38:10 natano Exp $ */ /* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */ /*- @@ -425,7 +425,8 @@ void mp_setperf_init(void); #define CPU_APMHALT 11 /* halt -p hack */ #define CPU_XCRYPT 12 /* supports VIA xcrypt in userland */ #define CPU_LIDSUSPEND 13 /* lid close causes a suspend */ -#define CPU_MAXID 14 /* number of valid machdep ids */ +#define CPU_LIDACTION 14 /* action caused by lid close */ +#define CPU_MAXID 15 /* number of valid machdep ids */ #define CTL_MACHDEP_NAMES { \ { 0, 0 }, \ @@ -442,6 +443,7 @@ void mp_setperf_init(void); { "apmhalt", CTLTYPE_INT }, \ { "xcrypt", CTLTYPE_INT }, \ { "lidsuspend", CTLTYPE_INT }, \ + { "lidaction", CTLTYPE_INT }, \ } /* diff --git a/sys/arch/arm/include/cpu.h b/sys/arch/arm/include/cpu.h index e82c6a761e2..9af743192f8 100644 --- a/sys/arch/arm/include/cpu.h +++ b/sys/arch/arm/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.43 2017/01/06 00:06:02 jsg Exp $ */ +/* $OpenBSD: cpu.h,v 1.44 2017/03/02 10:38:10 natano Exp $ */ /* $NetBSD: cpu.h,v 1.34 2003/06/23 11:01:08 martin Exp $ */ /* @@ -66,7 +66,8 @@ /* 10 formerly struct: CPU_ZTSSCALE */ #define CPU_MAXSPEED 11 /* int: number of valid machdep ids */ #define CPU_LIDSUSPEND 12 /* int: closing lid causes suspend */ -#define CPU_MAXID 13 /* number of valid machdep ids */ +#define CPU_LIDACTION 13 /* action caused by lid close */ +#define CPU_MAXID 14 /* number of valid machdep ids */ #define CTL_MACHDEP_NAMES { \ { 0, 0 }, \ @@ -82,6 +83,7 @@ { 0, 0 }, \ { "maxspeed", CTLTYPE_INT }, \ { "lidsuspend", CTLTYPE_INT } \ + { "lidaction", CTLTYPE_INT } \ } #ifdef _KERNEL diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index 79cb3bee093..bc9e3a05601 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.595 2017/01/13 17:15:27 mikeb Exp $ */ +/* $OpenBSD: machdep.c,v 1.596 2017/03/02 10:38:10 natano Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -234,7 +234,7 @@ void (*update_cpuspeed)(void) = NULL; void via_update_sensor(void *args); #endif int kbd_reset; -int lid_suspend = 1; +int lid_action = 1; /* * safepri is a safe priority for sleep to set for a spin-wait @@ -2655,7 +2655,7 @@ __dead void boot(int howto) { if ((howto & RB_POWERDOWN) != 0) - lid_suspend = 0; + lid_action = 0; if (cold) { if ((howto & RB_USERREQ) == 0) @@ -3595,7 +3595,8 @@ cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, case CPU_XCRYPT: return (sysctl_rdint(oldp, oldlenp, newp, i386_has_xcrypt)); case CPU_LIDSUSPEND: - return (sysctl_int(oldp, oldlenp, newp, newlen, &lid_suspend)); + case CPU_LIDACTION: + return (sysctl_int(oldp, oldlenp, newp, newlen, &lid_action)); default: return (EOPNOTSUPP); } diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h index bde738031e7..22538aad5fe 100644 --- a/sys/arch/i386/include/cpu.h +++ b/sys/arch/i386/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.152 2017/02/06 09:13:41 mpi Exp $ */ +/* $OpenBSD: cpu.h,v 1.153 2017/03/02 10:38:10 natano Exp $ */ /* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */ /*- @@ -524,7 +524,8 @@ int cpu_paenable(void *); #define CPU_SSE2 15 /* supports SSE2 */ #define CPU_XCRYPT 16 /* supports VIA xcrypt in userland */ #define CPU_LIDSUSPEND 17 /* lid close causes a suspend */ -#define CPU_MAXID 18 /* number of valid machdep ids */ +#define CPU_LIDACTION 18 /* action caused by lid close */ +#define CPU_MAXID 19 /* number of valid machdep ids */ #define CTL_MACHDEP_NAMES { \ { 0, 0 }, \ @@ -545,6 +546,7 @@ int cpu_paenable(void *); { "sse2", CTLTYPE_INT }, \ { "xcrypt", CTLTYPE_INT }, \ { "lidsuspend", CTLTYPE_INT }, \ + { "lidaction", CTLTYPE_INT }, \ } /* diff --git a/sys/arch/loongson/loongson/machdep.c b/sys/arch/loongson/loongson/machdep.c index 7aa6efac71b..73e74b515a4 100644 --- a/sys/arch/loongson/loongson/machdep.c +++ b/sys/arch/loongson/loongson/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.72 2017/01/19 15:09:04 visa Exp $ */ +/* $OpenBSD: machdep.c,v 1.73 2017/03/02 10:38:10 natano Exp $ */ /* * Copyright (c) 2009, 2010, 2014 Miodrag Vallat. @@ -116,7 +116,7 @@ int physmem; /* Max supported memory, changes to actual. */ int ncpu = 1; /* At least one CPU in the system. */ int nnodes = 1; /* Number of NUMA nodes, only on 3A. */ struct user *proc0paddr; -int lid_suspend = 1; +int lid_action = 1; #ifdef MULTIPROCESSOR uint64_t cpu_spinup_a0; @@ -1025,7 +1025,8 @@ cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, switch (name[0]) { case CPU_LIDSUSPEND: - return sysctl_int(oldp, oldlenp, newp, newlen, &lid_suspend); + case CPU_LIDACTION: + return sysctl_int(oldp, oldlenp, newp, newlen, &lid_action); default: return EOPNOTSUPP; } diff --git a/sys/arch/mips64/include/cpu.h b/sys/arch/mips64/include/cpu.h index 9bc7d881548..5206d877a5d 100644 --- a/sys/arch/mips64/include/cpu.h +++ b/sys/arch/mips64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.113 2016/12/17 11:51:01 visa Exp $ */ +/* $OpenBSD: cpu.h,v 1.114 2017/03/02 10:38:10 natano Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -362,13 +362,15 @@ void cp0_calibrate(struct cpu_info *); #define CPU_ALLOWAPERTURE 1 /* allow mmap of /dev/xf86 */ /* 2 formerly: keyboard reset */ #define CPU_LIDSUSPEND 3 /* lid close causes a suspend */ -#define CPU_MAXID 4 /* number of valid machdep ids */ +#define CPU_LIDACTION 4 /* action caused by lid close */ +#define CPU_MAXID 5 /* number of valid machdep ids */ #define CTL_MACHDEP_NAMES { \ { 0, 0 }, \ { "allowaperture", CTLTYPE_INT }, \ { 0, 0 }, \ { "lidsuspend", CTLTYPE_INT }, \ + { "lidaction", CTLTYPE_INT }, \ } /* diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index 0b4cdcc9c8c..67c76c6d21a 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.322 2017/02/28 10:39:07 natano Exp $ */ +/* $OpenBSD: acpi.c,v 1.323 2017/03/02 10:38:10 natano Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> @@ -2349,7 +2349,7 @@ int acpi_sleep_state(struct acpi_softc *sc, int sleepmode) { extern int perflevel; - extern int lid_suspend; + extern int lid_action; int error = ENXIO; size_t rndbuflen = 0; char *rndbuf = NULL; @@ -2506,7 +2506,7 @@ fail_alloc: acpi_indicator(sc, ACPI_SST_WORKING); /* If we woke up but all the lids are closed, go back to sleep */ - if (acpibtn_numopenlids() == 0 && lid_suspend != 0) + if (acpibtn_numopenlids() == 0 && lid_action != 0) acpi_addtask(sc, acpi_sleep_task, sc, sleepmode); fail_tts: diff --git a/sys/dev/acpi/acpibtn.c b/sys/dev/acpi/acpibtn.c index badfc8f23b3..8f9e2c20749 100644 --- a/sys/dev/acpi/acpibtn.c +++ b/sys/dev/acpi/acpibtn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpibtn.c,v 1.43 2017/02/28 10:39:07 natano Exp $ */ +/* $OpenBSD: acpibtn.c,v 1.44 2017/03/02 10:38:10 natano Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * @@ -207,7 +207,7 @@ acpibtn_notify(struct aml_node *node, int notify_type, void *arg) { struct acpibtn_softc *sc = arg; #ifndef SMALL_KERNEL - extern int lid_suspend; + extern int lid_action; int64_t lid; #endif @@ -227,10 +227,24 @@ acpibtn_notify(struct aml_node *node, int notify_type, void *arg) "_LID", 0, NULL, &lid)) return (0); sc->sc_sens.value = lid; - if (lid_suspend == 0) + + if (lid != 0) break; - if (lid == 0) + + switch (lid_action) { + case 1: goto sleep; +#ifdef HIBERNATE + case 2: + /* Request to go to sleep */ + if (acpi_record_event(sc->sc_acpi, APM_USER_HIBERNATE_REQ)) + acpi_addtask(sc->sc_acpi, acpi_sleep_task, + sc->sc_acpi, ACPI_SLEEP_HIBERNATE); + break; +#endif + default: + break; + } #endif /* SMALL_KERNEL */ break; case ACPIBTN_SLEEP: diff --git a/sys/dev/isa/aps.c b/sys/dev/isa/aps.c index fa1f4662e9d..c1f93bcaa74 100644 --- a/sys/dev/isa/aps.c +++ b/sys/dev/isa/aps.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aps.c,v 1.25 2015/03/14 03:38:47 jsg Exp $ */ +/* $OpenBSD: aps.c,v 1.26 2017/03/02 10:38:10 natano Exp $ */ /* * Copyright (c) 2005 Jonathan Gray <jsg@openbsd.org> * Copyright (c) 2008 Can Erkin Acar <canacar@openbsd.org> @@ -434,7 +434,7 @@ aps_refresh_sensor_data(struct aps_softc *sc) int64_t temp; int i; #if NAPM > 0 - extern int lid_suspend; + extern int lid_action; extern int apm_lidclose; #endif @@ -467,7 +467,7 @@ aps_refresh_sensor_data(struct aps_softc *sc) sc->sensors[APS_SENSOR_MSACT].value = (sc->aps_data.input & APS_INPUT_MS) ? 1 : 0; #if NAPM > 0 - if (lid_suspend && + if (lid_action && (sc->sensors[APS_SENSOR_LIDOPEN].value == 1) && (sc->aps_data.input & APS_INPUT_LIDOPEN) == 0) /* Inform APM that the lid has closed */ |