Home | History | Annotate | Download | only in sysmon
History log of /src/sys/dev/sysmon/sysmon_envsys.c
RevisionDateAuthorComments
 1.151  20-May-2022  andvar s/appropiate/appropriate/ in comments and readme file.
 1.150  31-Dec-2021  riastradh sysmon(9): Fix callout/thread synchronization.

Callout may ONLY take sme_work_mtx, at IPL_SOFTCLOCK; MUST NOT touch
sme_mtx at IPL_NONE. All state the callout needs is serialized by
sme_work_mtx now:

- calls to sme_schedule_callout
- calls to sme_schedule_halt
- struct sysmon_envsys::sme_events_timeout
- struct sysmon_envsys::sme_events_list
- struct sysmon_envsys::sme_callout_state
- struct envsys_data::flags
=> yes, this is a little silly -- used for ENVSYS_FNEED_REFRESH
=> should maybe separate the static driver-defined features from
the state flags needed by sysmon_envsys but not important now

Sleeping under sme_work_mtx (except on other adaptive locks at
IPL_SOFTCLOCK) is forbidden. Calling out to the driver under
sme_work_mtx is forbidden.

This should properly fix:

https://mail-index.netbsd.org/tech-kern/2015/10/14/msg019511.html
PR kern/56592
 1.149  31-Dec-2021  riastradh sysmon: Delete trailing whitespace. No functional change intended.
 1.148  07-Sep-2021  andvar s/aquire/acquire/ in comments, also one typo fix acqure->acquire.
 1.147  11-Jun-2020  thorpej Update for proplib(3) API changes.
 1.146  08-Jun-2020  thorpej Update for proplib(3) API changes.
 1.145  01-Jun-2020  riastradh Don't queue sysmon refresh until the rndsource is attached.

Using the rndsource, as refreshing the sensors will do, is not
allowed until _after_ rnd_source_attach.

XXX pullup-7
XXX pullup-8
XXX pullup-9
 1.144  26-Mar-2019  bad branches: 1.144.4;
in sysmon_envsys_unregister(): loop over sme_sensors_list with TAILQ_FIRST
instead of TAILQ_FOREACH.

sysmon_envsys_sensor_detach() removes the sensor from sme_sensors_list.
Hence using TAILQ_FOREACH is not safe.

Suggested by thorpej and jmcneill. Thanks!
 1.143  26-May-2018  thorpej branches: 1.143.2;
Avoid dereferencing NULL if we attempt to look up an known unit type.
 1.142  05-May-2018  pgoyette Defend against some table-lookup-not-found errors.
 1.141  11-Sep-2017  pgoyette branches: 1.141.2;
Improve tracking of the state of an event's callout, and protect all
queries or modifications of the state with the sme_mtx mutex.

Detach the rndsrc before re-attaching it (with potentially new values).

Clean up some lock-ordering issues.

And a couple of KNF issues for good measure!

Should address PR kern/52533

XXX Pullup-8 along with the previous fixes from msaitoh@
XXX http://mail-index.netbsd.org/source-changes/2017/09/06/msg088028.html
~
~
 1.140  06-Sep-2017  msaitoh Fixes a problem that some driver(e.g. acpitz(4) or coretemp(5)) which
use sysmon_envsys sleep waiting at "rndsrc" when "drvctl -d".
Don't call rnd_detach_source() in sme_remove_event() which is called
from sme_event_unregister_all(). Instead, call rnd_detach_source() in
sysmon_envsys_sensor_detach() and call sysmon_envsys_sensor_detach()
before sme_event_unregister_sensor(). Each sensor(envsys_data) has each
rnd_src, but some sme_events point to the same rnd_src in a sensor.
Calling rnd_detach_souce() twice with the same rnd_src brokes a reference
count in rnd_src. OK'd by pgoyette@.
 1.139  14-Dec-2015  pgoyette branches: 1.139.10;
sysmon's components need to be MODULE_CLASS_DRIVER so they will get
initialized before we configure/initialize any devices that interact
with them.

Thanks, marty!
 1.138  13-Dec-2015  jdc Note the sensor number in the error output. Useful for drivers adding
multiple sensors.
 1.137  25-Apr-2015  pgoyette Handle early initialization requirements - thanks martin@ and others
 1.136  25-Apr-2015  christos make things boot again, from martin.
 1.135  25-Apr-2015  pgoyette Use tabs for indentation.
 1.134  25-Apr-2015  pgoyette Release the mutex in the error path.
 1.133  24-Apr-2015  pgoyette The sysmon_envsys module also depends on sysmon_power (for delivery of
sensor events to userland).
 1.132  24-Apr-2015  pgoyette Remove a left-over debugging printf()
 1.131  23-Apr-2015  pgoyette Modularize sysmon and its components
 1.130  13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.129  14-Mar-2015  hannken Add a counter of busy events and stop enqueueing more work if a device is busy.
Protect this counter with a new short time lock "sme_work_mtx" and
keep "sme_mtx" as long time lock.

Removes a deadlock where an active event holds "sme_mtx", the callout
"sme_events_check" blocks on "sme_mtx" and callout processing stops.
 1.128  23-Nov-2014  ozaki-r branches: 1.128.2;
Pull workqueue_destroy out of sme->sme_mtx

workqueue_destroy may sleep so we shouldn't run it with holding a mutex.

