qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: Bharat Bhushan <r65777@freescale.com>
Cc: scottwood@freescale.com,
	Bharat Bhushan <bharat.bhushan@freescale.com>,
	qemu-ppc@nongnu.org, qemu-devel@nongnu.org, agraf@suse.de
Subject: Re: [Qemu-devel] [PATCH v2]booke: timer: Deactivate timer for target_bit above 61
Date: Mon, 10 Jun 2013 14:13:27 +0200	[thread overview]
Message-ID: <51B5C2E7.4040709@suse.de> (raw)
In-Reply-To: <1370850918-18687-1-git-send-email-Bharat.Bhushan@freescale.com>

Am 10.06.2013 09:55, schrieb Bharat Bhushan:
> QEMU timer supports a maximum timer of INT64_MAX. So starting timer only for
> time which is calculated using target_bit < 62 and deactivate/stop timer if
> the target bit is above 61.
> 
> This patch also fix the time calculation from target_bit.
> The code was doing (1 << (target_bit + 1)) while this
> should be (1ULL << (target_bit + 1)).
> 
> Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com>
> ---
> v1->v2
>  - Added "booke: timer:" in patch subject
> 
>  hw/ppc/ppc_booke.c |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/hw/ppc/ppc_booke.c b/hw/ppc/ppc_booke.c
> index e41b036..f4eda15 100644
> --- a/hw/ppc/ppc_booke.c
> +++ b/hw/ppc/ppc_booke.c
> @@ -133,9 +133,15 @@ static void booke_update_fixed_timer(CPUPPCState         *env,
>      ppc_tb_t *tb_env = env->tb_env;
>      uint64_t lapse;
>      uint64_t tb;
> -    uint64_t period = 1 << (target_bit + 1);
> +    uint64_t period;
>      uint64_t now;
>  
> +    /* Deactivate timer for target_bit > 61 */
> +    if (target_bit > 61)
> +        return; 

Braces missing and trailing whitespace after return.

So IIUC we can only allow 63 bits due to signedness, thus a maximum of
(1 << 62), thus target_bit <= 61.

Any chance at least the comment can be worded to explain that any
better? Maybe also use (target-bit + 1 >= 63) or period > INT64_MAX as
condition?

Best regards,
Andreas

> +
> +    period = 1ULL << (target_bit + 1);
> +
>      now = qemu_get_clock_ns(vm_clock);
>      tb  = cpu_ppc_get_tb(tb_env, now, tb_env->tb_offset);
>  
> 


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

  parent reply	other threads:[~2013-06-10 12:13 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-10  7:55 [Qemu-devel] [PATCH v2]booke: timer: Deactivate timer for target_bit above 61 Bharat Bhushan
2013-06-10  9:26 ` Peter Maydell
2013-06-10  9:53   ` Bhushan Bharat-R65777
2013-06-10 12:13 ` Andreas Färber [this message]
2013-06-10 12:47   ` Bhushan Bharat-R65777
2013-06-10 14:26     ` Alexander Graf
2013-06-10 17:20       ` Scott Wood
2013-06-10 18:09         ` Alexander Graf
2013-06-11 11:40           ` Bhushan Bharat-R65777
2013-06-11 12:39             ` Alexander Graf
2013-06-11 12:47               ` Bhushan Bharat-R65777
2013-06-11 12:56                 ` Alexander Graf
2013-06-11 13:18                   ` Bhushan Bharat-R65777
2013-06-11 14:02                     ` Alexander Graf

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=51B5C2E7.4040709@suse.de \
    --to=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=bharat.bhushan@freescale.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=r65777@freescale.com \
    --cc=scottwood@freescale.com \
    /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).