linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yinghai Lu <yinghai@kernel.org>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: Wilmer van der Gaast <kernel@wilmer.gaast.net>,
	Zhang Rui <rui.zhang@intel.com>,
	linux-pci@vger.kernel.org, Yinghai Lu <yinghai@kernel.org>,
	stable@vger.kernel.org.#.v3.10+
Subject: [PATCH] PCI: keep enable status consistent for device without driver
Date: Wed, 14 Jan 2015 21:36:48 -0800	[thread overview]
Message-ID: <1421300208-7087-1-git-send-email-yinghai@kernel.org> (raw)

Wilmer reported continuous suspend/resume does not work after
commit 928bea964827 ("PCI: Delay enabling bridges until they're needed").

For pci bridge without driver, FW enable it already.
In pci_pm_resume/pci_pm_reenable_device after first resume
will not reenable the device, aka the status is not the same
as that before first suspend.

Try to update enable status according to register value before
calling pci_reenable_device, so we will not miss those pm
operation calling for next suspend/resume.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=86421
Fixes: 928bea964827 ("PCI: Delay enabling bridges until they're needed")
Reported-by: Wilmer van der Gaast <kernel@wilmer.gaast.net>
Bisected-by: Wilmer van der Gaast <kernel@wilmer.gaast.net>
Tested-by: Wilmer van der Gaast <kernel@wilmer.gaast.net>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Zhang Rui <rui.zhang@intel.com>
CC: stable@vger.kernel.org  # v3.10+

---
 drivers/pci/pci-driver.c |    9 +++++++++
 1 file changed, 9 insertions(+)

Index: linux-2.6/drivers/pci/pci-driver.c
===================================================================
--- linux-2.6.orig/drivers/pci/pci-driver.c
+++ linux-2.6/drivers/pci/pci-driver.c
@@ -519,8 +519,17 @@ static void pci_pm_set_unknown_state(str
  */
 static int pci_pm_reenable_device(struct pci_dev *pci_dev)
 {
+	u16 cmd;
 	int retval;
 
+	/* update enable_cnt according to cmd register */
+	pci_read_config_word(pci_dev, PCI_COMMAND, &cmd);
+	if (!pci_dev->is_busmaster && (cmd & PCI_COMMAND_MASTER))
+		pci_dev->is_busmaster = true;
+	if (!pci_is_enabled(pci_dev) &&
+	    (cmd & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)))
+		atomic_inc(&pci_dev->enable_cnt);
+
 	/* if the device was enabled before suspend, reenable */
 	retval = pci_reenable_device(pci_dev);
 	/*

             reply	other threads:[~2015-01-15  5:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-15  5:36 Yinghai Lu [this message]
2015-01-15 23:55 ` [PATCH] PCI: keep enable status consistent for device without driver Bjorn Helgaas
2015-01-17  8:28   ` Pavel Machek
2015-01-19  2:29   ` Yinghai Lu

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=1421300208-7087-1-git-send-email-yinghai@kernel.org \
    --to=yinghai@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=kernel@wilmer.gaast.net \
    --cc=linux-pci@vger.kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=stable@vger.kernel.org.#.v3.10+ \
    /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;
as well as URLs for NNTP newsgroup(s).