Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/sysmon When removing sensor properties with envstat ...
details: https://anonhg.NetBSD.org/src/rev/aeb839e75d77
branches: trunk
changeset: 753800:aeb839e75d77
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Sat Apr 10 19:01:00 2010 +0000
description:
When removing sensor properties with envstat -S, ensure that drivers
which could have modified hardware state are informed so that original
state can be restored.
Welcome to 5.99.27
diffstat:
sys/dev/sysmon/sysmon_envsys.c | 44 ++++++++++++++++++++++++++--------
sys/dev/sysmon/sysmon_envsys_events.c | 40 +++++++++++++++++++++----------
sys/dev/sysmon/sysmon_envsysvar.h | 3 +-
3 files changed, 62 insertions(+), 25 deletions(-)
diffs (195 lines):
diff -r 18a20fe1f343 -r aeb839e75d77 sys/dev/sysmon/sysmon_envsys.c
--- a/sys/dev/sysmon/sysmon_envsys.c Sat Apr 10 18:32:13 2010 +0000
+++ b/sys/dev/sysmon/sysmon_envsys.c Sat Apr 10 19:01:00 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys.c,v 1.105 2010/04/03 13:55:09 pgoyette Exp $ */
+/* $NetBSD: sysmon_envsys.c,v 1.106 2010/04/10 19:01:00 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.105 2010/04/03 13:55:09 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.106 2010/04/10 19:01:00 pgoyette Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -1053,6 +1053,7 @@
prop_dictionary_t sdict;
envsys_data_t *edata = NULL;
char tmp[ENVSYS_DESCLEN];
+ sysmon_envsys_lim_t lims;
int ptype;
mutex_enter(&sme_global_mtx);
@@ -1090,10 +1091,6 @@
"maximum-capacity");
ptype = PENVSYS_EVENT_CAPACITY;
}
- if (ptype != 0)
- sme_event_unregister(sme, edata->desc, ptype);
-
- ptype = 0;
if (edata->upropset & PROP_WARNMAX) {
prop_dictionary_remove(sdict, "warning-max");
ptype = PENVSYS_EVENT_LIMITS;
@@ -1113,9 +1110,6 @@
prop_dictionary_remove(sdict, "critical-min");
ptype = PENVSYS_EVENT_LIMITS;
}
- if (ptype != 0)
- sme_event_unregister(sme, edata->desc, ptype);
-
if (edata->upropset & PROP_RFACT) {
(void)sme_sensor_upint32(sdict, "rfact", 0);
edata->rfact = 0;
@@ -1125,8 +1119,36 @@
(void)sme_sensor_upstring(sdict,
"description", edata->desc);
- if (edata->upropset)
- edata->upropset = 0;
+ if (ptype == 0)
+ continue;
+
+ /*
+ * If there were any limit values removed, we
+ * need to revert to initial limits.
+ *
+ * First, tell the driver that we need it to
+ * restore any h/w limits which may have been
+ * changed to stored, boot-time values. Then
+ * we need to retrieve those limits and update
+ * the event data in the dictionary.
+ */
+ if (sme->sme_set_limits) {
+ DPRINTF(("%s: reset limits for %s %s\n",
+ __func__, sme->sme_name, edata->desc));
+ (*sme->sme_set_limits)(sme, edata, NULL, NULL);
+ }
+ if (sme->sme_get_limits) {
+ DPRINTF(("%s: retrieve limits for %s %s\n",
+ __func__, sme->sme_name, edata->desc));
+ lims = edata->limits;
+ (*sme->sme_get_limits)(sme, edata, &lims,
+ &edata->upropset);
+ }
+ if (edata->upropset) {
+ DPRINTF(("%s: install limits for %s %s\n",
+ __func__, sme->sme_name, edata->desc));
+ sme_update_limits(sme, edata);
+ }
}
/*
diff -r 18a20fe1f343 -r aeb839e75d77 sys/dev/sysmon/sysmon_envsys_events.c
--- a/sys/dev/sysmon/sysmon_envsys_events.c Sat Apr 10 18:32:13 2010 +0000
+++ b/sys/dev/sysmon/sysmon_envsys_events.c Sat Apr 10 19:01:00 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys_events.c,v 1.91 2010/04/01 12:16:14 pgoyette Exp $ */
+/* $NetBSD: sysmon_envsys_events.c,v 1.92 2010/04/10 19:01:01 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.91 2010/04/01 12:16:14 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.92 2010/04/10 19:01:01 pgoyette Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -544,29 +544,45 @@
int
sysmon_envsys_update_limits(struct sysmon_envsys *sme, envsys_data_t *edata)
{
+ int err;
+
+ if (sme->sme_get_limits == NULL ||
+ (edata->flags & ENVSYS_FMONLIMITS) == 0)
+ return EINVAL;
+
+ sysmon_envsys_acquire(sme, false);
+ err = sme_update_limits(sme, edata);
+ sysmon_envsys_release(sme, false);
+
+ return err;
+}
+
+/*
+ * sme_update_limits
+ *
+ * + Internal version of sysmon_envsys_update_limits() to be used
+ * when the device has already been sysmon_envsys_acquire()d.
+ */
+
+int
+sme_update_limits(struct sysmon_envsys *sme, envsys_data_t *edata)
+{
prop_dictionary_t sdict = NULL;
prop_array_t array = NULL;
sysmon_envsys_lim_t lims;
sme_event_t *see;
uint32_t props = 0;
- if (sme->sme_get_limits == NULL ||
- (edata->flags & ENVSYS_FMONLIMITS) == 0)
- return EINVAL;
-
/* Find the dictionary for this sensor */
- sysmon_envsys_acquire(sme, false);
array = prop_dictionary_get(sme_propd, sme->sme_name);
if (array == NULL ||
prop_object_type(array) != PROP_TYPE_ARRAY) {
DPRINTF(("%s: array device failed\n", __func__));
- sysmon_envsys_release(sme, false);
return EINVAL;
}
sdict = prop_array_get(array, edata->sensor);
if (sdict == NULL) {
- sysmon_envsys_release(sme, false);
return EINVAL;
}
@@ -576,10 +592,9 @@
see->see_type == PENVSYS_EVENT_LIMITS)
break;
}
- if (see == NULL) {
- sysmon_envsys_release(sme, false);
+ if (see == NULL)
return EINVAL;
- }
+
/* Get new limit values */
(*sme->sme_get_limits)(sme, edata, &lims, &props);
@@ -587,7 +602,6 @@
sme_event_register(sdict, edata, sme, &lims, props,
PENVSYS_EVENT_LIMITS, see->see_pes.pes_type);
- sysmon_envsys_release(sme, false);
return 0;
}
diff -r 18a20fe1f343 -r aeb839e75d77 sys/dev/sysmon/sysmon_envsysvar.h
--- a/sys/dev/sysmon/sysmon_envsysvar.h Sat Apr 10 18:32:13 2010 +0000
+++ b/sys/dev/sysmon/sysmon_envsysvar.h Sat Apr 10 19:01:00 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsysvar.h,v 1.35 2010/04/01 12:16:14 pgoyette Exp $ */
+/* $NetBSD: sysmon_envsysvar.h,v 1.36 2010/04/10 19:01:01 pgoyette Exp $ */
/*-
* Copyright (c) 2007, 2008 Juan Romero Pardines.
@@ -132,6 +132,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 *);
/*
* common functions to create/update objects in a dictionary.
Home |
Main Index |
Thread Index |
Old Index