public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: Phil Carmody <ext-phil.2.carmody@nokia.com>
To: "khilman@deeprootsystems.com" <khilman@deeprootsystems.com>
Cc: "Kauppi Ari (EXT-Ixonos/Oulu)" <ext-ari.kauppi@nokia.com>,
	"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
	"Kristo Tero (Nokia-D/Tampere)" <Tero.Kristo@nokia.com>
Subject: Re: [PATCH] OMAP3: PM: Modify suspend wakeup timer to use milliseconds instead of seconds
Date: Mon, 22 Mar 2010 19:10:26 +0200	[thread overview]
Message-ID: <20100322171026.GP5610@pcarmody-desktop> (raw)
In-Reply-To: <1269245454-24254-1-git-send-email-Ext-Ari.Kauppi@nokia.com>

On 22/03/10 09:10 +0100, Kauppi Ari (EXT-Ixonos/Oulu) wrote:
> Millisecond resolution is possible and there are use cases for it
> (automatic testing).
> 
> Seconds-based interface is preserved for compatibility.
> 
> Signed-off-by: Ari Kauppi <Ext-Ari.Kauppi@nokia.com>
> ---
...
> diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
> index 3868c76..cd55968 100644
> --- a/arch/arm/mach-omap2/pm34xx.c
> +++ b/arch/arm/mach-omap2/pm34xx.c
...
> @@ -640,20 +640,20 @@ out:
>  }
>  
>  #ifdef CONFIG_SUSPEND
> -static void omap2_pm_wakeup_on_timer(u32 seconds)
> +static void omap2_pm_wakeup_on_timer(u32 milliseconds)
>  {
>  	u32 tick_rate, cycles;
>  
> -	if (!seconds)
> +	if (!milliseconds)
>  		return;
>  
>  	tick_rate = clk_get_rate(omap_dm_timer_get_fclk(gptimer_wakeup));
> -	cycles = tick_rate * seconds;
> +	cycles = tick_rate * milliseconds / 1000;

Ari has pointed me here regarding clarification of whether the above
is an overflow risk? At 32768 Hz, the above intermediate will overflow 
a u32 if milliseconds >= 131072, e.g. 2 minutes 10+ seconds. 

If there is an overflow risk, then something like the following would
work around it:

	u32 seconds = milliseconds / 1000;
	milliseconds -= seconds * 1000;
	cycles = tick_rate * seconds + tick_rate * milliseconds / 1000;

(Alternatively, a u64 could be used for the intermediate, and we could
just let gcc manage the 64 bit / constant 32 bit division.)

Unfortunately, as tick_rate is not a constant, there's no trivial fast-path 
check for overflow before it happens. Then again, this looks like it's
only used in debug code, so hopefully that's not an issue.

Phil

  reply	other threads:[~2010-03-22 17:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-22  8:10 [PATCH] OMAP3: PM: Modify suspend wakeup timer to use milliseconds instead of seconds Ari Kauppi
2010-03-22 17:10 ` Phil Carmody [this message]
2010-03-23  7:04 ` [PATCH v2] OMAP3: PM: Add milliseconds interface to suspend wakeup timer Ari Kauppi
2010-03-23  8:32   ` Phil Carmody
2010-04-28 18:51     ` Kevin Hilman

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=20100322171026.GP5610@pcarmody-desktop \
    --to=ext-phil.2.carmody@nokia.com \
    --cc=Tero.Kristo@nokia.com \
    --cc=ext-ari.kauppi@nokia.com \
    --cc=khilman@deeprootsystems.com \
    --cc=linux-omap@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