Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3297327pxk; Mon, 21 Sep 2020 09:59:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwErINNZ6wq9SKm5qfvwwA8cwu6rWlWUWtIfjfbWt81bNjD6mKBnqU2lal7Ub3ZQtNmUef2 X-Received: by 2002:a17:907:408e:: with SMTP id nt22mr366184ejb.169.1600707586756; Mon, 21 Sep 2020 09:59:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600707586; cv=none; d=google.com; s=arc-20160816; b=H37vn0Iueof3ONwUaXIFUHjOM9se0FimaIwGUR9T8b6mWUBiC1alY2ZqfeiyDp9eNT t7XDLxBQDScvHMkR2NeNbxQ+rCfGdtNNMOe5jc2DWthTf0nnKzZrvFSQ0uVkkwrOhLlw YQk0XQfxL0nTBlqFGMHGXIM+r50vpbu8s3AfeL3/HlmFkb4Cj59ISLE9rarFRy9UxCve fraEy6YfyuXUITWsZanoznJ3bpHmZ2Rv3Pvqfrvlu1R6mPxTegprlRmdxL6Lo6ZS1ERC mLtG+AycGcUQ7uThY4zFZt1PwypvKIWSkNE6ZwfQbS+vf6DHnQPJNzeMBEcMzfPNGGEE R+Sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YBCRrRnlSXBmHJWGRHifo7j+g2xtH7tNP8BK2vMYsgQ=; b=PE5bs6KUW3bwldY5qJQwVWh5Z/5pg3XQhv8/Ntz4rlTbGmLipVTLHVo6xPSSdFHotF eT5B7hCECiXu4O3qH6JmXJuAlm7zi/kV2byGv2I1E7sNf2AT+zRCdDReUUpDO3z6NQ5k eztFc1SyDeekWiIpiU2ahrwbrmorB+WuCf8L+vCQ69vHaK8Ponloob4qMDBLcjURTZJS vxYrLKhtQNuCfFZC2AVpSdA16dUsO55ujfc21i4xS67anQkorhiE0uxj9J9Nb4ELG7CE s3ROtBqREA7dP05rQjSSrJsTPiu76cROCX6eX4Ymfkc/fNLHQNyA4ekyYmZ7S8DPgOt6 l2Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cGw6D9Ho; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w4si8547259ede.468.2020.09.21.09.59.22; Mon, 21 Sep 2020 09:59:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cGw6D9Ho; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730246AbgIUQ6Q (ORCPT + 99 others); Mon, 21 Sep 2020 12:58:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:46168 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728467AbgIUQmK (ORCPT ); Mon, 21 Sep 2020 12:42:10 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8359823998; Mon, 21 Sep 2020 16:42:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706530; bh=as6jgWqCIPmLHQCB1DLUTGItG7xuB8XLrAePeyebm3k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cGw6D9HohwtfeZJxpRjHmuzNoI24PHwsypjn/GpLCU4q9ssnZ/fJqzYe4drJBIlAl u8+W/8KC6IUg/7w/EofzJEEphafem9pTFo9ni48k5h8wOb9Ns5/Dwji+Sghg5eR81Y HVJFdcc2hhtel25MgYdx1ZUKvg0XGJWEuWyJbwjw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Volker=20R=C3=BCmelin?= , Jean Delvare , Wolfram Sang Subject: [PATCH 4.19 40/49] i2c: i801: Fix resume bug Date: Mon, 21 Sep 2020 18:28:24 +0200 Message-Id: <20200921162036.437945375@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921162034.660953761@linuxfoundation.org> References: <20200921162034.660953761@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Volker RĂ¼melin commit 66d402e2e9455cf0213c42b97f22a0493372d7cc upstream. On suspend the original host configuration gets restored. The resume routine has to undo this, otherwise the SMBus master may be left in disabled state or in i2c mode. [JD: Rebased on v5.8, moved the write into i801_setup_hstcfg.] Signed-off-by: Volker RĂ¼melin Signed-off-by: Jean Delvare Signed-off-by: Wolfram Sang Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-i801.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -1506,6 +1506,16 @@ static inline int i801_acpi_probe(struct static inline void i801_acpi_remove(struct i801_priv *priv) { } #endif +static unsigned char i801_setup_hstcfg(struct i801_priv *priv) +{ + unsigned char hstcfg = priv->original_hstcfg; + + hstcfg &= ~SMBHSTCFG_I2C_EN; /* SMBus timing */ + hstcfg |= SMBHSTCFG_HST_EN; + pci_write_config_byte(priv->pci_dev, SMBHSTCFG, hstcfg); + return hstcfg; +} + static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) { unsigned char temp; @@ -1611,14 +1621,10 @@ static int i801_probe(struct pci_dev *de return err; } - pci_read_config_byte(priv->pci_dev, SMBHSTCFG, &temp); - priv->original_hstcfg = temp; - temp &= ~SMBHSTCFG_I2C_EN; /* SMBus timing */ - if (!(temp & SMBHSTCFG_HST_EN)) { + pci_read_config_byte(priv->pci_dev, SMBHSTCFG, &priv->original_hstcfg); + temp = i801_setup_hstcfg(priv); + if (!(priv->original_hstcfg & SMBHSTCFG_HST_EN)) dev_info(&dev->dev, "Enabling SMBus device\n"); - temp |= SMBHSTCFG_HST_EN; - } - pci_write_config_byte(priv->pci_dev, SMBHSTCFG, temp); if (temp & SMBHSTCFG_SMB_SMI_EN) { dev_dbg(&dev->dev, "SMBus using interrupt SMI#\n"); @@ -1745,6 +1751,7 @@ static int i801_resume(struct device *de struct pci_dev *pci_dev = to_pci_dev(dev); struct i801_priv *priv = pci_get_drvdata(pci_dev); + i801_setup_hstcfg(priv); i801_enable_host_notify(&priv->adapter); return 0;