summaryrefslogtreecommitdiff
path: root/sys/dev/acpi
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2021-10-30 23:24:49 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2021-10-30 23:24:49 +0000
commit4a040f14130cf3ef019f4e8666a73b85521bc8e6 (patch)
tree316e7afd09cdd81cc068bd9bc84235b51c9d9fba /sys/dev/acpi
parenta8538665d5b22f1fa88d61c5df3032dd59684611 (diff)
Change hw.perfpolicy=auto by default, at startup. If the system has AC
power connected (default is yes when no driver differentiates) then default to 100% performance. On battery, use the existing auto algorithm (which is admittedly somewhat unrefined). This change overrides the system/BIOS speed and puts OpenBSD in control. As this happens very early during boot, besides speedups in all usage usage patterns, some surprises: unhibernate and sysupgrade times are cut in half. note: on a few architectures, the setperf fn pointer is changed late, and thus the auto algorithm stops timeing out. kettenis and i will look for a solution. in snaps for more than a week. ok kettenis
Diffstat (limited to 'sys/dev/acpi')
-rw-r--r--sys/dev/acpi/acpi.c3
-rw-r--r--sys/dev/acpi/acpiac.c6
2 files changed, 7 insertions, 2 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c
index 1250bc3468c..8e2ac095c6c 100644
--- a/sys/dev/acpi/acpi.c
+++ b/sys/dev/acpi/acpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi.c,v 1.399 2021/07/20 00:41:54 mlarkin Exp $ */
+/* $OpenBSD: acpi.c,v 1.400 2021/10/30 23:24:46 deraadt Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -3556,6 +3556,7 @@ acpiioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
case APM_IOC_GETPOWER:
/* A/C */
pi->ac_state = APM_AC_UNKNOWN;
+// XXX replace with new power code
SLIST_FOREACH(ac, &sc->sc_ac, aac_link) {
if (ac->aac_softc->sc_ac_stat == PSR_ONLINE)
pi->ac_state = APM_AC_ON;
diff --git a/sys/dev/acpi/acpiac.c b/sys/dev/acpi/acpiac.c
index e2943ea4504..acd932280b5 100644
--- a/sys/dev/acpi/acpiac.c
+++ b/sys/dev/acpi/acpiac.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpiac.c,v 1.33 2020/06/10 22:26:40 jca Exp $ */
+/* $OpenBSD: acpiac.c,v 1.34 2021/10/30 23:24:47 deraadt Exp $ */
/*
* Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
*
@@ -70,6 +70,7 @@ void
acpiac_attach(struct device *parent, struct device *self, void *aux)
{
struct acpiac_softc *sc = (struct acpiac_softc *)self;
+ extern int hw_power;
struct acpi_attach_args *aa = aux;
sc->sc_acpi = (struct acpi_softc *)parent;
@@ -83,6 +84,7 @@ acpiac_attach(struct device *parent, struct device *self, void *aux)
printf("offline\n");
else
printf("in unknown state\n");
+ hw_power = (sc->sc_ac_stat == PSR_ONLINE);
strlcpy(sc->sc_sensdev.xname, DEVNAME(sc),
sizeof(sc->sc_sensdev.xname));
@@ -140,6 +142,7 @@ int
acpiac_notify(struct aml_node *node, int notify_type, void *arg)
{
struct acpiac_softc *sc = arg;
+ extern int hw_power;
dnprintf(10, "acpiac_notify: %.2x %s\n", notify_type,
DEVNAME(sc));
@@ -159,5 +162,6 @@ acpiac_notify(struct aml_node *node, int notify_type, void *arg)
dnprintf(10, "A/C status: %d\n", sc->sc_ac_stat);
break;
}
+ hw_power = (sc->sc_ac_stat == PSR_ONLINE);
return (0);
}