linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon (occ): Add temp sensor value check
@ 2019-07-10  7:26 Joel Stanley
  2019-07-10  8:57 ` Alexander Amelkin
  2019-07-10 20:56 ` Guenter Roeck
  0 siblings, 2 replies; 3+ messages in thread
From: Joel Stanley @ 2019-07-10  7:26 UTC (permalink / raw)
  To: Guenter Roeck, linux-hwmon
  Cc: Eddie James, Alexander Amelkin, Lei YU, Alexander Soldatov, linux-kernel

From: Alexander Soldatov <a.soldatov@yadro.com>

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.

Fixes: 54076cb3b5ff ("hwmon (occ): Add sensor attributes and register hwmon device")
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>
Reviewed-by: Eddie James <eajames@linux.ibm.com>
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
 drivers/hwmon/occ/common.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c
index cccf91742c1a..a7d2b16dd702 100644
--- a/drivers/hwmon/occ/common.c
+++ b/drivers/hwmon/occ/common.c
@@ -241,6 +241,12 @@ static ssize_t occ_show_temp_1(struct device *dev,
 		val = get_unaligned_be16(&temp->sensor_id);
 		break;
 	case 1:
+		/*
+		 * If a sensor reading has expired and couldn't be refreshed,
+		 * OCC returns 0xFFFF for that sensor.
+		 */
+		if (temp->value == 0xFFFF)
+			return -EREMOTEIO;
 		val = get_unaligned_be16(&temp->value) * 1000;
 		break;
 	default:
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] hwmon (occ): Add temp sensor value check
  2019-07-10  7:26 [PATCH] hwmon (occ): Add temp sensor value check Joel Stanley
@ 2019-07-10  8:57 ` Alexander Amelkin
  2019-07-10 20:56 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander Amelkin @ 2019-07-10  8:57 UTC (permalink / raw)
  To: Joel Stanley
  Cc: Guenter Roeck, linux-hwmon, Eddie James, Lei YU, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 2145 bytes --]

Thanks, Joel!

JFYI, Alexander Soldatov has left the YADRO team some time ago, so his e-mail @yadro.com isn't valid anymore.

Should anyone have any questions regarding this patch, feel free to email me.

With best regards,
Alexander Amelkin,
Leading BMC Software Engineer, YADRO
https://yadro.com

10.07.2019 10:26, Joel Stanley wrote:
> From: Alexander Soldatov <a.soldatov@yadro.com>
>
> 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.
>
> Fixes: 54076cb3b5ff ("hwmon (occ): Add sensor attributes and register hwmon device")
> 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>
> Reviewed-by: Eddie James <eajames@linux.ibm.com>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> ---
>  drivers/hwmon/occ/common.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c
> index cccf91742c1a..a7d2b16dd702 100644
> --- a/drivers/hwmon/occ/common.c
> +++ b/drivers/hwmon/occ/common.c
> @@ -241,6 +241,12 @@ static ssize_t occ_show_temp_1(struct device *dev,
>  		val = get_unaligned_be16(&temp->sensor_id);
>  		break;
>  	case 1:
> +		/*
> +		 * If a sensor reading has expired and couldn't be refreshed,
> +		 * OCC returns 0xFFFF for that sensor.
> +		 */
> +		if (temp->value == 0xFFFF)
> +			return -EREMOTEIO;
>  		val = get_unaligned_be16(&temp->value) * 1000;
>  		break;
>  	default:


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] hwmon (occ): Add temp sensor value check
  2019-07-10  7:26 [PATCH] hwmon (occ): Add temp sensor value check Joel Stanley
  2019-07-10  8:57 ` Alexander Amelkin
@ 2019-07-10 20:56 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2019-07-10 20:56 UTC (permalink / raw)
  To: Joel Stanley
  Cc: linux-hwmon, Eddie James, Alexander Amelkin, Lei YU,
	Alexander Soldatov, linux-kernel

On Wed, Jul 10, 2019 at 04:56:06PM +0930, Joel Stanley wrote:
> From: Alexander Soldatov <a.soldatov@yadro.com>
> 
> 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.
> 
> Fixes: 54076cb3b5ff ("hwmon (occ): Add sensor attributes and register hwmon device")
> 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>
> Reviewed-by: Eddie James <eajames@linux.ibm.com>
> Signed-off-by: Joel Stanley <joel@jms.id.au>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/occ/common.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c
> index cccf91742c1a..a7d2b16dd702 100644
> --- a/drivers/hwmon/occ/common.c
> +++ b/drivers/hwmon/occ/common.c
> @@ -241,6 +241,12 @@ static ssize_t occ_show_temp_1(struct device *dev,
>  		val = get_unaligned_be16(&temp->sensor_id);
>  		break;
>  	case 1:
> +		/*
> +		 * If a sensor reading has expired and couldn't be refreshed,
> +		 * OCC returns 0xFFFF for that sensor.
> +		 */
> +		if (temp->value == 0xFFFF)
> +			return -EREMOTEIO;
>  		val = get_unaligned_be16(&temp->value) * 1000;
>  		break;
>  	default:

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-07-10 20:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-10  7:26 [PATCH] hwmon (occ): Add temp sensor value check Joel Stanley
2019-07-10  8:57 ` Alexander Amelkin
2019-07-10 20:56 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).