[PATCH v5 0/4] hwmon: (pmbus/max31785) refactor inter-access delay handling
From: Pradhan, Sanman
Date: Fri Mar 20 2026 - 20:53:29 EST
From: Sanman Pradhan <psanman@xxxxxxxxxxx>
This v5 series addresses the feedback on v4. The timestamp spinlock
approach was dropped in favor of fixing the missing PMBus transaction
serialization in regulator voltage paths.
Patch 1 adds the missing mutex_lock(&data->update_lock) to the PMBus
regulator voltage operations get_voltage, set_voltage, and list_voltage.
These paths perform multi-step PMBus transactions that must not be
interleaved with concurrent PMBus users, since page selection and the
subsequent register access operate on shared core state.
Patch 2 exports pmbus_wait() and pmbus_update_ts() so PMBus device
drivers performing raw I2C transfers outside the core helpers can keep
the PMBus delay bookkeeping in sync. PMBUS_OP_WRITE and
PMBUS_OP_PAGE_CHANGE are moved to pmbus.h for use by device drivers.
Patch 3 refactors the max31785 fan controller driver to use the PMBus
core access_delay mechanism instead of driver-local PMBus timing
wrappers. The raw i2c_transfer() in max31785_read_long_data() is
bracketed with pmbus_wait() and pmbus_update_ts() so the PMBus core
timing state remains consistent.
Patch 4 fixes a pre-existing bug in max31785_read_long_data() where
partial i2c_transfer() completion was treated as success. If only the
write message completes, the read buffer is left uninitialized and may
be interpreted as valid data.
v5:
- Dropped the spinlock patch entirely.
- Added a new patch to serialize the missing regulator voltage paths
with update_lock.
- Updated the export patch to remove the spinlock-based timestamp
handling.
- Kept the max31785 access_delay refactor unchanged from v4.
- Added a new patch to treat partial i2c_transfer() completion in
max31785_read_long_data() as an error.
v4:
- Introduced a spinlock to protect 64-bit next_access_backoff accesses
on 32-bit architectures (dropped in v5).
- Standardized all commits and signatures on psanman@xxxxxxxxxxx.
v3:
- Dropped the u16 -> u8 wrapper type fix (already applied upstream).
- Fixed a comment style nit in max31785_read_long_data().
v2:
- Export pmbus_wait() and pmbus_update_ts() from the core.
- Use core timing helpers in max31785 to replace local boilerplate.
Sanman Pradhan (4):
hwmon: (pmbus) add missing mutex_lock in regulator ops
hwmon: (pmbus) export pmbus_wait and pmbus_update_ts
hwmon: (pmbus/max31785) use access_delay for PMBus-mediated accesses
hwmon: (pmbus/max31785) check for partial i2c_transfer in
read_long_data
drivers/hwmon/pmbus/max31785.c | 197 ++++++++++---------------------
drivers/hwmon/pmbus/pmbus.h | 6 +
drivers/hwmon/pmbus/pmbus_core.c | 55 ++++++---
3 files changed, 109 insertions(+), 149 deletions(-)
--
2.34.1