diff options
-rw-r--r-- | sys/dev/acpi/acpiac.c | 16 | ||||
-rw-r--r-- | sys/dev/acpi/acpibat.c | 21 | ||||
-rw-r--r-- | sys/dev/acpi/acpidev.h | 3 | ||||
-rw-r--r-- | sys/dev/acpi/acpiec.c | 32 | ||||
-rw-r--r-- | sys/dev/acpi/acpitz.c | 17 | ||||
-rw-r--r-- | sys/dev/acpi/dsdt.c | 13 |
6 files changed, 45 insertions, 57 deletions
diff --git a/sys/dev/acpi/acpiac.c b/sys/dev/acpi/acpiac.c index dcfb9859941..afba3d363df 100644 --- a/sys/dev/acpi/acpiac.c +++ b/sys/dev/acpi/acpiac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpiac.c,v 1.9 2006/10/19 08:56:46 marco Exp $ */ +/* $OpenBSD: acpiac.c,v 1.10 2006/11/29 22:17:07 marco Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * @@ -69,7 +69,8 @@ acpiac_attach(struct device *parent, struct device *self, void *aux) sc->sc_acpi = (struct acpi_softc *)parent; sc->sc_devnode = aa->aaa_node->child; - aml_register_notify(sc->sc_devnode->parent, aa->aaa_dev, acpiac_notify, sc); + aml_register_notify(sc->sc_devnode->parent, aa->aaa_dev, + acpiac_notify, sc); acpiac_getsta(sc); @@ -89,12 +90,8 @@ acpiac_attach(struct device *parent, struct device *self, void *aux) sc->sens[0].type = SENSOR_INDICATOR; sensor_add(&sc->sens[0]); sc->sens[0].value = sc->sc_ac_stat; - - if (sensor_task_register(sc, acpiac_refresh, 10)) - printf(", unable to register update task\n"); } -/* XXX this is for debug only, remove later */ void acpiac_refresh(void *arg) { @@ -110,12 +107,12 @@ acpiac_getsta(struct acpiac_softc *sc) { struct aml_value res; - if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "_STA", 0, NULL, NULL) != 0) { + if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "_STA", 0, NULL, NULL)) { dnprintf(10, "%s: no _STA\n", DEVNAME(sc)); } - if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "_PSR", 0, NULL, &res) != 0) { + if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "_PSR", 0, NULL, &res)) { dnprintf(10, "%s: no _PSR\n", DEVNAME(sc)); return (1); @@ -136,10 +133,11 @@ acpiac_notify(struct aml_node *node, int notify_type, void *arg) switch (notify_type) { case 0x80: - acpiac_getsta(sc); + acpiac_refresh(sc); dnprintf(10, "A/C status: %d\n", sc->sc_ac_stat); break; } + return (0); } diff --git a/sys/dev/acpi/acpibat.c b/sys/dev/acpi/acpibat.c index 4fb73597623..86273706158 100644 --- a/sys/dev/acpi/acpibat.c +++ b/sys/dev/acpi/acpibat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpibat.c,v 1.29 2006/10/19 18:02:19 marco Exp $ */ +/* $OpenBSD: acpibat.c,v 1.30 2006/11/29 22:17:07 marco Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * @@ -19,7 +19,6 @@ #include <sys/proc.h> #include <sys/systm.h> #include <sys/device.h> -#include <sys/rwlock.h> #include <sys/malloc.h> #include <sys/sensors.h> @@ -73,8 +72,6 @@ acpibat_attach(struct device *parent, struct device *self, void *aux) sc->sc_acpi = (struct acpi_softc *)parent; sc->sc_devnode = aa->aaa_node->child; - rw_init(&sc->sc_lock, "acpibat"); - if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "_STA", 0, NULL, &res)) dnprintf(10, "%s: no _STA\n", DEVNAME(sc)); @@ -96,9 +93,6 @@ acpibat_attach(struct device *parent, struct device *self, void *aux) sc->sc_bif.bif_type, sc->sc_bif.bif_oem); - if (sensor_task_register(sc, acpibat_refresh, 10)) - printf(", unable to register update task\n"); - acpibat_monitor(sc); } @@ -108,7 +102,6 @@ acpibat_attach(struct device *parent, struct device *self, void *aux) acpibat_notify, sc); } -/* XXX this is for debug only, remove later */ void acpibat_monitor(struct acpibat_softc *sc) { @@ -183,8 +176,6 @@ acpibat_refresh(void *arg) acpibat_getbif(sc); acpibat_getbst(sc); - rw_enter_write(&sc->sc_lock); - sc->sc_sens[0].value = sc->sc_bif.bif_last_capacity * 1000; sc->sc_sens[1].value = sc->sc_bif.bif_warning * 1000; sc->sc_sens[2].value = sc->sc_bif.bif_low * 1000; @@ -206,8 +197,6 @@ acpibat_refresh(void *arg) sc->sc_sens[5].value = sc->sc_bst.bst_rate; sc->sc_sens[6].value = sc->sc_bst.bst_capacity * 1000; sc->sc_sens[7].value = sc->sc_bst.bst_voltage * 1000; - - rw_exit_write(&sc->sc_lock); } int @@ -236,8 +225,6 @@ acpibat_getbif(struct acpibat_softc *sc) goto out; } - rw_enter_write(&sc->sc_lock); - memset(&sc->sc_bif, 0, sizeof sc->sc_bif); sc->sc_bif.bif_power_unit = aml_val2int(res.v_package[0]); sc->sc_bif.bif_capacity = aml_val2int(res.v_package[1]); @@ -258,8 +245,6 @@ acpibat_getbif(struct acpibat_softc *sc) strlcpy(sc->sc_bif.bif_oem, aml_strval(res.v_package[12]), sizeof(sc->sc_bif.bif_oem)); - rw_exit_write(&sc->sc_lock); - dnprintf(60, "power_unit: %u capacity: %u last_cap: %u tech: %u " "volt: %u warn: %u low: %u gran1: %u gran2: %d model: %s " "serial: %s type: %s oem: %s\n", @@ -303,16 +288,12 @@ acpibat_getbst(struct acpibat_softc *sc) goto out; } - rw_enter_write(&sc->sc_lock); - sc->sc_bst.bst_state = aml_val2int(res.v_package[0]); sc->sc_bst.bst_rate = aml_val2int(res.v_package[1]); sc->sc_bst.bst_capacity = aml_val2int(res.v_package[2]); sc->sc_bst.bst_voltage = aml_val2int(res.v_package[3]); aml_freevalue(&res); - rw_exit_write(&sc->sc_lock); - dnprintf(60, "state: %u rate: %u cap: %u volt: %u ", sc->sc_bst.bst_state, sc->sc_bst.bst_rate, diff --git a/sys/dev/acpi/acpidev.h b/sys/dev/acpi/acpidev.h index 7012f4ded51..4fff97272e4 100644 --- a/sys/dev/acpi/acpidev.h +++ b/sys/dev/acpi/acpidev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: acpidev.h,v 1.10 2006/10/19 08:56:46 marco Exp $ */ +/* $OpenBSD: acpidev.h,v 1.11 2006/11/29 22:17:07 marco Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> @@ -270,7 +270,6 @@ struct acpibat_softc { struct acpi_softc *sc_acpi; struct aml_node *sc_devnode; - struct rwlock sc_lock; struct acpibat_bif sc_bif; struct acpibat_bst sc_bst; volatile int sc_bat_present; diff --git a/sys/dev/acpi/acpiec.c b/sys/dev/acpi/acpiec.c index 1e586e99273..859c5ee029f 100644 --- a/sys/dev/acpi/acpiec.c +++ b/sys/dev/acpi/acpiec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpiec.c,v 1.8 2006/11/25 16:25:53 jordan Exp $ */ +/* $OpenBSD: acpiec.c,v 1.9 2006/11/29 22:17:07 marco Exp $ */ /* * Copyright (c) 2006 Can Erkin Acar <canacar@openbsd.org> * @@ -21,7 +21,6 @@ #include <sys/systm.h> #include <sys/device.h> #include <sys/malloc.h> -#include <sys/rwlock.h> #include <machine/bus.h> @@ -98,8 +97,8 @@ struct acpiec_softc { struct aml_node *sc_devnode; u_int32_t sc_gpe; struct acpiec_event sc_events[ACPIEC_MAX_EVENTS]; - struct rwlock sc_lock; int sc_locked; + int sc_handling_events; }; @@ -207,7 +206,14 @@ acpiec_sci_event(struct acpiec_softc *sc) evt = bus_space_read_1(sc->sc_data_bt, sc->sc_data_bh, 0); dnprintf(10, "%s: sci_event: 0x%02x\n", DEVNAME(sc), (int) evt); - aml_evalnode(sc->sc_acpi, sc->sc_events[evt].event, 0, NULL, NULL); + + /* FIXME this call is recursive, this works around that */ + if (sc->sc_handling_events == 0) { + sc->sc_handling_events = 1; + aml_evalnode(sc->sc_acpi, sc->sc_events[evt].event, 0, NULL, + NULL); + sc->sc_handling_events = 0; + } } u_int8_t @@ -248,7 +254,12 @@ void acpiec_read(struct acpiec_softc *sc, u_int8_t addr, int len, u_int8_t *buffer) { int reg; - rw_enter_write(&sc->sc_lock); + + /* + * this works because everything runs in the acpi thread context. + * at some point add a lock to deal with concurrency so that a + * transaction does not get interrupted. + */ sc->sc_locked = 1; acpiec_burst_enable(sc); @@ -258,14 +269,18 @@ acpiec_read(struct acpiec_softc *sc, u_int8_t addr, int len, u_int8_t *buffer) buffer[reg] = acpiec_read_1(sc, addr + reg); sc->sc_locked = 0; - rw_exit_write(&sc->sc_lock); } void acpiec_write(struct acpiec_softc *sc, u_int8_t addr, int len, u_int8_t *buffer) { int reg; - rw_enter_write(&sc->sc_lock); + + /* + * this works because everything runs in the acpi thread context. + * at some point add a lock to deal with concurrency so that a + * transaction does not get interrupted. + */ sc->sc_locked = 1; acpiec_burst_enable(sc); @@ -274,7 +289,6 @@ acpiec_write(struct acpiec_softc *sc, u_int8_t addr, int len, u_int8_t *buffer) acpiec_write_1(sc, addr + reg, buffer[reg]); sc->sc_locked = 0; - rw_exit_write(&sc->sc_lock); } int @@ -301,7 +315,6 @@ acpiec_attach(struct device *parent, struct device *self, void *aux) sc->sc_acpi = (struct acpi_softc *)parent; sc->sc_devnode = aa->aaa_node->child; - rw_init(&sc->sc_lock, "acpi_ec"); sc->sc_locked = 0; if (sc->sc_acpi->sc_ec != NULL) { @@ -358,6 +371,7 @@ acpiec_gpehandler(struct acpi_softc *acpi_sc, int gpe, void *arg) mask = (1L << (gpe & 7)); acpi_write_pmreg(acpi_sc, ACPIREG_GPE_STS, gpe>>3, mask); acpi_write_pmreg(acpi_sc, ACPIREG_GPE_EN, gpe>>3, mask); + return (0); } diff --git a/sys/dev/acpi/acpitz.c b/sys/dev/acpi/acpitz.c index 34358799eec..322ce2e4f51 100644 --- a/sys/dev/acpi/acpitz.c +++ b/sys/dev/acpi/acpitz.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpitz.c,v 1.8 2006/11/02 04:58:20 marco Exp $ */ +/* $OpenBSD: acpitz.c,v 1.9 2006/11/29 22:17:07 marco Exp $ */ /* * Copyright (c) 2006 Can Erkin Acar <canacar@openbsd.org> * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> @@ -21,7 +21,6 @@ #include <sys/signalvar.h> #include <sys/systm.h> #include <sys/device.h> -#include <sys/rwlock.h> #include <sys/malloc.h> #include <machine/bus.h> @@ -42,7 +41,6 @@ struct acpitz_softc { struct acpi_softc *sc_acpi; struct aml_node *sc_devnode; - struct rwlock sc_lock; int sc_tmp; int sc_crt; int sc_hot; @@ -104,8 +102,6 @@ acpitz_attach(struct device *parent, struct device *self, void *aux) sc->sc_acpi = (struct acpi_softc *)parent; sc->sc_devnode = aa->aaa_node->child; - rw_init(&sc->sc_lock, "acpitz"); - memset(&res, 0, sizeof(res)); memset(&env, 0, sizeof(env)); @@ -144,9 +140,6 @@ acpitz_attach(struct device *parent, struct device *self, void *aux) sensor_add(&sc->sc_sens); sc->sc_sens.value = 0; - if (sensor_task_register(sc, acpitz_refresh, 10)) - printf(", unable to register update task"); - printf("\n"); } @@ -302,11 +295,7 @@ acpitz_refresh(void *arg) } } - rw_enter_write(&sc->sc_lock); - sc->sc_sens.value = sc->sc_tmp * 100000; - - rw_exit_write(&sc->sc_lock); } int @@ -315,8 +304,6 @@ acpitz_getreading(struct acpitz_softc *sc, char *name) struct aml_value res; int rv = -1; - rw_enter_write(&sc->sc_lock); - if (aml_evalname(sc->sc_acpi, sc->sc_devnode, name, 0, NULL, &res)) { dnprintf(10, "%s: no %s\n", DEVNAME(sc), name); goto out; @@ -325,7 +312,7 @@ acpitz_getreading(struct acpitz_softc *sc, char *name) rv = aml_val2int(&res); out: aml_freevalue(&res); - rw_exit_write(&sc->sc_lock); + return (rv); } diff --git a/sys/dev/acpi/dsdt.c b/sys/dev/acpi/dsdt.c index f461a681f58..feb26797a13 100644 --- a/sys/dev/acpi/dsdt.c +++ b/sys/dev/acpi/dsdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsdt.c,v 1.66 2006/11/27 23:43:47 jordan Exp $ */ +/* $OpenBSD: dsdt.c,v 1.67 2006/11/29 22:17:07 marco Exp $ */ /* * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> * @@ -420,6 +420,11 @@ acpi_stall(int us) int acpi_mutex_acquire(struct aml_value *val, int timeout) { + /* XXX we currently do not have concurrency so assume mutex succeeds */ + dnprintf(50, "acpi_mutex_acquire\n"); + + return (0); +#if 0 struct acpi_mutex *mtx = val->v_mutex; int rv = 0, ts, tries = 0; @@ -449,11 +454,14 @@ acpi_mutex_acquire(struct aml_value *val, int timeout) rw_exit_write(&mtx->amt_lock); done: return (rv); +#endif } void acpi_mutex_release(struct aml_value *val) { + dnprintf(50, "acpi_mutex_release\n"); +#if 0 struct acpi_mutex *mtx = val->v_mutex; /* sanity */ @@ -473,6 +481,7 @@ acpi_mutex_release(struct aml_value *val) wakeup(mtx); /* wake all of them up */ done: rw_exit_write(&mtx->amt_lock); +#endif } /* @@ -2220,6 +2229,7 @@ aml_parsenamed(struct aml_scope *scope, int opcode, struct aml_value *res) _aml_setvalue(res, AML_OBJTYPE_EVENT, 0, NULL); break; case AMLOP_MUTEX: + /* XXX mutex is unused since we don't have concurrency */ _aml_setvalue(res, AML_OBJTYPE_MUTEX, 0, NULL); res->v_mutex = (struct acpi_mutex *)acpi_os_malloc( sizeof(struct acpi_mutex)); @@ -2664,7 +2674,6 @@ aml_parsemuxaction(struct aml_scope *scope, int opcode, struct aml_value *res) /* Assert: tmparg is AML_OBJTYPE_MUTEX */ i1 = aml_parseint(scope, AMLOP_WORDPREFIX); rv = acpi_mutex_acquire(tmparg->v_objref.ref, i1); - /* Return true if timed out */ aml_setvalue(scope, res, NULL, rv); break; |