Requested by riastradh@.
 1.127  10-Aug-2014  tls branches: 1.127.2;
Merge tls-earlyentropy branch into HEAD.
 1.126  29-Nov-2012  msaitoh branches: 1.126.10;
Remove trailing white space(s) from name of random source.
And also, changind space(s) in the middle with '-'.
PR#47232.
 1.125  06-Sep-2012  pgoyette branches: 1.125.2;
Remove (commented-out) definitions for debugging - thanks to macallan@
for defflagging these.
 1.124  27-Aug-2012  pgoyette Fix indentation. No code change.
 1.123  27-Aug-2012  pgoyette Simplify some logic - no functional change intended.

While here, clean up a couple of comments.
 1.122  19-Jul-2012  pgoyette Make sure to re-add the sensor as an entropy source after user request
to reset (via envstat -S)
 1.121  16-Jul-2012  pgoyette 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.
 1.120  15-Jul-2012  pgoyette 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.
 1.119  15-Jul-2012  pgoyette When unregistering a sensor device, make sure we unregister and delete
all the associated events.
 1.118  18-Feb-2012  matt Don't export sysmon_envsys_list as a common.
 1.117  01-Aug-2011  mbalmer branches: 1.117.2; 1.117.6; 1.117.8;
According to the Oxford Dictionary of Etymology, a wether is a male sheep
or ram.
 1.116  19-Jun-2011  martin Instead of crashing, print a usable error message when a driver eroneously
does not properly initialize sensor state.
 1.115  15-Jun-2011  pgoyette Previous fix broke the setting of current value for Indicator and
Battery-Charge sensors. Fix this.
 1.114  08-Jun-2011  pgoyette 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.
 1.113  04-Jun-2011  pgoyette 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.
 1.112  30-Dec-2010  pgoyette branches: 1.112.2; 1.112.6;
When the user updates the sensor device's refresh timer, reset the
callout immediately rather than waiting for the previous timer to
expire.
 1.111  16-Dec-2010  njoly 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.
 1.110  15-Dec-2010  pgoyette 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.
 1.109  11-Dec-2010  pgoyette Handle removal of limit properties correctly, even for sensors that
provide their own internal limit(s).
 1.108  08-Dec-2010  pgoyette 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!
 1.107  11-Apr-2010  pgoyette Use a typedef to define the prototype of the per-sensor callback.

Update manpage for the prototype, and fix a fubar'd Cross-reference.
 1.106  10-Apr-2010  pgoyette 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
 1.105  03-Apr-2010  pgoyette 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.)
 1.104  01-Apr-2010  pgoyette 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.)
 1.103  27-Mar-2010  pgoyette Constify the args to sysmon_envsys_foreach_sensor()'s callback function.
 1.102  27-Mar-2010  pgoyette 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.
 1.101  26-Mar-2010  pgoyette 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!
 1.100  26-Mar-2010  pgoyette 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.)
 1.99  26-Mar-2010  pgoyette Export the sensor device's class.
 1.98  24-Mar-2010  pgoyette 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.
 1.97  14-Mar-2010  pgoyette branches: 1.97.2;
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.
 1.96  15-Feb-2010  pgoyette For symmetry, allow warning and critical upper-limits for capacity
sensors.
 1.95  14-Feb-2010  pgoyette 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.
 1.94  05-Feb-2010  pgoyette branches: 1.94.2;
One more callback of sme_refresh() routine needs to check first that
there is a routine to be called!
 1.93  31-Jan-2010  martin Fix an outdated comment, noticed by Paul Goyette.
 1.92  31-Jan-2010  martin 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.
 1.91  30-Jan-2010  pgoyette 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.
 1.90  10-Jul-2009  pgoyette Remove some code (bracketed by #ifdef NOTYET / #endif) that should not
have been committed in the first place.
 1.89  08-Jul-2009  pgoyette 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.
 1.88  13-Jun-2009  pgoyette 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.)
 1.87  08-Jun-2009  pgoyette General clean-up and some restructuring of event handling. This is a
precursor to letting sensor drivers actually exchange limits/thresholds
with user-land.
 1.86  03-Jun-2009  pgoyette 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.
 1.85  22-Aug-2008  pgoyette branches: 1.85.8;
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@
 1.84  03-Jun-2008  jmcneill branches: 1.84.4;
Add SME_POLL_ONLY flag, which informs sme to only refresh the sensor when
it is polled (and not from GTREDATA).
 1.83  02-Apr-2008  xtraeme branches: 1.83.2; 1.83.4; 1.83.6;
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().
 1.82  01-Apr-2008  xtraeme 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
 1.81  23-Mar-2008  xtraeme 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.
 1.80  02-Feb-2008  xtraeme branches: 1.80.6;
Destroy the callout via sysmon_envsys_destroy() now that it's
initialized in sysmon_envsys_create().
 1.79  02-Jan-2008  xtraeme - 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).
 1.78  02-Jan-2008  dyoung 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().
 1.77  02-Jan-2008  dyoung Use LIST_FOREACH().
 1.76  02-Jan-2008  dyoung Use TAILQ_FOREACH().
 1.75  05-Dec-2007  ad branches: 1.75.4;
MUTEX_SPIN -> MUTEX_DEFAULT.
 1.74  20-Nov-2007  xtraeme branches: 1.74.2;
