Patch "hwmon: (pmbus) Conditionally clear individual status bits for pmbus rev >= 1.2" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    hwmon: (pmbus) Conditionally clear individual status bits for pmbus rev >= 1.2

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     hwmon-pmbus-conditionally-clear-individual-status-bi.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 203e2bd7162c1056d8dee4dd28377411a415266f
Author: Patryk Biel <pbiel7@xxxxxxxxx>
Date:   Mon Sep 9 11:30:28 2024 +0200

    hwmon: (pmbus) Conditionally clear individual status bits for pmbus rev >= 1.2
    
    [ Upstream commit 20471071f198c8626dbe3951ac9834055b387844 ]
    
    The current implementation of pmbus_show_boolean assumes that all devices
    support write-back operation of status register to clear pending warnings
    or faults. Since clearing individual bits in the status registers was only
    introduced in PMBus specification 1.2, this operation may not be supported
    by some older devices. This can result in an error while reading boolean
    attributes such as temp1_max_alarm.
    
    Fetch PMBus revision supported by the device and modify pmbus_show_boolean
    so that it only tries to clear individual status bits if the device is
    compliant with PMBus specs >= 1.2. Otherwise clear all fault indicators
    on the current page after a fault status was reported.
    
    Fixes: 35f165f08950a ("hwmon: (pmbus) Clear pmbus fault/warning bits after read")
    Signed-off-by: Patryk Biel <pbiel7@xxxxxxxxx>
    Message-ID: <20240909-pmbus-status-reg-clearing-v1-1-f1c0d68c6408@xxxxxxxxx>
    [groeck:
     Rewrote description
     Moved revision detection code ahead of clear faults command
     Assigned revision if return value from PMBUS_REVISION command is 0
     Improved return value check from calling _pmbus_write_byte_data()]
    Signed-off-by: Guenter Roeck <linux@xxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h
index b0832a4c690d..76c2b364c3fe 100644
--- a/drivers/hwmon/pmbus/pmbus.h
+++ b/drivers/hwmon/pmbus/pmbus.h
@@ -409,6 +409,12 @@ enum pmbus_sensor_classes {
 enum pmbus_data_format { linear = 0, ieee754, direct, vid };
 enum vrm_version { vr11 = 0, vr12, vr13, imvp9, amd625mv };
 
+/* PMBus revision identifiers */
+#define PMBUS_REV_10 0x00	/* PMBus revision 1.0 */
+#define PMBUS_REV_11 0x11	/* PMBus revision 1.1 */
+#define PMBUS_REV_12 0x22	/* PMBus revision 1.2 */
+#define PMBUS_REV_13 0x33	/* PMBus revision 1.3 */
+
 struct pmbus_driver_info {
 	int pages;		/* Total number of pages */
 	u8 phases[PMBUS_PAGES];	/* Number of phases per page */
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index 1363d9f89181..728c07c42651 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -85,6 +85,8 @@ struct pmbus_data {
 
 	u32 flags;		/* from platform data */
 
+	u8 revision;	/* The PMBus revision the device is compliant with */
+
 	int exponent[PMBUS_PAGES];
 				/* linear mode: exponent for output voltages */
 
@@ -1095,9 +1097,14 @@ static int pmbus_get_boolean(struct i2c_client *client, struct pmbus_boolean *b,
 
 	regval = status & mask;
 	if (regval) {
-		ret = _pmbus_write_byte_data(client, page, reg, regval);
-		if (ret)
-			goto unlock;
+		if (data->revision >= PMBUS_REV_12) {
+			ret = _pmbus_write_byte_data(client, page, reg, regval);
+			if (ret)
+				goto unlock;
+		} else {
+			pmbus_clear_fault_page(client, page);
+		}
+
 	}
 	if (s1 && s2) {
 		s64 v1, v2;
@@ -2640,6 +2647,10 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data,
 			data->flags |= PMBUS_WRITE_PROTECTED | PMBUS_SKIP_STATUS_CHECK;
 	}
 
+	ret = i2c_smbus_read_byte_data(client, PMBUS_REVISION);
+	if (ret >= 0)
+		data->revision = ret;
+
 	if (data->info->pages)
 		pmbus_clear_faults(client);
 	else




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux