From: Arthur Korn <akorn@google.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
Arthur Korn <akorn@google.com>
Subject: [PATCH v2] hwmon: (pmbus) Fall back to CLEAR_FAULTS when STATUS_CML is read-only
Date: Wed, 25 Nov 2026 18:13:35 +0000 [thread overview]
Message-ID: <20261125181336.3298961-1-akorn@google.com> (raw)
Some PMBus 1.2 devices (such as ADI ADM1273 and ADM1281) report
PMBUS_REVISION = 0x22 and implement STATUS_CML (0x7e) as read-only:
they ACK SMBus byte writes to PMBUS_STATUS_CML without clearing latched
fault bits, and only clear STATUS_CML via CLEAR_FAULTS (0x03).
During pmbus_init_common(), probing an unsupported register such as
PMBUS_WRITE_PROTECT (0x10) latches PB_CML_FAULT_INVALID_COMMAND in
STATUS_CML. When pmbus_clear_cml_fault() writes to PMBUS_STATUS_CML and
sees ret == 0, PB_CML_FAULT_INVALID_COMMAND remains latched, causing
subsequent pmbus_check_status_cml() calls during attribute discovery to
fail with -EIO.
Verify on non-write-protected devices that PB_CML_FAULT_INVALID_COMMAND
and PB_CML_FAULT_INVALID_DATA actually cleared when a CML fault is
expected or cleared unconditionally. If the write succeeds and either
bit remains set on readback, disable STATUS_CML write-1-to-clear for the
device and fall back to pmbus_clear_fault_page(). Do not clear
has_status_cml when _pmbus_write_byte_data() returns an error, so
per-page write failures (such as -EOPNOTSUPP on read-only virtual pages
like max16601 page 1) fall back for that page without disabling
STATUS_CML write-1-to-clear on other pages. Skipping the readback on
supported register probes (rv >= 0) avoids extra SMBus traffic in the
common path.
Tested on BMC hardware across ADI ADM1273-1A (adm1275), Maxim
MAX16600B.04 (max16601, 3 virtual pages across VCORE, sensor IIN/PIN,
and VSA), Renesas RAA228234 (isl68137), Infineon XDPE1A2G5B (tda38740),
ADI ADM1266, and factory write-protected converters.
Fixes: d9d30e1cb9ca ("hwmon: (pmbus) Clear only CML command and data faults during probe")
Signed-off-by: Arthur Korn <akorn@google.com>
---
v2:
- Only clear data->has_status_cml when _pmbus_write_byte_data()
succeeds and the post-write readback shows PB_CML_FAULT_CLEAR_MASK
still set, so per-page write failures (such as -EOPNOTSUPP on
max16601's read-only virtual page 1) do not disable STATUS_CML W1C
for other pages. (Sashiko, Guenter Roeck)
- Verified STATUS_CML W1C and virtual-page behavior on MAX16600B.04
(max16601) hardware.
- Link to v1: https://lore.kernel.org/linux-hwmon/20261125053711.3098007-1-akorn@google.com/
drivers/hwmon/pmbus/pmbus_core.c | 41 ++++++++++++++++++++++----------
1 file changed, 29 insertions(+), 12 deletions(-)
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index 2772860..b7f2f01 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -727,15 +727,32 @@ 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)
+#define PB_CML_FAULT_CLEAR_MASK (PB_CML_FAULT_INVALID_COMMAND | \
+ PB_CML_FAULT_INVALID_DATA)
+
+static void pmbus_clear_cml_fault(struct i2c_client *client, int page,
+ bool verify)
{
struct pmbus_data *data = i2c_get_clientdata(client);
+ int ret;
+
+ if (data->has_status_cml) {
+ ret = _pmbus_write_byte_data(client, page, PMBUS_STATUS_CML,
+ PB_CML_FAULT_CLEAR_MASK);
+ if (ret >= 0 && verify &&
+ !(data->flags & PMBUS_WRITE_PROTECTED)) {
+ ret = _pmbus_read_byte_data(client, page,
+ PMBUS_STATUS_CML);
+ if (ret >= 0 && (ret & PB_CML_FAULT_CLEAR_MASK)) {
+ data->has_status_cml = false;
+ ret = -EIO;
+ }
+ }
+ if (ret >= 0)
+ return;
+ }
- 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);
+ pmbus_clear_fault_page(client, page);
}
void pmbus_clear_cml_faults(struct i2c_client *client)
@@ -744,7 +761,7 @@ void pmbus_clear_cml_faults(struct i2c_client *client)
int i;
for (i = 0; i < data->info->pages; i++)
- pmbus_clear_cml_fault(client, i);
+ pmbus_clear_cml_fault(client, i, true);
}
EXPORT_SYMBOL_NS_GPL(pmbus_clear_cml_faults, "PMBUS");
@@ -776,7 +793,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_cml_fault(client, -1);
+ pmbus_clear_cml_fault(client, -1, rv < 0);
return rv >= 0;
}
@@ -793,7 +810,7 @@ static bool pmbus_check_status_register(struct i2c_client *client, int page)
status = -EIO;
}
- pmbus_clear_cml_fault(client, -1);
+ pmbus_clear_cml_fault(client, -1, status < 0);
return status >= 0;
}
@@ -821,7 +838,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_cml_fault(client, -1);
+ pmbus_clear_cml_fault(client, -1, rv < 0);
return rv >= 0;
}
@@ -3094,7 +3111,7 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data,
if (data->info->pages)
pmbus_clear_cml_faults(client);
else
- pmbus_clear_cml_fault(client, -1);
+ pmbus_clear_cml_fault(client, -1, true);
if (info->identify) {
ret = (*info->identify)(client, info);
@@ -3742,7 +3759,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_cml_fault(client, page);
+ pmbus_clear_cml_fault(client, page, true);
return ret;
}
--
2.56.1.750.gf70dc682cf-goog
reply other threads:[~2026-11-25 18:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261125181336.3298961-1-akorn@google.com \
--to=akorn@google.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®