LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
"preeti@linux.vnet.ibm.com" <preeti@linux.vnet.ibm.com>
Subject: [PATCH 0/2] cpuidle / sleep: fix timer stopping regression (was: drivers: cpuidle: minor suspend-to-idle fixes)
Date: Mon, 02 Mar 2015 15:50:26 +0100 [thread overview]
Message-ID: <1882932.aLeaejbmMz@vostro.rjw.lan> (raw)
In-Reply-To: <1809382.kscziWfTPN@vostro.rjw.lan>
On Monday, March 02, 2015 02:13:05 PM Rafael J. Wysocki wrote:
> On Monday, March 02, 2015 10:08:23 AM Lorenzo Pieralisi wrote:
> > On Sat, Feb 28, 2015 at 11:58:21PM +0000, Rafael J. Wysocki wrote:
> > > On Saturday, February 28, 2015 11:54:23 AM Lorenzo Pieralisi wrote:
>
> [cut]
>
> > > Index: linux-pm/drivers/cpuidle/cpuidle.c
> > > ===================================================================
> > > --- linux-pm.orig/drivers/cpuidle/cpuidle.c
> > > +++ linux-pm/drivers/cpuidle/cpuidle.c
> > > @@ -230,15 +230,39 @@ int cpuidle_select(struct cpuidle_driver
> > > * @dev: the cpuidle device
> > > * @index: the index in the idle state table
> > > *
> > > - * Returns the index in the idle state, < 0 in case of error.
> > > - * The error code depends on the backend driver
> > > + * Returns the index in the idle state, < 0 in case of error. -EBUSY is
> > > + * returned to indicate that the target state was temporarily inaccessible.
> > > + * The other error codes depend on the backend driver.
> > > */
> > > int cpuidle_enter(struct cpuidle_driver *drv, struct cpuidle_device *dev,
> > > int index)
> > > {
> > > - if (cpuidle_state_is_coupled(dev, drv, index))
> > > - return cpuidle_enter_state_coupled(dev, drv, index);
> > > - return cpuidle_enter_state(dev, drv, index);
> > > + unsigned int broadcast;
> > > + int ret;
> > > +
> > > + broadcast = drv->states[index].flags & CPUIDLE_FLAG_TIMER_STOP;
> > > +
> > > + /*
> > > + * Tell the time framework to switch to a broadcast timer
> > > + * because our local timer will be shutdown. If a local timer
> > > + * is used from another cpu as a broadcast timer, this call may
> > > + * fail if it is not available
> > > + */
> > > + if (broadcast) {
> > > + ret = clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER,
> > > + &dev->cpu);
> > > + if (ret)
> > > + return ret;
> > > + }
> > > +
> > > + ret = cpuidle_state_is_coupled(dev, drv, index) ?
> > > + cpuidle_enter_state_coupled(dev, drv, index) :
> > > + cpuidle_enter_state(dev, drv, index);
> > > +
> > > + if (broadcast)
> > > + clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &dev->cpu);
> > > +
> > > + return ret;
> >
> > You have to check this return value in cpuidle_enter_freeze() too
> > otherwise we return to the idle thread on -EBUSY without
> > even executing arch_cpu_idle() and with IRQ disabled, code hits
> > the WARN_ON_ONCE line 180.
>
> Right.
>
> > There are multiple ways of fixing the issue, either you check the
> > cpuidle_enter_freeze() return value (you add one) to cpuidle_idle_call()
> > to make code consistent with the cpuidle_idle_call "normal" idle
> > behaviour or you add the return value check in cpuidle_enter_freeze(),
> > I am fine both ways.
>
> Well, in both cases we'd end up with a function enabling interrupts on exit
> in some cases and not doing that in some other ones. Not nice.
>
> Below is an alternative to that (on top of the previous patches). Can you
> test it please?
Actually, this one is still slightly incorrect, because we only should call
cpuidle_reflect() if we've called cpuidle_select() before. Also it's better
to pass cpuidle_driver and cpuidle_device to all functions called by
cpuidle_idle_call().
Two patches will follow. [1/2] is a cleanup re-arranging the code in
cpuidle_idle_call() to move the fallback path to the end of the function.
[2/2] is a replacement for the patch sent previously.
Please test.
Rafael
next prev parent reply other threads:[~2015-03-02 14:30 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-24 17:58 [PATCH 0/2] drivers: cpuidle: minor suspend-to-idle fixes Lorenzo Pieralisi
2015-02-24 17:58 ` [PATCH 1/2] drivers: cpuidle: remove stale irq disabling call in cpuidle_enter_freeze() Lorenzo Pieralisi
2015-02-25 14:13 ` Daniel Lezcano
2015-02-25 14:39 ` Lorenzo Pieralisi
2015-02-25 23:36 ` Rafael J. Wysocki
2015-02-26 9:48 ` Lorenzo Pieralisi
2015-02-26 16:39 ` Rafael J. Wysocki
2015-02-24 17:58 ` [PATCH 2/2] drivers: cpuidle: add driver/device checks " Lorenzo Pieralisi
2015-02-25 14:30 ` Daniel Lezcano
2015-02-25 14:47 ` Lorenzo Pieralisi
2015-02-25 23:50 ` Rafael J. Wysocki
2015-02-26 0:35 ` Rafael J. Wysocki
2015-02-25 14:56 ` Lorenzo Pieralisi
2015-02-26 23:37 ` [PATCH 0/2] drivers: cpuidle: minor suspend-to-idle fixes Rafael J. Wysocki
2015-02-26 23:39 ` [PATCH 1/2] idle / sleep: Avoid excessive interrupts disabling and enabling Rafael J. Wysocki
2015-02-26 23:39 ` [PATCH 2/2] cpuidle / sleep: Do sanity checks in cpuidle_enter_freeze() too Rafael J. Wysocki
2015-02-27 8:41 ` [PATCH 0/2] drivers: cpuidle: minor suspend-to-idle fixes Peter Zijlstra
2015-02-27 10:00 ` Lorenzo Pieralisi
2015-02-27 22:11 ` Rafael J. Wysocki
2015-02-28 11:54 ` Lorenzo Pieralisi
2015-02-28 23:58 ` Rafael J. Wysocki
2015-03-02 10:08 ` Lorenzo Pieralisi
2015-03-02 13:13 ` Rafael J. Wysocki
2015-03-02 14:50 ` Rafael J. Wysocki [this message]
2015-03-02 14:51 ` [PATCH 1/2] cpuidle: Clean up fallback handling in cpuidle_idle_call() Rafael J. Wysocki
2015-03-02 16:05 ` Lorenzo Pieralisi
2015-03-02 22:30 ` Rafael J. Wysocki
2015-03-02 14:53 ` [PATCH 2/2] cpuidle / sleep: Use broadcast timer for states that stop local timer Rafael J. Wysocki
2015-03-02 16:27 ` Lorenzo Pieralisi
2015-03-02 22:28 ` Rafael J. Wysocki
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=1882932.aLeaejbmMz@vostro.rjw.lan \
--to=rjw@rjwysocki.net \
--cc=daniel.lezcano@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=peterz@infradead.org \
--cc=preeti@linux.vnet.ibm.com \
--subject='Re: [PATCH 0/2] cpuidle / sleep: fix timer stopping regression (was: drivers: cpuidle: minor suspend-to-idle fixes)' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).