summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/occ/common.c
Commit message (Collapse)AuthorAgeFilesLines
* hwmon (occ): Add temp sensor value checkAlexander Soldatov2019-04-181-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | The occ driver supports two formats for the temp sensor value. The OCC firmware for P8 supports only the first format, for which no range checking or error processing is performed in the driver. Inspecting the OCC sources for P8 reveals that OCC may send a special value 0xFFFF to indicate that a sensor read timeout has occurred, see https://github.com/open-power/occ/blob/master_p8/src/occ/cmdh/cmdh_fsp_cmds.c#L395 That situation wasn't handled in the driver. This patch adds invalid temp value check for the sensor data format 1 and handles it the same way as it is done for the format 2, where EREMOTEIO is reported for this case. Signed-off-by: Alexander Soldatov <a.soldatov@yadro.com> Signed-off-by: Alexander Amelkin <a.amelkin@yadro.com> Reviewed-by: Alexander Amelkin <a.amelkin@yadro.com> Cc: Edward A. James <eajames@us.ibm.com> Cc: Joel Stanley <joel@jms.id.au> Reviewed-by: Eddie James <eajames@linux.ibm.com>
* hwmon (occ): Store error condition for rate-limited pollsEddie James2019-04-181-0/+4
| | | | | | | | | | | The OCC driver limits the rate of sending poll commands to the OCC. If a user reads a hwmon entry after a poll response resulted in an error and is rate-limited, the error is invisible to the user. Fix this by storing the last error and returning that in the rate-limited case. OpenBMC-Staging-Count: 1 Signed-off-by: Eddie James <eajames@linux.ibm.com> Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* hwmon: occ: Fix power sensor indexingEddie James2019-03-201-2/+4
| | | | | | | | | | | | | | | | | In the case of power sensor version 0xA0, the sensor indexing overlapped with the "caps" power sensors, resulting in probe failure and kernel warnings. [ 81.895963] occ-hwmon occ-hwmon.1: OCC found, code level: op_occ_181108a [ 81.903965] sysfs: cannot create duplicate filename '/devices/platform/gpio-fsi/fsi0/slave@00:00/00:00:00:06/sbefifo1-dev0/occ-hwmon.1/hwmon/hwmon4/power2_label' Fix this by specifying the next index for each power sensor version. OpenBMC-Staging-Count: 1 Fixes: 54076cb ("hwmon (occ): Add sensor attributes and register ...") Signed-off-by: Eddie James <eajames@linux.ibm.com> Signed-off-by: Joel Stanley <joel@jms.id.au>
* hwmon: (occ) Fix potential integer overflowGustavo A. R. Silva2019-01-071-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | Cast get_unaligned_be32(...) to u64 in order to give the compiler complete information about the proper arithmetic to use and avoid a potential integer overflow. Notice that such function call is used in contexts that expect expressions of type u64 (64 bits, unsigned); and the following expressions are currently being evaluated using 32-bit arithmetic: val = get_unaligned_be32(&power->update_tag) * occ->powr_sample_time_us; val = get_unaligned_be32(&power->vdn.update_tag) * occ->powr_sample_time_us; Addresses-Coverity-ID: 1442357 ("Unintentional integer overflow") Addresses-Coverity-ID: 1442476 ("Unintentional integer overflow") Addresses-Coverity-ID: 1442508 ("Unintentional integer overflow") Fixes: ff692d80b2e2 ("hwmon (occ): Add sensor types and versions") Cc: stable@vger.kernel.org Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Reviewed-by: Eddie James <eajames@linux.ibm.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon (occ): Add sysfs attributes for additional OCC dataEddie James2018-12-161-3/+42
| | | | | | | | | | | | The OCC provides a variety of additional information about the state of the host processor, such as throttling, error conditions, and the number of OCCs detected in the system. This information is essential to service processor applications such as fan control and host management. Therefore, export this data in the form of sysfs attributes attached to the platform device (to which the hwmon device is also attached). Signed-off-by: Eddie James <eajames@linux.ibm.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon (occ): Add sensor attributes and register hwmon deviceEddie James2018-12-161-0/+337
| | | | | | | | Setup the sensor attributes for every OCC sensor found by the first poll response. Register the attributes with hwmon. Signed-off-by: Eddie James <eajames@linux.ibm.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon (occ): Add sensor types and versionsEddie James2018-12-161-0/+621
| | | | | | | | | | Add structures to define all sensor types and versions. Add sysfs show and store functions for each sensor type. Add a method to construct the "set user power cap" command and send it to the OCC. Add rate limit to polling the OCC (in case user-space reads our hwmon entries rapidly). Signed-off-by: Eddie James <eajames@linux.ibm.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon (occ): Parse OCC poll responseEddie James2018-12-161-0/+61
| | | | | | | | | | | | Add method to parse the response from the OCC poll command. This only needs to be done during probe(), since the OCC shouldn't change the number or format of sensors while it's running. The parsed response allows quick access to sensor data, as well as information on the number and version of sensors, which we need to instantiate hwmon attributes. Signed-off-by: Eddie James <eajames@linux.ibm.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: Add On-Chip Controller (OCC) hwmon driverEddie James2018-12-161-0/+40
The OCC is a device embedded on a POWER processor that collects and aggregates sensor data from the processor and system. The OCC can provide the raw sensor data as well as perform thermal and power management on the system. This driver provides a hwmon interface to the OCC from a service processor (e.g. a BMC). The driver supports both POWER8 and POWER9 OCCs. Communications with the POWER8 OCC are established over standard I2C bus. The driver communicates with the POWER9 OCC through the FSI-based OCC driver, which handles the lower-level communication details. This patch lays out the structure of the OCC hwmon driver. There are two platform drivers, one each for P8 and P9 OCCs. These are probed through the I2C tree and the FSI-based OCC driver, respectively. The patch also defines the first common structures and methods between the two OCC versions. Signed-off-by: Eddie James <eajames@linux.ibm.com> [groeck: Fix up SPDX license identifier] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
OpenPOWER on IntegriCloud