linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 5.14 088/252] i2c: i801: Fix handling SMBHSTCNT_PEC_EN
       [not found] <20210909114106.141462-1-sashal@kernel.org>
@ 2021-09-09 11:38 ` Sasha Levin
  2021-09-09 13:13   ` Jean Delvare
  0 siblings, 1 reply; 3+ messages in thread
From: Sasha Levin @ 2021-09-09 11:38 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Heiner Kallweit, Jean Delvare, Wolfram Sang, Sasha Levin, linux-i2c

From: Heiner Kallweit <hkallweit1@gmail.com>

[ Upstream commit a6b8bb6a813a6621c75ceacd1fa604c0229e9624 ]

Bit SMBHSTCNT_PEC_EN is used only if software calculates the CRC and
uses register SMBPEC. This is not supported by the driver, it supports
hw-calculation of CRC only (using bit SMBAUXSTS_CRCE). The chip spec
states the following, therefore never set bit SMBHSTCNT_PEC_EN.

Chapter SMBus CRC Generation and Checking
If the AAC bit is set in the Auxiliary Control register, the PCH
automatically calculates and drives CRC at the end of the transmitted
packet for write cycles, and will check the CRC for read cycles. It will
not transmit the contents of the PEC register for CRC. The PEC bit must
not be set in the Host Control register. If this bit is set, unspecified
behavior will result.

This patch is based solely on the specification and compile-tested only,
because I have no PEC-capable devices.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Tested-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/i2c/busses/i2c-i801.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index aa3f60e69230..92ec291c0648 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -503,19 +503,16 @@ static int i801_transaction(struct i801_priv *priv, int xact)
 
 static int i801_block_transaction_by_block(struct i801_priv *priv,
 					   union i2c_smbus_data *data,
-					   char read_write, int command,
-					   int hwpec)
+					   char read_write, int command)
 {
-	int i, len;
-	int status;
-	int xact = hwpec ? SMBHSTCNT_PEC_EN : 0;
+	int i, len, status, xact;
 
 	switch (command) {
 	case I2C_SMBUS_BLOCK_PROC_CALL:
-		xact |= I801_BLOCK_PROC_CALL;
+		xact = I801_BLOCK_PROC_CALL;
 		break;
 	case I2C_SMBUS_BLOCK_DATA:
-		xact |= I801_BLOCK_DATA;
+		xact = I801_BLOCK_DATA;
 		break;
 	default:
 		return -EOPNOTSUPP;
@@ -665,8 +662,7 @@ static irqreturn_t i801_isr(int irq, void *dev_id)
  */
 static int i801_block_transaction_byte_by_byte(struct i801_priv *priv,
 					       union i2c_smbus_data *data,
-					       char read_write, int command,
-					       int hwpec)
+					       char read_write, int command)
 {
 	int i, len;
 	int smbcmd;
@@ -764,9 +760,8 @@ static int i801_set_block_buffer_mode(struct i801_priv *priv)
 }
 
 /* Block transaction function */
-static int i801_block_transaction(struct i801_priv *priv,
-				  union i2c_smbus_data *data, char read_write,
-				  int command, int hwpec)
+static int i801_block_transaction(struct i801_priv *priv, union i2c_smbus_data *data,
+				  char read_write, int command)
 {
 	int result = 0;
 	unsigned char hostc;
@@ -802,11 +797,11 @@ static int i801_block_transaction(struct i801_priv *priv,
 	 && i801_set_block_buffer_mode(priv) == 0)
 		result = i801_block_transaction_by_block(priv, data,
 							 read_write,
-							 command, hwpec);
+							 command);
 	else
 		result = i801_block_transaction_byte_by_byte(priv, data,
 							     read_write,
-							     command, hwpec);
+							     command);
 
 	if (command == I2C_SMBUS_I2C_BLOCK_DATA
 	 && read_write == I2C_SMBUS_WRITE) {
@@ -917,8 +912,7 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,
 		       SMBAUXCTL(priv));
 
 	if (block)
-		ret = i801_block_transaction(priv, data, read_write, size,
-					     hwpec);
+		ret = i801_block_transaction(priv, data, read_write, size);
 	else
 		ret = i801_transaction(priv, xact);
 
@@ -1690,6 +1684,7 @@ static void i801_setup_hstcfg(struct i801_priv *priv)
 	unsigned char hstcfg = priv->original_hstcfg;
 
 	hstcfg &= ~SMBHSTCFG_I2C_EN;	/* SMBus timing */
+	hstcfg &= ~SMBHSTCNT_PEC_EN;	/* Disable software PEC */
 	hstcfg |= SMBHSTCFG_HST_EN;
 	pci_write_config_byte(priv->pci_dev, SMBHSTCFG, hstcfg);
 }
-- 
2.30.2


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

