summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2010-11-10 21:40:55 +0000
committerkettenis <kettenis@openbsd.org>2010-11-10 21:40:55 +0000
commitd1f44921107ef8e9365ab5556ab856cb2733dd29 (patch)
treec1a75e55d3595c4cc0fff701bbfdb984955b7fd0
parentSeveral updates for the Osprey (AR9380): (diff)
downloadwireguard-openbsd-d1f44921107ef8e9365ab5556ab856cb2733dd29.tar.xz
wireguard-openbsd-d1f44921107ef8e9365ab5556ab856cb2733dd29.zip
The acpibat(4) notify function should not unconditionally call both _BIF
and _BST. Some machines (like the Toshiba Satellite Pro U550 18F mentioned in PR 6508) have AML that does a Notify(0x81) from the _BST method, which leads to infinite recursion. Instead call _BIF when the argument is 0x81 and call _BST when the argument is 0x80 or 0x00 (the latter indicates we're polling). Simplify the battery detection logic while there. ok mikeb@, marco@
-rw-r--r--sys/dev/acpi/acpibat.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/sys/dev/acpi/acpibat.c b/sys/dev/acpi/acpibat.c
index 882846b6c60..8d131487b98 100644
--- a/sys/dev/acpi/acpibat.c
+++ b/sys/dev/acpi/acpibat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpibat.c,v 1.57 2010/08/07 16:55:38 canacar Exp $ */
+/* $OpenBSD: acpibat.c,v 1.58 2010/11/10 21:40:55 kettenis Exp $ */
/*
* Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
*
@@ -186,13 +186,6 @@ acpibat_refresh(void *arg)
return;
}
- /*
- * XXX don't really need _BIF but keep it here in case we
- * miss an insertion/removal event
- */
- acpibat_getbif(sc);
- acpibat_getbst(sc);
-
/* _BIF values are static, sensor 0..3 */
if (sc->sc_bif.bif_last_capacity == BIF_UNKNOWN) {
sc->sc_sens[0].value = 0;
@@ -386,7 +379,8 @@ out:
return (rv);
}
-/* XXX it has been observed that some systems do not propagate battery
+/*
+ * XXX it has been observed that some systems do not propagate battery
* insertion events up to the driver. What seems to happen is that DSDT
* does receive an interrupt however the originator bit is not set.
* This seems to happen when one inserts a 100% full battery. Removal
@@ -400,23 +394,25 @@ acpibat_notify(struct aml_node *node, int notify_type, void *arg)
{
struct acpibat_softc *sc = arg;
int64_t sta;
- int present;
dnprintf(10, "acpibat_notify: %.2x %s\n", notify_type,
sc->sc_devnode->name);
/* Check if installed state of battery has changed */
if (aml_evalinteger(sc->sc_acpi, node, "_STA", 0, NULL, &sta) == 0) {
- present = sta & STA_BATTERY;
- if (!sc->sc_bat_present && present)
+ if (sta & STA_BATTERY)
sc->sc_bat_present = 1;
- else if (sc->sc_bat_present && !present)
+ else
sc->sc_bat_present = 0;
}
+
switch (notify_type) {
+ case 0x00: /* Poll sensors */
case 0x80: /* _BST changed */
+ acpibat_getbst(sc);
break;
case 0x81: /* _BIF changed */
+ acpibat_getbif(sc);
break;
default:
break;