diff options
author | Marco Peereboom <marco@cvs.openbsd.org> | 2006-12-26 23:58:09 +0000 |
---|---|---|
committer | Marco Peereboom <marco@cvs.openbsd.org> | 2006-12-26 23:58:09 +0000 |
commit | 3ec9d9f20a5eb8e2025c6a5eba8af1ebae8c222e (patch) | |
tree | bbac69a627ad9988c23c4bb304bd82b068e66355 /sys | |
parent | 419e67afcb1e33df77313f59d0ae8b207f0ecf2b (diff) |
Add polling to devices that require it such as acpibat and acpitz.
Use the same tsleep/wakeup mechanism as the interrupt code to keep it non-
concurrent.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/acpi/acpi.c | 12 | ||||
-rw-r--r-- | sys/dev/acpi/acpiac.c | 4 | ||||
-rw-r--r-- | sys/dev/acpi/acpibat.c | 6 | ||||
-rw-r--r-- | sys/dev/acpi/acpibtn.c | 5 | ||||
-rw-r--r-- | sys/dev/acpi/acpicpu.c | 4 | ||||
-rw-r--r-- | sys/dev/acpi/acpidev.h | 5 | ||||
-rw-r--r-- | sys/dev/acpi/acpitz.c | 8 | ||||
-rw-r--r-- | sys/dev/acpi/acpivar.h | 7 | ||||
-rw-r--r-- | sys/dev/acpi/dsdt.c | 28 | ||||
-rw-r--r-- | sys/dev/acpi/dsdt.h | 6 |
10 files changed, 64 insertions, 21 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index 645fc909f86..a5cf767e4ba 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.73 2006/12/21 19:59:02 deraadt Exp $ */ +/* $OpenBSD: acpi.c,v 1.74 2006/12/26 23:58:08 marco Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> @@ -46,6 +46,7 @@ int acpi_debug = 16; #endif int acpi_enabled = 0; +int acpi_poll_enabled = 0; #define ACPIEN_RETRIES 15 @@ -778,6 +779,9 @@ acpi_attach(struct device *parent, struct device *self, void *aux) /* Initialize GPE handlers */ acpi_init_gpes(sc); + /* some devices require periodic polling */ + timeout_set(&sc->sc_dev_timeout, acpi_poll, sc); + /* * Take over ACPI control. Note that once we do this, we * effectively tell the system that we have ownership of @@ -1605,6 +1609,12 @@ acpi_isr_thread(void *arg) KNOTE(sc->sc_note, ACPI_EVENT_COMPOSE(ACPI_EV_SLPBTN, acpi_evindex)); } + + /* handle polling here to keep code non-concurrent*/ + if (sc->sc_poll) { + sc->sc_poll = 0; + acpi_poll_notify(); + } } free(thread, M_DEVBUF); diff --git a/sys/dev/acpi/acpiac.c b/sys/dev/acpi/acpiac.c index b9f3ff7b7b8..055bc435ed3 100644 --- a/sys/dev/acpi/acpiac.c +++ b/sys/dev/acpi/acpiac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpiac.c,v 1.13 2006/12/23 17:46:39 deraadt Exp $ */ +/* $OpenBSD: acpiac.c,v 1.14 2006/12/26 23:58:08 marco Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * @@ -69,7 +69,7 @@ acpiac_attach(struct device *parent, struct device *self, void *aux) sc->sc_devnode = aa->aaa_node->child; aml_register_notify(sc->sc_devnode->parent, aa->aaa_dev, - acpiac_notify, sc); + acpiac_notify, sc, ACPIDEV_NOPOLL); acpiac_getsta(sc); printf(": AC unit "); diff --git a/sys/dev/acpi/acpibat.c b/sys/dev/acpi/acpibat.c index e20ae8f01b7..d719a94c3be 100644 --- a/sys/dev/acpi/acpibat.c +++ b/sys/dev/acpi/acpibat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpibat.c,v 1.36 2006/12/23 17:46:39 deraadt Exp $ */ +/* $OpenBSD: acpibat.c,v 1.37 2006/12/26 23:58:08 marco Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * @@ -98,7 +98,7 @@ acpibat_attach(struct device *parent, struct device *self, void *aux) acpibat_refresh(sc); aml_register_notify(sc->sc_devnode->parent, aa->aaa_dev, - acpibat_notify, sc); + acpibat_notify, sc, ACPIDEV_POLL); } void @@ -345,8 +345,6 @@ acpibat_notify(struct aml_node *node, int notify_type, void *arg) } break; default: - printf("%s: unhandled battery event %x\n", DEVNAME(sc), - notify_type); break; } diff --git a/sys/dev/acpi/acpibtn.c b/sys/dev/acpi/acpibtn.c index 0ab39c1a40e..b47cb8b12e9 100644 --- a/sys/dev/acpi/acpibtn.c +++ b/sys/dev/acpi/acpibtn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpibtn.c,v 1.14 2006/12/21 11:23:41 deraadt Exp $ */ +/* $OpenBSD: acpibtn.c,v 1.15 2006/12/26 23:58:08 marco Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * @@ -99,7 +99,8 @@ acpibtn_attach(struct device *parent, struct device *self, void *aux) printf(": %s\n", sc->sc_devnode->parent->name); - aml_register_notify(sc->sc_devnode->parent, aa->aaa_dev, acpibtn_notify, sc); + aml_register_notify(sc->sc_devnode->parent, aa->aaa_dev, acpibtn_notify, + sc, ACPIDEV_NOPOLL); } int diff --git a/sys/dev/acpi/acpicpu.c b/sys/dev/acpi/acpicpu.c index 60289576b20..c76702443c4 100644 --- a/sys/dev/acpi/acpicpu.c +++ b/sys/dev/acpi/acpicpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpicpu.c,v 1.16 2006/12/21 11:23:41 deraadt Exp $ */ +/* $OpenBSD: acpicpu.c,v 1.17 2006/12/26 23:58:08 marco Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * @@ -131,7 +131,7 @@ acpicpu_attach(struct device *parent, struct device *self, void *aux) i < sc->sc_pss_len - 1 ? ", " : " MHz\n"); aml_register_notify(sc->sc_devnode->parent, NULL, - acpicpu_notify, sc); + acpicpu_notify, sc, ACPIDEV_NOPOLL); if (setperf_prio < 30) { cpu_setperf = acpicpu_setperf; diff --git a/sys/dev/acpi/acpidev.h b/sys/dev/acpi/acpidev.h index 4834910f2fb..d1183cc6eda 100644 --- a/sys/dev/acpi/acpidev.h +++ b/sys/dev/acpi/acpidev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: acpidev.h,v 1.13 2006/12/23 17:46:39 deraadt Exp $ */ +/* $OpenBSD: acpidev.h,v 1.14 2006/12/26 23:58:08 marco Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> @@ -24,6 +24,9 @@ #define DEVNAME(s) ((s)->sc_dev.dv_xname) +#define ACPIDEV_NOPOLL 0 +#define ACPIDEV_POLL 1 + /* * _BIF (Battery InFormation) * Arguments: none diff --git a/sys/dev/acpi/acpitz.c b/sys/dev/acpi/acpitz.c index 2d4f9200136..143a9ec1c85 100644 --- a/sys/dev/acpi/acpitz.c +++ b/sys/dev/acpi/acpitz.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpitz.c,v 1.13 2006/12/23 17:46:39 deraadt Exp $ */ +/* $OpenBSD: acpitz.c,v 1.14 2006/12/26 23:58:08 marco Exp $ */ /* * Copyright (c) 2006 Can Erkin Acar <canacar@openbsd.org> * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> @@ -126,9 +126,6 @@ acpitz_attach(struct device *parent, struct device *self, void *aux) sc->sc_tc2 = acpitz_getreading(sc, "_TC2"); sc->sc_psv = acpitz_getreading(sc, "_PSV"); - aml_register_notify(sc->sc_devnode->parent, NULL, - acpitz_notify, sc); - strlcpy(sc->sc_sensdev.xname, DEVNAME(sc), sizeof(sc->sc_sensdev.xname)); strlcpy(sc->sc_sens.desc, "zone temperature", @@ -137,6 +134,9 @@ acpitz_attach(struct device *parent, struct device *self, void *aux) sensor_attach(&sc->sc_sensdev, &sc->sc_sens); sensordev_install(&sc->sc_sensdev); sc->sc_sens.value = 0; + + aml_register_notify(sc->sc_devnode->parent, NULL, + acpitz_notify, sc, ACPIDEV_POLL); } int diff --git a/sys/dev/acpi/acpivar.h b/sys/dev/acpi/acpivar.h index ee3c728f6ac..b96470c14c5 100644 --- a/sys/dev/acpi/acpivar.h +++ b/sys/dev/acpi/acpivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: acpivar.h,v 1.32 2006/12/21 19:59:02 deraadt Exp $ */ +/* $OpenBSD: acpivar.h,v 1.33 2006/12/26 23:58:08 marco Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * @@ -188,6 +188,9 @@ struct acpi_softc { struct acpi_ac_head sc_ac; struct acpi_bat_head sc_bat; + + struct timeout sc_dev_timeout; + int sc_poll; }; #define GPE_NONE 0x00 @@ -240,6 +243,8 @@ void acpiec_handle_events(struct acpiec_softc *); int acpi_read_pmreg(struct acpi_softc *, int, int); void acpi_write_pmreg(struct acpi_softc *, int, int, int); + +void acpi_poll(void *); #endif #endif /* !_DEV_ACPI_ACPIVAR_H_ */ diff --git a/sys/dev/acpi/dsdt.c b/sys/dev/acpi/dsdt.c index a6a5ff6d64d..7897d74f774 100644 --- a/sys/dev/acpi/dsdt.c +++ b/sys/dev/acpi/dsdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsdt.c,v 1.73 2006/12/23 17:19:06 canacar Exp $ */ +/* $OpenBSD: dsdt.c,v 1.74 2006/12/26 23:58:08 marco Exp $ */ /* * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> @@ -348,6 +348,7 @@ struct aml_notify_data { char pnpid[20]; void *cbarg; int (*cbproc)(struct aml_node *, int, void *); + int poll; SLIST_ENTRY(aml_notify_data) link; }; @@ -547,12 +548,22 @@ aml_gasio(struct acpi_softc *sc, int type, uint64_t base, uint64_t length, /* * @@@: Notify functions */ +void +acpi_poll(void *arg) +{ + dsdt_softc->sc_poll = 1; + dsdt_softc->sc_wakeup = 0; + wakeup(dsdt_softc); + + timeout_add(&dsdt_softc->sc_dev_timeout, 10 * hz); +} void aml_register_notify(struct aml_node *node, const char *pnpid, - int (*proc)(struct aml_node *, int, void *), void *arg) + int (*proc)(struct aml_node *, int, void *), void *arg, int poll) { struct aml_notify_data *pdata; + extern int acpi_poll_enabled; dnprintf(10, "aml_register_notify: %s %s %x\n", node->name, pnpid ? pnpid : "", proc); @@ -561,11 +572,15 @@ aml_register_notify(struct aml_node *node, const char *pnpid, pdata->node = node; pdata->cbarg = arg; pdata->cbproc = proc; + pdata->poll = poll; if (pnpid) strlcpy(pdata->pnpid, pnpid, sizeof(pdata->pnpid)); SLIST_INSERT_HEAD(&aml_notify_list, pdata, link); + + if (poll && !acpi_poll_enabled) + timeout_add(&dsdt_softc->sc_dev_timeout, 10 * hz); } void @@ -594,6 +609,15 @@ aml_notify_dev(const char *pnpid, int notify_value) pdata->cbproc(pdata->node, notify_value, pdata->cbarg); } +void acpi_poll_notify(void) +{ + struct aml_notify_data *pdata = NULL; + + SLIST_FOREACH(pdata, &aml_notify_list, link) + if (pdata->cbproc && pdata->poll) + pdata->cbproc(pdata->node, 0, pdata->cbarg); +} + /* * @@@: Namespace functions */ diff --git a/sys/dev/acpi/dsdt.h b/sys/dev/acpi/dsdt.h index 319be28d0d7..546cf2350e9 100644 --- a/sys/dev/acpi/dsdt.h +++ b/sys/dev/acpi/dsdt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dsdt.h,v 1.23 2006/12/21 19:59:02 deraadt Exp $ */ +/* $OpenBSD: dsdt.h,v 1.24 2006/12/26 23:58:08 marco Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * @@ -70,7 +70,8 @@ int acpi_parse_aml(struct acpi_softc *, u_int8_t *, int aml_eval_object(struct acpi_softc *, struct aml_node *, struct aml_value *, int, struct aml_value *); void aml_register_notify(struct aml_node *, const char *, - int (*)(struct aml_node *, int, void *), void *); + int (*)(struct aml_node *, int, void *), void *, + int); u_int64_t aml_getpciaddr(struct acpi_softc *, struct aml_node *); @@ -193,5 +194,6 @@ void aml_walknodes(struct aml_node *, int, int (*)(struct aml_node *, void *), void *); void aml_postparse(void); +void acpi_poll_notify(void); #endif /* __DEV_ACPI_DSDT_H__ */ |