From e6f002a18228d4e19f52427893492737b99a0f3f Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Mon, 19 Feb 2024 07:56:36 -0500 Subject: [PATCH] Fixes for 5.4 Signed-off-by: Sasha Levin --- ...-fix-block-process-call-transactions.patch | 56 +++++++++++++++ ...01-remove-i801_set_block_buffer_mode.patch | 71 +++++++++++++++++++ queue-5.4/series | 2 + 3 files changed, 129 insertions(+) create mode 100644 queue-5.4/i2c-i801-fix-block-process-call-transactions.patch create mode 100644 queue-5.4/i2c-i801-remove-i801_set_block_buffer_mode.patch diff --git a/queue-5.4/i2c-i801-fix-block-process-call-transactions.patch b/queue-5.4/i2c-i801-fix-block-process-call-transactions.patch new file mode 100644 index 00000000000..34954c7c19c --- /dev/null +++ b/queue-5.4/i2c-i801-fix-block-process-call-transactions.patch @@ -0,0 +1,56 @@ +From 234f7062dd9844951eba4471eaf4cdb24c10d7bf Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 14 Feb 2024 15:59:39 +0100 +Subject: i2c: i801: Fix block process call transactions + +From: Jean Delvare + +[ Upstream commit c1c9d0f6f7f1dbf29db996bd8e166242843a5f21 ] + +According to the Intel datasheets, software must reset the block +buffer index twice for block process call transactions: once before +writing the outgoing data to the buffer, and once again before +reading the incoming data from the buffer. + +The driver is currently missing the second reset, causing the wrong +portion of the block buffer to be read. + +Signed-off-by: Jean Delvare +Reported-by: Piotr Zakowski +Closes: https://lore.kernel.org/linux-i2c/20240213120553.7b0ab120@endymion.delvare/ +Fixes: 315cd67c9453 ("i2c: i801: Add Block Write-Block Read Process Call support") +Reviewed-by: Alexander Sverdlin +Signed-off-by: Andi Shyti +Signed-off-by: Sasha Levin +--- + drivers/i2c/busses/i2c-i801.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c +index 21ed6d98c048..18489940a947 100644 +--- a/drivers/i2c/busses/i2c-i801.c ++++ b/drivers/i2c/busses/i2c-i801.c +@@ -531,11 +531,10 @@ static int i801_block_transaction_by_block(struct i801_priv *priv, + /* Set block buffer mode */ + outb_p(inb_p(SMBAUXCTL(priv)) | SMBAUXCTL_E32B, SMBAUXCTL(priv)); + +- inb_p(SMBHSTCNT(priv)); /* reset the data buffer index */ +- + if (read_write == I2C_SMBUS_WRITE) { + len = data->block[0]; + outb_p(len, SMBHSTDAT0(priv)); ++ inb_p(SMBHSTCNT(priv)); /* reset the data buffer index */ + for (i = 0; i < len; i++) + outb_p(data->block[i+1], SMBBLKDAT(priv)); + } +@@ -551,6 +550,7 @@ static int i801_block_transaction_by_block(struct i801_priv *priv, + return -EPROTO; + + data->block[0] = len; ++ inb_p(SMBHSTCNT(priv)); /* reset the data buffer index */ + for (i = 0; i < len; i++) + data->block[i + 1] = inb_p(SMBBLKDAT(priv)); + } +-- +2.43.0 + diff --git a/queue-5.4/i2c-i801-remove-i801_set_block_buffer_mode.patch b/queue-5.4/i2c-i801-remove-i801_set_block_buffer_mode.patch new file mode 100644 index 00000000000..83134b55882 --- /dev/null +++ b/queue-5.4/i2c-i801-remove-i801_set_block_buffer_mode.patch @@ -0,0 +1,71 @@ +From 8ff0daa9734dddd3ece3fd3cb2acce2cf614bfbd Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 18 Nov 2021 23:58:17 +0100 +Subject: i2c: i801: Remove i801_set_block_buffer_mode + +From: Heiner Kallweit + +[ Upstream commit 1e1d6582f483a4dba4ea03445e6f2f05d9de5bcf ] + +If FEATURE_BLOCK_BUFFER is set then bit SMBAUXCTL_E32B is supported +and there's no benefit in reading it back. Origin of this check +seems to be 14 yrs ago when people were not completely sure which +chip versions support the block buffer mode. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Jean Delvare +Tested-by: Jean Delvare +Signed-off-by: Wolfram Sang +Stable-dep-of: c1c9d0f6f7f1 ("i2c: i801: Fix block process call transactions") +Signed-off-by: Sasha Levin +--- + drivers/i2c/busses/i2c-i801.c | 17 +++++------------ + 1 file changed, 5 insertions(+), 12 deletions(-) + +diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c +index 50c972b3efe0..21ed6d98c048 100644 +--- a/drivers/i2c/busses/i2c-i801.c ++++ b/drivers/i2c/busses/i2c-i801.c +@@ -528,9 +528,11 @@ static int i801_block_transaction_by_block(struct i801_priv *priv, + return -EOPNOTSUPP; + } + ++ /* Set block buffer mode */ ++ outb_p(inb_p(SMBAUXCTL(priv)) | SMBAUXCTL_E32B, SMBAUXCTL(priv)); ++ + inb_p(SMBHSTCNT(priv)); /* reset the data buffer index */ + +- /* Use 32-byte buffer to process this transaction */ + if (read_write == I2C_SMBUS_WRITE) { + len = data->block[0]; + outb_p(len, SMBHSTDAT0(priv)); +@@ -768,14 +770,6 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv, + return i801_check_post(priv, status); + } + +-static int i801_set_block_buffer_mode(struct i801_priv *priv) +-{ +- outb_p(inb_p(SMBAUXCTL(priv)) | SMBAUXCTL_E32B, SMBAUXCTL(priv)); +- if ((inb_p(SMBAUXCTL(priv)) & SMBAUXCTL_E32B) == 0) +- return -EIO; +- return 0; +-} +- + /* Block transaction function */ + static int i801_block_transaction(struct i801_priv *priv, + union i2c_smbus_data *data, char read_write, +@@ -805,9 +799,8 @@ static int i801_block_transaction(struct i801_priv *priv, + /* Experience has shown that the block buffer can only be used for + SMBus (not I2C) block transactions, even though the datasheet + doesn't mention this limitation. */ +- if ((priv->features & FEATURE_BLOCK_BUFFER) +- && command != I2C_SMBUS_I2C_BLOCK_DATA +- && i801_set_block_buffer_mode(priv) == 0) ++ if ((priv->features & FEATURE_BLOCK_BUFFER) && ++ command != I2C_SMBUS_I2C_BLOCK_DATA) + result = i801_block_transaction_by_block(priv, data, + read_write, + command, hwpec); +-- +2.43.0 + diff --git a/queue-5.4/series b/queue-5.4/series index 12dbe4e3c4d..985ba86371f 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -216,3 +216,5 @@ hid-wacom-generic-avoid-reporting-a-serial-of-0-to-userspace.patch hid-wacom-do-not-register-input-devices-until-after-hid_hw_start.patch usb-hub-check-for-alternate-port-before-enabling-a_alt_hnp_support.patch usb-f_mass_storage-forbid-async-queue-when-shutdown-happen.patch +i2c-i801-remove-i801_set_block_buffer_mode.patch +i2c-i801-fix-block-process-call-transactions.patch -- 2.47.3