diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2010-08-08 20:45:19 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2010-08-08 20:45:19 +0000 |
commit | 6642620a0de9c576487d1d814ca28606fc9f1ba9 (patch) | |
tree | 60dbdf6eb2c1ed6b210322fd440e833477b4e189 /sys/dev | |
parent | 1bcb978a282b4836390048e46b7a652d102342ac (diff) |
Close race between the acpi thread and wscons ioctls running in process
context. We might rip this out post-release and replace it with a solution
that serializes things in a more obvious way.
ok deraadt@, miod@ and "those crazy texans who ok anything"
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/acpi/acpi.c | 8 | ||||
-rw-r--r-- | sys/dev/acpi/acpivar.h | 4 | ||||
-rw-r--r-- | sys/dev/acpi/acpivout.c | 6 |
3 files changed, 15 insertions, 3 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index 6017893f7b6..7ca92e2bcc1 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.208 2010/08/08 02:23:20 deraadt Exp $ */ +/* $OpenBSD: acpi.c,v 1.209 2010/08/08 20:45:18 kettenis Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> @@ -553,6 +553,8 @@ acpi_attach(struct device *parent, struct device *self, void *aux) sc->sc_iot = ba->ba_iot; sc->sc_memt = ba->ba_memt; + rw_init(&sc->sc_lck, "acpilk"); + acpi_softc = sc; if (acpi_map(ba->ba_acpipbase, sizeof(struct acpi_rsdp), &handle)) { @@ -2027,11 +2029,15 @@ acpi_thread(void *arg) } } + rw_enter_write(&sc->sc_lck); + while (thread->running) { s = spltty(); while (sc->sc_threadwaiting) { dnprintf(10, "acpi going to sleep...\n"); + rw_exit_write(&sc->sc_lck); tsleep(sc, PWAIT, "acpi0", 0); + rw_enter_write(&sc->sc_lck); } sc->sc_threadwaiting = 1; splx(s); diff --git a/sys/dev/acpi/acpivar.h b/sys/dev/acpi/acpivar.h index 6cf2bf2c5cd..2d8430bb394 100644 --- a/sys/dev/acpi/acpivar.h +++ b/sys/dev/acpi/acpivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: acpivar.h,v 1.65 2010/08/07 17:15:23 kettenis Exp $ */ +/* $OpenBSD: acpivar.h,v 1.66 2010/08/08 20:45:18 kettenis Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * @@ -212,6 +212,8 @@ struct acpi_softc { int sc_sleepmode; int sc_powerdown; + struct rwlock sc_lck; + struct { int slp_typa; int slp_typb; diff --git a/sys/dev/acpi/acpivout.c b/sys/dev/acpi/acpivout.c index 425d04975fc..160ebfa6850 100644 --- a/sys/dev/acpi/acpivout.c +++ b/sys/dev/acpi/acpivout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpivout.c,v 1.6 2010/07/21 19:35:15 deraadt Exp $ */ +/* $OpenBSD: acpivout.c,v 1.7 2010/08/08 20:45:18 kettenis Exp $ */ /* * Copyright (c) 2009 Paul Irofti <pirofti@openbsd.org> * @@ -336,7 +336,9 @@ acpivout_get_param(struct wsdisplay_param *dp) if (sc != NULL && sc->sc_bcl_len != 0) { dp->min = 0; dp->max = sc->sc_bcl[sc->sc_bcl_len - 1]; + rw_enter_write(&sc->sc_acpi->sc_lck); dp->curval = acpivout_get_brightness(sc); + rw_exit_write(&sc->sc_acpi->sc_lck); if (dp->curval != -1) return 0; } @@ -363,8 +365,10 @@ acpivout_set_param(struct wsdisplay_param *dp) break; } if (sc != NULL && sc->sc_bcl_len != 0) { + rw_enter_write(&sc->sc_acpi->sc_lck); exact = acpivout_find_brightness(sc, dp->curval); acpivout_set_brightness(sc, exact); + rw_exit_write(&sc->sc_acpi->sc_lck); return 0; } return -1; |