public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa@kernel.org>
To: Jean Delvare <jdelvare@suse.de>
Cc: "Linux I2C" <linux-i2c@vger.kernel.org>,
	"Volker Rümelin" <vr_qemu@t-online.de>,
	"Bjorn Helgaas" <helgaas@kernel.org>,
	"Vaibhav Gupta" <vaibhavgupta40@gmail.com>
Subject: Re: [PATCH] i2c: i801: Fix resume bug
Date: Fri, 28 Aug 2020 10:57:53 +0200	[thread overview]
Message-ID: <20200828085753.GH1343@ninjato> (raw)
In-Reply-To: <20200825191303.4a258073@endymion>

[-- Attachment #1: Type: text/plain, Size: 1770 bytes --]

On Tue, Aug 25, 2020 at 07:13:03PM +0200, Jean Delvare wrote:
> From: Volker Rümelin <vr_qemu@t-online.de>
> 
> 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, simplified a condition.]
> 
> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
> Signed-off-by: Jean Delvare <jdelvare@suse.de>
> ---
> I noticed this bug in a QEMU x86_64 q35 VM booted with OVMF. OVMF
> doesn't initialize the SMBus master. After 1s of SMBus inactivity
> autosuspend disables the SMBus master. To reproduce please note QEMU's
> ICH9 SMBus emulation does not handle interrupts and it's necessary
> to pass the parameter disable_features=0x10 to the i2c_i801 driver.
> 
> Note from JD: I can't test this.

Thanks for keeping up with this one. I have one high level comment but I
hope Volker, Bjorn, and Vaibhav have comments/tags, too.

> +static unsigned char i801_setup_hstcfg(unsigned char hstcfg)
> +{
> +	hstcfg &= ~SMBHSTCFG_I2C_EN;	/* SMBus timing */
> +	hstcfg |= SMBHSTCFG_HST_EN;
> +	return hstcfg;
> +}

What about putting the write to SMBHSTCFG here, too. When I read the
function name, I assumed it will do that.

> @@ -1961,8 +1965,11 @@ static int i801_suspend(struct device *d
>  
>  static int i801_resume(struct device *dev)
>  {
> -	struct i801_priv *priv = dev_get_drvdata(dev);
> +	struct pci_dev *pci_dev = to_pci_dev(dev);
> +	struct i801_priv *priv = pci_get_drvdata(pci_dev);
> +	unsigned char hstcfg = i801_setup_hstcfg(priv->original_hstcfg);
>  
> +	pci_write_config_byte(pci_dev, SMBHSTCFG, hstcfg);

And on top of that, we could skip the 'hstcfg' variable here.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2020-08-28  8:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-25 17:13 [PATCH] i2c: i801: Fix resume bug Jean Delvare
2020-08-28  8:57 ` Wolfram Sang [this message]
2020-08-28 16:40   ` Bjorn Helgaas
2020-08-31 14:33     ` Jean Delvare
2020-08-31 14:59   ` Vaibhav Gupta
2020-09-01  9:35     ` Jean Delvare

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200828085753.GH1343@ninjato \
    --to=wsa@kernel.org \
    --cc=helgaas@kernel.org \
    --cc=jdelvare@suse.de \
    --cc=linux-i2c@vger.kernel.org \
    --cc=vaibhavgupta40@gmail.com \
    --cc=vr_qemu@t-online.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox