Commit Graph

126 Commits

Author SHA1 Message Date
msaitoh
b9514938ff Remove trailing white space(s) from name of random source.
And also, changind space(s) in the middle with '-'.
PR#47232.
2012-11-29 10:29:45 +00:00
pgoyette
5b61c9d192 Remove (commented-out) definitions for debugging - thanks to macallan@
for defflagging these.
2012-09-06 12:21:40 +00:00
pgoyette
2c133669b5 Fix indentation. No code change. 2012-08-27 14:15:52 +00:00
pgoyette
941f09b7a5 Simplify some logic - no functional change intended.
While here, clean up a couple of comments.
2012-08-27 14:08:36 +00:00
pgoyette
840097bfdf Make sure to re-add the sensor as an entropy source after user request
to reset (via envstat -S)
2012-07-19 13:31:06 +00:00
pgoyette
063727a480 Extend previous changes so that even sensors which don't use a refresh()
callback to update the value can be polled to provide rnd(4) entropy.
2012-07-16 13:55:01 +00:00
pgoyette
87d1d2214b If a sensor is flagged as capable of providing rnd(4) with entropy,
hook the sensor into rnd subsystem, and make sure we periodically
refresh the sensor whether or not it is being actively monitored.
2012-07-15 18:33:07 +00:00
pgoyette
0bc91edaa9 When unregistering a sensor device, make sure we unregister and delete
all the associated events.
2012-07-15 17:41:39 +00:00
matt
a621c8945e Don't export sysmon_envsys_list as a common. 2012-02-18 01:08:00 +00:00
mbalmer
631d5867a0 According to the Oxford Dictionary of Etymology, a wether is a male sheep
or ram.
2011-08-01 12:28:53 +00:00
martin
b2ead544fd Instead of crashing, print a usable error message when a driver eroneously
does not properly initialize sensor state.
2011-06-19 11:40:26 +00:00
pgoyette
5960b5e520 Previous fix broke the setting of current value for Indicator and
Battery-Charge sensors.  Fix this.
2011-06-15 13:34:13 +00:00
pgoyette
35a3b0e4a6 Factor out some duplicated code to simplify maintenance. Reduces
the source file by ~100 lines, and amd64 object file shrinks by
~650 bytes.

No functional change intended.
2011-06-08 18:22:24 +00:00
pgoyette
77b2e2fc09 Since nothing actually records or maintains an average sensor value,
remove value_avg from the prop_dict.  We can't completely remove it
because there's one driver that uses this field for its own private
purposes, so for now we just rename the member.
2011-06-04 13:24:33 +00:00
pgoyette
59fe847ec9 When the user updates the sensor device's refresh timer, reset the
callout immediately rather than waiting for the previous timer to
expire.
2010-12-30 03:59:59 +00:00
njoly
608cbb3a81 Be sure to always initialize props variable to a sensible value.
Fix a problem with envstat -S call which was installing bogus/random
limits.

ok pgoyette.
2010-12-16 16:08:57 +00:00
pgoyette
e76f489b1b Extract searching of description tables into a single function, rather
than duplicating the code every time.  Minor reduction in code size
(about 1200 bytes on amd64), no change in functionality.
2010-12-15 17:17:16 +00:00
pgoyette
73ddb4f5d6 Handle removal of limit properties correctly, even for sensors that
provide their own internal limit(s).
2010-12-11 15:17:15 +00:00
pgoyette
9179849b5d When removing properties (as in envstat -S), clear the flags that track
whether the properties actually exist.

When setting new limit values, don't complain/ignore about duplicate
values if the associated flag bits (indicating that the limit is valid)
are not set.

These two fixes together should fix a problem reported in private Email
by njoly@ a couple months ago.  Issue replicated and solution tested
using my recent swsensor pseudo-device running inside qemu world!
2010-12-08 00:09:14 +00:00
pgoyette
730da12998 Use a typedef to define the prototype of the per-sensor callback.
Update manpage for the prototype, and fix a fubar'd Cross-reference.
2010-04-11 01:12:28 +00:00
pgoyette
d8f35b6e65 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
2010-04-10 19:01:00 +00:00
pgoyette
cae66ef7cc When unregistering a device, in addition to reducing the global count
of sensors, we need to adjust the sme_fsensor values for some devices.
Failure to do this leaves a sparesly-populated number-space and can
subsequently result in overlapping sensors number assignments.  (This
only affects the compatability-mode API, but still needs to be fixed.)
2010-04-03 13:55:09 +00:00
pgoyette
6d6a30996f Permit creation of an event-monitor for alarm limits even if the limits
are not currently set (and, in case of battery capacity sensors, if there
is no value_max).  Ensure that such an event-monitor does not trigger the
delivery of any actual events.

Provide a mechanism for sensors to set their limits at time other than
system startup (for example, when a battery is inserted).

This allows us to boot a system with a battery missing, install the
battery some time later, and automatically monitor it without requiring
any user intervention to create the event-monitor.  (The actual changes
for battery sensors to use this new capability will come later.)
2010-04-01 12:16:14 +00:00
pgoyette
aae23aaf98 Constify the args to sysmon_envsys_foreach_sensor()'s callback function. 2010-03-27 13:34:16 +00:00
pgoyette
5dbc4fad52 Fix the locking protocol in sysmon_envsys_foreach_sensor(), and add an
additional argument to control whether or not the sensors are refreshed
before invoking the callback routine.
2010-03-27 13:23:18 +00:00
pgoyette
6c1f2c419a Make this work the way the preceeding comment blocks says it works, and
break out of the while{ } when the callback returns false, not when it
returns true!
2010-03-26 21:06:25 +00:00
pgoyette
1de3adb5f4 Add a routine to iterate over all the sensors on the system. This will
be needed to update acpiapm_get_powstat() which is currently slightly
broken due to recent rearrangement of acpi_bat(4)'s sensors.  (This
approach is in lieu of exporting proplists between kernel entities, and
avoids exposing some internal sysmon_envsys details.)
2010-03-26 20:31:06 +00:00
pgoyette
e235f1e850 Export the sensor device's class. 2010-03-26 12:36:59 +00:00
pgoyette
f8d161b1f5 Do the initial refresh before creating the event monitors, in case the
event monitors require some of the data loaded by the refresh.  For
example, the initial refresh might load sensor limits and max_value in
addition to the cur_value.
2010-03-24 12:15:54 +00:00
pgoyette
d5f3dc8bdd Retire the 'monitor' member of the envsys_data_t. It was only used in
one place, and functioned as a logical OR of the ENVSYS_FMON* flag bits.
2010-03-14 18:03:15 +00:00
pgoyette
8844275b30 For symmetry, allow warning and critical upper-limits for capacity
sensors.
2010-02-15 22:32:04 +00:00
pgoyette
9150436462 Remove the flags member of the limits structure. Its value was only
meaningful for a few limited function calls;  all persitent storage
of limit-present flags is maintained in the edata->upropset member.
2010-02-14 23:06:01 +00:00
pgoyette
1fe73d6688 One more callback of sme_refresh() routine needs to check first that
there is a routine to be called!
2010-02-05 17:44:27 +00:00
martin
2a2c96609a Fix an outdated comment, noticed by Paul Goyette. 2010-01-31 22:53:56 +00:00
martin
889f82dd49 Add a convenience function to find the maximum value currently reported
by a set (selected via a passed callback predicate) of sensors.
This provides an easy way to query the current temperature of a thermal
zone, for example, from within the kernel - assuming the caller knows
the topology.
2010-01-31 21:36:38 +00:00
pgoyette
aaabf34dde Validate limit-based monitoring in one place, so we can apply the
constraints to both driver-requested and user-requested monitoring.

