Linux I2C development
 help / color / mirror / Atom feed
* [PATCH 1/2] i2c: acpi: Use I2C_M_DMA_SAFE in acpi_gsb_i2c_[read|write]_bytes()
@ 2026-09-19 19:36 Hans de Goede
  2026-09-19 19:36 ` [PATCH 2/2] i2c: acpi: Add AttribRawBytes accessor-type support to OpRegion handler Hans de Goede
  2026-09-21  5:17 ` [PATCH 1/2] i2c: acpi: Use I2C_M_DMA_SAFE in acpi_gsb_i2c_[read|write]_bytes() Mika Westerberg
  0 siblings, 2 replies; 4+ messages in thread
From: Hans de Goede @ 2026-09-19 19:36 UTC (permalink / raw)
  To: Andi Shyti, Mika Westerberg; +Cc: Hans de Goede, linux-i2c, linux-acpi

The main read / write "buffer" is kzalloc()ed and as such is safe to
directly use for DMA (unlike stack mem). Add the I2C_M_DMA_SAFE flag
to the transfers using these buffers.

Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
---
 drivers/i2c/i2c-core-acpi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
index 8f3bdd50186e..583d89c626e3 100644
--- a/drivers/i2c/i2c-core-acpi.c
+++ b/drivers/i2c/i2c-core-acpi.c
@@ -607,7 +607,7 @@ static int acpi_gsb_i2c_read_bytes(struct i2c_client *client,
 	msgs[0].buf = &cmd;
 
 	msgs[1].addr = client->addr;
-	msgs[1].flags = client->flags | I2C_M_RD;
+	msgs[1].flags = client->flags | I2C_M_RD | I2C_M_DMA_SAFE;
 	msgs[1].len = data_len;
 	msgs[1].buf = buffer;
 
@@ -648,7 +648,7 @@ static int acpi_gsb_i2c_write_bytes(struct i2c_client *client,
 	memcpy(buffer + 1, data, data_len);
 
 	msgs[0].addr = client->addr;
-	msgs[0].flags = client->flags;
+	msgs[0].flags = client->flags | I2C_M_DMA_SAFE;
 	msgs[0].len = data_len + 1;
 	msgs[0].buf = buffer;
 
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] i2c: acpi: Add AttribRawBytes accessor-type support to OpRegion handler
  2026-09-19 19:36 [PATCH 1/2] i2c: acpi: Use I2C_M_DMA_SAFE in acpi_gsb_i2c_[read|write]_bytes() Hans de Goede
@ 2026-09-19 19:36 ` Hans de Goede
  2026-09-21  5:18   ` Mika Westerberg
  2026-09-21  5:17 ` [PATCH 1/2] i2c: acpi: Use I2C_M_DMA_SAFE in acpi_gsb_i2c_[read|write]_bytes() Mika Westerberg
  1 sibling, 1 reply; 4+ messages in thread
From: Hans de Goede @ 2026-09-19 19:36 UTC (permalink / raw)
  To: Andi Shyti, Mika Westerberg; +Cc: Hans de Goede, linux-i2c, linux-acpi

Add AttribRawBytes accessor-type support to OpRegion handler, this is used
by the ACPI tables on a ThinkPad T14s gen6 Snapdragon laptop.

Looking at the AML it seems the expected behavior is to simply read or
write accessor-length bytes and this implementation allows successful
communication with the EC on a T14s gen6 Snapdragon laptop.

Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
---
 drivers/i2c/i2c-core-acpi.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
index 583d89c626e3..31fd88e63bf5 100644
--- a/drivers/i2c/i2c-core-acpi.c
+++ b/drivers/i2c/i2c-core-acpi.c
@@ -766,6 +766,18 @@ i2c_acpi_space_handler(u32 function, acpi_physical_address command,
 		}
 		break;
 
+	case ACPI_GSB_ACCESS_ATTRIB_RAW_BYTES:
+		if (action == ACPI_READ)
+			status = i2c_master_recv(client, gsb->data, info->access_length);
+		else
+			status = i2c_master_send(client, gsb->data, info->access_length);
+
+		if (status >= 0) {
+			gsb->len = status;
+			status = 0;
+		}
+		break;
+
 	default:
 		dev_warn(&adapter->dev, "protocol 0x%02x not supported for client 0x%02x\n",
 			 accessor_type, client->addr);
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] i2c: acpi: Use I2C_M_DMA_SAFE in acpi_gsb_i2c_[read|write]_bytes()
  2026-09-19 19:36 [PATCH 1/2] i2c: acpi: Use I2C_M_DMA_SAFE in acpi_gsb_i2c_[read|write]_bytes() Hans de Goede
  2026-09-19 19:36 ` [PATCH 2/2] i2c: acpi: Add AttribRawBytes accessor-type support to OpRegion handler Hans de Goede
@ 2026-09-21  5:17 ` Mika Westerberg
  1 sibling, 0 replies; 4+ messages in thread
From: Mika Westerberg @ 2026-09-21  5:17 UTC (permalink / raw)
  To: Hans de Goede; +Cc: Andi Shyti, linux-i2c, linux-acpi

On Sat, Sep 19, 2026 at 09:36:41PM +0200, Hans de Goede wrote:
> The main read / write "buffer" is kzalloc()ed and as such is safe to
> directly use for DMA (unlike stack mem). Add the I2C_M_DMA_SAFE flag
> to the transfers using these buffers.
> 
> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>

Acked-by: Mika Westerberg <westeri@kernel.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] i2c: acpi: Add AttribRawBytes accessor-type support to OpRegion handler
  2026-09-19 19:36 ` [PATCH 2/2] i2c: acpi: Add AttribRawBytes accessor-type support to OpRegion handler Hans de Goede
@ 2026-09-21  5:18   ` Mika Westerberg
  0 siblings, 0 replies; 4+ messages in thread
From: Mika Westerberg @ 2026-09-21  5:18 UTC (permalink / raw)
  To: Hans de Goede; +Cc: Andi Shyti, linux-i2c, linux-acpi

On Sat, Sep 19, 2026 at 09:36:42PM +0200, Hans de Goede wrote:
> Add AttribRawBytes accessor-type support to OpRegion handler, this is used
> by the ACPI tables on a ThinkPad T14s gen6 Snapdragon laptop.
> 
> Looking at the AML it seems the expected behavior is to simply read or
> write accessor-length bytes and this implementation allows successful
> communication with the EC on a T14s gen6 Snapdragon laptop.
> 
> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>

Acked-by: Mika Westerberg <westeri@kernel.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-21  5:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-19 19:36 [PATCH 1/2] i2c: acpi: Use I2C_M_DMA_SAFE in acpi_gsb_i2c_[read|write]_bytes() Hans de Goede
2026-09-19 19:36 ` [PATCH 2/2] i2c: acpi: Add AttribRawBytes accessor-type support to OpRegion handler Hans de Goede
2026-09-21  5:18   ` Mika Westerberg
2026-09-21  5:17 ` [PATCH 1/2] i2c: acpi: Use I2C_M_DMA_SAFE in acpi_gsb_i2c_[read|write]_bytes() Mika Westerberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox