summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2005-08-04 18:34:26 +0000
committerume <ume@FreeBSD.org>2005-08-04 18:34:26 +0000
commit11ce5e3c28af8da73f6f5996403a00280336fbc7 (patch)
treec574a18704504d39247c64914807a8d413fbeac0 /sys
parenta1fc2e1330c98642f81c5438892f71b8f66c025a (diff)
downloadFreeBSD-src-11ce5e3c28af8da73f6f5996403a00280336fbc7.zip
FreeBSD-src-11ce5e3c28af8da73f6f5996403a00280336fbc7.tar.gz
don't do mutex locking around kthread_create() call.
Reported by: Maxim Maximov <mcsi__at__mcsi.pp.ru>
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/acpica/acpi_thermal.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/sys/dev/acpica/acpi_thermal.c b/sys/dev/acpica/acpi_thermal.c
index 302df3d..e9034ed 100644
--- a/sys/dev/acpica/acpi_thermal.c
+++ b/sys/dev/acpica/acpi_thermal.c
@@ -112,6 +112,7 @@ struct acpi_tz_softc {
/* passive cooling */
struct proc *tz_cooling_proc;
+ int tz_cooling_proc_running;
int tz_cooling_enabled;
int tz_cooling_active;
int tz_cooling_updated;
@@ -198,6 +199,7 @@ acpi_tz_attach(device_t dev)
sc->tz_active = TZ_ACTIVE_NONE;
sc->tz_thflags = TZ_THFLAG_NONE;
sc->tz_cooling_proc = NULL;
+ sc->tz_cooling_proc_running = FALSE;
sc->tz_cooling_active = FALSE;
sc->tz_cooling_updated = FALSE;
@@ -994,8 +996,9 @@ acpi_tz_cooling_thread(void *arg)
acpi_tz_cpufreq_restore(sc);
sc->tz_cooling_active = FALSE;
}
- ACPI_LOCK(thermal);
sc->tz_cooling_proc = NULL;
+ ACPI_LOCK(thermal);
+ sc->tz_cooling_proc_running = FALSE;
ACPI_UNLOCK(thermal);
kthread_exit(0);
}
@@ -1019,16 +1022,25 @@ acpi_tz_cooling_thread_start(struct acpi_tz_softc *sc)
int error;
char name[16];
- error = 0;
ACPI_LOCK(thermal);
+ if (sc->tz_cooling_proc_running) {
+ ACPI_UNLOCK(thermal);
+ return (0);
+ }
+ sc->tz_cooling_proc_running = TRUE;
+ ACPI_UNLOCK(thermal);
+ error = 0;
if (sc->tz_cooling_proc == NULL) {
snprintf(name, sizeof(name), "acpi_cooling%d",
device_get_unit(sc->tz_dev));
error = kthread_create(acpi_tz_cooling_thread, sc,
&sc->tz_cooling_proc, RFHIGHPID, 0, name);
- if (error != 0)
+ if (error != 0) {
device_printf(sc->tz_dev, "could not create thread - %d", error);
+ ACPI_LOCK(thermal);
+ sc->tz_cooling_proc_running = FALSE;
+ ACPI_UNLOCK(thermal);
+ }
}
- ACPI_UNLOCK(thermal);
return (error);
}
OpenPOWER on IntegriCloud