Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Arthur Korn" <akorn@google.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH] hwmon: (pmbus) Fall back to CLEAR_FAULTS when STATUS_CML is read-only
Date: Wed, 25 Nov 2026 05:49:05 +0000	[thread overview]
Message-ID: <sashiko-outbox-232631@kernel.org> (raw)
In-Reply-To: <20261125053711.3098007-1-akorn@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] hwmon: (pmbus) pmbus_clear_cml_fault() disables W1C on
  virtual pages
--

commit 55aa274a3350ffb5857e7b698b066e9435f264ba
Author: Arthur Korn <akorn@google.com>

hwmon: (pmbus) Fall back to CLEAR_FAULTS when STATUS_CML is read-only

This commit reads back PMBUS_STATUS_CML after attempting to clear CML
faults on non-write-protected devices, disabling STATUS_CML write-1-to-clear
and falling back to CLEAR_FAULTS if the fault bits remain set.

> diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
> index db5c5f533eb97..af8f589b328df 100644
> --- a/drivers/hwmon/pmbus/pmbus_core.c
> +++ b/drivers/hwmon/pmbus/pmbus_core.c
> @@ -728,15 +728,31 @@ 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))
> +				ret = -EIO;
> +		}
> +		if (ret >= 0)
> +			return;
> +		data->has_status_cml = false;
> +	}
>  
> -	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);
>  }

[Severity: Medium]
Does clearing data->has_status_cml on any negative return value from
_pmbus_write_byte_data() disable STATUS_CML write-1-to-clear across the
whole device when a driver exposes a read-only virtual page?

During pmbus_init_common(), pmbus_clear_cml_faults() iterates over all
pages.  On multi-page devices such as max16601, virtual page 1 is
read-only while pages 0 (VCORE) and 2 (VSA) support byte writes:

drivers/hwmon/pmbus/max16601.c:max16601_write_byte_data() {
	...
	if (page > 0) {
		if (page == 2)	/* VSA */
			return i2c_smbus_write_byte_data(data->vsa, reg, value);
		return -EOPNOTSUPP;
	}
	return -ENODATA;
}

When pmbus_clear_cml_faults() reaches page 1, _pmbus_write_byte_data()
returns -EOPNOTSUPP and sets data->has_status_cml = false.  Unlike before,
where only page 1 fell back to pmbus_clear_fault_page(), this regression
disables STATUS_CML write-1-to-clear for page 2 and for all subsequent
register probes on page 0, sending PMBUS_CLEAR_FAULTS and wiping latched
faults on both rails.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261125053711.3098007-1-akorn@google.com?part=1

      reply	other threads:[~2026-11-25  5:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25  5:37 [PATCH] hwmon: (pmbus) Fall back to CLEAR_FAULTS when STATUS_CML is read-only Arthur Korn
2026-11-25  5:49 ` sashiko-bot [this message]

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=sashiko-outbox-232631@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=akorn@google.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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