diff options
| author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-09-30 14:46:13 -0400 |
|---|---|---|
| committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-09-30 14:46:13 -0400 |
| commit | e4cb0c9e92f7b16db7a1e892ac6bcf2f736dfd50 (patch) | |
| tree | 35d66a4fc97aa642c14483966f050b5663ff02ca /drivers | |
| parent | 905563ff47db35dcb3f69e69d434207270ad1966 (diff) | |
| parent | 27f3d18630cd7fbb03b62bd78a74303cb8c88069 (diff) | |
Merge branch 'pm-genirq' into acpi-pm
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/base/power/wakeup.c | 16 | ||||
| -rw-r--r-- | drivers/base/syscore.c | 7 | ||||
| -rw-r--r-- | drivers/pci/pcie/pme.c | 61 |
3 files changed, 69 insertions, 15 deletions
diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index eb1bd2ecad8b..c2744b30d5d9 100644 --- a/drivers/base/power/wakeup.c +++ b/drivers/base/power/wakeup.c | |||
| @@ -24,6 +24,9 @@ | |||
| 24 | */ | 24 | */ |
| 25 | bool events_check_enabled __read_mostly; | 25 | bool events_check_enabled __read_mostly; |
| 26 | 26 | ||
| 27 | /* If set and the system is suspending, terminate the suspend. */ | ||
| 28 | static bool pm_abort_suspend __read_mostly; | ||
| 29 | |||
| 27 | /* | 30 | /* |
| 28 | * Combined counters of registered wakeup events and wakeup events in progress. | 31 | * Combined counters of registered wakeup events and wakeup events in progress. |
| 29 | * They need to be modified together atomically, so it's better to use one | 32 | * They need to be modified together atomically, so it's better to use one |
| @@ -719,7 +722,18 @@ bool pm_wakeup_pending(void) | |||
| 719 | pm_print_active_wakeup_sources(); | 722 | pm_print_active_wakeup_sources(); |
| 720 | } | 723 | } |
| 721 | 724 | ||
| 722 | return ret; | 725 | return ret || pm_abort_suspend; |
| 726 | } | ||
| 727 | |||
| 728 | void pm_system_wakeup(void) | ||
| 729 | { | ||
| 730 | pm_abort_suspend = true; | ||
| 731 | freeze_wake(); | ||
| 732 | } | ||
| 733 | |||
| 734 | void pm_wakeup_clear(void) | ||
| 735 | { | ||
| 736 | pm_abort_suspend = false; | ||
| 723 | } | 737 | } |
| 724 | 738 | ||
| 725 | /** | 739 | /** |
diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c index dbb8350ea8dc..8d98a329f6ea 100644 --- a/drivers/base/syscore.c +++ b/drivers/base/syscore.c | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | #include <linux/syscore_ops.h> | 9 | #include <linux/syscore_ops.h> |
| 10 | #include <linux/mutex.h> | 10 | #include <linux/mutex.h> |
| 11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
| 12 | #include <linux/interrupt.h> | 12 | #include <linux/suspend.h> |
| 13 | #include <trace/events/power.h> | 13 | #include <trace/events/power.h> |
| 14 | 14 | ||
| 15 | static LIST_HEAD(syscore_ops_list); | 15 | static LIST_HEAD(syscore_ops_list); |
| @@ -54,9 +54,8 @@ int syscore_suspend(void) | |||
| 54 | pr_debug("Checking wakeup interrupts\n"); | 54 | pr_debug("Checking wakeup interrupts\n"); |
| 55 | 55 | ||
| 56 | /* Return error code if there are any wakeup interrupts pending. */ | 56 | /* Return error code if there are any wakeup interrupts pending. */ |
| 57 | ret = check_wakeup_irqs(); | 57 | if (pm_wakeup_pending()) |
| 58 | if (ret) | 58 | return -EBUSY; |
| 59 | return ret; | ||
| 60 | 59 | ||
| 61 | WARN_ONCE(!irqs_disabled(), | 60 | WARN_ONCE(!irqs_disabled(), |
| 62 | "Interrupts enabled before system core suspend.\n"); | 61 | "Interrupts enabled before system core suspend.\n"); |
diff --git a/drivers/pci/pcie/pme.c b/drivers/pci/pcie/pme.c index 82e06a86cd77..a9f9c46e5022 100644 --- a/drivers/pci/pcie/pme.c +++ b/drivers/pci/pcie/pme.c | |||
| @@ -41,11 +41,17 @@ static int __init pcie_pme_setup(char *str) | |||
| 41 | } | 41 | } |
| 42 | __setup("pcie_pme=", pcie_pme_setup); | 42 | __setup("pcie_pme=", pcie_pme_setup); |
| 43 | 43 | ||
| 44 | enum pme_suspend_level { | ||
| 45 | PME_SUSPEND_NONE = 0, | ||
| 46 | PME_SUSPEND_WAKEUP, | ||
| 47 | PME_SUSPEND_NOIRQ, | ||
| 48 | }; | ||
| 49 | |||
| 44 | struct pcie_pme_service_data { | 50 | struct pcie_pme_service_data { |
| 45 | spinlock_t lock; | 51 | spinlock_t lock; |
| 46 | struct pcie_device *srv; | 52 | struct pcie_device *srv; |
| 47 | struct work_struct work; | 53 | struct work_struct work; |
| 48 | bool noirq; /* Don't enable the PME interrupt used by this service. */ | 54 | enum pme_suspend_level suspend_level; |
| 49 | }; | 55 | }; |
| 50 | 56 | ||
| 51 | /** | 57 | /** |
| @@ -223,7 +229,7 @@ static void pcie_pme_work_fn(struct work_struct *work) | |||
| 223 | spin_lock_irq(&data->lock); | 229 | spin_lock_irq(&data->lock); |
| 224 | 230 | ||
| 225 | for (;;) { | 231 | for (;;) { |
| 226 | if (data->noirq) | 232 | if (data->suspend_level != PME_SUSPEND_NONE) |
| 227 | break; | 233 | break; |
| 228 | 234 | ||
| 229 | pcie_capability_read_dword(port, PCI_EXP_RTSTA, &rtsta); | 235 | pcie_capability_read_dword(port, PCI_EXP_RTSTA, &rtsta); |
| @@ -250,7 +256,7 @@ static void pcie_pme_work_fn(struct work_struct *work) | |||
| 250 | spin_lock_irq(&data->lock); | 256 | spin_lock_irq(&data->lock); |
| 251 | } | 257 | } |
| 252 | 258 | ||
| 253 | if (!data->noirq) | 259 | if (data->suspend_level == PME_SUSPEND_NONE) |
| 254 | pcie_pme_interrupt_enable(port, true); | 260 | pcie_pme_interrupt_enable(port, true); |
| 255 | 261 | ||
| 256 | spin_unlock_irq(&data->lock); | 262 | spin_unlock_irq(&data->lock); |
| @@ -367,6 +373,21 @@ static int pcie_pme_probe(struct pcie_device *srv) | |||
| 367 | return ret; | 373 | return ret; |
| 368 | } | 374 | } |
| 369 | 375 | ||
| 376 | static bool pcie_pme_check_wakeup(struct pci_bus *bus) | ||
| 377 | { | ||
| 378 | struct pci_dev *dev; | ||
| 379 | |||
| 380 | if (!bus) | ||
| 381 | return false; | ||
| 382 | |||
| 383 | list_for_each_entry(dev, &bus->devices, bus_list) | ||
| 384 | if (device_may_wakeup(&dev->dev) | ||
| 385 | || pcie_pme_check_wakeup(dev->subordinate)) | ||
| 386 | return true; | ||
| 387 | |||
| 388 | return false; | ||
| 389 | } | ||
| 390 | |||
| 370 | /** | 391 | /** |
| 371 | * pcie_pme_suspend - Suspend PCIe PME service device. | 392 | * pcie_pme_suspend - Suspend PCIe PME service device. |
| 372 | * @srv: PCIe service device to suspend. | 393 | * @srv: PCIe service device to suspend. |
| @@ -375,11 +396,26 @@ static int pcie_pme_suspend(struct pcie_device *srv) | |||
| 375 | { | 396 | { |
| 376 | struct pcie_pme_service_data *data = get_service_data(srv); | 397 | struct pcie_pme_service_data *data = get_service_data(srv); |
| 377 | struct pci_dev *port = srv->port; | 398 | struct pci_dev *port = srv->port; |
| 399 | bool wakeup; | ||
| 378 | 400 | ||
| 401 | if (device_may_wakeup(&port->dev)) { | ||
| 402 | wakeup = true; | ||
| 403 | } else { | ||
| 404 | down_read(&pci_bus_sem); | ||
| 405 | wakeup = pcie_pme_check_wakeup(port->subordinate); | ||
| 406 | up_read(&pci_bus_sem); | ||
| 407 | } | ||
| 379 | spin_lock_irq(&data->lock); | 408 | spin_lock_irq(&data->lock); |
| 380 | pcie_pme_interrupt_enable(port, false); | 409 | if (wakeup) { |
| 381 | pcie_clear_root_pme_status(port); | 410 | enable_irq_wake(srv->irq); |
| 382 | data->noirq = true; | 411 | data->suspend_level = PME_SUSPEND_WAKEUP; |
| 412 | } else { | ||
| 413 | struct pci_dev *port = srv->port; | ||
| 414 | |||
| 415 | pcie_pme_interrupt_enable(port, false); | ||
| 416 | pcie_clear_root_pme_status(port); | ||
| 417 | data->suspend_level = PME_SUSPEND_NOIRQ; | ||
| 418 | } | ||
| 383 | spin_unlock_irq(&data->lock); | 419 | spin_unlock_irq(&data->lock); |
| 384 | 420 | ||
| 385 | synchronize_irq(srv->irq); | 421 | synchronize_irq(srv->irq); |
| @@ -394,12 +430,17 @@ static int pcie_pme_suspend(struct pcie_device *srv) | |||
| 394 | static int pcie_pme_resume(struct pcie_device *srv) | 430 | static int pcie_pme_resume(struct pcie_device *srv) |
| 395 | { | 431 | { |
| 396 | struct pcie_pme_service_data *data = get_service_data(srv); | 432 | struct pcie_pme_service_data *data = get_service_data(srv); |
| 397 | struct pci_dev *port = srv->port; | ||
| 398 | 433 | ||
| 399 | spin_lock_irq(&data->lock); | 434 | spin_lock_irq(&data->lock); |
| 400 | data->noirq = false; | 435 | if (data->suspend_level == PME_SUSPEND_NOIRQ) { |
| 401 | pcie_clear_root_pme_status(port); | 436 | struct pci_dev *port = srv->port; |
| 402 | pcie_pme_interrupt_enable(port, true); | 437 | |
| 438 | pcie_clear_root_pme_status(port); | ||
| 439 | pcie_pme_interrupt_enable(port, true); | ||
| 440 | } else { | ||
| 441 | disable_irq_wake(srv->irq); | ||
| 442 | } | ||
| 443 | data->suspend_level = PME_SUSPEND_NONE; | ||
| 403 | spin_unlock_irq(&data->lock); | 444 | spin_unlock_irq(&data->lock); |
| 404 | 445 | ||
| 405 | return 0; | 446 | return 0; |