Update a comment.
 1.73  20-Nov-2007  xtraeme 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.
 1.72  16-Nov-2007  xtraeme Extend the envsys2 API (one more time, sorry) as defined in:

http://mail-index.netbsd.org/tech-kern/2007/11/09/0001.html

sysmon_envsys_create() and sysmon_envsys_destroy() were added to
create/destroy sysmon_envsys objects (and its TAILQ/LIST for sensors/events).

sysmon_envsys_sensor_attach() and sysmon_envsys_sensor_detach() were
added to attach/detach sensors to a specified sysmon_envsys device.

The events framework is now per device and configurable via the
ENVSYS_SETDICTIONARY ioctl or /etc/envsys.conf and envstat(8).

Update all users and documentation to reflect these changes.
 1.71  03-Nov-2007  xtraeme branches: 1.71.2;
- Rename ENVSYS_BATTERY_STATE units to ENVSYS_BATTERY_CAPACITY and
introduce ENVSYS_BATTERY_CHARGE, which is the same than an Indicator and
it's used to know if the battery is currently charging or discharging.

- Require two sensors at least for SME_CLASS_BATTERY to make the low-power
condition work: a ENVSYS_BATTERY_CAPACITY plus ENVSYS_BATTERY_CHARGE.

- Simplify sme_event_check_lowpower() and make it check the required
sensors in the SME_CLASS_ACADAPTER and SME_CLASS_BATTERY classes.
If the acadapter is not ready, trust the state returned by the battery
device.

Based on suggestion from joerg@.
 1.70  02-Nov-2007  plunky do not embed acpi device names in the sensor names
fake it in the compat code for the old envsys API
 1.69  07-Oct-2007  xtraeme branches: 1.69.2;
New changes to support the new configuration file format for
envstat(8) and the envsys framework:

- Modify the ENVSYS_SETDICTIONARY ioctl to support the following
plist structure:

<dict>
<key>foo0</key>
<array>
<dict>
<key>index</key>
<string>sensor0</string>
<key>description</key>
<string>cpu temp</string>
...
Another property for this sensor
...
</dict>
...
Another dictionary for other sensor
...
</array>
...
Another device as above
...
</dict>

Multiple devices with multiple sensors can now be specified, that means
that to set the properties only one copyin(9) is needed now.

- Added the ENVSYS_REMOVEPROPS ioctl, that accepts a boolean object
"envsys-remove-props" and when set to true, all properties that were
set previously by ENVSYS_SETDICTIONARY will be removed. That means that
you can now set multiple critical limits, descriptions and all they
will be removed or changed to its default value (for rfact and
description objects).

- Added the 'index' and 'allow-rfact' objects into the sensor dictionaries,
for better interactivity with userland. To know the position of the
sensor and to know if sensor allows to change the rfact.

- Misc cosmetic changes for consistency.

- Use a two clause license for all my code.
 1.68  24-Sep-2007  xtraeme sme_add_sensor_dictionary: don't forget to release the dictionary when
an error ocurrs. This is the last memleak in the code, let me know if
you find more and I'll pay you a beer.
 1.67  09-Sep-2007  xtraeme branches: 1.67.2;
Change the DPRINTFs in sysmon_envsys_destroy_plist() to DPRINTFOBJs
(second level of verbosity).
 1.66  08-Sep-2007  xtraeme sysmon_envsys_register: don't forget to clear SME_FLAG_BUSY when
registration succeeds.
 1.65  08-Sep-2007  xtraeme Use DPRINTF for a debugging printf.
 1.64  08-Sep-2007  xtraeme Remove an unused variable.
 1.63  08-Sep-2007  xtraeme Fix another memleak that only happened when using
sysmon_envsys_unregister(): in sysmon_envsys_destroy_plist() I wasn't
removing the _objects_ from the dictionary, instead I was calling
prop_object_release() with the keysym returned by
prop_object_iterator_next()... obviously this wasn't correct.
 1.62  08-Sep-2007  xtraeme Don't forget to free sme_evdrv in non error case too. Noticed and
reviewed by rmind.
 1.61  08-Sep-2007  xtraeme Use only one single condvar(9) for devices and events, they are protected
by the same mutex (sme_mtx) and there's no point in using two of them.

Also add a comment mentioning some locking notes.

Reviewed and ok by rmind.
 1.60  08-Sep-2007  xtraeme Disable debug, committed accidentally in previous.
 1.59  08-Sep-2007  xtraeme sysmon_envsys_register: only call sme_event_unregister_all when any
other error than EEXIST is returned.
 1.58  08-Sep-2007  xtraeme - Use only one global mutex for all tasks with devices & events.
- sysmon_envsys_register: use a SLIST to maintain allocated sme_event_drv_t
structs for later use in sysmon_task_queue_sched(). This avoids a
locking error acquiring/dropping the mutex multiple times.

Suggested by rmind.
 1.57  08-Sep-2007  xtraeme Remove another COMPAT_40 block, found by rmind@.
 1.56  08-Sep-2007  xtraeme - Build unconditionally compatibility code, there's no point to have it
disabled, because some drivers depend in the old code yet.
- Use a new mutex for sysmon_envsys_next_sensor_index (used in
compatibility code), otherwise bad things happen with LKMs. Thanks
to this, the hack for LKMs has been removed.
- Check in advance if the driver doesn't exist already on the list
before adding the sensors in the dictionary.
- Don't forget to call sme_event_unregister_all() if
sysmon_envsys_unregister() fails after adding the array into the global
dictionary or when creating sensors.
- Modify and add some DPRINTFs.

