Skip to content

Commit

Permalink
PM / wakeup: Fix up wakeup_source_report_event()
Browse files Browse the repository at this point in the history
Commit 8a537ec (PM / wakeup: Integrate mechanism to abort
transitions in progress) modified wakeup_source_report_event()
and wakeup_source_activate() to make it possible to call
pm_system_wakeup() from the latter if so indicated by the
caller of the former (via a new function argument added by that
commit), but it overlooked the fact that in some situations
wakeup_source_report_event() is called to signal a "hard" event
(ie. such that should abort a system suspend in progress) after
pm_stay_awake() has been called for the same wakeup source object,
in which case the pm_system_wakeup() will not trigger.

To work around this issue, modify wakeup_source_activate() and
wakeup_source_report_event() again so that pm_system_wakeup() is
called by the latter directly (if its last argument is true), in
which case the additional argument does not need to be passed
to wakeup_source_activate() any more, so drop it from there.

Fixes: 8a537ec (PM / wakeup: Integrate mechanism to abort transitions in progress)
Reported-by: David E. Box <david.e.box@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Rafael J. Wysocki committed May 14, 2017
1 parent eed4d47 commit 60d4553
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions drivers/base/power/wakeup.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,23 +512,19 @@ static bool wakeup_source_not_registered(struct wakeup_source *ws)
/**
* wakup_source_activate - Mark given wakeup source as active.
* @ws: Wakeup source to handle.
* @hard: If set, abort suspends in progress and wake up from suspend-to-idle.
*
* Update the @ws' statistics and, if @ws has just been activated, notify the PM
* core of the event by incrementing the counter of of wakeup events being
* processed.
*/
static void wakeup_source_activate(struct wakeup_source *ws, bool hard)
static void wakeup_source_activate(struct wakeup_source *ws)
{
unsigned int cec;

if (WARN_ONCE(wakeup_source_not_registered(ws),
"unregistered wakeup source\n"))
return;

if (hard)
pm_system_wakeup();

ws->active = true;
ws->active_count++;
ws->last_time = ktime_get();
Expand All @@ -554,7 +550,10 @@ static void wakeup_source_report_event(struct wakeup_source *ws, bool hard)
ws->wakeup_count++;

if (!ws->active)
wakeup_source_activate(ws, hard);
wakeup_source_activate(ws);

if (hard)
pm_system_wakeup();
}

/**
Expand Down

0 comments on commit 60d4553

Please sign in to comment.