* [PATCH v2] hwmon: (pmbus) Clear only CML invalid command fault during probe
@ 2026-11-19 1:32 Arthur Korn
2026-11-19 2:08 ` sashiko-bot
0 siblings, 1 reply; 3+ messages in thread
From: Arthur Korn @ 2026-11-19 1:32 UTC (permalink / raw)
To: Guenter Roeck; +Cc: linux-hwmon, linux-kernel, Arthur Korn
During driver initialization and register capability probing, pmbus_core
and the generic pmbus driver send CLEAR_FAULTS (0x03) to clear any
communication or command faults triggered while probing unsupported
registers. 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 (such as PMBUS_PAGE on single-page PMBus
devices) asserts PB_CML_FAULT_INVALID_COMMAND in STATUS_CML. Leaving
that bit latched causes pmbus_check_status_cml() to fail subsequent
capability checks (including PMBUS_VOUT_MODE and sensor discovery) with
-EIO.
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 write
PB_CML_FAULT_INVALID_COMMAND to PMBUS_STATUS_CML during device
initialization, register probing, and pmbus_identify() on PMBus 1.2+
devices while preserving all other latched fault bits. Fall back to
pmbus_clear_fault_page() on PMBus < 1.2 devices 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
that all devices probe cleanly with no -EIO regressions. Also verified
via unbind, fault injection, and re-bind across both driver-specific and
generic pmbus_identify() paths that PB_CML_FAULT_INVALID_COMMAND in
PMBUS_STATUS_CML is cleared on probe while other STATUS_CML and
STATUS_WORD fault bits remain preserved, and verified clean fallback
when writing PMBUS_STATUS_CML is NACKed.
Signed-off-by: Arthur Korn <akorn@google.com>
---
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 | 30 +++++++++++++++++++++++++-----
3 files changed, 27 insertions(+), 6 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..a5255ffb 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -717,6 +717,26 @@ 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->revision < PMBUS_REV_12 ||
+ _pmbus_write_byte_data(client, page, PMBUS_STATUS_CML,
+ PB_CML_FAULT_INVALID_COMMAND) < 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 +765,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 +782,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 +810,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;
}
@@ -3053,9 +3073,9 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data,
}
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);
--
2.56.1.703.gf848ed807c-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] hwmon: (pmbus) Clear only CML invalid command fault during probe
2026-11-19 1:32 [PATCH v2] hwmon: (pmbus) Clear only CML invalid command fault during probe Arthur Korn
@ 2026-11-19 2:08 ` sashiko-bot
2026-11-19 2:29 ` Guenter Roeck
0 siblings, 1 reply; 3+ messages in thread
From: sashiko-bot @ 2026-11-19 2:08 UTC (permalink / raw)
To: Arthur Korn; +Cc: linux-hwmon
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] hwmon: (pmbus) pmbus_write_smbalert_mask() clears all faults
on probe
- [Medium] hwmon: (pmbus) pmbus_clear_cml_fault() leaves INVALID_DATA
fault latched
- [Medium] hwmon: (pmbus) pmbus_clear_cml_fault() bypasses driver
write_byte() hooks
--
commit 94d47b10140ba57df41cbee449647587f625d5f3
Author: Arthur Korn <akorn@google.com>
hwmon: (pmbus) Clear only CML invalid command fault during probe
This commit introduces pmbus_clear_cml_fault() and pmbus_clear_cml_faults()
to clear only PB_CML_FAULT_INVALID_COMMAND in PMBUS_STATUS_CML during probe
on PMBus 1.2+ devices instead of sending PMBUS_CLEAR_FAULTS.
> diff --git a/drivers/hwmon/pmbus/pmbus.c b/drivers/hwmon/pmbus/pmbus.c
> index 28889fb743b3e..e2e49fdd54841 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)) {
[Severity: Medium]
Does pmbus_clear_cml_faults() leave PB_CML_FAULT_INVALID_DATA latched
after page auto-detection?
When PMBUS_PAGE is supported, the loop right above probes page numbers
with pmbus_set_page() until writing an out-of-range page index to the
valid PMBUS_PAGE command fails, which latches PB_CML_FAULT_INVALID_DATA
in PMBUS_STATUS_CML. Because pmbus_clear_cml_fault() only writes
PB_CML_FAULT_INVALID_COMMAND, PB_CML_FAULT_INVALID_DATA and PB_STATUS_CML
remain latched after probe.
> diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
> index 82dac2c6c579f..74fc8d7481689 100644
> --- a/drivers/hwmon/pmbus/pmbus_core.c
> +++ b/drivers/hwmon/pmbus/pmbus_core.c
> @@ -713,6 +713,26 @@ 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->revision < PMBUS_REV_12 ||
> + _pmbus_write_byte_data(client, page, PMBUS_STATUS_CML,
> + PB_CML_FAULT_INVALID_COMMAND) < 0)
> + pmbus_clear_fault_page(client, page);
> +}
[Severity: Medium]
Does calling _pmbus_write_byte_data() here bypass driver info->write_byte
callbacks that intercept or block fault clearing?
Previously, probe-time fault clearing always went through
pmbus_clear_fault_page() -> _pmbus_write_byte(client, page,
PMBUS_CLEAR_FAULTS). Several drivers hook write_byte without
implementing write_byte_data: for example, max16601_write_byte() routes
page 2 (PMBUS_PAGE_VIRTUAL) PMBUS_CLEAR_FAULTS to a separate I2C client
(data->vsa), so _pmbus_write_byte_data() writes PMBUS_STATUS_CML to
client (page 0) instead and leaves CML faults on data->vsa uncleared.
Similarly, delta-ahe50dc-fan and max31785 block fault-clearing writes in
write_byte(), and mpq8646 blocks unsupported PMBUS_STATUS_CML reads in
read_byte_data(), none of which implement write_byte_data().
> +
> +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);
[ ... ]
> @@ -2978,9 +2998,9 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data,
> }
>
> 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);
[Severity: Medium]
Should pmbus_write_smbalert_mask() also use pmbus_clear_cml_fault()
instead of pmbus_clear_fault_page()?
When client->irq is set, pmbus_do_probe() -> pmbus_irq_setup() calls
pmbus_write_smbalert_mask() across every page:
drivers/hwmon/pmbus/pmbus_core.c:pmbus_write_smbalert_mask() {
...
ret = _pmbus_write_word_data(client, page, PMBUS_SMBALERT_MASK,
reg | (val << 8));
/*
* Clear fault systematically in case writing PMBUS_SMBALERT_MASK
* is not supported by the chip.
*/
pmbus_clear_fault_page(client, page);
return ret;
}
On any IRQ-enabled PMBus device, this still sends PMBUS_CLEAR_FAULTS on
all pages during probe and erases the latched fault registers that this
patch aims to preserve.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119013208.4089480-1-akorn@google.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] hwmon: (pmbus) Clear only CML invalid command fault during probe
2026-11-19 2:08 ` sashiko-bot
@ 2026-11-19 2:29 ` Guenter Roeck
0 siblings, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2026-11-19 2:29 UTC (permalink / raw)
To: sashiko-reviews, Arthur Korn; +Cc: linux-hwmon
Hi Arthur,
On 11/18/26 18:08, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 3 potential
> issues to consider:
> - [Medium] hwmon: (pmbus) pmbus_write_smbalert_mask() clears all faults
> on probe
> - [Medium] hwmon: (pmbus) pmbus_clear_cml_fault() leaves INVALID_DATA
> fault latched
> - [Medium] hwmon: (pmbus) pmbus_clear_cml_fault() bypasses driver
> write_byte() hooks
> --
>
Looks like Sashiko has a point, including the write_byte hook problem.
I think Google uses MAX16601, and that is a PMBus 1.2 chip, so it may
be affected.
On a side note, it should be possible to run Sashiko locally on your
system, or I can run it before you submit the next version if you
have trouble setting it up. This might avoid a couple of revisions
if/when Sashiko finds new problems.
Thanks
Guenter
> commit 94d47b10140ba57df41cbee449647587f625d5f3
> Author: Arthur Korn <akorn@google.com>
>
> hwmon: (pmbus) Clear only CML invalid command fault during probe
>
> This commit introduces pmbus_clear_cml_fault() and pmbus_clear_cml_faults()
> to clear only PB_CML_FAULT_INVALID_COMMAND in PMBUS_STATUS_CML during probe
> on PMBus 1.2+ devices instead of sending PMBUS_CLEAR_FAULTS.
>
>> diff --git a/drivers/hwmon/pmbus/pmbus.c b/drivers/hwmon/pmbus/pmbus.c
>> index 28889fb743b3e..e2e49fdd54841 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)) {
>
> [Severity: Medium]
> Does pmbus_clear_cml_faults() leave PB_CML_FAULT_INVALID_DATA latched
> after page auto-detection?
>
> When PMBUS_PAGE is supported, the loop right above probes page numbers
> with pmbus_set_page() until writing an out-of-range page index to the
> valid PMBUS_PAGE command fails, which latches PB_CML_FAULT_INVALID_DATA
> in PMBUS_STATUS_CML. Because pmbus_clear_cml_fault() only writes
> PB_CML_FAULT_INVALID_COMMAND, PB_CML_FAULT_INVALID_DATA and PB_STATUS_CML
> remain latched after probe.
>
>> diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
>> index 82dac2c6c579f..74fc8d7481689 100644
>> --- a/drivers/hwmon/pmbus/pmbus_core.c
>> +++ b/drivers/hwmon/pmbus/pmbus_core.c
>> @@ -713,6 +713,26 @@ 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->revision < PMBUS_REV_12 ||
>> + _pmbus_write_byte_data(client, page, PMBUS_STATUS_CML,
>> + PB_CML_FAULT_INVALID_COMMAND) < 0)
>> + pmbus_clear_fault_page(client, page);
>> +}
>
> [Severity: Medium]
> Does calling _pmbus_write_byte_data() here bypass driver info->write_byte
> callbacks that intercept or block fault clearing?
>
> Previously, probe-time fault clearing always went through
> pmbus_clear_fault_page() -> _pmbus_write_byte(client, page,
> PMBUS_CLEAR_FAULTS). Several drivers hook write_byte without
> implementing write_byte_data: for example, max16601_write_byte() routes
> page 2 (PMBUS_PAGE_VIRTUAL) PMBUS_CLEAR_FAULTS to a separate I2C client
> (data->vsa), so _pmbus_write_byte_data() writes PMBUS_STATUS_CML to
> client (page 0) instead and leaves CML faults on data->vsa uncleared.
> Similarly, delta-ahe50dc-fan and max31785 block fault-clearing writes in
> write_byte(), and mpq8646 blocks unsupported PMBUS_STATUS_CML reads in
> read_byte_data(), none of which implement write_byte_data().
>
>> +
>> +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);
>
> [ ... ]
>
>> @@ -2978,9 +2998,9 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data,
>> }
>>
>> 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);
>
> [Severity: Medium]
> Should pmbus_write_smbalert_mask() also use pmbus_clear_cml_fault()
> instead of pmbus_clear_fault_page()?
>
> When client->irq is set, pmbus_do_probe() -> pmbus_irq_setup() calls
> pmbus_write_smbalert_mask() across every page:
>
> drivers/hwmon/pmbus/pmbus_core.c:pmbus_write_smbalert_mask() {
> ...
> ret = _pmbus_write_word_data(client, page, PMBUS_SMBALERT_MASK,
> reg | (val << 8));
> /*
> * Clear fault systematically in case writing PMBUS_SMBALERT_MASK
> * is not supported by the chip.
> */
> pmbus_clear_fault_page(client, page);
>
> return ret;
> }
>
> On any IRQ-enabled PMBus device, this still sends PMBUS_CLEAR_FAULTS on
> all pages during probe and erases the latched fault registers that this
> patch aims to preserve.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-19 2:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 1:32 [PATCH v2] hwmon: (pmbus) Clear only CML invalid command fault during probe Arthur Korn
2026-11-19 2:08 ` sashiko-bot
2026-11-19 2:29 ` 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.