The lm(4) lkm works without known problems registering and unregistering
it multiple times.
 1.55  04-Sep-2007  xtraeme - Remove ENVSYS_GSTRING and the genstr member from envsys_data_t.
(at least three or four persons were against it).
- Add a new sensor type: ENVSYS_BATTERY_STATE, this uses value_cur
and some predefined values in a static table, like ENVSYS_DRIVE.
- Move all static tables to sysmon_envsys_tables.c and use a function
on it to retrieve a pointer to the struct of the specified type.
- Rename the ENVSYS_FMONDRVSTCHANGED to ENVSYS_FMONSTCHANGED and make
it generic for Battery state and drive sensors (this flag enables
monitoring on these sensors when state has been changed).
- Update sysmon_penvsys_event() to report state changes on
ENVSYS_BATTERY_STATE sensors and remove other type of events, with
PENVSYS_EVENT_STATE_CHANGED they are not necessary anymore.
 1.54  02-Sep-2007  xtraeme Add a new sensor type to sysmon_envsys(9): ENVSYS_GSTRING.

ENVSYS_GSTRING (aka Generic String) uses the genstr member in
the envsys_data_t struct to add a generic string that envstat(8)
will show as value or state.

It's like the ENVSYS_DRIVER, but doesn't use value_cur. Below
is the dictionary created on these sensors:

<dict>
<key>description</key>
<string>acpibat0 charge state</string>
<key>generic-state-string</key>
<string>NORMAL</string>
<key>monitoring-supported</key>
<false/>
<key>state</key>
<string>valid</string>
<key>type</key>
<string>Generic string</string>
</dict>

Note that it's limited to 32 chars, but we can grow it if needed.

envstat(8) will print ENVSYS_GSTRING sensors as:

$ envstat -dacpibat0 -s"acpibat0 charge state"
acpibat0 charge state: NORMAL
$
 1.53  01-Sep-2007  xtraeme - Fix a memleak in ENVSYS_SETDICTIONARY if there wasn't any error
(thanks god for KMEMSTATS).
- sysmon_envsys_register: add all objects in the dictionary without any
lock, at this point the sme device hasn't been added into the list
and it's safe.
- Add sysmon_envsys_destroy_plist(prop_array_t) that destroys all objects
associated with a device and use it on sysmon_envsys_unregister() and
sysmon_envsys_register() if there's any error.

Thanks to Mindaugas Rasiukevicius (rmind@) for the great comments/ideas.
 1.52  31-Aug-2007  xtraeme - sme_unregister_all: there's no need to use a struct sysmon_envsys as
argument, just pass sme->sme_name to it.
- sysmon_envsys_register: drop the array in all cases, not just when
there's an error. The reference is stored in the dictionary anyway...
- Update some comments.
 1.51  31-Aug-2007  xtraeme Merge sme_event_add() into sme_event_register()... there's no need
to have two different functions for this.
 1.50  31-Aug-2007  xtraeme Add a few KASSERT(mutex_owned(&foo_lock)) as suggested by Andrew Doran.
 1.49  30-Aug-2007  xtraeme More misc changes for sysmon_envsys(9):

