* [PATCH v2 0/3] hwmon: (pmbus) Add PMBUS_FORCE_PAGE_CHANGE flag
@ 2026-11-22 17:09 Felix Radensky
2026-11-22 17:09 ` [PATCH v2 1/3] hwmon: (pmbus/core) Keep cached page and phase in sync with the chip Felix Radensky
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Felix Radensky @ 2026-11-22 17:09 UTC (permalink / raw)
To: Guenter Roeck; +Cc: Vadim Pasternak, Felix Radensky, linux-hwmon, linux-doc
As discussed in [1], this series adds the PMBUS_FORCE_PAGE_CHANGE device
flag, which makes pmbus_set_page() change the page of a chip with a
single page as well, and converts mp2975 to it. The mp2975 driver then
accesses the page 3 voltage reference with pmbus_set_page() also in a
single rail configuration, instead of writing PAGE directly.
Patch 1 keeps the page and phase cached by pmbus_set_page() in sync
with the chip. It invalidates them when changing them fails, so that the
next access sends PAGE and PHASE again, and updates them only when the
respective command is sent. Without it, a PAGE or PHASE write accepted
by the chip, but reported as failed, or a failed or mismatched PAGE
read-back, leaves the chip on a value other than the cached one, and an
access to a page without phases updates the cached phase without
sending PHASE. This already applies to chips with multiple pages or
phases, and would apply to chips using the new flag as well.
Patch 3 depends on commit 00944852275e ("hwmon: (pmbus/mp2975) Get vout
fault limits dynamically"), which is in v7.4-rc3, but not in hwmon-next
yet. The series is based on v7.4-rc3, and applies to hwmon-next with
that commit on top.
Tested on a switch platform carrying twelve MP2975 devices, twenty one
rails in total. On a single rail device, the change to page 3 is now
issued by the core and read back, while reading a sensor of the rail
issues no PAGE command. 400 page 3 excursions on a single rail device,
and 800 on a dual rail device, each followed by a read of the other
rail, showed no page 3 or other rail register value in place of a sensor
value. The limits of all rails matched those reported before the series,
and in2_crit of the rail supplying the CPU core voltage followed the CPU
between 1145mV and 1725mV. On this platform, patch 1 changes the bus
traffic only after a failed transfer, which was not exercised.
Changes in v2:
- Patch 1: update the cached page and phase only once the PAGE or PHASE
command succeeded, not also when no command is sent, that is for a
virtual page, and for a page without phases or with virtual phases
(Sashiko)
v1: https://lore.kernel.org/linux-hwmon/20261122073322.1712843-1-fradensky@nvidia.com/
[1] https://lore.kernel.org/linux-hwmon/8e4410db-66df-44b8-9617-1013545d7b43@roeck-us.net/
Felix Radensky (3):
hwmon: (pmbus/core) Keep cached page and phase in sync with the chip
hwmon: (pmbus/core) Add PMBUS_FORCE_PAGE_CHANGE flag
hwmon: (pmbus/mp2975) Use PMBUS_FORCE_PAGE_CHANGE
Documentation/hwmon/pmbus-core.rst | 12 +++++++++++-
drivers/hwmon/pmbus/mp2975.c | 29 +++++++++--------------------
drivers/hwmon/pmbus/pmbus_core.c | 15 ++++++++++++---
include/linux/pmbus.h | 11 +++++++++++
4 files changed, 43 insertions(+), 24 deletions(-)
base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/3] hwmon: (pmbus/core) Keep cached page and phase in sync with the chip
2026-11-22 17:09 [PATCH v2 0/3] hwmon: (pmbus) Add PMBUS_FORCE_PAGE_CHANGE flag Felix Radensky
@ 2026-11-22 17:09 ` Felix Radensky
2026-11-22 17:09 ` [PATCH v2 2/3] hwmon: (pmbus/core) Add PMBUS_FORCE_PAGE_CHANGE flag Felix Radensky
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Felix Radensky @ 2026-11-22 17:09 UTC (permalink / raw)
To: Guenter Roeck; +Cc: Vadim Pasternak, Felix Radensky, linux-hwmon, linux-doc
pmbus_set_page() caches the page and phase it sets, and skips the PAGE
and PHASE commands when the requested value matches the cached one. The
cache can get out of sync with the chip though.
If a PAGE write succeeds, while the read-back fails or returns a
different page, pmbus_set_page() returns an error without updating the
cached page. The chip can then be on the requested page, while the core
still caches the previous one, and the next access to the previous page
skips the PAGE command. The same applies to a PAGE or PHASE write which
returns an error after the chip has accepted it, such as on a late NAK,
a PEC error or an adapter timeout.
In addition, the cached page and phase are updated even if no command
is sent, that is for a virtual page, and for a page without phases or
with virtual phases. The cached phase then no longer reflects the phase
of the chip, and can suppress a PHASE command required for another page,
even if a failed phase change had invalidated it. For the page, this
only causes a redundant PAGE command, since a virtual page never matches
a page of the chip.
Invalidate the cached page and phase before changing them, and update
them only once the respective command succeeded, so that the cache only
holds values the chip has accepted.
Signed-off-by: Felix Radensky <fradensky@nvidia.com>
Reviewed-by: Vadim Pasternak <vadimp@nvidia.com>
---
v2:
- Update the cached page and phase only once the PAGE or PHASE command
succeeded, not also when no command is sent, that is for a virtual
page, and for a page without phases or with virtual phases (Sashiko)
- Reword the subject and commit message accordingly
drivers/hwmon/pmbus/pmbus_core.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index 82dac2c6c579..5138c802d8ab 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);
@@ -241,19 +244,24 @@ int pmbus_set_page(struct i2c_client *client, int page, int phase)
if (rv != page)
return -EIO;
+
+ data->currpage = page;
}
- data->currpage = page;
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);
pmbus_update_ts(client, PMBUS_OP_WRITE);
if (rv)
return rv;
+
+ data->currphase = phase;
}
- data->currphase = phase;
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/3] hwmon: (pmbus/core) Add PMBUS_FORCE_PAGE_CHANGE flag
2026-11-22 17:09 [PATCH v2 0/3] hwmon: (pmbus) Add PMBUS_FORCE_PAGE_CHANGE flag Felix Radensky
2026-11-22 17:09 ` [PATCH v2 1/3] hwmon: (pmbus/core) Keep cached page and phase in sync with the chip Felix Radensky
@ 2026-11-22 17:09 ` Felix Radensky
2026-11-22 17:09 ` [PATCH v2 3/3] hwmon: (pmbus/mp2975) Use PMBUS_FORCE_PAGE_CHANGE Felix Radensky
2026-11-22 17:16 ` [PATCH v2 0/3] hwmon: (pmbus) Add PMBUS_FORCE_PAGE_CHANGE flag sashiko-bot
3 siblings, 0 replies; 5+ messages in thread
From: Felix Radensky @ 2026-11-22 17:09 UTC (permalink / raw)
To: Guenter Roeck; +Cc: Vadim Pasternak, Felix Radensky, linux-hwmon, linux-doc
The PMBus core driver only changes the page of chips with more than one
page, and neither writes nor verifies the page of a chip with a single
page. Some chips with a single page provide manufacturer specific
registers on additional pages. Their drivers write PAGE directly to
access them, and have to change back to the page the core expects on
their own. If changing back fails, the core accesses the chip on the
wrong page.
Add the PMBUS_FORCE_PAGE_CHANGE flag, which makes pmbus_set_page()
change the page of a chip with a single page as well, so that its driver
can access the additional pages with pmbus_set_page(). The page change
is then read back, and a failed page change is repeated on the next
access, as for chips with multiple pages.
While at it, drop the outdated number of flags from the platform data
description in the documentation.
Suggested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Felix Radensky <fradensky@nvidia.com>
Reviewed-by: Vadim Pasternak <vadimp@nvidia.com>
---
v2:
- No changes
Documentation/hwmon/pmbus-core.rst | 12 +++++++++++-
drivers/hwmon/pmbus/pmbus_core.c | 3 ++-
include/linux/pmbus.h | 11 +++++++++++
3 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/Documentation/hwmon/pmbus-core.rst b/Documentation/hwmon/pmbus-core.rst
index fdfb23773148..bca387518b6a 100644
--- a/Documentation/hwmon/pmbus-core.rst
+++ b/Documentation/hwmon/pmbus-core.rst
@@ -298,7 +298,7 @@ PMBus driver platform data
==========================
PMBus platform data is defined in include/linux/pmbus.h. Platform data
-currently provides a flags field with four bits used::
+currently provides a flags field with the following bits::
#define PMBUS_SKIP_STATUS_CHECK BIT(0)
@@ -316,6 +316,8 @@ currently provides a flags field with four bits used::
#define PMBUS_VOUT_PROTECTED BIT(7)
+ #define PMBUS_FORCE_PAGE_CHANGE BIT(8)
+
struct pmbus_platform_data {
u32 flags; /* Device specific flags */
@@ -388,6 +390,14 @@ PMBUS_VOUT_PROTECTED
Set if the chip VOUT_COMMAND command is protected and protection is not
determined by the standard WRITE_PROTECT command.
+PMBUS_FORCE_PAGE_CHANGE
+
+The PMBus core driver only changes the page of chips with more than one
+page. Some chips with a single page provide manufacturer specific registers
+on additional pages. Set this flag so that the PMBus core driver changes the
+page of such chips as well, which lets the chip driver access the additional
+pages with pmbus_set_page().
+
Module parameter
----------------
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index 5138c802d8ab..aed1c4605952 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -226,7 +226,8 @@ int pmbus_set_page(struct i2c_client *client, int page, int phase)
return 0;
if (!(data->info->func[page] & PMBUS_PAGE_VIRTUAL) &&
- data->info->pages > 1 && page != data->currpage) {
+ (data->info->pages > 1 || (data->flags & PMBUS_FORCE_PAGE_CHANGE)) &&
+ page != data->currpage) {
/* A failed page change can leave the chip on any page */
data->currpage = -1;
diff --git a/include/linux/pmbus.h b/include/linux/pmbus.h
index 884040e1383b..b3bc4cced461 100644
--- a/include/linux/pmbus.h
+++ b/include/linux/pmbus.h
@@ -87,6 +87,17 @@
*/
#define PMBUS_VOUT_PROTECTED BIT(7)
+/*
+ * PMBUS_FORCE_PAGE_CHANGE
+ *
+ * The PMBus core driver only changes the page of chips with more than one
+ * page. Some chips with a single page provide manufacturer specific registers
+ * on additional pages. Set this flag so that the PMBus core driver changes the
+ * page of such chips as well, which lets the chip driver access the additional
+ * pages with pmbus_set_page().
+ */
+#define PMBUS_FORCE_PAGE_CHANGE BIT(8)
+
struct pmbus_platform_data {
u32 flags; /* Device specific flags */
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 3/3] hwmon: (pmbus/mp2975) Use PMBUS_FORCE_PAGE_CHANGE
2026-11-22 17:09 [PATCH v2 0/3] hwmon: (pmbus) Add PMBUS_FORCE_PAGE_CHANGE flag Felix Radensky
2026-11-22 17:09 ` [PATCH v2 1/3] hwmon: (pmbus/core) Keep cached page and phase in sync with the chip Felix Radensky
2026-11-22 17:09 ` [PATCH v2 2/3] hwmon: (pmbus/core) Add PMBUS_FORCE_PAGE_CHANGE flag Felix Radensky
@ 2026-11-22 17:09 ` Felix Radensky
2026-11-22 17:16 ` [PATCH v2 0/3] hwmon: (pmbus) Add PMBUS_FORCE_PAGE_CHANGE flag sashiko-bot
3 siblings, 0 replies; 5+ messages in thread
From: Felix Radensky @ 2026-11-22 17:09 UTC (permalink / raw)
To: Guenter Roeck; +Cc: Vadim Pasternak, Felix Radensky, linux-hwmon, linux-doc
The voltage reference, from which the vout fault limits are derived, is
read on page 3. In a single rail configuration the driver writes PAGE
directly for it, since the PMBus core does not change the page of a chip
with a single page. If changing back to the rail page fails, the core
reads page 3 registers in place of the rail registers, until the next
voltage reference read changes the page again.
Set PMBUS_FORCE_PAGE_CHANGE, and change the page with pmbus_set_page()
in both configurations. The page change is then read back, and a failed
change is repeated on the next access, as for two rails.
Signed-off-by: Felix Radensky <fradensky@nvidia.com>
Reviewed-by: Vadim Pasternak <vadimp@nvidia.com>
---
v2:
- No changes
drivers/hwmon/pmbus/mp2975.c | 29 +++++++++--------------------
1 file changed, 9 insertions(+), 20 deletions(-)
diff --git a/drivers/hwmon/pmbus/mp2975.c b/drivers/hwmon/pmbus/mp2975.c
index 2ad6b7d831c8..4eba171ab87b 100644
--- a/drivers/hwmon/pmbus/mp2975.c
+++ b/drivers/hwmon/pmbus/mp2975.c
@@ -11,6 +11,7 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/pmbus.h>
#include "pmbus.h"
@@ -105,6 +106,7 @@ struct mp2975_driver_info {
struct mp2975_data {
struct pmbus_driver_info info;
+ struct pmbus_platform_data pdata;
enum chips chip_id;
int vout_scale;
int max_phases[MP2975_PAGE_NUM];
@@ -457,37 +459,20 @@ static int mp2973_write_word_data(struct i2c_client *client, int page,
return pmbus_write_word_data(client, 0, PMBUS_SMBALERT_MASK, ret);
}
-/*
- * Let the PMBus core change the page, so that the page it caches matches the
- * device. The core does not issue PAGE commands for a single rail
- * configuration, thus change the page directly then.
- */
-static int
-mp2975_page_set(struct i2c_client *client, struct mp2975_data *data, int page)
-{
- if (data->info.pages > 1)
- return pmbus_set_page(client, page, 0xff);
-
- return i2c_smbus_write_byte_data(client, PMBUS_PAGE, page);
-}
-
-/*
- * Voltage reference is available on page 3 only. The callers read a register
- * of the rail through the core first, thus the core caches the rail page.
- */
+/* Voltage reference is available on page 3 only. */
static int
mp2975_vref_get(struct i2c_client *client, struct mp2975_data *data, int page)
{
int ret, vref;
- ret = mp2975_page_set(client, data, 3);
+ ret = pmbus_set_page(client, 3, 0xff);
if (ret < 0)
return ret;
vref = i2c_smbus_read_word_data(client, page ? MP2975_MFR_READ_VREF_R2 :
MP2975_MFR_READ_VREF_R1);
- ret = mp2975_page_set(client, data, page);
+ ret = pmbus_set_page(client, page, 0xff);
if (ret < 0)
return ret;
@@ -1072,6 +1057,10 @@ static int mp2975_probe(struct i2c_client *client)
if (ret)
return ret;
+ /* Page 3 is accessed in a single rail configuration as well. */
+ data->pdata.flags = PMBUS_FORCE_PAGE_CHANGE;
+ client->dev.platform_data = &data->pdata;
+
ret = pmbus_do_probe(client, info);
if (ret)
return ret;
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/3] hwmon: (pmbus) Add PMBUS_FORCE_PAGE_CHANGE flag
2026-11-22 17:09 [PATCH v2 0/3] hwmon: (pmbus) Add PMBUS_FORCE_PAGE_CHANGE flag Felix Radensky
` (2 preceding siblings ...)
2026-11-22 17:09 ` [PATCH v2 3/3] hwmon: (pmbus/mp2975) Use PMBUS_FORCE_PAGE_CHANGE Felix Radensky
@ 2026-11-22 17:16 ` sashiko-bot
3 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-11-22 17:16 UTC (permalink / raw)
To: Felix Radensky; +Cc: linux-hwmon
Sashiko has reviewed this 3-patch series and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261122170949.3059743-1-fradensky@nvidia.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-22 17:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-22 17:09 [PATCH v2 0/3] hwmon: (pmbus) Add PMBUS_FORCE_PAGE_CHANGE flag Felix Radensky
2026-11-22 17:09 ` [PATCH v2 1/3] hwmon: (pmbus/core) Keep cached page and phase in sync with the chip Felix Radensky
2026-11-22 17:09 ` [PATCH v2 2/3] hwmon: (pmbus/core) Add PMBUS_FORCE_PAGE_CHANGE flag Felix Radensky
2026-11-22 17:09 ` [PATCH v2 3/3] hwmon: (pmbus/mp2975) Use PMBUS_FORCE_PAGE_CHANGE Felix Radensky
2026-11-22 17:16 ` [PATCH v2 0/3] hwmon: (pmbus) Add PMBUS_FORCE_PAGE_CHANGE flag sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox