Commit 702c31e8 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'pm-5.2-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull power management fixes from Rafael Wysocki:
 "These fix three issues in the system-wide suspend and hibernation area
  related to PCI device PM handling by suspend-to-idle, device wakeup
  optimizations and arbitrary differences between suspend and
  hiberantion.

  Specifics:

   - Modify the PCI bus type's PM code to avoid putting devices left by
     their drivers in D0 on purpose during suspend to idle into
     low-power states as doing that may confuse the system resume
     callbacks of the drivers in question (Rafael Wysocki).

   - Avoid checking ACPI wakeup configuration during system-wide suspend
     for suspended devices that do not use ACPI-based wakeup to allow
     them to stay in suspend more often (Rafael Wysocki).

   - The last phase of hibernation is analogous to system-wide suspend
     also because on platforms with ACPI it passes control to the
     platform firmware to complete the transision, so make it indicate
     that by calling pm_set_suspend_via_firmware() to allow the drivers
     that care about this to do the right thing (Rafael Wysocki)"

* tag 'pm-5.2-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  PCI: PM: Avoid possible suspend-to-idle issue
  ACPI: PM: Call pm_set_suspend_via_firmware() during hibernation
  ACPI/PCI: PM: Add missing wakeup.flags.valid checks
parents 72cea7ac d491f2b7
......@@ -944,8 +944,8 @@ static bool acpi_dev_needs_resume(struct device *dev, struct acpi_device *adev)
u32 sys_target = acpi_target_system_state();
int ret, state;
if (!pm_runtime_suspended(dev) || !adev ||
device_may_wakeup(dev) != !!adev->wakeup.prepare_count)
if (!pm_runtime_suspended(dev) || !adev || (adev->wakeup.flags.valid &&
device_may_wakeup(dev) != !!adev->wakeup.prepare_count))
return true;
if (sys_target == ACPI_STATE_S0)
......
......@@ -1132,15 +1132,19 @@ void __init acpi_no_s4_hw_signature(void)
nosigcheck = true;
}
static int acpi_hibernation_begin(void)
static int acpi_hibernation_begin(pm_message_t stage)
{
int error;
if (!nvs_nosave) {
int error = suspend_nvs_alloc();
if (error)
return error;
}
error = nvs_nosave ? 0 : suspend_nvs_alloc();
if (!error)
acpi_pm_start(ACPI_STATE_S4);
if (stage.event == PM_EVENT_HIBERNATE)
pm_set_suspend_via_firmware();
return error;
acpi_pm_start(ACPI_STATE_S4);
return 0;
}
static int acpi_hibernation_enter(void)
......@@ -1200,7 +1204,7 @@ static const struct platform_hibernation_ops acpi_hibernation_ops = {
* function is used if the pre-ACPI 2.0 suspend ordering has been
* requested.
*/
static int acpi_hibernation_begin_old(void)
static int acpi_hibernation_begin_old(pm_message_t stage)
{
int error;
/*
......@@ -1211,16 +1215,21 @@ static int acpi_hibernation_begin_old(void)
acpi_sleep_tts_switch(ACPI_STATE_S4);
error = acpi_sleep_prepare(ACPI_STATE_S4);
if (error)
return error;
if (!error) {
if (!nvs_nosave)
if (!nvs_nosave) {
error = suspend_nvs_alloc();
if (!error) {
if (error)
return error;
}
if (stage.event == PM_EVENT_HIBERNATE)
pm_set_suspend_via_firmware();
acpi_target_sleep_state = ACPI_STATE_S4;
acpi_scan_lock_acquire();
}
}
return error;
return 0;
}
/*
......
......@@ -733,7 +733,8 @@ static bool acpi_pci_need_resume(struct pci_dev *dev)
if (!adev || !acpi_device_power_manageable(adev))
return false;
if (device_may_wakeup(&dev->dev) != !!adev->wakeup.prepare_count)
if (adev->wakeup.flags.valid &&
device_may_wakeup(&dev->dev) != !!adev->wakeup.prepare_count)
return true;
if (acpi_target_system_state() == ACPI_STATE_S0)
......
......@@ -734,6 +734,8 @@ static int pci_pm_suspend(struct device *dev)
struct pci_dev *pci_dev = to_pci_dev(dev);
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
pci_dev->skip_bus_pm = false;
if (pci_has_legacy_pm_support(pci_dev))
return pci_legacy_suspend(dev, PMSG_SUSPEND);
......@@ -827,7 +829,20 @@ static int pci_pm_suspend_noirq(struct device *dev)
}
}
if (!pci_dev->state_saved) {
if (pci_dev->skip_bus_pm) {
/*
* The function is running for the second time in a row without
* going through full resume, which is possible only during
* suspend-to-idle in a spurious wakeup case. Moreover, the
* device was originally left in D0, so its power state should
* not be changed here and the device register values saved
* originally should be restored on resume again.
*/
pci_dev->state_saved = true;
} else if (pci_dev->state_saved) {
if (pci_dev->current_state == PCI_D0)
pci_dev->skip_bus_pm = true;
} else {
pci_save_state(pci_dev);
if (pci_power_manageable(pci_dev))
pci_prepare_to_sleep(pci_dev);
......
......@@ -344,6 +344,7 @@ struct pci_dev {
D3cold, not set for devices
powered on/off by the
corresponding bridge */
unsigned int skip_bus_pm:1; /* Internal: Skip bus-level PM */
unsigned int ignore_hotplug:1; /* Ignore hotplug events */
unsigned int hotplug_user_indicators:1; /* SlotCtl indicators
controlled exclusively by
......
......@@ -359,7 +359,7 @@ extern void mark_free_pages(struct zone *zone);
* platforms which require special recovery actions in that situation.
*/
struct platform_hibernation_ops {
int (*begin)(void);
int (*begin)(pm_message_t stage);
void (*end)(void);
int (*pre_snapshot)(void);
void (*finish)(void);
......
......@@ -129,7 +129,7 @@ static int hibernation_test(int level) { return 0; }
static int platform_begin(int platform_mode)
{
return (platform_mode && hibernation_ops) ?
hibernation_ops->begin() : 0;
hibernation_ops->begin(PMSG_FREEZE) : 0;
}
/**
......@@ -542,7 +542,7 @@ int hibernation_platform_enter(void)
* hibernation_ops->finish() before saving the image, so we should let
* the firmware know that we're going to enter the sleep state after all
*/
error = hibernation_ops->begin();
error = hibernation_ops->begin(PMSG_HIBERNATE);
if (error)
goto Close;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment