Skip to contentSkip to conversation

i2c: i801: Fix incorrect and needless software PEC disabling

PATCH Applied Jarkko Nikula 4 participants 4 messages Oct 26, 2021 – Oct 29, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: i801: Fix incorrect and needless software PEC disabling

Commit a6b8bb6a813a ("i2c: i801: Fix handling SMBHSTCNT_PEC_EN") attempts to disable software PEC by clearing the SMBHSTCNT_PEC_EN (bit 7) in the SMBus Host Control register (I/O SMBHSTCNT) but incorrectly clears it in the PCI Host Configuration register (PCI SMBHSTCFG).

This clearing is actually needless since after above commit the SMBHSTCNT_PEC_EN is never set and the register is initialized with known values.

---
I didn't add Fixes tag and Cc [email protected] since I don't see this causes any real issues. A few platforms I checked the PCI Host Configuration register bit 7 was reserved 0.

---
 drivers/i2c/busses/i2c-i801.c | 1 -
 1 file changed, 1 deletion(-)
drivers/i2c/busses/i2c-i801.c +0 -1
index 115660dce722..b6048a571543 100644
@@ -1657,7 +1657,6 @@ 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);
 }
Signature · 1 line
2.33.0
#1 lore raw
Quoted 5 lines · Jarkko Nikula

Commit a6b8bb6a813a ("i2c: i801: Fix handling SMBHSTCNT_PEC_EN") attempts to disable software PEC by clearing the SMBHSTCNT_PEC_EN (bit 7) in the SMBus Host Control register (I/O SMBHSTCNT) but incorrectly clears it in the PCI Host Configuration register (PCI SMBHSTCFG).

Indeed, my bad. Mixed up HSTCFG and HSTCNT here.

Quoted 26 lines

This clearing is actually needless since after above commit the SMBHSTCNT_PEC_EN is never set and the register is initialized with known values.

---
I didn't add Fixes tag and Cc [email protected] since I don't see this causes any real issues. A few platforms I checked the PCI Host Configuration register bit 7 was reserved 0.

---
 drivers/i2c/busses/i2c-i801.c | 1 -
 1 file changed, 1 deletion(-)
drivers/i2c/busses/i2c-i801.c +0 -1
index 115660dce722..b6048a571543 100644
@@ -1657,7 +1657,6 @@ 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);
 }
Reviewed-by on v1 1/1
#2 lore raw
In reply to Jarkko Nikula
Quoted 10 lines · Jarkko Nikula

Commit a6b8bb6a813a ("i2c: i801: Fix handling SMBHSTCNT_PEC_EN") attempts to disable software PEC by clearing the SMBHSTCNT_PEC_EN (bit 7) in the SMBus Host Control register (I/O SMBHSTCNT) but incorrectly clears it in the PCI Host Configuration register (PCI SMBHSTCFG).

This clearing is actually needless since after above commit the SMBHSTCNT_PEC_EN is never set and the register is initialized with known values.

Oops, sorry for missing this and duplicating your work. I noticed the bug while reviewing your other change and wrote a fix without realizing you were already working on it.

Quoted 4 lines

---
I didn't add Fixes tag and Cc [email protected] since I don't see this causes any real issues. A few platforms I checked the PCI Host Configuration register bit 7 was reserved 0.

I checked the datasheets too and came to the same conclusion, but added the Fixes tag still, because the new fix is definitely safe and we have no idea if the broken fix was actually harmless as it must have seen very little deployment at this point (kernel 5.15 isn't out yet). Better safe than sorry.

Quoted 16 lines
---
 drivers/i2c/busses/i2c-i801.c | 1 -
 1 file changed, 1 deletion(-)
drivers/i2c/busses/i2c-i801.c +0 -1
index 115660dce722..b6048a571543 100644
@@ -1657,7 +1657,6 @@ 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);
 }
Signature · 2 lines
Jean Delvare
SUSE L3 Support
Applied
#3 lore raw
In reply to Jarkko Nikula
Quoted 10 lines · Jarkko Nikula

Commit a6b8bb6a813a ("i2c: i801: Fix handling SMBHSTCNT_PEC_EN") attempts to disable software PEC by clearing the SMBHSTCNT_PEC_EN (bit 7) in the SMBus Host Control register (I/O SMBHSTCNT) but incorrectly clears it in the PCI Host Configuration register (PCI SMBHSTCFG).

This clearing is actually needless since after above commit the SMBHSTCNT_PEC_EN is never set and the register is initialized with known values.

Applied to for-next, thanks!