Skip to content

Commit eb9c39d

Browse files
committed
PCI: set device wakeup capable flag if platform support is present
When PCI devices are initialized, we check whether they support PCI PM caps and set the device can_wakeup flag if so. However, some devices may have platform provided wakeup events rather than PCI PME signals, so we need to set can_wakeup in that case too. Doing so should allow wakeups from many more devices, especially on cost constrained systems. Reported-by: Alan Stern <stern@rowland.harvard.edu> Tested-by: Joseph Chan <JosephChan@via.com.tw> Acked-by: "Rafael J. Wysocki" <rjw@sisk.pl> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
1 parent 876e501 commit eb9c39d

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

‎drivers/pci/pci.c‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,26 @@ void pci_pm_init(struct pci_dev *dev)
12851285
}
12861286
}
12871287

1288+
/**
1289+
* platform_pci_wakeup_init - init platform wakeup if present
1290+
* @dev: PCI device
1291+
*
1292+
* Some devices don't have PCI PM caps but can still generate wakeup
1293+
* events through platform methods (like ACPI events). If @dev supports
1294+
* platform wakeup events, set the device flag to indicate as much. This
1295+
* may be redundant if the device also supports PCI PM caps, but double
1296+
* initialization should be safe in that case.
1297+
*/
1298+
void platform_pci_wakeup_init(struct pci_dev *dev)
1299+
{
1300+
if (!platform_pci_can_wakeup(dev))
1301+
return;
1302+
1303+
device_set_wakeup_capable(&dev->dev, true);
1304+
device_set_wakeup_enable(&dev->dev, false);
1305+
platform_pci_sleep_wake(dev, false);
1306+
}
1307+
12881308
/**
12891309
* pci_add_save_buffer - allocate buffer for saving given capability registers
12901310
* @dev: the PCI device

‎drivers/pci/pci.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ struct pci_platform_pm_ops {
4545

4646
extern int pci_set_platform_pm(struct pci_platform_pm_ops *ops);
4747
extern void pci_pm_init(struct pci_dev *dev);
48+
extern void platform_pci_wakeup_init(struct pci_dev *dev);
4849
extern void pci_allocate_cap_save_buffers(struct pci_dev *dev);
4950

5051
extern int pci_user_read_config_byte(struct pci_dev *dev, int where, u8 *val);

‎drivers/pci/probe.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,7 @@ static void pci_init_capabilities(struct pci_dev *dev)
965965

966966
/* Power Management */
967967
pci_pm_init(dev);
968+
platform_pci_wakeup_init(dev);
968969

969970
/* Vital Product Data */
970971
pci_vpd_pci22_init(dev);

0 commit comments

Comments
 (0)