While here, clean up some of the debugging DPRINTFs.
2010-01-30 02:46:52 +00:00
pgoyette
0fab9769e4 Remove some code (bracketed by #ifdef NOTYET / #endif) that should not
have been committed in the first place.
2009-07-10 13:09:09 +00:00
pgoyette
e17701cfef Remove driver name from debug message. Not all drivers have set this
early enough, and we can easily figure out the driver name from some
subsequent debug messages.
2009-07-08 17:54:27 +00:00
pgoyette
c235777756 Add capability to send sensor limit values to the driver so they can
be programmed into device registers.  This way we can let the hardware
help us out instead of having to always compare the value against each
limit.  (Driver updates for some sensors to take advantage of this
capability will be forthcoming.)
2009-06-13 16:08:25 +00:00
pgoyette
f7ad703892 General clean-up and some restructuring of event handling. This is a
precursor to letting sensor drivers actually exchange limits/thresholds
with user-land.
2009-06-08 00:55:35 +00:00
pgoyette
677e91afbc Don't allocate the private list-threading structure unless we're going
to use it.  Otherwise we end up leaking little bits of memory for each
sensor that is not monitored at time of initial registration.
2009-06-03 11:43:15 +00:00
pgoyette
6d65ba8398 1. provide for warning-min and warning-max alarm levels in addition to
critical-min and critical-max; also, a battery warning-capacity is
   added in addition to a critical-capacity.

2. usr.sbin/envstat is modified to introduce a -W command line switch to
   display the warning-* values instead of the critical-* values, and
   envstat(8) and envsys.conf(5) man pages are updated appropriately.

3. Treat user-defined limits as a single continuum and generate a single
   event regardless of how many boundaries a change in sensor value
   crosses;  ditto for driver-defined limits.

Fixes my PR/39021
Fixes my PR/39022

OK'd by christos@ bouyer@ cube@
2008-08-22 11:27:50 +00:00
jmcneill
b9f9379e74 Add SME_POLL_ONLY flag, which informs sme to only refresh the sensor when
it is polled (and not from GTREDATA).
2008-06-03 15:00:57 +00:00
xtraeme
6dcb9dd40c Initialize and destroy the callout in sme_events_init() and
sme_events_destroy() respectively. And don't stop twice the callout
when calling sysmon_envsys_unregister().
2008-04-02 11:19:22 +00:00
xtraeme
5ee4eba88d Introduce per-device locking/synchronization and maintain only a
global mutex for the linked list of devices and the global proplib
dictionary.

This has improved locking contention a lot when multiple devices with
multiple monitoring events are running:

New:

 0.30      35      0.33 sme_global_mtx         sysmonioctl_envsys+28b
 0.10      10      0.11 00000000cd97feac       sysmon_envsys_acquire+4c
 0.08       6      0.09 00000000cd97feac       sme_update_dictionary+24f
 0.01       4      0.01 00000000cd97feac       sme_events_worker+2f
 0.01      10      0.01 00000000cd97fe2c       sysmon_envsys_acquire+4c
 0.00       1      0.00 00000000cd97fe2c       sysmon_envsys_release+3b
28.38      94      9.16 sme_global_mtx         sysmonioctl_envsys+28b
 4.54      74      1.47 00000000cd97fe2c       sysmon_envsys_acquire+4c
 0.06       3      0.02 00000000cd97fe2c       sysmon_envsys_release+3b
 0.03       1      0.01 00000000cd97fe2c       sme_events_worker+2f
 1.40      19      0.45 00000000cd97bee4       sysmon_envsys_acquire+4c

Old:

 4.25     313      4.74 sme_mtx                <all>
 3.12     185      3.49 sme_mtx                sme_events_worker+21
 1.12     128      1.25 sme_mtx                sysmonioctl_envsys+29b
34.75    1423     59.52 sme_mtx                <all>
22.08     477     37.82 sme_mtx                sysmonioctl_envsys+29b
12.67     946     21.70 sme_mtx                sme_events_worker+21
2008-04-01 12:25:30 +00:00
xtraeme
a826e85aba Fix some problems reported by <drochner> a while ago on tech-kern:
sme_events_worker: skip sensors with invalid state.
sme_acadapter_check:

	* use a boolean to check if an SME_CLASS_ACADAPTER was found.
	* Always refresh sensor data before checking value_cur.

Introduce the SME_INIT_REFRESH flag. If a device sets this it will mean
that after interrupts are enabled in the autoconf(9) process, sensor
data will be refreshed once.
2008-03-23 16:09:41 +00:00
xtraeme
b5abdb42f6 Destroy the callout via sysmon_envsys_destroy() now that it's
initialized in sysmon_envsys_create().
2008-02-02 02:02:37 +00:00
xtraeme
b88ea32e70 - Initialize the callout with CALLOUT_MPSAFE, like it was done before
in sysmon_envsys_events.c.
- Separate sme_event_check_low_power() into sme_battery_check(),
  sme_acadapter_check() and sme_battery_critical() (no functional changes).
2008-01-02 12:20:26 +00:00
dyoung
09767a906c In sysmon_envsys_create(), initialize the callout structure. Stops
panics with a DIAGNOSTIC kernel.

In sysmon_envsys_find_40(), wait until an envsys is not busy before
settings its busy flag, in the pattern of sysmon_envsys_find().
2008-01-02 10:15:53 +00:00
dyoung
5493a07f14 Use LIST_FOREACH(). 2008-01-02 03:06:02 +00:00