public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: "Arve Hjønnevåg" <arve@android.com>
Cc: Linux PM list <linux-pm@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/3] PM / Sleep: Make __pm_stay_awake() delete wakeup source timers
Date: Fri, 17 Feb 2012 21:46:59 +0100	[thread overview]
Message-ID: <201202172146.59236.rjw@sisk.pl> (raw)
In-Reply-To: <CAMP5Xgc5JtqH-PqS9+z1swg9CR5w6Az+_HNyuO9uG9WyGONRaw@mail.gmail.com>

On Friday, February 17, 2012, Arve Hjønnevåg wrote:
> 2012/2/16 Rafael J. Wysocki <rjw@sisk.pl>:
> > On Thursday, February 16, 2012, Arve Hjønnevåg wrote:
> >> 2012/2/15 Rafael J. Wysocki <rjw@sisk.pl>:
> >> ...
> >> > --- linux.orig/drivers/base/power/wakeup.c
> >> > +++ linux/drivers/base/power/wakeup.c
> >> > @@ -365,9 +365,15 @@ void __pm_stay_awake(struct wakeup_sourc
> >> >                return;
> >> >
> >> >        spin_lock_irqsave(&ws->lock, flags);
> >> > +
> >> > +       del_timer(&ws->timer);
> >> > +       ws->timer_expires = 0;
> >>
> >> timer_expires gets overwritten in wakeup_source_activate,
> >
> > I actually don't remember why it does that and with the $subject changes
> > it's just pointless.
> >
> >> so __pm_relax followed by __pm_stay_awake is still not safe.
> >
> > Yes, I overlooked that timer_expires modification.  Updated patch follows.
> >
> >> ...
> >> > @@ -529,8 +535,12 @@ void __pm_wakeup_event(struct wakeup_sou
> >> >        spin_lock_irqsave(&ws->lock, flags);
> >> >
> >> >        ws->event_count++;
> >> > -       if (!ws->active)
> >> > +       if (ws->active) {
> >> > +               if (!ws->timer_expires)
> >> > +                       goto unlock;
> >> > +       } else {
> >> >                wakeup_source_activate(ws);
> >> > +       }
> >> >
> >> >        if (!msec) {
> >> >                wakeup_source_deactivate(ws);
> >> >
> >>
> >> I suggest dropping this and adding:
> >
> > Well, what exactly would you like to drop?  The above proposed changes I guess?
> 
> Yes.
> 
> >
> >> -       if (time_after(expires, ws->timer_expires)) {
> >> +       if (!ws->timer_expires || time_after(expires, ws->timer_expires)) {
> >
> > I've tried to follow your suggestion, so that __pm_wakeup_event() always
> > sets the timer, if msec is positive, or deactivates the wakeup source, if
> > msec is 0.  Please let me know if that's what you wanted. :-)
> >
> 
> Yes. I should be able to replace a wake_lock with a single wakeup_source now.

Good, thanks for the confirmation!

Rafael

      reply	other threads:[~2012-02-17 20:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-15 22:18 [PATCH 0/3] PM / Sleep: Wakeup sources concurrency fixes Rafael J. Wysocki
2012-02-15 22:19 ` [PATCH 1/3] PM / Sleep: Fix possible infinite loop during wakeup source destruction Rafael J. Wysocki
2012-02-15 22:21 ` [PATCH 2/3] PM / Sleep: Fix race conditions related to wakeup source timer function Rafael J. Wysocki
2012-02-15 22:24 ` [PATCH 3/3] PM / Sleep: Make __pm_stay_awake() delete wakeup source timers Rafael J. Wysocki
2012-02-16  4:39   ` Arve Hjønnevåg
2012-02-16 22:09     ` Rafael J. Wysocki
2012-02-16  4:55   ` Arve Hjønnevåg
2012-02-16 22:20     ` Rafael J. Wysocki
2012-02-17  2:07       ` Arve Hjønnevåg
2012-02-17 20:46         ` Rafael J. Wysocki [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201202172146.59236.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=arve@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox