From: Laurent Vivier <lvivier@redhat.com>
To: qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
qemu-trivial@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3 7/9] hpet: remove muldiv64()
Date: Tue, 8 Sep 2015 14:55:25 +0200 [thread overview]
Message-ID: <55EEDABD.5090305@redhat.com> (raw)
In-Reply-To: <1440703987-29012-8-git-send-email-lvivier@redhat.com>
ping ?
On 27/08/2015 21:33, Laurent Vivier wrote:
> hpet defines a clock period in femtoseconds but
> then converts it to nanoseconds to use the internal
> timers.
>
> We can define the period in nanoseconds and use it
> directly, this allows to remove muldiv64().
>
> We only need to convert the period to femtoseconds
> to put it in internal hpet capability register.
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
> hw/timer/hpet.c | 6 +++---
> include/hw/timer/hpet.h | 4 ++--
> 2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
> index 2bb6221..3037bef 100644
> --- a/hw/timer/hpet.c
> +++ b/hw/timer/hpet.c
> @@ -126,12 +126,12 @@ static uint32_t hpet_time_after64(uint64_t a, uint64_t b)
>
> static uint64_t ticks_to_ns(uint64_t value)
> {
> - return (muldiv64(value, HPET_CLK_PERIOD, FS_PER_NS));
> + return value * HPET_CLK_PERIOD;
> }
>
> static uint64_t ns_to_ticks(uint64_t value)
> {
> - return (muldiv64(value, FS_PER_NS, HPET_CLK_PERIOD));
> + return value / HPET_CLK_PERIOD;
> }
>
> static uint64_t hpet_fixup_reg(uint64_t new, uint64_t old, uint64_t mask)
> @@ -758,7 +758,7 @@ static void hpet_realize(DeviceState *dev, Error **errp)
> /* 64-bit main counter; LegacyReplacementRoute. */
> s->capability = 0x8086a001ULL;
> s->capability |= (s->num_timers - 1) << HPET_ID_NUM_TIM_SHIFT;
> - s->capability |= ((HPET_CLK_PERIOD) << 32);
> + s->capability |= ((uint64_t)(HPET_CLK_PERIOD * FS_PER_NS) << 32);
>
> qdev_init_gpio_in(dev, hpet_handle_legacy_irq, 2);
> qdev_init_gpio_out(dev, &s->pit_enabled, 1);
> diff --git a/include/hw/timer/hpet.h b/include/hw/timer/hpet.h
> index 773953b..d872909 100644
> --- a/include/hw/timer/hpet.h
> +++ b/include/hw/timer/hpet.h
> @@ -16,9 +16,9 @@
> #include "qom/object.h"
>
> #define HPET_BASE 0xfed00000
> -#define HPET_CLK_PERIOD 10000000ULL /* 10000000 femtoseconds == 10ns*/
> +#define HPET_CLK_PERIOD 10 /* 10 ns*/
>
> -#define FS_PER_NS 1000000
> +#define FS_PER_NS 1000000 /* 1000000 femtoseconds == 1 ns */
> #define HPET_MIN_TIMERS 3
> #define HPET_MAX_TIMERS 32
>
>
next prev parent reply other threads:[~2015-09-08 12:55 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-27 19:32 [Qemu-devel] [PATCH v3 0/9] remove useless muldiv64() Laurent Vivier
2015-08-27 19:32 ` [Qemu-devel] [PATCH v3 1/9] i6300esb: remove muldiv64() Laurent Vivier
2015-09-14 13:31 ` [Qemu-devel] [PATCH v4 " Laurent Vivier
2015-08-27 19:33 ` [Qemu-devel] [PATCH v3 2/9] rtl8139: " Laurent Vivier
2015-08-28 14:12 ` Stefan Hajnoczi
2015-08-27 19:33 ` [Qemu-devel] [PATCH v3 3/9] pcnet: " Laurent Vivier
2015-08-28 14:12 ` Stefan Hajnoczi
2015-08-27 19:33 ` [Qemu-devel] [PATCH v3 4/9] mips: " Laurent Vivier
2015-09-08 12:54 ` Laurent Vivier
2015-09-08 13:42 ` Leon Alrae
2015-08-27 19:33 ` [Qemu-devel] [PATCH v3 5/9] openrisc: " Laurent Vivier
2015-09-08 12:54 ` Laurent Vivier
2015-08-27 19:33 ` [Qemu-devel] [PATCH v3 6/9] arm: clarify the use of muldiv64() Laurent Vivier
2015-08-27 20:23 ` Peter Crosthwaite
2015-09-01 11:17 ` Peter Maydell
2015-09-01 11:23 ` Laurent Vivier
2015-09-01 11:30 ` Peter Maydell
2015-08-27 19:33 ` [Qemu-devel] [PATCH v3 7/9] hpet: remove muldiv64() Laurent Vivier
2015-09-08 12:55 ` Laurent Vivier [this message]
2015-09-08 12:58 ` Paolo Bonzini
2015-08-27 19:33 ` [Qemu-devel] [PATCH v3 8/9] bt: " Laurent Vivier
2015-09-08 12:55 ` Laurent Vivier
2015-09-08 12:57 ` Paolo Bonzini
2015-08-27 19:33 ` [Qemu-devel] [PATCH v3 9/9] net: " Laurent Vivier
2015-08-28 14:12 ` Stefan Hajnoczi
2015-09-24 16:21 ` [Qemu-devel] [PATCH v3 0/9] remove useless muldiv64() Laurent Vivier
2015-09-25 10:31 ` Paolo Bonzini
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=55EEDABD.5090305@redhat.com \
--to=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=stefanha@redhat.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).