From 78ac519a498ddeaa7fc3934ccfeb5fbec3fe5450 Mon Sep 17 00:00:00 2001 From: deraadt Date: Tue, 20 Jul 2010 12:12:19 +0000 Subject: [PATCH] tsleep() and EWOULDBLOCK was being used incorrectly for fixed minumum delays. tsleep() on an unknown wait channel, to ensure the minimum is met, and that wakeup()'s don't make the delay get restarted over and over.. ok kettenis mlarkin --- sys/dev/acpi/acpitz.c | 9 ++------- sys/dev/acpi/acpivar.h | 3 ++- sys/dev/acpi/dsdt.c | 11 +++++------ 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/sys/dev/acpi/acpitz.c b/sys/dev/acpi/acpitz.c index 811b0548742..54cefb4df01 100644 --- a/sys/dev/acpi/acpitz.c +++ b/sys/dev/acpi/acpitz.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpitz.c,v 1.35 2010/01/13 23:31:25 marco Exp $ */ +/* $OpenBSD: acpitz.c,v 1.36 2010/07/20 12:12:19 deraadt Exp $ */ /* * Copyright (c) 2006 Can Erkin Acar * Copyright (c) 2005 Marco Peereboom @@ -442,12 +442,7 @@ acpitz_gettempreading(struct acpitz_softc *sc, char *name) "debouncing\n", DEVNAME(sc), tmp, name); } - /* debounce value */ - if (cold) - delay(1000000); - else - while (tsleep(sc, PWAIT, "tzsleep", hz) != - EWOULDBLOCK); + acpi_sleep(1000, "acpitz"); /* debounce: 1000 msec */ } if (i >= ACPITZ_TMP_RETRY) { printf("%s: %s: failed to read %s\n", DEVNAME(sc), diff --git a/sys/dev/acpi/acpivar.h b/sys/dev/acpi/acpivar.h index 57b8b8cae97..d87f1ec1697 100644 --- a/sys/dev/acpi/acpivar.h +++ b/sys/dev/acpi/acpivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: acpivar.h,v 1.61 2010/07/19 16:57:27 deraadt Exp $ */ +/* $OpenBSD: acpivar.h,v 1.62 2010/07/20 12:12:19 deraadt Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert * @@ -322,6 +322,7 @@ int acpi_read_pmreg(struct acpi_softc *, int, int); void acpi_write_pmreg(struct acpi_softc *, int, int, int); void acpi_poll(void *); +void acpi_sleep(int, char *); int acpi_matchhids(struct acpi_attach_args *, const char *[], const char *); diff --git a/sys/dev/acpi/dsdt.c b/sys/dev/acpi/dsdt.c index 87ad8140f30..112280fe3c8 100644 --- a/sys/dev/acpi/dsdt.c +++ b/sys/dev/acpi/dsdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsdt.c,v 1.167 2010/07/19 16:57:27 deraadt Exp $ */ +/* $OpenBSD: dsdt.c,v 1.168 2010/07/20 12:12:20 deraadt Exp $ */ /* * Copyright (c) 2005 Jordan Hargrave * @@ -93,7 +93,6 @@ struct aml_opcode *aml_findopcode(int); void *_acpi_os_malloc(size_t, const char *, int); void _acpi_os_free(void *, const char *, int); -void acpi_sleep(int); void acpi_stall(int); struct aml_value *aml_callosi(struct aml_scope *, struct aml_value *); @@ -456,8 +455,9 @@ acpi_walkmem(int sig, const char *lbl) } void -acpi_sleep(int ms) +acpi_sleep(int ms, char *reason) { + static int acpinowait; int to = ms * hz / 1000; if (cold) @@ -465,8 +465,7 @@ acpi_sleep(int ms) else { if (to <= 0) to = 1; - while (tsleep(acpi_softc, PWAIT, "asleep", to) != - EWOULDBLOCK); + tsleep(&acpinowait, PWAIT, reason, to); } } @@ -3887,7 +3886,7 @@ aml_xparse(struct aml_scope *scope, int ret_type, const char *stype) break; case AMLOP_SLEEP: /* Sleep: i */ - acpi_sleep(opargs[0]->v_integer); + acpi_sleep(opargs[0]->v_integer, "amlsleep"); break; case AMLOP_NOTIFY: /* Notify: Si */ -- 2.20.1