All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: akpm@osdl.org, greg@kroah.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Make pci_set_power_state() check register version
Date: Fri, 17 Dec 2004 16:58:52 +0000	[thread overview]
Message-ID: <24151.1103302732@redhat.com> (raw)


The attached patch makes pci_set_power_state() check the PM register version
and ignore non-version 2 registers. Trampling on earlier version PM registers
such as are sported by the Promise 20269 IDE card can cause the system to
hang.

Signed-Off-By: David Howells <dhowells@redhat.com>
---
warthog>diffstat pci-pm-2610rc3mm1.diff 
 pci.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff -uNrp linux-2.6.10-rc3-mm1-asmoffsets/drivers/pci/pci.c linux-2.6.10-rc3-mm1-debug/drivers/pci/pci.c
--- linux-2.6.10-rc3-mm1-asmoffsets/drivers/pci/pci.c	2004-12-13 14:29:51.000000000 +0000
+++ linux-2.6.10-rc3-mm1-debug/drivers/pci/pci.c	2004-12-17 16:50:09.637295082 +0000
@@ -245,7 +245,7 @@ int
 pci_set_power_state(struct pci_dev *dev, int state)
 {
 	int pm;
-	u16 pmcsr;
+	u16 pmcsr, pmc;
 
 	/* bound the state we're entering */
 	if (state > 3) state = 3;
@@ -265,10 +265,16 @@ pci_set_power_state(struct pci_dev *dev,
 	/* abort if the device doesn't support PM capabilities */
 	if (!pm) return -EIO; 
 
+	pci_read_config_word(dev,pm + PCI_PM_PMC,&pmc);
+	if ((pmc & PCI_PM_CAP_VER_MASK) != 2) {
+		printk(KERN_WARNING
+		       "PCI: %s has unsupported PM cap regs version (%u)\n",
+		       dev->slot_name, pmc & PCI_PM_CAP_VER_MASK);
+		return -EIO;
+	}
+
 	/* check if this device supports the desired state */
 	if (state == 1 || state == 2) {
-		u16 pmc;
-		pci_read_config_word(dev,pm + PCI_PM_PMC,&pmc);
 		if (state == 1 && !(pmc & PCI_PM_CAP_D1)) return -EIO;
 		else if (state == 2 && !(pmc & PCI_PM_CAP_D2)) return -EIO;
 	}

             reply	other threads:[~2004-12-17 16:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-17 16:58 David Howells [this message]
2004-12-17 21:45 ` [PATCH] Make pci_set_power_state() check register version Greg KH

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=24151.1103302732@redhat.com \
    --to=dhowells@redhat.com \
    --cc=akpm@osdl.org \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    /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.