diff mbox series

[2/2,v2] i2c: i801: Restore configuration at shutdown

Message ID 20180411180534.59301c6e@endymion
State Accepted
Headers show
Series i2c: i801: Fix hard hang on reboot on HP EliteBook G3 850 | expand

Commit Message

Jean Delvare April 11, 2018, 4:05 p.m. UTC
On some systems, the BIOS expects certain SMBus register values to
match the hardware defaults. Restore these configuration registers at
shutdown time to avoid confusing the BIOS. This avoids hard-locking
such systems upon reboot.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Tested-by: Jason Andryuk <jandryuk@gmail.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: stable@vger.kernel.org
---
Changes since v1:
 * Added proper subject and description.
 * Removed debug print.
 * Added a comment.
 * Added stable tag.

 drivers/i2c/busses/i2c-i801.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Wolfram Sang April 11, 2018, 9:13 p.m. UTC | #1
On Wed, Apr 11, 2018 at 06:05:34PM +0200, Jean Delvare wrote:
> On some systems, the BIOS expects certain SMBus register values to
> match the hardware defaults. Restore these configuration registers at
> shutdown time to avoid confusing the BIOS. This avoids hard-locking
> such systems upon reboot.
> 
> Signed-off-by: Jean Delvare <jdelvare@suse.de>
> Tested-by: Jason Andryuk <jandryuk@gmail.com>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Cc: stable@vger.kernel.org

Applied to for-current, thanks!
diff mbox series

Patch

--- linux-4.16.orig/drivers/i2c/busses/i2c-i801.c	2018-04-11 17:52:34.340485371 +0200
+++ linux-4.16/drivers/i2c/busses/i2c-i801.c	2018-04-11 17:52:37.501523189 +0200
@@ -1701,6 +1701,15 @@  static void i801_remove(struct pci_dev *
 	 */
 }
 
+static void i801_shutdown(struct pci_dev *dev)
+{
+	struct i801_priv *priv = pci_get_drvdata(dev);
+
+	/* Restore config registers to avoid hard hang on some systems */
+	i801_disable_host_notify(priv);
+	pci_write_config_byte(dev, SMBHSTCFG, priv->original_hstcfg);
+}
+
 #ifdef CONFIG_PM
 static int i801_suspend(struct device *dev)
 {
@@ -1730,6 +1739,7 @@  static struct pci_driver i801_driver = {
 	.id_table	= i801_ids,
 	.probe		= i801_probe,
 	.remove		= i801_remove,
+	.shutdown	= i801_shutdown,
 	.driver		= {
 		.pm	= &i801_pm_ops,
 	},