From: deraadt Date: Thu, 5 Aug 2010 21:10:06 +0000 (+0000) Subject: new i386/amd64 machdep.lidsuspend sysctl which decides whether a lid X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a48c61d8b1d3dd859bd63050a426cb3940d5b9a6;p=openbsd new i386/amd64 machdep.lidsuspend sysctl which decides whether a lid close causes a suspend. resumes are not tied to this; they happen unconditionally. this is a temporary knob for the 4.8 release; afterwards it will move to a more convenient place much moaning discussing where to put the knob with kettenis tested by various including phessler --- diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index 4c0701b40d6..c68a2b31c97 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.118 2010/07/25 21:43:38 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.119 2010/08/05 21:10:10 deraadt Exp $ */ /* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */ /*- @@ -178,6 +178,7 @@ paddr_t lo32_paddr; paddr_t tramp_pdirpa; int kbd_reset; +int lid_suspend; /* * safepri is a safe priority for sleep to set for a spin-wait @@ -530,6 +531,8 @@ cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, #endif case CPU_XCRYPT: return (sysctl_rdint(oldp, oldlenp, newp, amd64_has_xcrypt)); + case CPU_LIDSUSPEND: + return (sysctl_int(oldp, oldlenp, newp, newlen, &lid_suspend)); default: return (EOPNOTSUPP); } diff --git a/sys/arch/amd64/include/cpu.h b/sys/arch/amd64/include/cpu.h index a3e5a30d11a..fd16b34f02e 100644 --- a/sys/arch/amd64/include/cpu.h +++ b/sys/arch/amd64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.53 2010/07/25 21:43:38 deraadt Exp $ */ +/* $OpenBSD: cpu.h,v 1.54 2010/08/05 21:10:10 deraadt Exp $ */ /* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */ /*- @@ -348,7 +348,8 @@ void mp_setperf_init(void); #define CPU_KBDRESET 10 /* keyboard reset under pcvt */ #define CPU_APMHALT 11 /* halt -p hack */ #define CPU_XCRYPT 12 /* supports VIA xcrypt in userland */ -#define CPU_MAXID 13 /* number of valid machdep ids */ +#define CPU_LIDSUSPEND 13 /* lid close causes a suspend */ +#define CPU_MAXID 14 /* number of valid machdep ids */ #define CTL_MACHDEP_NAMES { \ { 0, 0 }, \ @@ -364,6 +365,7 @@ void mp_setperf_init(void); { "kbdreset", CTLTYPE_INT }, \ { "apmhalt", CTLTYPE_INT }, \ { "xcrypt", CTLTYPE_INT }, \ + { "lidsuspend", CTLTYPE_INT }, \ } /* diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index 73da8f7d959..1f0818edcc1 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.480 2010/07/25 21:43:35 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.481 2010/08/05 21:10:09 deraadt Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -242,6 +242,7 @@ void (*update_cpuspeed)(void) = NULL; void via_update_sensor(void *args); #endif int kbd_reset; +int lid_suspend; /* * safepri is a safe priority for sleep to set for a spin-wait @@ -3411,6 +3412,8 @@ cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, return (sysctl_rdint(oldp, oldlenp, newp, i386_has_sse2)); case CPU_XCRYPT: return (sysctl_rdint(oldp, oldlenp, newp, i386_has_xcrypt)); + case CPU_LIDSUSPEND: + return (sysctl_int(oldp, oldlenp, newp, newlen, &lid_suspend)); default: return (EOPNOTSUPP); } diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h index 04ee23d9986..7ab24ef2037 100644 --- a/sys/arch/i386/include/cpu.h +++ b/sys/arch/i386/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.112 2010/07/25 21:43:37 deraadt Exp $ */ +/* $OpenBSD: cpu.h,v 1.113 2010/08/05 21:10:09 deraadt Exp $ */ /* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */ /*- @@ -456,7 +456,8 @@ void vm86_gpfault(struct proc *, int); #define CPU_SSE 14 /* supports SSE */ #define CPU_SSE2 15 /* supports SSE2 */ #define CPU_XCRYPT 16 /* supports VIA xcrypt in userland */ -#define CPU_MAXID 17 /* number of valid machdep ids */ +#define CPU_LIDSUSPEND 17 /* lid close causes a suspend */ +#define CPU_MAXID 18 /* number of valid machdep ids */ #define CTL_MACHDEP_NAMES { \ { 0, 0 }, \ @@ -476,6 +477,7 @@ void vm86_gpfault(struct proc *, int); { "sse", CTLTYPE_INT }, \ { "sse2", CTLTYPE_INT }, \ { "xcrypt", CTLTYPE_INT }, \ + { "lidsuspend", CTLTYPE_INT }, \ } /* diff --git a/sys/dev/acpi/acpibtn.c b/sys/dev/acpi/acpibtn.c index 739c3a134e5..278e296cd4f 100644 --- a/sys/dev/acpi/acpibtn.c +++ b/sys/dev/acpi/acpibtn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpibtn.c,v 1.30 2010/08/05 20:11:32 deraadt Exp $ */ +/* $OpenBSD: acpibtn.c,v 1.31 2010/08/05 21:10:06 deraadt Exp $ */ /* * Copyright (c) 2005 Marco Peereboom * @@ -120,14 +120,12 @@ acpibtn_getsta(struct acpibtn_softc *sc) return (0); } -/* XXX tie this to a sysctl later */ -int acpi_lid_suspend = 0; - int acpibtn_notify(struct aml_node *node, int notify_type, void *arg) { struct acpibtn_softc *sc = arg; #ifndef SMALL_KERNEL + extern int lid_suspend; int64_t lid; #endif @@ -143,7 +141,7 @@ acpibtn_notify(struct aml_node *node, int notify_type, void *arg) * _LID method. 0 means the lid is closed and we * should go to sleep. */ - if (acpi_lid_suspend == 0) + if (lid_suspend == 0) break; if (aml_evalinteger(sc->sc_acpi, sc->sc_devnode, "_LID", 0, NULL, &lid))