On Tuesday, December 16, 2008 7:02 am Alan Stern wrote:> On Mon, 15 Dec 2008, Jesse Barnes wrote:> > Yeah, if it's a PCI device pci_enable_wake should do the right thing (use> > ACPI or other platform code if needed, otherwise fall back to banging on> > the PM cap bits, etc.). The call can fail if the device or platform> > can't wake up the system, is that what you're looking for?>> You don't understand. pci_enable_wake() enables wakeup events> (assuming the device supports them). But that's not what Joseph is> concerned about. He's concerned about device_init_wakeup(), which sets> the can_wakeup flag to indicate that the device is _capable_ of> generating wakeup events.>> Why doesn't the PCI core set the can_wakeup flag when a PCI device is> first discovered? pci_pm_init() should do that, from pci_init_capabilities(), but only if thedevice has PM caps will can_wakeup be set correctly. OTOH, pci_enable_wake()will enable wake on a device even w/o PM caps if the platform supports it. Wedon't check for platform support at init time though, so if your driver checksfor can_wake it may fail. So something like this patch might be what you'relooking for? Or are you seeing cases where the PM cap bits are ignored too?In that case we'd have a bug in our pm_init code... -- Jesse Barnes, Intel Open Source Technology Center diff --git a/drivers/pci/pci.c b/drivers/pci/pci.cindex 3222f90..02fe393 100644--- a/drivers/pci/pci.c+++ b/drivers/pci/pci.c@@ -1285,6 +1285,20 @@ void pci_pm_init(struct pci_dev *dev) } /**+ * platform_pci_wakeup_init - init platform wakeup if present+ * @dev: PCI device+ */+void platform_pci_wakeup_init(struct pci_dev *dev)+{+ if (!platform_pci_can_wakeup(dev))+ return;++ device_set_wakeup_capable(&dev->dev, true);+ device_set_wakeup_enable(&dev->dev, false);+ platform_pci_sleep_wake(dev, false);+}++/** * pci_add_save_buffer - allocate buffer for saving given capability registers * @dev: the PCI device * @cap: the capability to allocate the buffer fordiff --git a/drivers/pci/pci.h b/drivers/pci/pci.hindex 7242b51..447e2da 100644--- a/drivers/pci/pci.h+++ b/drivers/pci/pci.h@@ -45,6 +45,7 @@ struct pci_platform_pm_ops { extern int pci_set_platform_pm(struct pci_platform_pm_ops *ops); extern void pci_pm_init(struct pci_dev *dev);+extern void platform_pci_wakeup_init(struct pci_dev *dev); extern void pci_allocate_cap_save_buffers(struct pci_dev *dev); extern int pci_user_read_config_byte(struct pci_dev *dev, int where, u8 *val);diff --git a/drivers/pci/probe.c b/drivers/pci/probe.cindex 4160069..4980f60 100644--- a/drivers/pci/probe.c+++ b/drivers/pci/probe.c@@ -963,6 +963,7 @@ static void pci_init_capabilities(struct pci_dev *dev) /* Power Management */ pci_pm_init(dev);+ platform_pci_wakeup_init(dev); /* Vital Product Data */ pci_vpd_pci22_init(dev); ÿôèº{.nÇ+?·?®??+%?Ëÿ±éݶ¥?wÿº{.nÇ+?·¥?{±þ?"þ)í?æèw*jg¬±¨¶????Ý¢jÿ¾«þG«?éÿ¢¸¢·¦j:+v?¨?wèjØm¶?ÿþø¯ù®w¥þ?àþf£¢·h??â?úÿ?Ù¥