* [PATCH v3 1/2] hwmon: (pmbus/max16601) Support byte data writes on VSA rail
@ 2026-11-20 2:44 Arthur Korn
2026-11-20 2:44 ` [PATCH v3 2/2] hwmon: (pmbus) Clear only CML command and data faults during probe Arthur Korn
2026-11-20 19:28 ` [PATCH v3 1/2] hwmon: (pmbus/max16601) Support byte data writes on VSA rail Guenter Roeck
0 siblings, 2 replies; 4+ messages in thread
From: Arthur Korn @ 2026-11-20 2:44 UTC (permalink / raw)
To: Guenter Roeck; +Cc: linux-hwmon, linux-kernel, Arthur Korn
MAX16601 exposes the secondary VSA rail on virtual PMBus page 2 backed
by a separate I2C client (data->vsa), while page 1 is a read-only
virtual page for VCORE input current and power telemetry. Although the
driver routes byte reads on page 2 to data->vsa via max16601_read_byte()
and PMBUS_CLEAR_FAULTS byte writes via max16601_write_byte(), it does
not implement write_byte_data(), and max16601_write_byte() falls through
to -ENODATA on virtual page 1.
As a result, PMBus 1.2+ byte-data status writes from pmbus_core (such as
clearing individual status bits in pmbus_get_boolean() or clearing
STATUS_CML faults during probe) on page 2 are sent to the primary VCORE
client instead of data->vsa, and byte writes on virtual page 1 fall
through to page 0.
Implement max16601_write_byte_data() mirroring max16601_read_byte() to
forward page 2 byte-data writes to data->vsa and reject virtual page 1
with -EOPNOTSUPP, and reject virtual page 1 in max16601_write_byte() as
well.
Fixes: 2138f8853a00 ("hwmon: (pmbus) Driver for Maxim MAX16601")
Signed-off-by: Arthur Korn <akorn@google.com>
---
Changes in v3:
- New preparatory patch to route MAX16601 page 2 (VSA) byte-data writes
to data->vsa and reject virtual page 1 byte/byte-data writes.
drivers/hwmon/pmbus/max16601.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/pmbus/max16601.c b/drivers/hwmon/pmbus/max16601.c
index 2eca7525..f9138fc0 100644
--- a/drivers/hwmon/pmbus/max16601.c
+++ b/drivers/hwmon/pmbus/max16601.c
@@ -153,14 +153,28 @@ static int max16601_write_byte(struct i2c_client *client, int page, u8 reg)
const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
struct max16601_data *data = to_max16601_data(info);
- if (page == 2) {
- if (reg == PMBUS_CLEAR_FAULTS)
+ if (page > 0) {
+ if (page == 2 && reg == PMBUS_CLEAR_FAULTS)
return i2c_smbus_write_byte(data->vsa, reg);
return -EOPNOTSUPP;
}
return -ENODATA;
}
+static int max16601_write_byte_data(struct i2c_client *client, int page,
+ int reg, u8 value)
+{
+ const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
+ struct max16601_data *data = to_max16601_data(info);
+
+ if (page > 0) {
+ if (page == 2) /* VSA */
+ return i2c_smbus_write_byte_data(data->vsa, reg, value);
+ return -EOPNOTSUPP;
+ }
+ return -ENODATA;
+}
+
static int max16601_write_word(struct i2c_client *client, int page, int reg,
u16 value)
{
@@ -252,6 +266,7 @@ static struct pmbus_driver_info max16601_info = {
.read_byte_data = max16601_read_byte,
.read_word_data = max16601_read_word,
.write_byte = max16601_write_byte,
+ .write_byte_data = max16601_write_byte_data,
.write_word_data = max16601_write_word,
};
--
2.56.1.703.gf848ed807c-goog
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH v3 2/2] hwmon: (pmbus) Clear only CML command and data faults during probe 2026-11-20 2:44 [PATCH v3 1/2] hwmon: (pmbus/max16601) Support byte data writes on VSA rail Arthur Korn @ 2026-11-20 2:44 ` Arthur Korn 2026-11-20 19:28 ` Guenter Roeck 2026-11-20 19:28 ` [PATCH v3 1/2] hwmon: (pmbus/max16601) Support byte data writes on VSA rail Guenter Roeck 1 sibling, 1 reply; 4+ messages in thread From: Arthur Korn @ 2026-11-20 2:44 UTC (permalink / raw) To: Guenter Roeck; +Cc: linux-hwmon, linux-kernel, Arthur Korn During driver initialization, register capability probing, and SMBALERT mask setup, pmbus_core and the generic pmbus driver send CLEAR_FAULTS (0x03) to clear any communication or command faults triggered while probing unsupported commands or out-of-range page/register operands. However, CLEAR_FAULTS unconditionally clears all latched fault status bits across the device, including hardware power fault registers such as STATUS_WORD, STATUS_VOUT, STATUS_IOUT, and STATUS_MFR_SPECIFIC. As a result, a BMC reboot or driver re-probe erases pre-existing voltage regulator fault telemetry before monitoring or diagnostic tools can inspect it. Simply omitting fault clearing during probe is not viable because probing unsupported commands asserts PB_CML_FAULT_INVALID_COMMAND in STATUS_CML (causing pmbus_check_status_cml() to fail subsequent checks with -EIO), and probing out-of-range PMBUS_PAGE or PMBUS_SMBALERT_MASK operands asserts PB_CML_FAULT_INVALID_DATA and PB_STATUS_CML. Starting with PMBus Revision 1.2, individual bits in STATUS_CML can be cleared via Write-1-to-Clear (W1C), a mechanism pmbus_core already uses in pmbus_get_boolean(). Introduce pmbus_clear_cml_fault() and export pmbus_clear_cml_faults() in the "PMBUS" module namespace to clear PB_CML_FAULT_INVALID_COMMAND | PB_CML_FAULT_INVALID_DATA in PMBUS_STATUS_CML during device initialization, register probing, pmbus_write_smbalert_mask(), and pmbus_identify() while preserving all other latched fault bits: - Verify during pmbus_init_common() that PMBUS_REVISION is valid (>= 1.2 and not 0xff), that the driver does not hook write_byte() without write_byte_data(), and that PMBUS_STATUS_CML is readable before enabling STATUS_CML W1C clearing. - Fall back to pmbus_clear_fault_page() when STATUS_CML W1C is unavailable or if writing PMBUS_STATUS_CML fails. Tested on BMC hardware across 130 hwmon devices (105 PMBus devices covering tda38740/xdpe1a2g5b, isl68137/raa228234, adm1266, ltc4286/ltc4287, and generic pmbus regulators including TI tps546e25/tps546b25 and factory write-protected converters), verifying clean probing with no -EIO regressions, preservation of non-CML status faults across re-binds, and fallback when writing PMBUS_STATUS_CML is NACKed. Signed-off-by: Arthur Korn <akorn@google.com> --- Changes in v3: - Clear PB_CML_FAULT_INVALID_DATA in addition to PB_CML_FAULT_INVALID_COMMAND so out-of-range PMBUS_PAGE and PMBUS_SMBALERT_MASK operand probes do not leave CML faults latched. - Use pmbus_clear_cml_fault() in pmbus_write_smbalert_mask() so IRQ setup during probe also preserves pre-existing non-CML faults. - Gate STATUS_CML W1C clearing via data->has_status_cml in pmbus_init_common() (requiring valid PMBUS_REVISION >= 1.2 and != 0xff, no write_byte() hook without write_byte_data(), and readable PMBUS_STATUS_CML != 0xff) so driver write_byte() / read_byte_data() filters are respected. Changes in v2: - Fall back to pmbus_clear_fault_page() if writing PMBUS_STATUS_CML fails (e.g. NACK on devices that do not support W1C on STATUS_CML). - Export pmbus_clear_cml_faults() in the "PMBUS" namespace and use it in pmbus_identify() (pmbus.c) so generic pmbus devices also preserve non-CML faults during probe. - Re-tested on hardware covering generic pmbus_identify() fault preservation and the STATUS_CML write-failure fallback path. drivers/hwmon/pmbus/pmbus.c | 2 +- drivers/hwmon/pmbus/pmbus.h | 1 + drivers/hwmon/pmbus/pmbus_core.c | 44 +++++++++++++++++++++++++++----- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/drivers/hwmon/pmbus/pmbus.c b/drivers/hwmon/pmbus/pmbus.c index f8189c11..f239dafb 100644 --- a/drivers/hwmon/pmbus/pmbus.c +++ b/drivers/hwmon/pmbus/pmbus.c @@ -113,7 +113,7 @@ static int pmbus_identify(struct i2c_client *client, info->pages = 1; } - pmbus_clear_faults(client); + pmbus_clear_cml_faults(client); } if (pmbus_check_byte_register(client, 0, PMBUS_VOUT_MODE)) { diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h index 5525c048..8170098f 100644 --- a/drivers/hwmon/pmbus/pmbus.h +++ b/drivers/hwmon/pmbus/pmbus.h @@ -581,6 +581,7 @@ int pmbus_write_byte_data(struct i2c_client *client, int page, u8 reg, int pmbus_update_byte_data(struct i2c_client *client, int page, u8 reg, u8 mask, u8 value); void pmbus_clear_faults(struct i2c_client *client); +void pmbus_clear_cml_faults(struct i2c_client *client); void pmbus_check_and_notify_faults(struct i2c_client *client); bool pmbus_check_byte_register(struct i2c_client *client, int page, int reg); bool pmbus_check_word_register(struct i2c_client *client, int page, int reg); diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index b3aa7f1a..89a96732 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -122,6 +122,7 @@ struct pmbus_data { #endif bool has_status_word; /* device uses STATUS_WORD register */ + bool has_status_cml; /* device supports STATUS_CML W1C */ int (*read_status)(struct i2c_client *client, int page); s16 currpage; /* current page, -1 for unknown/unset */ @@ -717,6 +718,27 @@ void pmbus_clear_faults(struct i2c_client *client) } EXPORT_SYMBOL_NS_GPL(pmbus_clear_faults, "PMBUS"); +static void pmbus_clear_cml_fault(struct i2c_client *client, int page) +{ + struct pmbus_data *data = i2c_get_clientdata(client); + + if (!data->has_status_cml || + _pmbus_write_byte_data(client, page, PMBUS_STATUS_CML, + PB_CML_FAULT_INVALID_COMMAND | + PB_CML_FAULT_INVALID_DATA) < 0) + pmbus_clear_fault_page(client, page); +} + +void pmbus_clear_cml_faults(struct i2c_client *client) +{ + struct pmbus_data *data = i2c_get_clientdata(client); + int i; + + for (i = 0; i < data->info->pages; i++) + pmbus_clear_cml_fault(client, i); +} +EXPORT_SYMBOL_NS_GPL(pmbus_clear_cml_faults, "PMBUS"); + static int pmbus_check_status_cml(struct i2c_client *client) { struct pmbus_data *data = i2c_get_clientdata(client); @@ -745,7 +767,7 @@ static bool pmbus_check_register(struct i2c_client *client, if (rv < 0 && (data->flags & PMBUS_READ_STATUS_AFTER_FAILED_CHECK)) data->read_status(client, -1); if (reg < PMBUS_VIRT_BASE) - pmbus_clear_fault_page(client, -1); + pmbus_clear_cml_fault(client, -1); return rv >= 0; } @@ -762,7 +784,7 @@ static bool pmbus_check_status_register(struct i2c_client *client, int page) status = -EIO; } - pmbus_clear_fault_page(client, -1); + pmbus_clear_cml_fault(client, -1); return status >= 0; } @@ -790,7 +812,7 @@ static bool __maybe_unused pmbus_check_block_register(struct i2c_client *client, rv = pmbus_check_status_cml(client); if (rv < 0 && (data->flags & PMBUS_READ_STATUS_AFTER_FAILED_CHECK)) data->read_status(client, -1); - pmbus_clear_fault_page(client, -1); + pmbus_clear_cml_fault(client, -1); return rv >= 0; } @@ -3046,16 +3068,24 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data, data->revision = info->pmbus_revision; } else { ret = i2c_smbus_read_byte_data(client, PMBUS_REVISION); - if (ret >= 0) { + if (ret >= 0 && ret != 0xff) { data->have_pmbus_revision = true; data->revision = ret; } } + if (data->revision >= PMBUS_REV_12 && + (!info->write_byte || info->write_byte_data)) { + ret = _pmbus_read_byte_data(client, info->pages ? 0 : -1, + PMBUS_STATUS_CML); + if (ret >= 0 && ret != 0xff) + data->has_status_cml = true; + } + if (data->info->pages) - pmbus_clear_faults(client); + pmbus_clear_cml_faults(client); else - pmbus_clear_fault_page(client, -1); + pmbus_clear_cml_fault(client, -1); if (info->identify) { ret = (*info->identify)(client, info); @@ -3703,7 +3733,7 @@ static int pmbus_write_smbalert_mask(struct i2c_client *client, u8 page, u8 reg, * Clear fault systematically in case writing PMBUS_SMBALERT_MASK * is not supported by the chip. */ - pmbus_clear_fault_page(client, page); + pmbus_clear_cml_fault(client, page); return ret; } -- 2.56.1.703.gf848ed807c-goog ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3 2/2] hwmon: (pmbus) Clear only CML command and data faults during probe 2026-11-20 2:44 ` [PATCH v3 2/2] hwmon: (pmbus) Clear only CML command and data faults during probe Arthur Korn @ 2026-11-20 19:28 ` Guenter Roeck 0 siblings, 0 replies; 4+ messages in thread From: Guenter Roeck @ 2026-11-20 19:28 UTC (permalink / raw) To: Arthur Korn; +Cc: linux-hwmon, linux-kernel On Fri, Nov 20, 2026 at 02:44:16AM +0000, Arthur Korn wrote: > During driver initialization, register capability probing, and SMBALERT > mask setup, pmbus_core and the generic pmbus driver send CLEAR_FAULTS > (0x03) to clear any communication or command faults triggered while > probing unsupported commands or out-of-range page/register operands. > However, CLEAR_FAULTS unconditionally clears all latched fault status > bits across the device, including hardware power fault registers such as > STATUS_WORD, STATUS_VOUT, STATUS_IOUT, and STATUS_MFR_SPECIFIC. As a > result, a BMC reboot or driver re-probe erases pre-existing voltage > regulator fault telemetry before monitoring or diagnostic tools can > inspect it. > > Simply omitting fault clearing during probe is not viable because > probing unsupported commands asserts PB_CML_FAULT_INVALID_COMMAND in > STATUS_CML (causing pmbus_check_status_cml() to fail subsequent checks > with -EIO), and probing out-of-range PMBUS_PAGE or PMBUS_SMBALERT_MASK > operands asserts PB_CML_FAULT_INVALID_DATA and PB_STATUS_CML. > > Starting with PMBus Revision 1.2, individual bits in STATUS_CML can be > cleared via Write-1-to-Clear (W1C), a mechanism pmbus_core already uses > in pmbus_get_boolean(). Introduce pmbus_clear_cml_fault() and export > pmbus_clear_cml_faults() in the "PMBUS" module namespace to clear > PB_CML_FAULT_INVALID_COMMAND | PB_CML_FAULT_INVALID_DATA in > PMBUS_STATUS_CML during device initialization, register probing, > pmbus_write_smbalert_mask(), and pmbus_identify() while preserving all > other latched fault bits: > > - Verify during pmbus_init_common() that PMBUS_REVISION is valid (>= 1.2 > and not 0xff), that the driver does not hook write_byte() without > write_byte_data(), and that PMBUS_STATUS_CML is readable before > enabling STATUS_CML W1C clearing. > - Fall back to pmbus_clear_fault_page() when STATUS_CML W1C is > unavailable or if writing PMBUS_STATUS_CML fails. > > Tested on BMC hardware across 130 hwmon devices (105 PMBus devices > covering tda38740/xdpe1a2g5b, isl68137/raa228234, adm1266, > ltc4286/ltc4287, and generic pmbus regulators including TI > tps546e25/tps546b25 and factory write-protected converters), verifying > clean probing with no -EIO regressions, preservation of non-CML status > faults across re-binds, and fallback when writing PMBUS_STATUS_CML is > NACKed. > > Signed-off-by: Arthur Korn <akorn@google.com> Applied. Thanks, Guenter ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3 1/2] hwmon: (pmbus/max16601) Support byte data writes on VSA rail 2026-11-20 2:44 [PATCH v3 1/2] hwmon: (pmbus/max16601) Support byte data writes on VSA rail Arthur Korn 2026-11-20 2:44 ` [PATCH v3 2/2] hwmon: (pmbus) Clear only CML command and data faults during probe Arthur Korn @ 2026-11-20 19:28 ` Guenter Roeck 1 sibling, 0 replies; 4+ messages in thread From: Guenter Roeck @ 2026-11-20 19:28 UTC (permalink / raw) To: Arthur Korn; +Cc: linux-hwmon, linux-kernel On Fri, Nov 20, 2026 at 02:44:15AM +0000, Arthur Korn wrote: > MAX16601 exposes the secondary VSA rail on virtual PMBus page 2 backed > by a separate I2C client (data->vsa), while page 1 is a read-only > virtual page for VCORE input current and power telemetry. Although the > driver routes byte reads on page 2 to data->vsa via max16601_read_byte() > and PMBUS_CLEAR_FAULTS byte writes via max16601_write_byte(), it does > not implement write_byte_data(), and max16601_write_byte() falls through > to -ENODATA on virtual page 1. > > As a result, PMBus 1.2+ byte-data status writes from pmbus_core (such as > clearing individual status bits in pmbus_get_boolean() or clearing > STATUS_CML faults during probe) on page 2 are sent to the primary VCORE > client instead of data->vsa, and byte writes on virtual page 1 fall > through to page 0. > > Implement max16601_write_byte_data() mirroring max16601_read_byte() to > forward page 2 byte-data writes to data->vsa and reject virtual page 1 > with -EOPNOTSUPP, and reject virtual page 1 in max16601_write_byte() as > well. > > Fixes: 2138f8853a00 ("hwmon: (pmbus) Driver for Maxim MAX16601") > Signed-off-by: Arthur Korn <akorn@google.com> Applied. Thanks, Guenter ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-20 19:28 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-11-20 2:44 [PATCH v3 1/2] hwmon: (pmbus/max16601) Support byte data writes on VSA rail Arthur Korn 2026-11-20 2:44 ` [PATCH v3 2/2] hwmon: (pmbus) Clear only CML command and data faults during probe Arthur Korn 2026-11-20 19:28 ` Guenter Roeck 2026-11-20 19:28 ` [PATCH v3 1/2] hwmon: (pmbus/max16601) Support byte data writes on VSA rail Guenter Roeck
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®