]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 5.4
authorSasha Levin <sashal@kernel.org>
Mon, 19 Feb 2024 12:56:36 +0000 (07:56 -0500)
committerSasha Levin <sashal@kernel.org>
Mon, 19 Feb 2024 12:56:36 +0000 (07:56 -0500)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-5.4/i2c-i801-fix-block-process-call-transactions.patch [new file with mode: 0644]
queue-5.4/i2c-i801-remove-i801_set_block_buffer_mode.patch [new file with mode: 0644]
queue-5.4/series

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 (file)
index 0000000..34954c7
--- /dev/null
@@ -0,0 +1,56 @@
+From 234f7062dd9844951eba4471eaf4cdb24c10d7bf Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 14 Feb 2024 15:59:39 +0100
+Subject: i2c: i801: Fix block process call transactions
+
+From: Jean Delvare <jdelvare@suse.de>
+
+[ 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 <jdelvare@suse.de>
+Reported-by: Piotr Zakowski <piotr.zakowski@intel.com>
+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 <alexander.sverdlin@gmail.com>
+Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ 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 (file)
index 0000000..83134b5
--- /dev/null
@@ -0,0 +1,71 @@
+From 8ff0daa9734dddd3ece3fd3cb2acce2cf614bfbd Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 18 Nov 2021 23:58:17 +0100
+Subject: i2c: i801: Remove i801_set_block_buffer_mode
+
+From: Heiner Kallweit <hkallweit1@gmail.com>
+
+[ 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 <hkallweit1@gmail.com>
+Reviewed-by: Jean Delvare <jdelvare@suse.de>
+Tested-by: Jean Delvare <jdelvare@suse.de>
+Signed-off-by: Wolfram Sang <wsa@kernel.org>
+Stable-dep-of: c1c9d0f6f7f1 ("i2c: i801: Fix block process call transactions")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ 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
+
index 12dbe4e3c4db3e46b28069ff0fbf5a9ec7342c67..985ba86371f957573e52ae65b818eac6b346c78c 100644 (file)
@@ -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