Skip to content

Commit

Permalink
PM / core: Propagate wakeup_path status flag in __device_suspend_late()
Browse files Browse the repository at this point in the history
Currently the wakeup_path status flag becomes propagated from a child
device to its parent device at __device_suspend(). This allows a driver
dealing with a parent device to act on the flag from its ->suspend()
callback.

However, in situations when the wakeup_path status flag needs to be set
from a ->suspend_late() callback, its value doesn't get propagated to the
parent by the PM core. Let's address this limitation, by also propagating
the flag at __device_suspend_late().

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Ulf Hansson authored and Rafael J. Wysocki committed Jan 10, 2018
1 parent c23bd38 commit 0a99d76
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions drivers/base/power/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,21 @@ int dpm_suspend_noirq(pm_message_t state)
return ret;
}

static void dpm_propagate_wakeup_to_parent(struct device *dev)
{
struct device *parent = dev->parent;

if (!parent)
return;

spin_lock_irq(&parent->power.lock);

if (dev->power.wakeup_path && !parent->power.ignore_children)
parent->power.wakeup_path = true;

spin_unlock_irq(&parent->power.lock);
}

static pm_callback_t dpm_subsys_suspend_late_cb(struct device *dev,
pm_message_t state,
const char **info_p)
Expand Down Expand Up @@ -1527,6 +1542,7 @@ static int __device_suspend_late(struct device *dev, pm_message_t state, bool as
async_error = error;
goto Complete;
}
dpm_propagate_wakeup_to_parent(dev);

Skip:
dev->power.is_late_suspended = true;
Expand Down Expand Up @@ -1660,21 +1676,6 @@ static int legacy_suspend(struct device *dev, pm_message_t state,
return error;
}

static void dpm_propagate_wakeup_to_parent(struct device *dev)
{
struct device *parent = dev->parent;

if (!parent)
return;

spin_lock_irq(&parent->power.lock);

if (dev->power.wakeup_path && !parent->power.ignore_children)
parent->power.wakeup_path = true;

spin_unlock_irq(&parent->power.lock);
}

static void dpm_clear_superiors_direct_complete(struct device *dev)
{
struct device_link *link;
Expand Down

0 comments on commit 0a99d76

Please sign in to comment.