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.
- Add a lot of missing selinit() and seldestroy() calls.
- Merge selwakeup() and selnotify() calls into a single selnotify().
- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.
Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
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).
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().
timer's users are gone. A signal cancels the unregister:
sysmon_wdog_unregister() leaves the watchdog registered.
The only user of sysmon_wdog_unregister() that I can find is in
elansc(4), so this looks like a safe change to make.
volumes that are migrating such as when you change the stripe size.
While I'm here use the same string than we had in the old framework to
report status "online" vs "drive is online", because the sensor might be
a RAID volume and not just a drive.
- 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.
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.
(and its dictionary created) successfully and use it in the
POWER_EVENT_RECVDICT ioctl to check if the dictionary is ready before
calling prop_dictionary_copyout_ioctl().
This fixes a rare condition when too many events are enqueued and
there wasn't time to create the dictionary, so prop_dictionary_copyout_ioctl()
fails with a NULL pointer dereference.
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@.
http://mail-index.netbsd.org/current-users/2007/07/16/0012.html
- Introduce sme_class into the sysmon_envsys struct to specify a
class; currently there are two classes: SME_CLASS_ACADAPTER and
SME_CLASS_BATTERY.
- Add a new envsys event: PENVSYS_EVENT_LOW_POWER that is reached when
all SME_CLASS_BATTERY devices are in CRITICAL/LOW state and there's not
any SME_CLASS_ACADAPTER connected.
- Add the 'low-power' event into the sensor_battery script that will
shutdown the system gracefully via 'shutdown -p'. If powerd(8) is
not running, cpu_reboot(9) with RB_POWERDOWN is used.
- Make acpiacad(4) a SME_CLASS_ACADAPTER device and acpibat(4) a
SME_CLASS_BATTERY device.
Update the documentation accordingly to these changes.
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.
at the same time and the code accessed to an unexistent dictionary:
- Rather than using a global dictionary, use a singly linked list to
access to the dictionaries, one per event.
- When the dictionary has been sent to userland, destroy it and remove
it from the list.
With that change it is possible to receive multiple events at the
same time without panics; again thanks to rmind@ for comments and help
with locking.
Reviewed and ok by rmind.
of another object that will be released shortly.
- Fix a memleak: add sysmon_power_destroy_dictionary() and remove
all objects that are currently in the dictionary and finally release
the dictionary.