[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH][TRIVIAL] i6300esb: fix timer overflow
From: |
David Gibson |
Subject: |
Re: [Qemu-devel] [PATCH][TRIVIAL] i6300esb: fix timer overflow |
Date: |
Wed, 5 Aug 2015 10:01:02 +1000 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Tue, Aug 04, 2015 at 10:27:31AM +0200, Laurent Vivier wrote:
> We use muldiv64() to compute the time to wait:
>
> timeout = muldiv64(get_ticks_per_sec(), timeout, 33000000);
>
> but get_ticks_per_sec() is 10^9 (30 bit value) and timeout
> is a 35 bit value.
>
> Whereas muldiv64 is:
>
> uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)
>
> So we loose 3 bits of timeout.
>
> Swapping get_ticks_per_sec() and timeout fixes it.
>
> We can also replace it by a multiplication by 30 ns,
> but this changes PCI clock frequency from 33MHz to 33.333333MHz
> and we need to do this on all the QEMU PCI devices (later...)
>
> Signed-off-by: Laurent Vivier <address@hidden>
Hah. 32-bit second argument. Totally missed that when I put the
muldiv64() in there. So I didn't eliminate the overflow, just pushed
it out some bits.
Thanks for finding this.
Reviewed-by: David Gibson <address@hidden>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
pgphVlzzYtrpr.pgp
Description: PGP signature
- Re: [Qemu-devel] [PATCH] i6300esb: correctly convert watchdog clock ticks into nanoseconds, (continued)
- Re: [Qemu-devel] [PATCH] i6300esb: correctly convert watchdog clock ticks into nanoseconds, Laurent Vivier, 2015/08/03
- Re: [Qemu-devel] [PATCH] i6300esb: correctly convert watchdog clock ticks into nanoseconds, Richard W.M. Jones, 2015/08/03
- Re: [Qemu-devel] [PATCH] i6300esb: correctly convert watchdog clock ticks into nanoseconds, Paolo Bonzini, 2015/08/03
- Re: [Qemu-devel] [PATCH] i6300esb: correctly convert watchdog clock ticks into nanoseconds, Laurent Vivier, 2015/08/03
- Re: [Qemu-devel] [PATCH] i6300esb: correctly convert watchdog clock ticks into nanoseconds, Paolo Bonzini, 2015/08/03
- Re: [Qemu-devel] [PATCH] i6300esb: correctly convert watchdog clock ticks into nanoseconds, Laurent Vivier, 2015/08/03
- Re: [Qemu-devel] [PATCH] i6300esb: correctly convert watchdog clock ticks into nanoseconds, Paolo Bonzini, 2015/08/03
- Re: [Qemu-devel] [PATCH] i6300esb: correctly convert watchdog clock ticks into nanoseconds, Laurent Vivier, 2015/08/03
[Qemu-devel] [PATCH][TRIVIAL] i6300esb: fix timer overflow, Laurent Vivier, 2015/08/04
Re: [Qemu-devel] [PATCH] i6300esb: correctly convert watchdog clock ticks into nanoseconds, Richard W.M. Jones, 2015/08/04