Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2992794AbbEPAJT (ORCPT ); Fri, 15 May 2015 20:09:19 -0400 Received: from v094114.home.net.pl ([79.96.170.134]:51032 "HELO v094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S2992574AbbEPAJR (ORCPT ); Fri, 15 May 2015 20:09:17 -0400 From: "Rafael J. Wysocki" To: Jin Qian Cc: Len Brown , Pavel Machek , Greg Kroah-Hartman , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] power: increment wakeup_count when save_wakeup_count failed. Date: Sat, 16 May 2015 02:34:32 +0200 Message-ID: <6356516.qkiSo3Mux2@vostro.rjw.lan> User-Agent: KMail/4.11.5 (Linux/4.0.0+; KDE/4.11.5; x86_64; ; ) In-Reply-To: <1429750212-28659-3-git-send-email-jinqian@android.com> References: <1429750212-28659-1-git-send-email-jinqian@android.com> <1429750212-28659-3-git-send-email-jinqian@android.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2326 Lines: 74 On Wednesday, April 22, 2015 05:50:11 PM Jin Qian wrote: > user-space aborts suspend attempt if writing wakeup_count failed. > Count the write failure towards wakeup_count. A use case, please? > Signed-off-by: Jin Qian > --- > drivers/base/power/wakeup.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c > index f24c622..bdb45f3 100644 > --- a/drivers/base/power/wakeup.c > +++ b/drivers/base/power/wakeup.c > @@ -57,6 +57,8 @@ static LIST_HEAD(wakeup_sources); > > static DECLARE_WAIT_QUEUE_HEAD(wakeup_count_wait_queue); > > +static ktime_t last_read_time; > + > /** > * wakeup_source_prepare - Prepare a new wakeup source for initialization. > * @ws: Wakeup source to prepare. > @@ -771,10 +773,15 @@ void pm_wakeup_clear(void) > bool pm_get_wakeup_count(unsigned int *count, bool block) > { > unsigned int cnt, inpr; > + unsigned long flags; > > if (block) { > DEFINE_WAIT(wait); > > + spin_lock_irqsave(&events_lock, flags); > + last_read_time = ktime_get(); > + spin_unlock_irqrestore(&events_lock, flags); > + > for (;;) { > prepare_to_wait(&wakeup_count_wait_queue, &wait, > TASK_INTERRUPTIBLE); > @@ -806,6 +813,7 @@ bool pm_save_wakeup_count(unsigned int count) > { > unsigned int cnt, inpr; > unsigned long flags; > + struct wakeup_source *ws; > > events_check_enabled = false; > spin_lock_irqsave(&events_lock, flags); > @@ -813,6 +821,15 @@ bool pm_save_wakeup_count(unsigned int count) > if (cnt == count && inpr == 0) { > saved_count = count; > events_check_enabled = true; > + } else { > + rcu_read_lock(); > + list_for_each_entry_rcu(ws, &wakeup_sources, entry) { > + if (ws->active || > + ktime_compare(ws->last_time, last_read_time) > 0) { > + ws->wakeup_count++; > + } > + } > + rcu_read_unlock(); > } > spin_unlock_irqrestore(&events_lock, flags); > return events_check_enabled; > -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/