From patchwork Wed Apr 11 16:05:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Delvare X-Patchwork-Id: 897264 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40LpmM3T7pz9s35 for ; Thu, 12 Apr 2018 02:05:39 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752906AbeDKQFh (ORCPT ); Wed, 11 Apr 2018 12:05:37 -0400 Received: from mx2.suse.de ([195.135.220.15]:42615 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752664AbeDKQFh (ORCPT ); Wed, 11 Apr 2018 12:05:37 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 02617AFBD; Wed, 11 Apr 2018 16:05:36 +0000 (UTC) Date: Wed, 11 Apr 2018 18:05:34 +0200 From: Jean Delvare To: Linux I2C , Wolfram Sang Cc: Jason Andryuk , Benjamin Tissoires Subject: [PATCH 2/2 v2] i2c: i801: Restore configuration at shutdown Message-ID: <20180411180534.59301c6e@endymion> In-Reply-To: <20180411180104.6d1f1e6e@endymion> References: <20180411180104.6d1f1e6e@endymion> Organization: SUSE Linux X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.31; x86_64-suse-linux-gnu) MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org 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 Tested-by: Jason Andryuk Cc: Wolfram Sang 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(+) --- 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, },