From: sashiko-bot@kernel.org
To: "Felix Radensky" <fradensky@nvidia.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH 1/3] hwmon: (pmbus/core) Invalidate cached page and phase on failed change
Date: Sun, 22 Nov 2026 07:48:16 +0000 [thread overview]
Message-ID: <sashiko-outbox-227794@kernel.org> (raw)
In-Reply-To: <20261122073322.1712843-2-fradensky@nvidia.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] hwmon: (pmbus/core) pmbus_set_page() updates cache outside
conditional blocks
--
commit 03751a48b86432f4503eb9a4970150b29ef4ab2c
Author: Felix Radensky <fradensky@nvidia.com>
hwmon: (pmbus/core) Invalidate cached page and phase on failed change
This commit resets data->currpage and data->currphase to -1 in
pmbus_set_page() before issuing PMBUS_PAGE and PMBUS_PHASE commands so
that a failed transfer forces a retry on the next access.
> diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
> index 82dac2c6c579f..dae56e2e6f21f 100644
> --- a/drivers/hwmon/pmbus/pmbus_core.c
> +++ b/drivers/hwmon/pmbus/pmbus_core.c
> @@ -227,6 +227,9 @@ int pmbus_set_page(struct i2c_client *client, int page, int phase)
>
> if (!(data->info->func[page] & PMBUS_PAGE_VIRTUAL) &&
> data->info->pages > 1 && page != data->currpage) {
> + /* A failed page change can leave the chip on any page */
> + data->currpage = -1;
> +
> pmbus_wait(client);
> rv = i2c_smbus_write_byte_data(client, PMBUS_PAGE, page);
> pmbus_update_ts(client, PMBUS_OP_WRITE | PMBUS_OP_PAGE_CHANGE);
> @@ -246,6 +249,9 @@ int pmbus_set_page(struct i2c_client *client, int page, int phase)
>
> if (data->info->phases[page] && data->currphase != phase &&
> !(data->info->func[page] & PMBUS_PHASE_VIRTUAL)) {
> + /* A failed phase change can leave the chip on any phase */
> + data->currphase = -1;
> +
> pmbus_wait(client);
> rv = i2c_smbus_write_byte_data(client, PMBUS_PHASE,
> phase);
[Severity: Medium]
Should data->currpage = page and data->currphase = phase be moved inside
their respective conditional blocks?
Because both assignments remain outside the if blocks:
drivers/hwmon/pmbus/pmbus_core.c:pmbus_set_page() {
...
data->currpage = page;
if (data->info->phases[page] && data->currphase != phase &&
!(data->info->func[page] & PMBUS_PHASE_VIRTUAL)) {
...
}
data->currphase = phase;
}
any call that skips the SMBus write still overwrites the cached value
(including an invalidated -1) without programming the chip. For example,
on a multi-page device where page 0 has phases and page 1 has
info->phases[1] == 0 (such as tps53681), if a phase change to 0xff on page
0 fails (leaving currphase == -1), an access to page 1 with phase 0xff
skips the PMBUS_PHASE write but sets currphase = 0xff. A subsequent access
to page 0 with phase 0xff then sees currphase == phase and skips sending
PMBUS_PHASE, accessing the wrong phase on the chip. The same happens for
currpage when accessing a page with PMBUS_PAGE_VIRTUAL set.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261122073322.1712843-1-fradensky@nvidia.com?part=1
next prev parent reply other threads:[~2026-11-22 7:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 7:33 [PATCH 0/3] hwmon: (pmbus) Add PMBUS_FORCE_PAGE_CHANGE flag Felix Radensky
2026-11-22 7:33 ` [PATCH 1/3] hwmon: (pmbus/core) Invalidate cached page and phase on failed change Felix Radensky
2026-11-22 7:48 ` sashiko-bot [this message]
2026-11-22 7:33 ` [PATCH 2/3] hwmon: (pmbus/core) Add PMBUS_FORCE_PAGE_CHANGE flag Felix Radensky
2026-11-22 7:33 ` [PATCH 3/3] hwmon: (pmbus/mp2975) Use PMBUS_FORCE_PAGE_CHANGE Felix Radensky
2026-11-22 7:48 ` [PATCH 0/3] hwmon: (pmbus) Add PMBUS_FORCE_PAGE_CHANGE flag sashiko-bot
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-227794@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=fradensky@nvidia.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