All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] hwmon: (pmbus) Clear pmbus fault/warning bits after read
@ 2022-02-22 13:12 Vikash Chandola
  2022-02-22 16:15 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Vikash Chandola @ 2022-02-22 13:12 UTC (permalink / raw)
  To: linux, jdelvare, linux-hwmon, linux-kernel, iwona.winiarska
  Cc: Vikash Chandola

Almost all fault/warning bits in pmbus status registers remain set even
after fault/warning condition are removed. As per pmbus specification
these faults must be cleared by user.
Modify hwmon behavior to clear fault/warning bit after fetching data if
fault/warning bit was set. This allows to get fresh data in next read.

Signed-off-by: Vikash Chandola <vikash.chandola@linux.intel.com>
---
changes since v1:
v1 patch was clearing all the faults. That would have lead faults not
getting reported to user at all. This change clears only current fault
and that too after reporting it at least once. This way all the faults
will be reported to user space at least once.

Behaviour has been verified with following PSU
FRU Device Description : IS162F22 (ID 84)
Product Manufacturer   : SOLUM CO., LTD.
Product Name           : IS162F22
Product Part Number    : G36234-015
Product Version        : 10A

 drivers/hwmon/pmbus/pmbus_core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index 776ee2237be2..ac2fbee1ba9c 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -911,6 +911,11 @@ static int pmbus_get_boolean(struct i2c_client *client, struct pmbus_boolean *b,
 		pmbus_update_sensor_data(client, s2);
 
 	regval = status & mask;
+	if (regval) {
+		ret = pmbus_write_byte_data(client, page, reg, regval);
+		if (ret)
+			goto unlock;
+	}
 	if (s1 && s2) {
 		s64 v1, v2;
 
-- 
2.25.1


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

* Re: [PATCH v2] hwmon: (pmbus) Clear pmbus fault/warning bits after read
  2022-02-22 13:12 [PATCH v2] hwmon: (pmbus) Clear pmbus fault/warning bits after read Vikash Chandola
@ 2022-02-22 16:15 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2022-02-22 16:15 UTC (permalink / raw)
  To: Vikash Chandola; +Cc: jdelvare, linux-hwmon, linux-kernel, iwona.winiarska

On Tue, Feb 22, 2022 at 01:12:53PM +0000, Vikash Chandola wrote:
> Almost all fault/warning bits in pmbus status registers remain set even
> after fault/warning condition are removed. As per pmbus specification
> these faults must be cleared by user.
> Modify hwmon behavior to clear fault/warning bit after fetching data if
> fault/warning bit was set. This allows to get fresh data in next read.
> 
> Signed-off-by: Vikash Chandola <vikash.chandola@linux.intel.com>

Applied.

Thanks,
Guenter

> ---
> changes since v1:
> v1 patch was clearing all the faults. That would have lead faults not
> getting reported to user at all. This change clears only current fault
> and that too after reporting it at least once. This way all the faults
> will be reported to user space at least once.
> 
> Behaviour has been verified with following PSU
> FRU Device Description : IS162F22 (ID 84)
> Product Manufacturer   : SOLUM CO., LTD.
> Product Name           : IS162F22
> Product Part Number    : G36234-015
> Product Version        : 10A
> 
>  drivers/hwmon/pmbus/pmbus_core.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
> index 776ee2237be2..ac2fbee1ba9c 100644
> --- a/drivers/hwmon/pmbus/pmbus_core.c
> +++ b/drivers/hwmon/pmbus/pmbus_core.c
> @@ -911,6 +911,11 @@ static int pmbus_get_boolean(struct i2c_client *client, struct pmbus_boolean *b,
>  		pmbus_update_sensor_data(client, s2);
>  
>  	regval = status & mask;
> +	if (regval) {
> +		ret = pmbus_write_byte_data(client, page, reg, regval);
> +		if (ret)
> +			goto unlock;
> +	}
>  	if (s1 && s2) {
>  		s64 v1, v2;
>  

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

end of thread, other threads:[~2022-02-22 16:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-22 13:12 [PATCH v2] hwmon: (pmbus) Clear pmbus fault/warning bits after read Vikash Chandola
2022-02-22 16:15 ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.