All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adam Belay <abelay@novell.com>
To: Greg KH <greg@kroah.com>, Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org, linux-pci@atrey.karlin.mff.cuni.cz
Subject: [PATCH 9/9] PCI PM: generic suspend/resume fixes
Date: Mon, 05 Jun 2006 04:46:18 -0400	[thread overview]
Message-ID: <1149497178.7831.163.camel@localhost.localdomain> (raw)

Some drivers never call pci_enable_device() or pci_enable_master() and
instead assume the bios will have initialized the device.  As a
workaround, this patch modifies the generic resume function to verify
which device features need to be enabled by checking the previous state
of the COMMAND register.  Also, pci_disable_device() is now called
during generic suspend.

Signed-off-by: Adam Belay <abelay@novell.com>

---
 pci-driver.c |   21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff -urN a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
--- a/drivers/pci/pci-driver.c	2006-05-30 21:41:14.000000000 -0400
+++ b/drivers/pci/pci-driver.c	2006-06-05 00:29:24.000000000 -0400
@@ -265,6 +265,16 @@
 	return 0;
 }
 
+/*
+ * Default suspend method for devices that have no driver provided suspend,
+ * or not even a driver at all.
+ */
+static void pci_default_suspend(struct pci_dev *pci_dev)
+{
+	pci_save_state(pci_dev);
+	pci_disable_device(pci_dev);
+}
+
 static int pci_device_suspend(struct device * dev, pm_message_t state)
 {
 	struct pci_dev * pci_dev = to_pci_dev(dev);
@@ -274,13 +284,11 @@
 	if (drv && drv->suspend) {
 		i = drv->suspend(pci_dev, state);
 		suspend_report_result(drv->suspend, i);
-	} else {
-		pci_save_state(pci_dev);
-	}
+	} else
+		pci_default_suspend(pci_dev);
 	return i;
 }
 
-
 /*
  * Default resume method for devices that have no driver provided resume,
  * or not even a driver at all.
@@ -288,14 +296,15 @@
 static void pci_default_resume(struct pci_dev *pci_dev)
 {
 	int retval;
+	u16 cmd = pci_dev->saved_config.command;
 
 	/* restore the PCI config space */
 	pci_restore_state(pci_dev);
 	/* if the device was enabled before suspend, reenable */
-	if (pci_dev->is_enabled)
+	if (cmd & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY))
 		retval = pci_enable_device(pci_dev);
 	/* if the device was busmaster before the suspend, make it busmaster again */
-	if (pci_dev->is_busmaster)
+	if (cmd & PCI_COMMAND_MASTER)
 		pci_set_master(pci_dev);
 }
 



             reply	other threads:[~2006-06-05  8:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-05  8:46 Adam Belay [this message]
2006-06-05 10:21 ` [PATCH 9/9] PCI PM: generic suspend/resume fixes Alan Cox
2006-06-05 17:48   ` Adam Belay
2006-06-05 18:45     ` Alan Cox
2006-06-06  0:33     ` Benjamin Herrenschmidt
2006-06-07  3:13       ` Adam Belay

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=1149497178.7831.163.camel@localhost.localdomain \
    --to=abelay@novell.com \
    --cc=akpm@osdl.org \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@atrey.karlin.mff.cuni.cz \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.