- Add the SLIST for sensor descriptions and sme_uniqsensors into the
struct sysmon_envsys (it's per device now).
- Use only one common struct with three members for the static tables
(there's no need to have different structs just for them).
- While initializing/destroying the events framework, use the
strategy specified by Andrew Doran in:
http://mail-index.netbsd.org/tech-kern/2007/06/21/0025.html).
 1.48  30-Aug-2007  xtraeme Simplify sysmon_envsys_register() and fix an obvious error in
previous.
 1.47  30-Aug-2007  xtraeme Some changes to improve locking on sysmon_envsys(9):

- Remove sme_mtx, a global lock (sme_list_mtx) is used to access to
the sysmon envsys device.
- Allocate memory with KM_NOSLEEP rather than KM_SLEEP if there's a
mutex held, to avoid sleeping.
- Remove sysmon_envsys_createplist() and add the logic into
sysmon_envsys_register().
- sysmon_envsys_register: allocate the array and dictionaries required
in advance for a device before the locking and adding the objects
into the array happens.
- Rename sme_make_dictionary() to sme_add_sensor_dictionary() and pass
to it the dictionary on which the objects will be stored for a sensor.
- Improve locking here and there.

Thanks to Mindaugas Rasiukevicius and Andrew Doran for comments.
 1.46  05-Aug-2007  xtraeme branches: 1.46.2; 1.46.4;
In ENVSYS_SETDICTIONARY if sysmon_envsys_find() returns NULL, do not
call sysmon_envsys_release with a NULL argument.
 1.45  29-Jul-2007  xtraeme branches: 1.45.4;
- Do not call sme_gtredata in sysmon_envsys_createplist, as in some
systems the interrupts are not configured and causes unexpected behaviour
in acpi_bat and other drivers, reported by cube@.
- Update the 'type' object in sme_update_dictionary(), so that it can
report the correct units type in acpibat(4).
 1.44  27-Jul-2007  xtraeme Change locking stuff in sysmon_envsys_register() and
sysmon_envsys_createplist().
 1.43  23-Jul-2007  xtraeme - ENVSYS_SETDICTIONARY: use sysmon_envsys_release() if there's an error.
- sme_events_worker: use sme_list_mtx when accessing to the sysmon_envsys
linked list.
- Improve the comments in sysmon_envsysvar.h about the mutexes and condvar.
 1.42  23-Jul-2007  xtraeme - sysmon_envsys_createplist: do not return the error of sme->sme_gtredata
in all cases to the caller, just continue and show a debug printf if it
fails, because it's not a critical error.

- Improve some debugging printfs.

Fixes another part of yamt@'s PR kern/36673, that I forgot to commit
yesterday.
 1.41  22-Jul-2007  xtraeme Fix the last point reported by yamt in PR kern/36673:

- There must be three mandatory objects in a sensor to be valid and be
enabled on its dictionary: units, state and desc. If any of these
objects fails for some reason, its dictionary won't created in the
array and sensor will be marked with ENVSYS_FNOTVALID in edata->flags.

That means there won't never be a partial dictionary.

- Mark all invalid sensors and sensors with duplicate description with
ENVSYS_FNOTVALID and remove ENVSYS_FDUPDESC. The former is the generic
way to say that a sensor does not obey the rules and must be not
created.

- sysmon_envsys_createplist: if the array does not contain any object,
release the array and return the error.

And with all that stuff I can go to holidays and be happy.
 1.40  21-Jul-2007  xtraeme - Do not touch sme_nsensors when sensors with duplicate description are
found, rather maintain a global counter for all sensors that are unique,
and use this global to get the correct index in the array.
- Use prop_array_set() rather than prop_array_add() for adding dictionaries
into our global array. Thanks to yamt@.
- Overwrite the sensor index in the first sensor of a device, to avoid
a problem with LKMs where the first sensor gets the index of all edata
structures allocated in kernel.
- Add missing proto for sme_register_sensorname().

All them fix another part of yamt@'s PR.
 1.39  21-Jul-2007  xtraeme Use the mutex that belongs to the specific task and do not mix them
blindly.

- sme_list_mtx to access to the linked lists sme_list/sme_names_list.
- sme_mtx to access to the data in the sysmon envsys device.
 1.38  21-Jul-2007  xtraeme sme_update_dictionary: if there's a sensor with duplicate description,
there's no need to decrease 'i' again, just sme->sme_nsensors is enough.

Reported by yamt@.
 1.37  21-Jul-2007  xtraeme Simplify previous.
 1.36  21-Jul-2007  xtraeme Skip sensor with duplicate descriptions in the COMPAT_40 case, verified
with envstat(8) from netbsd-4 and sys/lkm/misc/envsys2.

Fixes another part of kern/36673 by yamt@.
 1.35  21-Jul-2007  xtraeme - Add sme_events_destroy() to stop/destroy the callout and workqueue if
there are no more events.
- Add sme_event_unregister_all() to remove all events associated with
a device and use it in sysmon_envsys_unregister() to fix a "use-after-free".
- Check return error of sme_sensor_upfoo() in sme_make_dictionary() and
return it rather than 0 all the time.
- Add more KASSERTS.
 1.34  21-Jul-2007  xtraeme Some fixes for kern/36673 by yamt@:

- sme_register_sensorname: there's no need to handle empty list case.
- 'obj' argument in sme_sensor_upstring and similar functions is useless:
removed the obj argument from the functions, it's handled in the function
itself now.
- check for more errors in sme_make_dictionary() and
sysmon_envsys_createplist().
 1.33  21-Jul-2007  xtraeme Re-add a strlcpy() to copy the new description in edata->desc, if the
object in dictionary was updated succesfully.
 1.32  20-Jul-2007  xtraeme Add another missing break if updating the drive-state object fails.
 1.31  20-Jul-2007  xtraeme Add a missing break if error when setting a new description.
 1.30  20-Jul-2007  xtraeme Replace the macros to create/update objects in dictionary with three
inline functions, suggested by yamt@.

This also gets rid of a few gotos.
 1.29  19-Jul-2007  xtraeme sysmon_envsys_unregister: do not kmem_free(9) with the mutex held.
 1.28  19-Jul-2007  xtraeme sme_register_sensorname: don't forget to kmem_free(9) before returning
EEXIST.
 1.27  19-Jul-2007  xtraeme Maintain a SLIST per device to check for unique descriptions and do not
create any dictionary if it's duplicated. Only the first sensor that has
a unique description will be added.

Remove all elements from the list at sysmon_envsys_unregister() time and
free resources associated with it.
 1.26  18-Jul-2007  xtraeme - More changes related to locking.
- Add a condvar(9) to protect deletions on the list if there's an event
in the worker thread.
 1.25  18-Jul-2007  xtraeme sme_make_dictionary: if prop_array_add() fails, don't forget to release
the dictionary. Pointed out by yamt@.
 1.24  17-Jul-2007  xtraeme branches: 1.24.2;
Add more debugging printfs to catch sensors with duplicate description,
and some cosmetic ones.
 1.23  17-Jul-2007  xtraeme Skip sensors with the same description on the same device at attach time,
if the description of it is not unique, mark the sensor with
ENVSYS_FDUPDESC, return EEXIST and continue.

Also, when changing a description, check that the new description is not
assigned by any other sensor, otherwise return EEXIST.

Note that these restrictions are only per device. Fixes PR kern/36660.
 1.22  17-Jul-2007  xtraeme Only allow to use ENVSYS_SETDICTIONARY if the user has write permission
in the /dev/sysmon device.

Use O_RDONLY for ENVSYS_GETDICTIONARY and O_RDWR for ENVSYS_SETDICTIONARY
in envstat(8).

Fixes PR kern/36661 by YAMAMOTO Takashi.
 1.21  16-Jul-2007  xtraeme There's no reason why integer sensors were disabled for monitoring,
so enable it. This will allow to set a min/max limit for the
macppc/battery.c driver, which uses an integer sensor to report the
battery capacity.

Indicator/Integer sensors will share the /etc/power/scripts/sensor_indicator
script to report the events.
 1.20  04-Jul-2007  xtraeme Fix the old ENVSYS_GTREDATA ioctl if there are sensors with invalid
state. Enable all sensors by default as valid and current valid data and
if there is one that is in invalid state, mark current data as not valid.

This matches the behaviour with the old API. Also, this fixes the problem
with ipmi(4) reporting bogus values with sensors in invalid state using
the old envstat(8).

Note that this only happened when using the old envstat(8).
 1.19  02-Jul-2007  xtraeme Add PENVSYS_TYPE_INDICATOR to handle events on Indicator sensors.

ipmi(4) uses this for the Intrussion and Power Supply sensors.
 1.18  01-Jul-2007  xtraeme Imported envsys 2, a brief description of the new features:
(Part 1: API)

* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.

Tested by:

blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
 1.17  04-Mar-2007  christos branches: 1.17.2; 1.17.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.16  19-Feb-2007  ad Back out previous for now. There isn't currently an easy way to set up
shared state before these get attached or used.

From xtraeme@.
 1.15  19-Feb-2007  xtraeme Replace SYSMON_ENVSYS_{LOCK,UNLOCK} with mutex_{enter,exit}.
 1.14  18-Feb-2007  xtraeme * Replace simple_locks and exclusive locks with adaptive mutexes.
* Replace ltsleep/wakeup pairs with condition variables
(cv_init/cv_wait/cv_broadcast).

Reviewed by ad@.
 1.13  16-Nov-2006  christos branches: 1.13.4;
__unused removal on arguments; approved by core.
 1.12  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.11  08-Jul-2006  christos branches: 1.11.4; 1.11.6;
expose the ioctl internal function now used by the acpi_apm code.
 1.10  20-Mar-2006  lukem branches: 1.10.4;
Don't attempt to call (*sme->sme_gtredata)() or (*sme->sme_streinfo)()
if those members are NULL.
As discussed on tech-kern in October/November 2005.
 1.9  11-Dec-2005  christos branches: 1.9.4; 1.9.6; 1.9.8; 1.9.10; 1.9.12;
merge ktrace-lwp.
 1.8  11-Aug-2003  yamt branches: 1.8.16;
do wakeup() only when someone is waiting for us.
 1.7  11-Aug-2003  yamt introduce SME_FLAG_BUSY and set it during operations
instead of keeping sysmon_envsys_list_slock spinlock held
because some drivers might sleep in sysmon_envsys ops,

XXX sysmon_envsys_lock is now redundant
 1.6  29-Jun-2003  fvdl branches: 1.6.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.5  28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.4  31-Dec-2002  explorer add envsys support to acpi A/C adapter and batteries. This is still a work
in progress, much like the rest of ACPI.
 1.3  03-Jan-2002  jdolecek The device close routine is called when _last_ descriptor to the
device file is closed, rather on every descriptor close. Instead of
getting the exclusive lock on open and releasing on close, get
the lock only when needed in sysmonioctl_envsys().
Fixes kern/14368 by Anthony Mallet. Okayed by Jason Thorpe.

While here, also inline sysmon_envsys_init() to sysmonopen_envsys(),
and g/c sysmonioctl_wdog() prototype.
 1.2  13-Nov-2001  lukem add RCSIDs
 1.1  05-Nov-2000  thorpej branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Split the envsys and watchdog parts of sysmon into their own
files.
 1.1.8.1  18-Sep-2001  fvdl Various changes to make cloning devices possible:

* Add an extra argument (struct vnode **) to VOP_OPEN. If it is
not NULL, specfs will create a cloned (aliased) vnode during
the call, and return it there. The caller should release and
unlock the original vnode if a new vnode was returned. The
new vnode is returned locked.

* Add a flag field to the cdevsw and bdevsw structures.
DF_CLONING indicates that it wants a new vnode for each
open (XXX is there a better way? devprop?)

* If a device is cloning, always call the close entry
point for a VOP_CLOSE.


Also, rewrite cons.c to do the right thing with vnodes. Use VOPs
rather then direct device entry calls. Suggested by mycroft@

Light to moderate testing done an i386 system (arch doesn't matter
though, these are MI changes).
 1.1.6.1  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.4.4  03-Jan-2003  thorpej Sync with HEAD.
 1.1.4.3  28-Feb-2002  nathanw Catch up to -current.
 1.1.4.2  11-Jan-2002  nathanw More catchup.
 1.1.4.1  14-Nov-2001  nathanw Catch up to -current.
 1.1.2.2  22-Nov-2000  bouyer Sync with HEAD.
 1.1.2.1  05-Nov-2000  bouyer file sysmon_envsys.c was added on branch thorpej_scsipi on 2000-11-22 16:04:54 +0000
 1.6.2.4  21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.2.3  18-Sep-2004  skrll Sync with HEAD.
 1.6.2.2  03-Aug-2004  skrll Sync with HEAD
 1.6.2.1  02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.8.16.9  24-Mar-2008  yamt sync with head.
 1.8.16.8  04-Feb-2008  yamt sync with head.
 1.8.16.7  21-Jan-2008  yamt sync with head
 1.8.16.6  07-Dec-2007  yamt sync with head
 1.8.16.5  15-Nov-2007  yamt sync with head.
 1.8.16.4  27-Oct-2007  yamt sync with head.
 1.8.16.3  03-Sep-2007  yamt sync with head.
 1.8.16.2  30-Dec-2006  yamt sync with head.
 1.8.16.1  21-Jun-2006  yamt sync with head.
 1.9.12.1  28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.9.10.1  19-Apr-2006  elad sync with head.
 1.9.8.2  11-Aug-2006  yamt sync with head
 1.9.8.1  01-Apr-2006  yamt sync with head.
 1.9.6.1  22-Apr-2006  simonb Sync with head.
 1.9.4.1  09-Sep-2006  rpaulo sync with head
 1.10.4.1  13-Jul-2006  gdamore Merge from HEAD.
 1.11.6.2  10-Dec-2006  yamt sync with head.
 1.11.6.1  22-Oct-2006  yamt sync with head
 1.11.4.1  18-Nov-2006  ad Sync with head.
 1.13.4.1  12-Mar-2007  rmind Sync with HEAD.
 1.17.4.1  11-Jul-2007  mjf Sync with head.
 1.17.2.4  09-Oct-2007  ad Sync with head.
 1.17.2.3  20-Aug-2007  ad Sync with HEAD.
 1.17.2.2  15-Jul-2007  ad Sync with head.
 1.17.2.1  15-Jul-2007  ad Sync with head.
 1.24.2.3  10-Sep-2007  skrll Sync with HEAD.
 1.24.2.2  03-Sep-2007  skrll Sync with HEAD.
 1.24.2.1  15-Aug-2007  skrll Sync with HEAD.
 1.45.4.7  09-Dec-2007  jmcneill Sync with HEAD.
 1.45.4.6  21-Nov-2007  joerg Sync with HEAD.
 1.45.4.5  04-Nov-2007  jmcneill Sync with HEAD.
 1.45.4.4  07-Oct-2007  joerg Sync with HEAD.
 1.45.4.3  02-Oct-2007  joerg Sync with HEAD.
 1.45.4.2  03-Sep-2007  jmcneill Sync with HEAD.
 1.45.4.1  09-Aug-2007  jmcneill Sync with HEAD.
 1.46.4.2  05-Aug-2007  xtraeme In ENVSYS_SETDICTIONARY if sysmon_envsys_find() returns NULL, do not
call sysmon_envsys_release with a NULL argument.
 1.46.4.1  05-Aug-2007  xtraeme file sysmon_envsys.c was added on branch matt-mips64 on 2007-08-05 23:16:26 +0000
 1.46.2.3  23-Mar-2008  matt sync with HEAD
 1.46.2.2  09-Jan-2008  matt sync with HEAD
 1.46.2.1  06-Nov-2007  matt sync with HEAD
 1.67.2.2  14-Oct-2007  yamt sync with head.
 1.67.2.1  06-Oct-2007  yamt sync with head.
 1.69.2.3  21-Nov-2007  bouyer Sync with HEAD
 1.69.2.2  18-Nov-2007  bouyer Sync with HEAD
 1.69.2.1  13-Nov-2007  bouyer Sync with HEAD
 1.71.2.3  18-Feb-2008  mjf Sync with HEAD.
 1.71.2.2  08-Dec-2007  mjf Sync with HEAD.
 1.71.2.1  19-Nov-2007  mjf Sync with HEAD.
 1.74.2.1  08-Dec-2007  ad Sync with head.
 1.75.4.1  02-Jan-2008  bouyer Sync with HEAD
 1.80.6.3  28-Sep-2008  mjf Sync with HEAD.
 1.80.6.2  05-Jun-2008  mjf Sync with HEAD.

Also fix build.
 1.80.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.83.6.2  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.83.6.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.83.4.5  11-Aug-2010  yamt sync with head.
 1.83.4.4  11-Mar-2010  yamt sync with head
 1.83.4.3  18-Jul-2009  yamt sync with head.
 1.83.4.2  20-Jun-2009  yamt sync with head
 1.83.4.1  04-May-2009  yamt sync with head.
 1.83.2.1  04-Jun-2008  yamt sync with head
 1.84.4.1  19-Oct-2008  haad Sync with HEAD.
 1.85.8.1  23-Jul-2009  jym Sync with HEAD.
 1.94.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.97.2.3  12-Jun-2011  rmind sync with head
 1.97.2.2  05-Mar-2011  rmind sync with head
 1.97.2.1  30-May-2010  rmind sync with head
 1.112.6.1  23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.112.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.117.8.2  19-Oct-2012  riz Remove stray CR characters introduced in ticket #544. From pgoyette.
 1.117.8.1  17-Oct-2012  riz Pull up following revision(s) (requested by pgoyette in ticket #544):
sys/dev/sysmon/sysmon_envsysvar.h: revision 1.42
sys/dev/sysmon/sysmon_envsys_events.c: revision 1.99
sys/dev/sysmon/sysmon_envsys.c: revision 1.119
When unregistering a sensor device, make sure we unregister and delete
all the associated events.
 1.117.6.1  18-Feb-2012  mrg merge to -current.
 1.117.2.3  16-Jan-2013  yamt sync with (a bit old) head
 1.117.2.2  30-Oct-2012  yamt sync with head
 1.117.2.1  17-Apr-2012  yamt sync with head
 1.125.2.3  03-Dec-2017  jdolecek update from HEAD
 1.125.2.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.125.2.1  25-Feb-2013  tls resync with head
 1.126.10.1  07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.127.2.4  07-Jun-2020  martin Pull up following revision(s) (requested by riastradh in ticket #1733):

sys/dev/sysmon/sysmon_envsys.c: revision 1.145

Don't queue sysmon refresh until the rndsource is attached.

Using the rndsource, as refreshing the sensors will do, is not
allowed until _after_ rnd_source_attach.

XXX pullup-7
XXX pullup-8
XXX pullup-9
 1.127.2.3  24-Oct-2017  snj Fix fallout from ticket #1511:
It's rnd_detach_source, not rnd_detach_sources.
 1.127.2.2  23-Oct-2017  snj Apply patch (requested by pgoyette in ticket #1511):
Detach the rndsrc before re-attaching it.
 1.127.2.1  06-Apr-2015  snj branches: 1.127.2.1.2; 1.127.2.1.6;
Pull up following revision(s) (requested by hannken in ticket #666):
sys/dev/sysmon/sysmon_envsys.c: revision 1.129
sys/dev/sysmon/sysmon_envsys_events.c: revision 1.114
sys/dev/sysmon/sysmonvar.h: revision 1.46
Add a counter of busy events and stop enqueueing more work if a device =
is busy.
Protect this counter with a new short time lock "sme_work_mtx" and
keep "sme_mtx" as long time lock.
Removes a deadlock where an active event holds "sme_mtx", the callout
"sme_events_check" blocks on "sme_mtx" and callout processing stops.
 1.127.2.1.6.2  24-Oct-2017  snj Fix fallout from ticket #1511:
It's rnd_detach_source, not rnd_detach_sources.
 1.127.2.1.6.1  23-Oct-2017  snj Apply patch (requested by pgoyette in ticket #1511):
Detach the rndsrc before re-attaching it.
 1.127.2.1.2.2  24-Oct-2017  snj Fix fallout from ticket #1511:
It's rnd_detach_source, not rnd_detach_sources.
 1.127.2.1.2.1  23-Oct-2017  snj Apply patch (requested by pgoyette in ticket #1511):
Detach the rndsrc before re-attaching it.
 1.128.2.3  27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.128.2.2  06-Jun-2015  skrll Sync with HEAD
 1.128.2.1  06-Apr-2015  skrll Sync with HEAD
 1.139.10.2  07-Jun-2020  martin Pull up following revision(s) (requested by riastradh in ticket #1555):

sys/dev/sysmon/sysmon_envsys.c: revision 1.145

Don't queue sysmon refresh until the rndsource is attached.

Using the rndsource, as refreshing the sensors will do, is not
allowed until _after_ rnd_source_attach.

XXX pullup-7
XXX pullup-8
XXX pullup-9
 1.139.10.1  23-Sep-2017  snj Pull up following revision(s) (requested by pgoyette in ticket #281):
sys/dev/sysmon/sysmon_envsys.c: 1.140-1.141
sys/dev/sysmon/sysmon_envsys_events.c: 1.120-1.121
sys/dev/sysmon/sysmonvar.h: 1.50
Fixes a problem that some driver(e.g. acpitz(4) or coretemp(5)) which
use sysmon_envsys sleep waiting at "rndsrc" when "drvctl -d".
Don't call rnd_detach_source() in sme_remove_event() which is called
from sme_event_unregister_all(). Instead, call rnd_detach_source() in
sysmon_envsys_sensor_detach() and call sysmon_envsys_sensor_detach()
before sme_event_unregister_sensor(). Each sensor(envsys_data) has each
rnd_src, but some sme_events point to the same rnd_src in a sensor.
Calling rnd_detach_souce() twice with the same rnd_src brokes a reference
count in rnd_src. OK'd by pgoyette@.
--
Improve tracking of the state of an event's callout, and protect all
queries or modifications of the state with the sme_mtx mutex.
Detach the rndsrc before re-attaching it (with potentially new values).
Clean up some lock-ordering issues.
And a couple of KNF issues for good measure!
Should address PR kern/52533
 1.141.2.2  25-Jun-2018  pgoyette Sync with HEAD
 1.141.2.1  21-May-2018  pgoyette Sync with HEAD
 1.143.2.1  10-Jun-2019  christos Sync with HEAD
 1.144.4.1  07-Jun-2020  martin Pull up following revision(s) (requested by riastradh in ticket #946):

sys/dev/sysmon/sysmon_envsys.c: revision 1.145

Don't queue sysmon refresh until the rndsource is attached.

Using the rndsource, as refreshing the sensors will do, is not
allowed until _after_ rnd_source_attach.

XXX pullup-7
XXX pullup-8
XXX pullup-9

RSS XML Feed