yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
5d360b
From a548a4b5d3a130ada6498669b4bf01bf47fe4560 Mon Sep 17 00:00:00 2001
5d360b
From: Richard Jones <rjones@redhat.com>
5d360b
Date: Wed, 1 Nov 2017 11:33:02 +0100
5d360b
Subject: [PATCH 7/7] i6300esb: remove muldiv64()
5d360b
5d360b
RH-Author: Richard Jones <rjones@redhat.com>
5d360b
Message-id: <1509535982-27927-4-git-send-email-rjones@redhat.com>
5d360b
Patchwork-id: 77463
5d360b
O-Subject: [RHEL-7.5 qemu-kvm PATCH v3 3/3] i6300esb: remove muldiv64()
5d360b
Bugzilla: 1470244
5d360b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
5d360b
RH-Acked-by: Thomas Huth <thuth@redhat.com>
5d360b
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
5d360b
5d360b
From: Laurent Vivier <lvivier@redhat.com>
5d360b
5d360b
Originally, timers were ticks based, and it made sense to
5d360b
add ticks to current time to know when to trigger an alarm.
5d360b
5d360b
But since commit:
5d360b
5d360b
7447545 change all other clock references to use nanosecond resolution accessors
5d360b
5d360b
All timers use nanoseconds and we need to convert ticks to nanoseconds, by
5d360b
doing something like:
5d360b
5d360b
    y = muldiv64(x, get_ticks_per_sec(), PCI_FREQUENCY)
5d360b
5d360b
where x is the number of device ticks and y the number of system ticks.
5d360b
5d360b
y is used as nanoseconds in timer functions,
5d360b
it works because 1 tick is 1 nanosecond.
5d360b
(get_ticks_per_sec() is 10^9)
5d360b
5d360b
But as PCI frequency is 33 MHz, we can also do:
5d360b
5d360b
    y = x * 30; /* 33 MHz PCI period is 30 ns */
5d360b
5d360b
Which is much more simple.
5d360b
5d360b
This implies a 33.333333 MHz PCI frequency,
5d360b
but this is correct.
5d360b
5d360b
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
5d360b
(cherry picked from commit 9491e9bc019a365dfa9780f462984a0d052f4c0d)
5d360b
5d360b
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1470244
5d360b
Upstream-status: 9491e9bc019a365dfa9780f462984a0d052f4c0d
5d360b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
5d360b
---
5d360b
 hw/watchdog/wdt_i6300esb.c | 11 +++--------
5d360b
 1 file changed, 3 insertions(+), 8 deletions(-)
5d360b
5d360b
diff --git a/hw/watchdog/wdt_i6300esb.c b/hw/watchdog/wdt_i6300esb.c
5d360b
index fa8e3b9..6dede4e 100644
5d360b
--- a/hw/watchdog/wdt_i6300esb.c
5d360b
+++ b/hw/watchdog/wdt_i6300esb.c
5d360b
@@ -125,14 +125,9 @@ static void i6300esb_restart_timer(I6300State *d, int stage)
5d360b
     else
5d360b
         timeout <<= 5;
5d360b
 
5d360b
-    /* Get the timeout in units of ticks_per_sec.
5d360b
-     *
5d360b
-     * ticks_per_sec is typically 10^9 == 0x3B9ACA00 (30 bits), with
5d360b
-     * 20 bits of user supplied preload, and 15 bits of scale, the
5d360b
-     * multiply here can exceed 64-bits, before we divide by 33MHz, so
5d360b
-     * we use a higher-precision intermediate result.
5d360b
-     */
5d360b
-    timeout = muldiv64(timeout, get_ticks_per_sec(), 33000000);
5d360b
+    /* Get the timeout in nanoseconds. */
5d360b
+
5d360b
+    timeout = timeout * 30; /* on a PCI bus, 1 tick is 30 ns*/
5d360b
 
5d360b
     i6300esb_debug("stage %d, timeout %" PRIi64 "\n", d->stage, timeout);
5d360b
 
5d360b
-- 
5d360b
1.8.3.1
5d360b