From: "Nuno Sá" <noname.nuno@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: nuno.sa@analog.com, linux-hwmon@vger.kernel.org,
devicetree@vger.kernel.org, linux-doc@vger.kernel.org,
Mark Brown <broonie@kernel.org>,
Alan Tull <atull@opensource.altera.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH 3/5] hwmon: (pmbus/core) Add mapping function to pmbus_read_block_data()
Date: Mon, 3 Aug 2026 16:03:04 +0100 [thread overview]
Message-ID: <anCsIHUkaL7ckyiL@nsa> (raw)
In-Reply-To: <b48636b8-33d1-425f-93a7-d0b9c4dd86ca@roeck-us.net>
On Fri, Jul 31, 2026 at 09:46:29AM -0700, Guenter Roeck wrote:
> On 7/31/26 08:42, Nuno Sá wrote:
> > On Thu, Jul 30, 2026 at 08:54:25AM -0700, Guenter Roeck wrote:
> > > On 7/30/26 08:19, Nuno Sá wrote:
> > > > On Thu, Jul 30, 2026 at 07:47:37AM -0700, Guenter Roeck wrote:
> > > > > On 7/30/26 07:27, Nuno Sá wrote:
> > > > > > On Tue, Jul 28, 2026 at 02:05:53PM -0700, Guenter Roeck wrote:
> > > > > > > On 7/28/26 09:03, Nuno Sá via B4 Relay wrote:
> > > > > > > > From: Nuno Sá <nuno.sa@analog.com>
> > > > > > > >
> > > > > > > > This is in preparation for adding support to a device which needs to
> > > > > > > > use it's own read_block implementation.
> > > > > > > >
> > > > > > >
> > > > > > > The chip-specific implementation calls i2c_smbus_read_i2c_block_data().
> > > > > > > I'll need to know if this is a chip limit or a controller limit.
> > > > > > > If it is a controller limit, a chip specific override would be
> > > > > > > inappropriate.
> > > > > >
> > > > > > I'll reply from top of my head (did not looked at the driver again).
> > > > > > IIRC, the biggest reason we need the chip-specific implementation is because of
> > > > > > the RAIL selection logic (mainly when not in page mode).
> > > > > >
> > > > >
> > > > > Yes, I have seen that. Question is why you use i2c_smbus_read_i2c_block_data()
> > > > > instead of i2c_smbus_read_block_data(). The rail selection logic would not
> > > > > require that.
> > > >
> > > > IIRC the reason was because the i2c controller on the raspberry pie does not
> > > > support i2c_smbus_read_block_data(). So I guess this:
> > > >
> > > > https://elixir.bootlin.com/linux/v7.1.4/source/drivers/i2c/i2c-core-smbus.c#L220
> > > >
> > >
> > > Hmm, I think we really need a common solution for that problem. Not all
> > > controllers support i2c_smbus_read_i2c_block_data(), so you are just moving
> > > the problem from one controller to another.
> >
> > Yikes. I actually though i2c_smbus_read_i2c_block_data(9 was more widely
> > supported (if not always). Not sure if you have something in mind but
> > one straight way would be to choose different implementations (for
> > read_block) depending on i2c_check_functionality()
> >
>
> Handling it in pmbus_read_block_data() would be straightforward. Actually, I
> wonder why it isn't handled as fallback in i2c_smbus_read_block_data(),
> but I assume there must be a reason.
>
> Either case, I don't understand how the existing calls to i2c_smbus_read_i2c_block_data()
> work. For example, in drivers/hwmon/pmbus/max20830.c, the assumption is that the
> first returned data byte would be the length field. However, that is already done
> in i2c_smbus_read_i2c_block_data():
>
> /* Returns the number of read bytes */
> s32 i2c_smbus_read_i2c_block_data(const struct i2c_client *client, u8 command,
> u8 length, u8 *values)
> {
> union i2c_smbus_data data;
> int status;
>
> if (length > I2C_SMBUS_BLOCK_MAX)
> length = I2C_SMBUS_BLOCK_MAX;
> data.block[0] = length;
> status = i2c_smbus_xfer(client->adapter, client->addr, client->flags,
> I2C_SMBUS_READ, command,
> I2C_SMBUS_I2C_BLOCK_DATA, &data);
> if (status < 0)
> return status;
>
> memcpy(values, &data.block[1], data.block[0]);
> return data.block[0];
> }
>
> Does the command return the length twice ?
I think the device is actually the one sending the block size again. I
went looking at very old emails and found this chain:
Me:
"Thanks for the inputs... As I said, I think know what’s my issue. I’m fairly sure the first
byte I’m reading is the block size. I’ll take this into account and re-test."
Reply:
"On one hand, that does make sense. The first byte in a block read transaction should indeed
be the block size. That said, 0xB1 is 6 bytes long when not including this first byte. So we
are still missing a byte with actual information. Could you perhaps please share the full
packet data that you are capturing?"
The above was me struggling with per phase reads.
But maybe the above changed with newer FW versions for the chips. I'll
ask around.
- Nuno Sá
>
> > >
> > > One key example is the PIIX4 driver. Your new driver does not support the
> > > majority of PC style systems with AMD CPUs.
> > >
> >
> > I see!
> >
> > - Nuno Sá
> >
>
next prev parent reply other threads:[~2026-08-03 15:01 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 16:03 [PATCH 0/5] hwmon: (pmbus) Add support for MAX20826 and similar devices Nuno Sá
2026-07-28 16:03 ` Nuno Sá via B4 Relay
2026-07-28 16:03 ` [PATCH 1/5] hwmon: (pmbus/core) fix regulator enable/disable Nuno Sá
2026-07-28 16:03 ` Nuno Sá via B4 Relay
2026-07-28 16:22 ` sashiko-bot
2026-07-28 16:58 ` Guenter Roeck
2026-07-28 16:03 ` [PATCH 2/5] hwmon: (pmbus/core) increase number of phases and add new mask Nuno Sá
2026-07-28 16:03 ` Nuno Sá via B4 Relay
2026-07-28 16:19 ` sashiko-bot
2026-07-28 16:03 ` [PATCH 3/5] hwmon: (pmbus/core) Add mapping function to pmbus_read_block_data() Nuno Sá
2026-07-28 16:03 ` Nuno Sá via B4 Relay
2026-07-28 16:27 ` sashiko-bot
2026-07-28 18:13 ` Guenter Roeck
2026-08-04 9:05 ` Nuno Sá
2026-08-04 14:16 ` Guenter Roeck
2026-07-28 21:05 ` Guenter Roeck
2026-07-30 14:27 ` Nuno Sá
2026-07-30 14:47 ` Guenter Roeck
2026-07-30 15:19 ` Nuno Sá
2026-07-30 15:54 ` Guenter Roeck
2026-07-31 15:42 ` Nuno Sá
2026-07-31 16:46 ` Guenter Roeck
2026-08-03 15:03 ` Nuno Sá [this message]
2026-08-03 15:45 ` Guenter Roeck
2026-07-28 16:03 ` [PATCH 4/5] dt-bindings: hwmon/pmbus: Document MAX20826 and similar devices Nuno Sá
2026-07-28 16:03 ` Nuno Sá via B4 Relay
2026-07-28 16:17 ` sashiko-bot
2026-07-28 16:03 ` [PATCH 5/5] hwmon: (pmbus) add support for " Nuno Sá
2026-07-28 16:03 ` Nuno Sá via B4 Relay
2026-07-28 16:24 ` sashiko-bot
2026-07-28 22:12 ` Guenter Roeck
2026-08-04 9:20 ` Nuno Sá
2026-07-29 12:18 ` Uwe Kleine-König
2026-07-30 11:08 ` Nuno Sá
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=anCsIHUkaL7ckyiL@nsa \
--to=noname.nuno@gmail.com \
--cc=atull@opensource.altera.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
--cc=skhan@linuxfoundation.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.