Skip to content

Commit

Permalink
drivers: wakeup: run the wakelock blockers during wakeup_source activ…
Browse files Browse the repository at this point in the history
…ation and every resume

Clean up the implementation to make it usable in more than one function.
Run it every resume to make sure the wakeup source isn't still alive and kicking.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: engstk <eng.stk@sapo.pt>
  • Loading branch information
franciscofranco authored and engstk committed Apr 12, 2017
1 parent 48b2f22 commit ba5fe54
Showing 1 changed file with 31 additions and 17 deletions.
48 changes: 31 additions & 17 deletions drivers/base/power/wakeup.c
Expand Up @@ -462,6 +462,33 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
wake_up(&wakeup_count_wait_queue);
}

static bool wakeup_source_blocker(struct wakeup_source *ws)
{
unsigned int wslen = 0;

if (ws && ws->active) {
wslen = strlen(ws->name);

if ((!enable_ipa_ws && !strncmp(ws->name, "IPA_WS", wslen)) ||
(!enable_wlan_extscan_wl_ws &&
!strncmp(ws->name, "wlan_extscan_wl", wslen)) ||
(!enable_qcom_rx_wakelock_ws &&
!strncmp(ws->name, "qcom_rx_wakelock", wslen)) ||
(!enable_wlan_ws &&
!strncmp(ws->name, "wlan", wslen)) ||
(!enable_timerfd_ws &&
!strncmp(ws->name, "[timerfd]", wslen)) ||
(!enable_netlink_ws &&
!strncmp(ws->name, "NETLINK", wslen))) {
wakeup_source_deactivate(ws);
pr_info("forcefully deactivate wakeup source: %s\n", ws->name);
return true;
}
}

return false;
}

/*
* The functions below use the observation that each wakeup event starts a
* period in which the system should not be suspended. The moment this period
Expand Down Expand Up @@ -502,6 +529,9 @@ static void wakeup_source_activate(struct wakeup_source *ws)
{
unsigned int cec;

if (wakeup_source_blocker(ws))
return;

/*
* active wakeup source should bring the system
* out of PM_SUSPEND_FREEZE state
Expand Down Expand Up @@ -752,26 +782,10 @@ void pm_print_active_wakeup_sources(void)
rcu_read_lock();
list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
if (ws->active) {
int wslen = strlen(ws->name);

pr_info("active wakeup source: %s\n", ws->name);

if ((!enable_ipa_ws && !strncmp(ws->name, "IPA_WS", wslen)) ||
(!enable_wlan_extscan_wl_ws &&
!strncmp(ws->name, "wlan_extscan_wl", wslen)) ||
(!enable_qcom_rx_wakelock_ws &&
!strncmp(ws->name, "qcom_rx_wakelock", wslen)) ||
(!enable_wlan_ws &&
!strncmp(ws->name, "wlan", wslen)) ||
(!enable_timerfd_ws &&
!strncmp(ws->name, "[timerfd]", wslen)) ||
(!enable_netlink_ws &&
!strncmp(ws->name, "NETLINK", wslen))) {
wakeup_source_deactivate(ws);
pr_info("forcefully deactivate wakeup source: %s\n", ws->name);
} else {
if (!wakeup_source_blocker(ws))
active = 1;
}
} else if (!active &&
(!last_activity_ws ||
ktime_to_ns(ws->last_time) >
Expand Down

0 comments on commit ba5fe54

Please sign in to comment.