summaryrefslogtreecommitdiff
path: root/sys/dev/sysmon
diff options
context:
space:
mode:
authorpgoyette <pgoyette@NetBSD.org>2010-12-30 03:59:59 +0000
committerpgoyette <pgoyette@NetBSD.org>2010-12-30 03:59:59 +0000
commit6bd5c834ee39e7385bc7b26d724952a863014ef8 (patch)
tree4898e6f3024498c47464c7f5418da7566b434d7a /sys/dev/sysmon
parent02a9bce1849a293ec9d62d45248549b2ae06c163 (diff)
When the user updates the sensor device's refresh timer, reset the
callout immediately rather than waiting for the previous timer to expire.
Diffstat (limited to 'sys/dev/sysmon')
-rw-r--r--sys/dev/sysmon/sysmon_envsys.c14
-rw-r--r--sys/dev/sysmon/sysmon_envsys_events.c38
-rw-r--r--sys/dev/sysmon/sysmon_envsysvar.h3
3 files changed, 40 insertions, 15 deletions
diff --git a/sys/dev/sysmon/sysmon_envsys.c b/sys/dev/sysmon/sysmon_envsys.c
index 9ecc65152d9..0aa21716f4b 100644
--- a/sys/dev/sysmon/sysmon_envsys.c
+++ b/sys/dev/sysmon/sysmon_envsys.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys.c,v 1.111 2010/12/16 16:08:57 njoly Exp $ */
+/* $NetBSD: sysmon_envsys.c,v 1.112 2010/12/30 03:59:59 pgoyette Exp $ */
/*-
* Copyright (c) 2007, 2008 Juan Romero Pardines.
@@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.111 2010/12/16 16:08:57 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.112 2010/12/30 03:59:59 pgoyette Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -1175,6 +1175,7 @@ sme_remove_userprops(void)
* Restore default timeout value.
*/
sme->sme_events_timeout = SME_EVENTS_DEFTIMEOUT;
+ sme_schedule_callout(sme);
sysmon_envsys_release(sme, false);
}
mutex_exit(&sme_global_mtx);
@@ -1214,8 +1215,10 @@ sme_add_property_dictionary(struct sysmon_envsys *sme, prop_array_t array,
* ...
*
*/
- if (!sme->sme_events_timeout)
+ if (sme->sme_events_timeout == 0) {
sme->sme_events_timeout = SME_EVENTS_DEFTIMEOUT;
+ sme_schedule_callout(sme);
+ }
if (!prop_dictionary_set_uint64(pdict, "refresh-timeout",
sme->sme_events_timeout)) {
@@ -1805,7 +1808,10 @@ sme_userset_dictionary(struct sysmon_envsys *sme, prop_dictionary_t udict,
error = EINVAL;
else {
mutex_enter(&sme->sme_mtx);
- sme->sme_events_timeout = refresh_timo;
+ if (sme->sme_events_timeout != refresh_timo) {
+ sme->sme_events_timeout = refresh_timo;
+ sme_schedule_callout(sme);
+ }
mutex_exit(&sme->sme_mtx);
}
}
diff --git a/sys/dev/sysmon/sysmon_envsys_events.c b/sys/dev/sysmon/sysmon_envsys_events.c
index 2ff75137fc4..b9d473526b0 100644
--- a/sys/dev/sysmon/sysmon_envsys_events.c
+++ b/sys/dev/sysmon/sysmon_envsys_events.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys_events.c,v 1.96 2010/12/15 17:17:17 pgoyette Exp $ */
+/* $NetBSD: sysmon_envsys_events.c,v 1.97 2010/12/30 03:59:59 pgoyette Exp $ */
/*-
* Copyright (c) 2007, 2008 Juan Romero Pardines.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.96 2010/12/15 17:17:17 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.97 2010/12/30 03:59:59 pgoyette Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -486,16 +486,10 @@ int
sme_events_init(struct sysmon_envsys *sme)
{
int error = 0;
- uint64_t timo;
KASSERT(sme != NULL);
KASSERT(mutex_owned(&sme->sme_mtx));
- if (sme->sme_events_timeout)
- timo = sme->sme_events_timeout * hz;
- else
- timo = SME_EVTIMO;
-
error = workqueue_create(&sme->sme_wq, sme->sme_name,
sme_events_worker, sme, PRI_NONE, IPL_SOFTCLOCK, WQ_MPSAFE);
if (error)
@@ -504,8 +498,8 @@ sme_events_init(struct sysmon_envsys *sme)
mutex_init(&sme->sme_callout_mtx, MUTEX_DEFAULT, IPL_SOFTCLOCK);
callout_init(&sme->sme_callout, CALLOUT_MPSAFE);
callout_setfunc(&sme->sme_callout, sme_events_check, sme);
- callout_schedule(&sme->sme_callout, timo);
sme->sme_flags |= SME_CALLOUT_INITIALIZED;
+ sme_schedule_callout(sme);
DPRINTF(("%s: events framework initialized for '%s'\n",
__func__, sme->sme_name));
@@ -513,6 +507,30 @@ sme_events_init(struct sysmon_envsys *sme)
}
/*
+ * sme_schedule_callout
+ *
+ * (Re)-schedule the device's callout timer
+ */
+void
+sme_schedule_callout(struct sysmon_envsys *sme)
+{
+ uint64_t timo;
+
+ KASSERT(sme != NULL);
+
+ if ((sme->sme_flags & SME_CALLOUT_INITIALIZED) == 0)
+ return;
+
+ if (sme->sme_events_timeout)
+ timo = sme->sme_events_timeout * hz;
+ else
+ timo = SME_EVTIMO;
+
+ callout_stop(&sme->sme_callout);
+ callout_schedule(&sme->sme_callout, timo);
+}
+
+/*
* sme_events_destroy:
*
* + Destroys the event framework for this device: callout
@@ -630,7 +648,7 @@ sme_events_check(void *arg)
else
timo = SME_EVTIMO;
if (!sysmon_low_power)
- callout_schedule(&sme->sme_callout, timo);
+ sme_schedule_callout(sme);
mutex_exit(&sme->sme_callout_mtx);
}
diff --git a/sys/dev/sysmon/sysmon_envsysvar.h b/sys/dev/sysmon/sysmon_envsysvar.h
index 680e20d29f1..4b993cd164a 100644
--- a/sys/dev/sysmon/sysmon_envsysvar.h
+++ b/sys/dev/sysmon/sysmon_envsysvar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsysvar.h,v 1.37 2010/12/15 17:17:17 pgoyette Exp $ */
+/* $NetBSD: sysmon_envsysvar.h,v 1.38 2010/12/30 03:59:59 pgoyette Exp $ */
/*-
* Copyright (c) 2007, 2008 Juan Romero Pardines.
@@ -133,6 +133,7 @@ void sme_events_check(void *);
void sme_events_worker(struct work *, void *);
void sme_deliver_event(sme_event_t *);
int sme_update_limits(struct sysmon_envsys *, envsys_data_t *);
+void sme_schedule_callout(struct sysmon_envsys *);
/*
* common functions to create/update objects in a dictionary.