* Re: [PATCH AUTOSEL 5.14 088/252] i2c: i801: Fix handling SMBHSTCNT_PEC_EN
  2021-09-09 11:38 ` [PATCH AUTOSEL 5.14 088/252] i2c: i801: Fix handling SMBHSTCNT_PEC_EN Sasha Levin
@ 2021-09-09 13:13   ` Jean Delvare
  2021-09-13 16:55     ` Sasha Levin
  0 siblings, 1 reply; 3+ messages in thread
From: Jean Delvare @ 2021-09-09 13:13 UTC (permalink / raw)
  To: Sasha Levin
  Cc: linux-kernel, stable, Heiner Kallweit, Wolfram Sang, linux-i2c

Hi Sascha,

On Thu,  9 Sep 2021 07:38:22 -0400, Sasha Levin wrote:
> From: Heiner Kallweit <hkallweit1@gmail.com>
> 
> [ Upstream commit a6b8bb6a813a6621c75ceacd1fa604c0229e9624 ]
> 
> Bit SMBHSTCNT_PEC_EN is used only if software calculates the CRC and
> uses register SMBPEC. This is not supported by the driver, it supports
> hw-calculation of CRC only (using bit SMBAUXSTS_CRCE). The chip spec
> states the following, therefore never set bit SMBHSTCNT_PEC_EN.
> 
> Chapter SMBus CRC Generation and Checking
> If the AAC bit is set in the Auxiliary Control register, the PCH
> automatically calculates and drives CRC at the end of the transmitted
> packet for write cycles, and will check the CRC for read cycles. It will
> not transmit the contents of the PEC register for CRC. The PEC bit must
> not be set in the Host Control register. If this bit is set, unspecified
> behavior will result.
> 
> This patch is based solely on the specification and compile-tested only,
> because I have no PEC-capable devices.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> Tested-by: Jean Delvare <jdelvare@suse.de>
> Signed-off-by: Wolfram Sang <wsa@kernel.org>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
>  drivers/i2c/busses/i2c-i801.c | 27 +++++++++++----------------
>  1 file changed, 11 insertions(+), 16 deletions(-)

This patch fixes a theoretical problem nobody has ever complained
about. I don't think it makes sense to backport it to stable kernel
branches.

-- 
Jean Delvare
SUSE L3 Support

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

* Re: [PATCH AUTOSEL 5.14 088/252] i2c: i801: Fix handling SMBHSTCNT_PEC_EN
  2021-09-09 13:13   ` Jean Delvare
@ 2021-09-13 16:55     ` Sasha Levin
  0 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2021-09-13 16:55 UTC (permalink / raw)
  To: Jean Delvare
  Cc: linux-kernel, stable, Heiner Kallweit, Wolfram Sang, linux-i2c

On Thu, Sep 09, 2021 at 03:13:20PM +0200, Jean Delvare wrote:
>Hi Sascha,
>
>On Thu,  9 Sep 2021 07:38:22 -0400, Sasha Levin wrote:
>> From: Heiner Kallweit <hkallweit1@gmail.com>
>>
>> [ Upstream commit a6b8bb6a813a6621c75ceacd1fa604c0229e9624 ]
>>
>> Bit SMBHSTCNT_PEC_EN is used only if software calculates the CRC and
>> uses register SMBPEC. This is not supported by the driver, it supports
>> hw-calculation of CRC only (using bit SMBAUXSTS_CRCE). The chip spec
>> states the following, therefore never set bit SMBHSTCNT_PEC_EN.
>>
>> Chapter SMBus CRC Generation and Checking
>> If the AAC bit is set in the Auxiliary Control register, the PCH
>> automatically calculates and drives CRC at the end of the transmitted
>> packet for write cycles, and will check the CRC for read cycles. It will
>> not transmit the contents of the PEC register for CRC. The PEC bit must
>> not be set in the Host Control register. If this bit is set, unspecified
>> behavior will result.
>>
>> This patch is based solely on the specification and compile-tested only,
>> because I have no PEC-capable devices.
>>
>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>> Tested-by: Jean Delvare <jdelvare@suse.de>
>> Signed-off-by: Wolfram Sang <wsa@kernel.org>
>> Signed-off-by: Sasha Levin <sashal@kernel.org>
>> ---
>>  drivers/i2c/busses/i2c-i801.c | 27 +++++++++++----------------
>>  1 file changed, 11 insertions(+), 16 deletions(-)
>
>This patch fixes a theoretical problem nobody has ever complained
>about. I don't think it makes sense to backport it to stable kernel
>branches.

Sure, I'll drop it. Thanks.

-- 
Thanks,
Sasha

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

end of thread, other threads:[~2021-09-13 16:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20210909114106.141462-1-sashal@kernel.org>
2021-09-09 11:38 ` [PATCH AUTOSEL 5.14 088/252] i2c: i801: Fix handling SMBHSTCNT_PEC_EN Sasha Levin
2021-09-09 13:13   ` Jean Delvare
2021-09-13 16:55     ` Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).