linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: pawel.moll@arm.com (Pawel Moll)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC 02/18] power/reset: vexpress: Use sched_clock as the time source
Date: Wed, 08 Jan 2014 16:01:03 +0000	[thread overview]
Message-ID: <1389196863.23721.20.camel@hornet> (raw)
In-Reply-To: <CANcMJZALQ0khcqkdQA5Tnr6_9kfWK=UUmrUB4mCv2MEkmLv0sg@mail.gmail.com>

On Mon, 2013-12-23 at 19:28 +0000, John Stultz wrote:
> On Mon, Dec 23, 2013 at 8:23 AM, Pawel Moll <pawel.moll@arm.com> wrote:
> > At this stage of system shutdown procedure the jiffies may
> > not be updated anymore, so have to base on raw sched_clock
> > values.
> >
> > Signed-off-by: Pawel Moll <pawel.moll@arm.com>
> > Cc: Anton Vorontsov <anton@enomsg.org>
> > Cc: David Woodhouse <dwmw2@infradead.org>
> > ---
> >  drivers/power/reset/vexpress-poweroff.c | 7 ++++---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/power/reset/vexpress-poweroff.c b/drivers/power/reset/vexpress-poweroff.c
> > index 476aa49..d752233 100644
> > --- a/drivers/power/reset/vexpress-poweroff.c
> > +++ b/drivers/power/reset/vexpress-poweroff.c
> > @@ -15,6 +15,7 @@
> >  #include <linux/of.h>
> >  #include <linux/of_device.h>
> >  #include <linux/platform_device.h>
> > +#include <linux/sched.h>
> >  #include <linux/stat.h>
> >  #include <linux/vexpress.h>
> >
> > @@ -27,12 +28,12 @@ static void vexpress_reset_do(struct device *dev, const char *what)
> >                         vexpress_config_func_get_by_dev(dev);
> >
> >         if (func) {
> > -               unsigned long timeout;
> > +               unsigned long long timeout_ns;
> >
> >                 err = vexpress_config_write(func, 0, 0);
> >
> > -               timeout = jiffies + HZ;
> > -               while (time_before(jiffies, timeout))
> > +               timeout_ns = sched_clock() + 50000000;
> > +               while (!err && time_before64(sched_clock(), timeout_ns))
> >                         cpu_relax();
> >         }
> 
> So this may not be a problem in this particular case, but sched_clock
> could be backed by jiffies on some hardware, causing the same problem
> to appear.

Uh, right. As you guessed, on vexpress sched_clock, once registered, is
always available. But of course I shouldn't fully rely on this.

> Might udelay/mdelay be a better fit for this sort of case (since
> udelay may be counter backed, but may also be loop backed on hardware
> without continuous counters)?

I'm sure I though about udelay, but for some reason decided against it.
The reason may be already invalid, so I'll check it again :-)

Thanks!

Pawe?

  reply	other threads:[~2014-01-08 16:01 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-23 16:23 [RFC 00/18] Versatile Express config rework Pawel Moll
     [not found] ` < 1387815830-8794-5-git-send-email-pawel.moll@arm.com>
     [not found] ` < 1387815830-8794-7-git-send-email-pawel.moll@arm.com>
2013-12-23 16:23 ` [RFC 05/18] driver core: Do not WARN when devres list is not empty at probe time Pawel Moll
     [not found] ` <1387815830-8794-4-git-send-email-pawel.moll@arm.com>
2013-12-23 17:26   ` [RFC 03/18] GPIO: gpio-generic: Add label to platform data Linus Walleij
2014-01-08 15:57     ` Pawel Moll
2014-01-14 10:30       ` Linus Walleij
2014-01-14 10:44         ` Pawel Moll
     [not found] ` <1387815830-8794-9-git-send-email-pawel.moll@arm.com>
2013-12-23 17:31   ` [RFC 08/18] hwmon: vexpress: Use regmap instead of custom interface Guenter Roeck
2014-01-08 15:57     ` Pawel Moll
     [not found] ` <1387815830-8794-3-git-send-email-pawel.moll@arm.com>
2013-12-23 19:28   ` [RFC 02/18] power/reset: vexpress: Use sched_clock as the time source John Stultz
2014-01-08 16:01     ` Pawel Moll [this message]
     [not found] ` <1387815830-8794-13-git-send-email-pawel.moll@arm.com>
2013-12-23 20:05   ` [RFC 12/18] clk: versatile: Split config options for sp810 and vexpress_osc Mike Turquette
2014-01-08 16:06     ` Pawel Moll
     [not found] ` <1387815830-8794-8-git-send-email-pawel.moll@arm.com>
2013-12-24 12:19   ` [RFC 07/18] regmap: debugfs: Always create "registers" & "access" files Mark Brown
2014-01-08 17:31     ` Pawel Moll
2014-01-08 18:00       ` Mark Brown
     [not found] ` <1387815830-8794-11-git-send-email-pawel.moll@arm.com>
2013-12-24 12:24   ` [RFC 10/18] regulator: vexpress: Use regmap instead of custom interface Mark Brown
2014-01-08 18:25     ` Pawel Moll
2014-01-09 13:35       ` Mark Brown
     [not found] ` <1387815830-8794-7-git-send-email-pawel.moll@arm.com>
2013-12-24 12:45   ` [RFC 06/18] regmap: Formalise use of non-bus context Mark Brown
2014-01-09 13:08     ` Pawel Moll
2014-01-09 13:34       ` Mark Brown
2014-01-09 15:47         ` Pawel Moll
2014-01-16 17:09       ` Grant Likely
2014-01-16 17:20         ` Pawel Moll
     [not found] ` <1387815830-8794-2-git-send-email-pawel.moll@arm.com>
2014-01-06  9:48   ` [RFC 01/18] mfd: syscon: Consider platform data a regmap config name Lee Jones
2014-01-06 10:20     ` Lee Jones
     [not found] ` <1387815830-8794-19-git-send-email-pawel.moll@arm.com>
2014-01-06 10:40   ` [RFC 18/18] mfd: vexpress: Split sysreg functions into MFD cells Lee Jones
2014-01-08 16:17     ` Pawel Moll
     [not found] ` <1387815830-8794-5-git-send-email-pawel.moll@arm.com>
2014-01-08 17:28   ` [RFC 04/18] driver core & of: Mark of_nodes of added device as populated Rob Herring
2014-01-16 17:03     ` Grant Likely

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=1389196863.23721.20.camel@hornet \
    --to=pawel.moll@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).