After comments from Andrew Doran:
- The mutex for the callout handler must run at IPL_SOFTCLOCK. - Just stop the callout in sysmon_envsys_unregister() and don't wait for the callout to finish.
This commit is contained in:
parent
10564377d6
commit
714201def5
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sysmon_envsys.c,v 1.72 2007/11/16 08:00:16 xtraeme Exp $ */
|
||||
/* $NetBSD: sysmon_envsys.c,v 1.73 2007/11/20 17:24:32 xtraeme Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 Juan Romero Pardines.
|
||||
|
@ -64,7 +64,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.72 2007/11/16 08:00:16 xtraeme Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.73 2007/11/20 17:24:32 xtraeme Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -102,7 +102,7 @@ __KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.72 2007/11/16 08:00:16 xtraeme E
|
|||
*/
|
||||
|
||||
kmutex_t sme_mtx, sme_events_mtx, sme_callout_mtx;
|
||||
kcondvar_t sme_cv, sme_callout_cv;
|
||||
kcondvar_t sme_cv;
|
||||
|
||||
/*
|
||||
* Types of properties that can be set via userland.
|
||||
|
@ -135,9 +135,8 @@ sysmon_envsys_init(void)
|
|||
LIST_INIT(&sysmon_envsys_list);
|
||||
mutex_init(&sme_mtx, MUTEX_DEFAULT, IPL_NONE);
|
||||
mutex_init(&sme_events_mtx, MUTEX_DEFAULT, IPL_NONE);
|
||||
mutex_init(&sme_callout_mtx, MUTEX_SPIN, IPL_NONE);
|
||||
mutex_init(&sme_callout_mtx, MUTEX_SPIN, IPL_SOFTCLOCK);
|
||||
cv_init(&sme_cv, "smeworker");
|
||||
cv_init(&sme_callout_cv, "smecallout");
|
||||
sme_propd = prop_dictionary_create();
|
||||
}
|
||||
|
||||
|
@ -890,12 +889,9 @@ sysmon_envsys_unregister(struct sysmon_envsys *sme)
|
|||
while (sme->sme_flags & SME_FLAG_BUSY)
|
||||
cv_wait(&sme_cv, &sme_mtx);
|
||||
/*
|
||||
* Wait for the callout to finish.
|
||||
* Stop the callout.
|
||||
*/
|
||||
mutex_enter(&sme_callout_mtx);
|
||||
while (sme->sme_flags & SME_CALLOUT_BUSY)
|
||||
cv_wait(&sme_callout_cv, &sme_callout_mtx);
|
||||
mutex_exit(&sme_callout_mtx);
|
||||
callout_stop(&sme->sme_callout);
|
||||
/*
|
||||
* Decrement global sensors counter (only useful for compatibility).
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sysmon_envsys_events.c,v 1.45 2007/11/16 08:00:16 xtraeme Exp $ */
|
||||
/* $NetBSD: sysmon_envsys_events.c,v 1.46 2007/11/20 17:24:32 xtraeme Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 Juan Romero Pardines.
|
||||
|
@ -30,7 +30,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.45 2007/11/16 08:00:16 xtraeme Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.46 2007/11/20 17:24:32 xtraeme Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -63,7 +63,7 @@ static const struct sme_sensor_event sme_sensor_event[] = {
|
|||
};
|
||||
|
||||
kmutex_t sme_mtx, sme_events_mtx, sme_callout_mtx;
|
||||
kcondvar_t sme_cv, sme_callout_cv;
|
||||
kcondvar_t sme_cv;
|
||||
static bool sysmon_low_power = false;
|
||||
|
||||
#define SME_EVTIMO (SME_EVENTS_DEFTIMEOUT * hz)
|
||||
|
@ -413,7 +413,6 @@ sme_events_check(void *arg)
|
|||
KASSERT(sme != NULL);
|
||||
|
||||
mutex_enter(&sme_callout_mtx);
|
||||
sme->sme_flags |= SME_CALLOUT_BUSY;
|
||||
|
||||
LIST_FOREACH(see, &sme->sme_events_list, see_list)
|
||||
workqueue_enqueue(sme->sme_wq, &see->see_wk, NULL);
|
||||
|
@ -429,11 +428,9 @@ sme_events_check(void *arg)
|
|||
else
|
||||
timo = SME_EVTIMO;
|
||||
|
||||
sme->sme_flags &= ~SME_CALLOUT_BUSY;
|
||||
if (!sysmon_low_power)
|
||||
callout_schedule(&sme->sme_callout, timo);
|
||||
|
||||
cv_broadcast(&sme_callout_cv);
|
||||
mutex_exit(&sme_callout_mtx);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sysmon_envsysvar.h,v 1.25 2007/11/16 08:18:33 xtraeme Exp $ */
|
||||
/* $NetBSD: sysmon_envsysvar.h,v 1.26 2007/11/20 17:24:32 xtraeme Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 Juan Romero Pardines.
|
||||
|
@ -113,7 +113,6 @@ extern kmutex_t sme_mtx; /* mutex for devices/events */
|
|||
extern kmutex_t sme_events_mtx; /* to init/destroy the events layer */
|
||||
extern kmutex_t sme_callout_mtx; /* for the callouts */
|
||||
extern kcondvar_t sme_cv; /* to wait for devices/events working */
|
||||
extern kcondvar_t sme_callout_cv; /* to wait for the callout handler */
|
||||
|
||||
/*
|
||||
* linked list for the sysmon envsys devices.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sysmonvar.h,v 1.21 2007/11/16 08:00:16 xtraeme Exp $ */
|
||||
/* $NetBSD: sysmonvar.h,v 1.22 2007/11/20 17:24:32 xtraeme Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 Zembu Labs, Inc.
|
||||
|
@ -71,7 +71,6 @@ struct sysmon_envsys {
|
|||
#define SME_FLAG_BUSY 0x00000001 /* device busy */
|
||||
#define SME_DISABLE_REFRESH 0x00000002 /* disable sme_refresh */
|
||||
#define SME_CALLOUT_INITIALIZED 0x00000004 /* callout was initialized */
|
||||
#define SME_CALLOUT_BUSY 0x00000008 /* callout is busy */
|
||||
|
||||
void *sme_cookie; /* for ENVSYS back-end */
|
||||
|
||||
|
|
Loading…
Reference in New Issue