summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* Clear errno before reading/writingMatt Spinler2018-01-171-0/+2
| | | | | | | | | | | | | | | | | Ensure the errno is cleared before accessing the sysfs file, so exceptions thrown without setting an errno can be recognized as such. Without this, the errno could still be set to a nonzero value from a previous operation, and the error handling code would think it happened on the current operation. The difference being if there is a nonzero errno a Read/WriteFailure error will be logged, and if zero the exception will be rethrown. Change-Id: Ia958376ca80484d4d594872ab8ab0154d1b767ca Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Silently exit on ENODEVEdward A. James2017-12-111-11/+3
| | | | | | | | | | | ENODEV should be included in the check for "disappeared" device or directory when hwmon driver is being unloaded. There is a race condition between unloading drivers and stopping hwmon polling, even up to several seconds, which exceeds the previous retry period for ENODEV. Change-Id: I39c8ae9ea79aa41028f5529c7ea9816d4736fc65 Signed-off-by: Edward A. James <eajames@us.ibm.com>
* Support reading 64 bit integersMatt Spinler2017-11-293-6/+6
| | | | | | | | | | | | | Some sysfs *_input values may be bigger than 32 bits, for example power values reported in microwatts. As such, read an int64_t value out of sysfs instead of just a uint32_t. The D-Bus property that will hold the value is also the same type, an int64_t. Resolves openbmc/openbmc#2686 Change-Id: I4376de120825b73580d18d339fe76be454eeb18d Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Retry on ENODATA errorsMatt Spinler2017-11-161-0/+8
| | | | | | | | | | | | | | | A particular device in a particular system is known to fail with an ENODATA errno when another entity is using the same path to access it. Add it to the retry list so that phosphor-hwmon will retry and hopefully be able to get a clean read. Even for devices where this contention isn't the case, the code may as well retry as opposed to trying once and giving up. Resolves openbmc/openbmc#2645 Change-Id: Ib7aaaa14be33a33794a8c62d6991f77ab65a2ffa Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Claim a stable well known busnameBrad Bishop2017-11-142-2/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this patch readd instances claim a busname with a format of: xyz.openbmc_project.Hwmon.Hwmon<N> where N is the hwmon sysfs class instance. This is problematic for client applications that cache sensor object busname mappings for objects provided by readd. When readd instances restart (due to udev events) the hwmon sysfs class index may have changed, resulting in clients connecting to the wrong service instance. Address this by ensuring readd instances claim the same name every time they are started: xyz.openbmc_project.Hwmon-<ID>.Hwmon1 Where ID is a std::hash of the /sys/devices path backing the hwmon instance. Additionally, add a trailing API version as recommended best practice by the D-Bus specification. Change-Id: Idd0057ce883a49c1e828fb54fede27ea14022d6a Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
* Update threshold checking comparison operatorsChiabing Lee2017-11-031-4/+4
| | | | | | | | | Change sensors threshold value checking to less/greater than or equal Resolves openbmc/openbmc#2531 Change-Id: I4f177f583c95ffd278d696d053644c453d03ab7b Signed-off-by: Chiabing Lee <chiabinglee@gmail.com>
* Spelling fixesGunnar Mills2017-10-252-4/+4
| | | | | | | | | Spelling errors found using github.com/lucasdemarchi/codespell A tool to fix common misspellings. This tool is licensed under GNU General Public License, version 2. Change-Id: Ia3256c0771a94cc44154a7f81af2dcfaf851ffa7 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
* Read fan target sysfs value on startupMatt Spinler2017-10-243-8/+44
| | | | | | | | | | | | | | | When creating the object that represents the Control.FanSpeed interface for a fan, read the target fan speed out of sysfs and save it in the object so it shows up in D-Bus immediately. Previously the Target property would have a value of zero until another application wrote it, leaving a window where the D-Bus property wouldn't match the underlying sysfs file value. Change-Id: I08b149840c2cf731bc48f89118622fa63222600e Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Only write pwm_enable if it has an env varMatt Spinler2017-10-243-19/+17
| | | | | | | | | | | | | Some device drivers don't need pwmX_enable written, so only do it if an environment variable is present that contains the value to write. The environment variable is specified in the conf file along with the other enviroment variables and would look like: ENABLE_fan1 = "2" Change-Id: I484ada60957cb0d2b133a69b36bf12cbaad948dc Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Pass discrete type/ID values into addThresholdMatt Spinler2017-10-172-7/+11
| | | | | | | | The ID has to be looked up separately in some cases so can't always be the ID specified in the key_type object. Change-Id: I7f5b395ec3db2182fe84df24047bfae64fcee479 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Remove getIndirectLabelEnvMatt Spinler2017-10-172-57/+0
| | | | | | | It is no longer used. Change-Id: I4713fbd9232dfeed045125cbb827b4fe98c53717 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Refactor method of looking up indirect labelsMatt Spinler2017-10-171-11/+15
| | | | | | | | | | | | Use a combination of getIndirectID() and getEnv() when looking up labels when their values are specified in sysfs files instead of getIndirectLabelEnv(). This is done so the ID is exposed and can be used later for looking up thresholds. Change-Id: I4d2399bb7717130e61a8aacc37e75f36f410c94e Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Remove old TODOMatt Spinler2017-10-171-2/+1
| | | | | | | This ended up being handled completely outside of hwmon. Change-Id: I54d322761a90a6efb033b9994974b4d1933bf88e Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Add getIndirectID functionMatt Spinler2017-10-172-0/+40
| | | | | | | | | | | | | This function will look up the sensor ID for a sensor when it is specified in a label file in hwmon sysfs. This functionality was previously all contained in getIndirectlLabelEnv(). A future commit will remove this function entirely and just use getIndirectID() and getEnv() to look up the label for the indirect case. Change-Id: Ifeb636eb0e58a6204f782f64e9aba839b812a967 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Add another version of getEnvMatt Spinler2017-10-172-0/+31
| | | | | | | | The new version takes the type and ID parameters separately as opposed to together in a key_type. Change-Id: I7796e8e6d680ffb640028e91eb3dcc8e7d99bc2e Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* use stoll() to convert threshold string to numberMatt Spinler2017-10-121-2/+2
| | | | | | | | | The stoi() and stol() functions will throw out of range exceptions when trying to convert valid threshold values, such as power numbers in microwatts. Change-Id: Ifd4c12fb37d6bd905c73633a468f35361b544fa7 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Log the failing sysfs filenameMatt Spinler2017-10-092-0/+33
| | | | | | | | | | | | | Add the name of the sysfs path an access failed on to the journal when an error log is created. This is useful for debug. An example of the path in the journal metadata is: FILE=/sys/class/hwmon/hwmon7/temp1_input Change-Id: I4bc3548619e561cd3acc95ba3ecc778fb08c7104 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Retry on ENODEV errnosMatt Spinler2017-10-091-0/+8
| | | | | | | | | | | | | | This errno can be returned by certain device drivers when they are in the process of being unbound. Retrying will give the driver time to finish unbinding, and phosphor-hwmon will then die off naturally as phosphor-hwmon's lifetime is tied to the loaded driver's. Resolves openbmc/openbmc#2401 Change-Id: Ife888f3b608d7694d22f95412a7d320377daefa4 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Enhancement to support GAIN and OFFSET value for sensor readingChiabing Lee2017-09-141-0/+40
| | | | | | | | | | | | | | | | | | | | | | For example, AST BMC chips ADC input voltage range is 0 to 2.5V, good nominal input voltage is 1.8V. Other voltages are scaled into that range using external resistors(ADC voltage divider). Since the values of these resistors can change from their own motherboard design, the conversions cannot be hard coded into the Linux driver and have to be done in user space. In the sensor configuration file, add the GAIN_in[0-*] and OFFSET_in[0-*] value. The sensor reading conversion can be: value = (raw sensor reading) * gain + offset Resolves: openbmc/openbmc#2259 Change-Id: I2502c656e0d34dd69b9c795788505f209a77a72b Signed-off-by: Chiabing Lee <chiabinglee@gmail.com> Signed-off-by: Lei YU <mine260309@gmail.com>
* sysfs IO enhancementsBrad Bishop2017-09-085-98/+168
| | | | | | | | | | | | | | | | | | Add retries for some sysfs IO errors: EIO: Tolerate intermittant device or bus failures. ETIMEDOUT: Tolerate intermittant timeouts. EAGAIN: Tolerate drivers that do not block. ENXIO: Tolerate momentarily unplugged devices on busses that don't support hotplug. EBADMSG: Tolerate CRC errors. Flush stdio buffers after writes. Remove redundant retry and delay constants. Resolves: openbmc/openbmc#2262 Change-Id: I2104139bf7ced96bb10f7450b42ca36e61c84287 Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
* Docs: Add IIO device limitation informationBrad Bishop2017-08-311-0/+14
| | | | | | | | Add an IIO devices README to ward off the typical questions about IIO. Change-Id: If126daf1ddf550d9d7bf475b4d68ae2566f72c74 Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
* test: Add a number of test applicationsBrad Bishop2017-08-315-1/+163
| | | | | | | Add a number of applications for testing. Change-Id: I2d85c33d0d85f2a551e644a722107bb78250b2cd Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
* sysfs: Removed unused codeBrad Bishop2017-08-312-172/+0
| | | | | | | A number of methods have been deprecated. Remove. Change-Id: I87fa63724d67770719e93a85803fa37737d5cfad Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
* Use hwmonio for attribute IOBrad Bishop2017-08-315-84/+142
| | | | | | | | | | Moves disparate error handling scenarios from the method doing the IO to the call point. Resolves openbmc/openbmc#2166 Change-Id: I3b6d2e175433dd8b2946ae60381901f2d7ca1798 Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
* Add hwmon io wrapper classBrad Bishop2017-08-312-0/+179
| | | | | | | | | | | | | Add a convenience class for doing hwmon attribute sysfs IO. A convenience class is warranted given some necessary workarounds for some GCC io exception bugs, and more importantly to remove the burden of the rest of the application checking for ENOENT in the case of a driver unbind event. Change-Id: I73d5a9aaaac1d5546109ae18854fe5db0b5acb26 Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
* mainloop: Cache devpath at startupBrad Bishop2017-08-314-0/+15
| | | | | | | | | | Currently the devpath is determined after a bus error to make a callout. Finding the path at startup is less prone to race conditions around ENOENT on driver unload in the event of a callout. Change-Id: I8ce8d9f630c8b7ecc398082002aa113ab352d3cb Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
* sysfs: refactor findCalloutBrad Bishop2017-08-312-23/+84
| | | | | | | | | | | | | | - Export findCalloutPath so other modules can use it. - Change parameter to hwmon instance path to avoid fs::canonical outside sysfs.cpp. - Check for the iio-hwmon driver instead of relying on DT nodes having 'iio-hwmon' in them. - For iio devices, provide a /sys/devices path rather than a DT path. - Use existing application indenting and doxygen style. Change-Id: I16c2dc7417eb68f7cbef44243f481df8040ec1fd Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
* sysfs: refactor findHwmonBrad Bishop2017-08-311-15/+23
| | | | | | | | - Invert branch logic to reduce indent levels. - Handle disappearing hwmon instances while searching. Change-Id: I20f93003bd3fa4f849341c4cf08a0f6a29bf785a Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
* sysfs: refactor findPhandleMatchBrad Bishop2017-08-292-47/+59
| | | | | | | | | | | | | - Use same indenting style as the rest of the application. - Invert branch logic to reduce indent levels. - Move logic that does not depend on loop variants outside loop. - Fix a bug where the io-channels phandle is read from the wrong file. - Remove unnecessary try/catch block around DT IOs (DT is immutable). - Export findPhandle so other modules can use it. - Document current method limitations. Change-Id: I34c1c6731a5e2334075b2d25c6583143c2997207 Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
* sysfs: Removed unused headersBrad Bishop2017-08-281-2/+1
| | | | | | | Also put fstream in the right place. Change-Id: I3c199c49f6c4068f0483b923f51dc4750aa42596 Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
* Add configure option to control how fails behaveMatt Spinler2017-08-102-0/+24
| | | | | | | | | | | | | | | | | Different platforms have different requirements for handling hwmon sysfs access failures. The default behavior is now that the application will terminate if a hardware read fails, and rely on systemd restarting it as a way of doing retries. The new configure option --enable-remove-from-dbus-on-fail will cause the application to remove the property permanently from D-Bus and never try to access it again, but not fail out. This was the previous (recently added) default behavior. Change-Id: I6367f2e3e072a2ca9a3da700d4de1b6c34b219ff Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Change current label to reflect the terminology used in hwmon intfJaghathiswari Rankappagounder Natarajan2017-08-041-1/+1
| | | | | Change-Id: I5ac1a7a8647968002ad81b600293ded019977ddc Signed-off-by: Jaghathiswari Rankappagounder Natarajan <jaghu@google.com>
* msl: Add a max31785 MSL checking scriptBrad Bishop2017-08-014-2/+78
| | | | | | | | | Add a script that checks the firmware revision of a max31785 hwmon device and populates the MeetsMinimumShipLevel interface of the specified inventory items. Change-Id: If3dd527d2815edffd3b8b425a15617290016769b Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
* Allow EAGAIN failuresMatt Spinler2017-07-283-20/+75
| | | | | | | | | | | | | | Certain devices are known to return EAGAIN failures when read too frequently, so be tolerant of them. On startup, the code will retry for up to a second to get a good first reading, and then in the main loop the code will just stick with the current value if it fails that way. Resolves openbmc/openbmc#2038 Change-Id: I7621aa30429c43276239982a03ec3eef02ce9c6e Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Don't exit program on sysfs read failures.Patrick Venture2017-07-276-55/+102
| | | | | | | | | | | | | | | | | | | | | We have an unreliable fan in one of the test systems and at present if the sysfs entry is unavailable or returns failure, then the program will exit. The program could be serving many sensors, and any one failure will cause it to exit. This is true not only when initially creating the sensors, but also if any sensor read fails at run-time. Testing: I verified the program logged the failures, which may not be ideal if there is a buggy sensor, but, I also ran it and managed to catch it where the sensor wasn't there initially and it cleanly reported only the sensors that were responsive and didn't just exit. There is certainly a case to be made for re-scanning periodically if the sensor returns or there was a timing issue, and there is a separate bug for that. This commit means only to make the program more robust on failure. Change-Id: I310a3e3c0e0ea86e439341a296b741ded18f46f2 Signed-off-by: Patrick Venture <venture@google.com>
* Fix high CPU usage noted with BMP280Brandon Wyman2017-06-261-4/+2
| | | | | | | | The call to findCallOutPath() is really only needed if we have encountered a read or write error. Change-Id: I81136156ba3a42546a5e2cec85283a0082358853 Signed-off-by: Brandon Wyman <v2cib530@us.ibm.com>
* Don't exit with error when hwmon dir is removedAndrew Geissler2017-06-161-0/+12
| | | | | | | | | | | | | There is a race condition between when an hwmon directory is removed and systemd halting the phosphor-hwmon application monitoring it. This code change ensures the application does not return an error in these cases. Resolves openbmc/openbmc#1789 Change-Id: If4f032759c522aa811d4092e7a7d8ea275480e4a Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
* Add a level of indirection when naming the DBUS objectsTom Joseph2017-06-143-7/+87
| | | | | | | | | | | | The current design ignores the itemX_label sysfs attribute, if the environment variable is populated with the MODE_itemX="label", then fetch the label from itemX_label file.The actual label for the dbus object is fetched from the environment variable LABEL_item<label>. Resolves openbmc/openbmc#1633 Change-Id: I0d4baaa91073dd5db75ac62277d78ad9b3065e64 Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
* Update call out algorithm for iio hwmon instanceBrandon Wyman2017-06-061-23/+91
| | | | | | | | | | | | | | | When readSysfsWithCallout() or writeSysfsWithCallout() get run, use the instancePath to search for a call out path. For instances with an hwmon driver, the passed in path should be used. For instances with an iio driver, search for a phandle file that has a value matching to that in the io-channels file for this phosphor-hwmon instance. If an error occurs on the read or write, use that matching phandle path to create a call out path. Resolves openbmc/openbmc#1265 Change-Id: I6390d0dfb3d67ce8a55d171ca9a3cb8f3057a8c9 Signed-off-by: Brandon Wyman <v2cib530@us.ibm.com>
* Update algorithm to find iio hwmon instanceBrandon Wyman2017-06-061-0/+33
| | | | | | | | If the hwmon instance cannot be found via the path symlink, try to find the instance via the phandle value in io-channels. Change-Id: I20966ec465baca41c1122afe714c1260926eade9 Signed-off-by: Brandon Wyman <v2cib530@us.ibm.com>
* Introduce interval configuration for sensor reads.Patrick Venture2017-06-052-4/+13
| | | | | | | | | | | | | | | | | This introduces the ability to specify in the sensor label configuration file, a specific sleep interval. The interval is in this file to allow straightforward interval control over the sensors listed in that file. Sensors grouped in the same file are treated as a group and run within the same instance. Tested: I tested setting the interval in one of four running configurations and the change was picked up in that configuration while the others ran at the default interval. Resolves openbmc/phosphor-hwmon#5 Change-Id: Ia9e474bc446090c8ac95dc2e6bf23a4fd6ccf7b7 Signed-off-by: Patrick Venture <venture@google.com>
* Exit early if no sensors matched.Patrick Venture2017-05-231-0/+6
| | | | | | | | | | | | | | | | | | | Previously, if it finds that there are no sensors or no matching labels it would create the bus and then spin on the interval indefinitely doing nothing but occupying precious memory. Not that this is a case that is likely to happen in real-use, but it is a reasonable edge execution case that can be easily addressed. I ran into this when trying to momentarily stop it from reading the fans while I was running timing code. I had simply commented out the fan labels, but the program ran anyway -- now it didn't read the fans, but it seemed odd that it didn't simply exit when it had nothing to do. There is a comment about checking for new sensors in the map, but this idea isn't fully fleshed out. Therefore, in the interim, this is a perfectly reasonable execution flow modification. Change-Id: Idd2a9568b09148ffffe1af5c00193a0f394ec6a6 Signed-off-by: Patrick Venture <venture@google.com>
* Write pwmX_enable for fans that have a fanX_targetMatt Spinler2017-05-115-12/+64
| | | | | | | | | | | | | | | | | | For fans that have a fanX_target hwmon sysfs attribute, write the pwmX_enable on startup to put that fan into RPM mode, which is safe to do because this application requires that the target is written in RPMs. The write will only occur if the pwm_enable file exists. In the future, if fans with a target need to run in pwm mode, this code will need to be updated to convert between RPM and pwm anyway and the pwm_enable value can then be different based on that. Resolves openbmc/openbmc#1584 Change-Id: I4f6f3ac8d6651314367aaf5c51ac176220f1fba6 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Cater for change in elog create and commit interfaceMarri Devender Rao2017-04-151-26/+14
| | | | | Change-Id: I2a3fb65781965502d705bca772ebfb11e2334af9 Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
* Update sysfs readsMatthew Barth2017-03-301-6/+15
| | | | | | | Log an error with a device callout on read failures Change-Id: Ic9cd7ce3964e49879efd4bb19f197fd6a306773c Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
* Update hwmon fan target sysfs entriesMatthew Barth2017-03-307-18/+177
| | | | | | | | | | | | | Override the default FanSpeed.Target set implementation so when a target value is written to the FanSpeed interface it is also updated in the related fan target sysfs file. This sets a particular fan to the given target speed. Resolves openbmc/openbmc#962 Resolves openbmc/phosphor-hwmon#1 Change-Id: I867811737269b3f42d2a0dc15b37782a74f147b8 Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
* Create a FanSpeedObject interfaceMatthew Barth2017-03-304-0/+81
| | | | | | | | | Create the FanSpeedObject target interface when the fanx_target sysfs file exists. The "xyz.openbmc_project.Control.Target" interface is on the /xyz/openbmc_project/sensors/fan_tac/fan[#] object paths. Change-Id: Ib4a099cff17cacea501b474969f292516db212b5 Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
* Use std::filesystem when generating callout pathsBrad Bishop2017-03-271-7/+9
| | | | | Change-Id: Ia4dbe7e27368a7136d3767f105f6af78d9627c3f Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
* Change constexpr function pointers to static constantsSaqib Khan2017-03-202-24/+41
| | | | | | | | | | | Note: Newer version of gcc no longer supports constexpr function pointers to be declared in the header file. Therefore we fixed this by declaring them as static constants in the header file and moved the initialization to the source file. Change-Id: Ied87c62b14be79cc268cfe8c63e8f2385c7e75b6 Signed-off-by: Saqib Khan <khansa@us.ibm.com>
* Remove unnecessary copy constructing ObjectManagerBrad Bishop2017-03-081-1/+1
| | | | | Change-Id: I62cca216546f82fa93cbdd22f40b00ca8c189859 Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
OpenPOWER on IntegriCloud