All of lore.kernel.org
 help / color / mirror / Atom feed
From: Titus Rwantare <titusr@google.com>
To: peter.maydell@linaro.org
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, kfting@nuvoton.com,
	 imaginos32@gmail.com, wuhaotsh@google.com, philmd@mailo.com,
	 titusr <titusr@google.com>
Subject: [PATCH 4/5] hw/i2c: smbus: increase MAX_DATA_LEN
Date: Mon,  6 Jul 2026 23:00:53 +0000	[thread overview]
Message-ID: <20260706230056.1888992-5-titusr@google.com> (raw)
In-Reply-To: <20260706230056.1888992-1-titusr@google.com>

From: titusr <titusr@google.com>

The 32 byte payload was raised to 255 for block reads in the SMBus 3.0
specification. SMBus does not provide a way for devices to declare which
version of the spec they are designed to so we must allow newer devices
to return as much data as they allow.

Specification: https://smbus.org/specs/SMBus_3_3_20240512.pdf

> 6.5.7 Block Write/Read
The Block Write begins with a slave address and a write condition. After the command code the host issues a byte count which describes how many more bytes will follow in the message. If a slave has 20 bytes to send, the byte count field will have the value 20 (14h), followed by the 20 bytes of data. The byte count does not include the PEC byte. The byte count may be 0. A Block Read or Block Write is allowed to transfer a maximum of 255 data bytes.

Signed-off-by: Titus Rwantare <titusr@google.com>
---
 hw/i2c/smbus_slave.c         | 4 ++--
 include/hw/i2c/smbus_slave.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/i2c/smbus_slave.c b/hw/i2c/smbus_slave.c
index cfb61c879e..407a118d24 100644
--- a/hw/i2c/smbus_slave.c
+++ b/hw/i2c/smbus_slave.c
@@ -217,8 +217,8 @@ bool smbus_vmstate_needed(SMBusDevice *dev)
 
 const VMStateDescription vmstate_smbus_device = {
     .name = TYPE_SMBUS_DEVICE,
-    .version_id = 1,
-    .minimum_version_id = 1,
+    .version_id = 2,
+    .minimum_version_id = 2,
     .fields = (const VMStateField[]) {
         VMSTATE_I2C_SLAVE(i2c, SMBusDevice),
         VMSTATE_INT32(mode, SMBusDevice),
diff --git a/include/hw/i2c/smbus_slave.h b/include/hw/i2c/smbus_slave.h
index 86bfe0a79e..59522ff1b1 100644
--- a/include/hw/i2c/smbus_slave.h
+++ b/include/hw/i2c/smbus_slave.h
@@ -64,7 +64,7 @@ struct SMBusDeviceClass {
     uint8_t (*receive_byte)(SMBusDevice *dev);
 };
 
-#define SMBUS_DATA_MAX_LEN 34  /* command + len + 32 bytes of data.  */
+#define SMBUS_DATA_MAX_LEN 257  /* command + len + 255 bytes of data.  */
 
 struct SMBusDevice {
     /* The SMBus protocol is implemented on top of I2C.  */
-- 
2.55.0.rc2.803.g1fd1e6609c-goog



  parent reply	other threads:[~2026-07-06 23:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-06 23:00 [PATCH 0/5] hw/i2c: PMBus updates Titus Rwantare
2026-07-06 23:00 ` [PATCH 1/5] osdep: add DIV_ROUND_CLOSEST Titus Rwantare
2026-07-09 11:09   ` Peter Maydell
2026-07-09 11:16     ` Peter Maydell
2026-07-06 23:00 ` [PATCH 2/5] hw/i2c: pmbus: add milliunits linear mode functions Titus Rwantare
2026-07-06 23:00 ` [PATCH 3/5] hw/i2c: pmbus: clear output buffer on write Titus Rwantare
2026-07-07  9:20   ` Philippe Mathieu-Daudé
2026-07-09 15:35   ` Peter Maydell
2026-07-06 23:00 ` Titus Rwantare [this message]
2026-07-07  9:18   ` [PATCH 4/5] hw/i2c: smbus: increase MAX_DATA_LEN Philippe Mathieu-Daudé
2026-07-09 11:25   ` Peter Maydell
2026-07-06 23:00 ` [PATCH 5/5] hw/i2c: pmbus: add Linear11 format helpers Titus Rwantare
2026-07-09 11:14   ` Peter Maydell

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=20260706230056.1888992-5-titusr@google.com \
    --to=titusr@google.com \
    --cc=imaginos32@gmail.com \
    --cc=kfting@nuvoton.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@mailo.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=wuhaotsh@google.com \
    /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.