public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: david-b@pacbell.net
Subject: [PATCH] pci device wakeup flags
Date: Thu, 27 Oct 2005 23:30:22 -0700	[thread overview]
Message-ID: <11304810223093@kroah.com> (raw)
In-Reply-To: <11304810221338@kroah.com>

[PATCH] pci device wakeup flags

This patch teaches "pci_dev" about the new driver model wakeup support:

 - It marks devices as supporting wakeup when "can issue PME#" is
   listed in its PCI PM capability.

 - pci_enable_wake() refuses to enable wake if that's been disabled
   (e.g. through sysfs).

NOTE that a recent patch changed PCI probing, and this reverts part
of that change ... so that driver model initialization is again done
before the PCI setup.

(One issue is that the driver model "init + add == register" pattern isn't
being used inside PCI ...  and that probe change worsened the problem by
making "add" do some "init" too.  Maybe PCI should match the driver model
more closely, and just grow a new "pci_dev_init" function.)

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
commit 454a289c5bc26384c2bdc40c0d232cf47bcf0a5d
tree e012cb9ddae22f2bb7fba37b6834e2123070eaa0
parent f69079c91f8ade0bb306d137d60cc9892e89f35a
author David Brownell <david-b@pacbell.net> Mon, 12 Sep 2005 19:48:14 -0700
committer Greg Kroah-Hartman <gregkh@suse.de> Thu, 27 Oct 2005 22:47:59 -0700

 drivers/pci/pci.c   |    4 ++++
 drivers/pci/probe.c |   16 +++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 259d247..6c1c56b 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -539,6 +539,10 @@ int pci_enable_wake(struct pci_dev *dev,
 	if (!pm) 
 		return enable ? -EIO : 0; 
 
+	/* don't enable unless policy set through driver core allows it */
+	if (!device_may_wakeup(&dev->dev) && enable)
+		return -EROFS;
+
 	/* Check device's ability to generate PME# */
 	pci_read_config_word(dev,pm+PCI_PM_PMC,&value);
 
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 0057864..0a7eec1 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -589,6 +589,7 @@ static void pci_read_irq(struct pci_dev 
 static int pci_setup_device(struct pci_dev * dev)
 {
 	u32 class;
+	u16 pm;
 
 	sprintf(pci_name(dev), "%04x:%02x:%02x.%d", pci_domain_nr(dev->bus),
 		dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
@@ -616,6 +617,19 @@ static int pci_setup_device(struct pci_d
 		pci_read_bases(dev, 6, PCI_ROM_ADDRESS);
 		pci_read_config_word(dev, PCI_SUBSYSTEM_VENDOR_ID, &dev->subsystem_vendor);
 		pci_read_config_word(dev, PCI_SUBSYSTEM_ID, &dev->subsystem_device);
+
+		/* PCI PM capable devices may be able to issue PME# (wakeup) */
+		pm = pci_find_capability(dev, PCI_CAP_ID_PM);
+		if (pm) {
+			pci_read_config_word(dev, pm + PCI_PM_PMC, &pm);
+			if (pm & PCI_PM_CAP_PME_MASK)
+				device_init_wakeup(&dev->dev, 1);
+
+			/* REVISIT: if (pm & PCI_PM_CAP_PME_D3cold) then
+			 * pci pm spec 1.2, section 3.2.4 says we should
+			 * init PCI_PM_CTRL_PME_{STATUS,ENABLE} ...
+			 */
+		}
 		break;
 
 	case PCI_HEADER_TYPE_BRIDGE:		    /* bridge header */
@@ -755,6 +769,7 @@ pci_scan_device(struct pci_bus *bus, int
 	memset(dev, 0, sizeof(struct pci_dev));
 	dev->bus = bus;
 	dev->sysdata = bus->sysdata;
+	device_initialize(&dev->dev);
 	dev->dev.parent = bus->bridge;
 	dev->dev.bus = &pci_bus_type;
 	dev->devfn = devfn;
@@ -777,7 +792,6 @@ pci_scan_device(struct pci_bus *bus, int
 
 void __devinit pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
 {
-	device_initialize(&dev->dev);
 	dev->dev.release = pci_release_dev;
 	pci_dev_get(dev);
 


  reply	other threads:[~2005-10-28  6:34 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-28  6:29 [GIT PATCH] Driver Core patches for 2.6.14 Greg KH
2005-10-28  6:30 ` [PATCH] aoe: update to version 14 Greg KH
2005-10-28  6:30   ` [PATCH] aoe: use get_unaligned for accesses in ATA id buffer Greg KH
2005-10-28  6:30     ` [PATCH] kobject_uevent.c has a typo in a comment Greg KH
2005-10-28  6:30       ` [PATCH] changes device to driver in porting.txt Greg KH
2005-10-28  6:30         ` [PATCH] kobject: fix gfp flags type Greg KH
2005-10-28  6:30           ` Greg KH [this message]
2005-10-28  6:30             ` [PATCH] driver model wakeup flags Greg KH
2005-10-28  6:30               ` [PATCH] add sysfs support for ide tape Greg KH
2005-10-28  6:30                 ` [PATCH] usb device wakeup flags Greg KH
2005-10-28  6:30                   ` [PATCH] I2O: Clean up some pretty bad driver model abuses in the i2o code Greg KH
2005-10-28  6:30                     ` [PATCH] Driver core: pass interface to class interface methods Greg KH
2005-10-28  6:30                       ` [PATCH] Driver core: send hotplug event before adding class interfaces Greg KH
2005-10-28  6:30                         ` [PATCH] I2O: remove i2o_device_class Greg KH
2005-10-28  6:30                           ` [PATCH] add sysfs attr to re-emit device hotplug event Greg KH
2005-10-28  6:30                             ` [PATCH] I2O: remove class interface Greg KH
2005-10-28  6:30                               ` [PATCH] Driver Core: add the ability for class_device structures to be nested Greg KH
2005-10-28  6:30                                 ` [PATCH] Driver Core: fix up all callers of class_device_create() Greg KH
2005-10-28  6:30                                   ` [PATCH] Input: prepare to sysfs integration Greg KH
2005-10-28  6:30                                     ` [PATCH] Driver Core: document struct class_device properly Greg KH
2005-10-28  6:30                                       ` [PATCH] drivers/input/mouse: convert to dynamic input_dev allocation Greg KH
2005-10-28  6:30                                         ` [PATCH] Input: kill devfs references Greg KH
2005-10-28  6:30                                           ` [PATCH] Input: convert sonypi to dynamic input_dev allocation Greg KH
2005-10-28  6:30                                             ` [PATCH] Input: convert ucb1x00-ts " Greg KH
2005-10-28  6:30                                               ` [PATCH] drivers/input/keyboard: convert " Greg KH
2005-10-28  6:30                                                 ` [PATCH] Input: convert onetouch " Greg KH
2005-10-28  6:30                                                   ` [PATCH] drivers/input/touchscreen: convert " Greg KH
2005-10-28  6:55                                                 ` [PATCH] drivers/input/keyboard: " Jan-Benedict Glaw
2005-10-28  7:05                                                   ` Dmitry Torokhov
2005-10-29  5:59                                                     ` Dmitry Torokhov
2005-10-29 14:37                                                       ` Jan-Benedict Glaw
2005-10-29 15:04                                                       ` Jan-Benedict Glaw
2005-10-29 16:28                                                         ` Dmitry Torokhov
2005-10-29 18:53                                                           ` Jan-Benedict Glaw
2005-10-31  7:02                                                             ` Dmitry Torokhov
2005-10-31  7:20                                                               ` [PATCH] input/lkkbd: misc fixes Jan-Benedict Glaw
2005-10-28  6:54                                       ` [PATCH] Driver Core: document struct class_device properly Dmitry Torokhov
2005-10-28 19:09                                         ` Greg KH
2005-10-28 19:18                                           ` Dmitry Torokhov
2005-11-07  8:00                                           ` Miles Bader
2005-11-07 17:00                                             ` Greg KH
2005-10-29  7:55               ` [PATCH] driver model wakeup flags Pavel Machek
2005-11-02 21:59                 ` Greg KH
2005-11-04 17:43                   ` David Brownell
2005-10-28 10:51             ` [PATCH] pci device " Andrew Morton
2005-10-28 14:31               ` Linus Torvalds
2005-10-28 23:03                 ` Benjamin Herrenschmidt
2005-10-28 15:50               ` Greg KH
2005-10-28 19:34                 ` Andrew Morton
2005-10-28 19:45                   ` Greg KH
2005-10-28 19:47                   ` Linus Torvalds
2005-10-28 19:56                     ` Russell King
2005-10-28 20:08                       ` Greg KH
2005-10-28 20:01                     ` Greg KH
2005-10-28  9:21           ` [PATCH] kobject: fix gfp flags type Al Viro
2005-10-28 17:48 ` [GIT PATCH] Driver Core patches for 2.6.14 Greg KH
2005-10-28 18:55   ` Jan-Benedict Glaw
2005-10-28 19:11     ` Greg KH
2005-10-28 19:16       ` Jan-Benedict Glaw

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=11304810223093@kroah.com \
    --to=gregkh@suse.de \
    --cc=david-b@pacbell.net \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox