summaryrefslogtreecommitdiff
path: root/sys/dev/sysmon
AgeCommit message (Collapse)Author
2007-11-03Remove sysmon_envsys_find() proto, it's defined on sysmon_envsysvar.h.xtraeme
2007-11-03- Rename ENVSYS_BATTERY_STATE units to ENVSYS_BATTERY_CAPACITY andxtraeme
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@.
2007-11-02do not embed acpi device names in the sensor namesplunky
fake it in the compat code for the old envsys API
2007-10-23Use a flag for see_flags to know when the sensor has been refreshedxtraeme
rather than using a boolean. Suggested by rmind.
2007-10-20performance fix: in the workqueue handler only refresh the sensor once,xtraeme
not multiple times for the same sensor and clear its state after all events were processed.
2007-10-13sme_event_drvadd: there's no need to acquire the mutex only whenxtraeme
setting the object on its dictionary.
2007-10-13Use PRI_NONE for the priority argument in workqueue_create(9).xtraeme
2007-10-11Check for the low power condition only when a new battery state sensorxtraeme
changed its state, there's no need to check this in all cases.
2007-10-10Fix the problems described in:xtraeme
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.
2007-10-07sme_event_unregister: remove a goto that is not needed anymore.xtraeme
2007-10-07New changes to support the new configuration file format forxtraeme
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.
2007-10-06Forgot to change the kmem_zalloc(9) calls to use KM_NOSLEEP in previous,xtraeme
as was suggested by rmind.
2007-10-06Fix a bug that happened when two or more events were received almostxtraeme
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.
2007-10-06- sysmon_power_daemon_task: check if pev is valid before use.xtraeme
- Add two more KASSERTS in strategic places.
2007-09-25- Don't use _nocopy in prop_dictionary_set_cstring, the string is partxtraeme
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.
2007-09-24sme_add_sensor_dictionary: don't forget to release the dictionary whenxtraeme
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.
2007-09-24do not use _nocopy, this string is part of another object thatplunky
will be released shortly..
2007-09-09Change the DPRINTFs in sysmon_envsys_destroy_plist() to DPRINTFOBJsxtraeme
(second level of verbosity).
2007-09-08sysmon_envsys_register: don't forget to clear SME_FLAG_BUSY whenxtraeme
registration succeeds.
2007-09-08Use DPRINTF for a debugging printf.xtraeme
2007-09-08Use panic(9) for previous. To make pooka and rmind happy.xtraeme
2007-09-08Remove an unused variable.xtraeme
2007-09-08sme_event_worker: in PENVSYS_EVENT_STATE_CHANGED, onlyxtraeme
ENVSYS_DRIVE or ENVSYS_BATTERY_STATE sensors are allowed for now. Other type of sensors will be ignored. Added this to make Coverity Prevent happy.
2007-09-08Fix another memleak that only happened when usingxtraeme
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.
2007-09-08Don't forget to free sme_evdrv in non error case too. Noticed andxtraeme
reviewed by rmind.
2007-09-08Use only one single condvar(9) for devices and events, they are protectedxtraeme
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.
2007-09-08Disable debug, committed accidentally in previous.xtraeme
2007-09-08sysmon_envsys_register: only call sme_event_unregister_all when anyxtraeme
other error than EEXIST is returned.
2007-09-08- Use only one global mutex for all tasks with devices & events.xtraeme
- 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.
2007-09-08Remove another COMPAT_40 block, found by rmind@.xtraeme
2007-09-08Fix previous.xtraeme
2007-09-08- Build unconditionally compatibility code, there's no point to have itxtraeme
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.
2007-09-07- sme_event_unregister_all: check if sme_events_initialized is setxtraeme
before calling sme_events_destroy(). - sme_event_worker: remove a KASSERT and always check if returned sme is NULL and do not continue the task.
2007-09-04- Remove ENVSYS_GSTRING and the genstr member from envsys_data_t.xtraeme
(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.
2007-09-03Add some KASSERT(mutex_owned(&foo_lock)).xtraeme
2007-09-02Add a new sensor type to sysmon_envsys(9): ENVSYS_GSTRING.xtraeme
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 $
2007-09-02Add <sys/mutex.h> rather than <sys/lock.h>.xtraeme
2007-09-02Convert the sysmon watchdog framework to use mutex(9) rather thanxtraeme
simple_locks and initialize them on init_main via sysmon_wdog_init(). All the sysmon code now is cleaned up and doesn't use old style locking.
2007-09-02Remove unused (and inexistent) flag.xtraeme
2007-09-01- Fix a memleak in ENVSYS_SETDICTIONARY if there wasn't any errorxtraeme
(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.
2007-09-01sme_event_register: don't forget to add the object in dictionary whenxtraeme
a critical value is added via ENVSYS_SETDICTIONARY.
2007-09-01sme_event_register: sme_sensor_upint32() was being called even whenxtraeme
adding events via sme_event_drvadd(), fix it.
2007-08-31- sme_unregister_all: there's no need to use a struct sysmon_envsys asxtraeme
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.
2007-08-31Merge sme_event_add() into sme_event_register()... there's no needxtraeme
to have two different functions for this.
2007-08-31Simplify sme_event_add() and fix a problem when updating criticalxtraeme
values.
2007-08-31Add a few KASSERT(mutex_owned(&foo_lock)) as suggested by Andrew Doran.xtraeme
2007-08-30More misc changes for sysmon_envsys(9):xtraeme
- 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). (forgot in previous)
2007-08-30More misc changes for sysmon_envsys(9):xtraeme
- 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).
2007-08-30Simplify sysmon_envsys_register() and fix an obvious error inxtraeme
previous.
2007-08-30Some changes to improve locking on sysmon_envsys(9):xtraeme
- 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.