Blame SOURCES/kvm-Revert-mc146818rtc-fix-timer-interrupt-reinjection.patch

12991f
From 8af16b9722f5bdeacf3a30c21490846e24b989b2 Mon Sep 17 00:00:00 2001
12991f
From: Marcelo Tosatti <mtosatti@redhat.com>
12991f
Date: Wed, 4 Dec 2019 15:21:08 +0100
12991f
Subject: [PATCH 2/3] Revert "mc146818rtc: fix timer interrupt reinjection"
12991f
12991f
RH-Author: Marcelo Tosatti <mtosatti@redhat.com>
12991f
Message-id: <20191204152436.753293175@amt.cnet>
12991f
Patchwork-id: 92888
12991f
O-Subject: [RHEL-7.8 qemu-kvm-rhev PATCH 2/3] Revert "mc146818rtc: fix timer interrupt reinjection"
12991f
Bugzilla: 1639098
12991f
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
12991f
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
12991f
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
12991f
12991f
BZ: 1639098
12991f
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=24854309
12991f
BRANCH: rhv7/master-2.12.0
12991f
Upstream: 3ae32adff17226bc6a5f3fd7bb9804e6779e0660
12991f
of pbonzini's for-upstream tree.
12991f
12991f
This reverts commit b429de730174b388ea5760e3debb0d542ea3c261, except
12991f
that the reversal of the outer "if (period)" is left in.
12991f
12991f
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12991f
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
12991f
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
12991f
---
12991f
 hw/timer/mc146818rtc.c | 67 +++++++++++++++++++++++++-------------------------
12991f
 1 file changed, 33 insertions(+), 34 deletions(-)
12991f
12991f
diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
12991f
index 296d974..d848911 100644
12991f
--- a/hw/timer/mc146818rtc.c
12991f
+++ b/hw/timer/mc146818rtc.c
12991f
@@ -196,7 +196,6 @@ periodic_timer_update(RTCState *s, int64_t current_time, uint32_t old_period)
12991f
     int64_t cur_clock, next_irq_clock, lost_clock = 0;
12991f
 
12991f
     period = rtc_periodic_clock_ticks(s);
12991f
-
12991f
     if (!period) {
12991f
         s->irq_coalesced = 0;
12991f
         timer_del(s->periodic_timer);
12991f
@@ -219,42 +218,42 @@ periodic_timer_update(RTCState *s, int64_t current_time, uint32_t old_period)
12991f
         last_periodic_clock = next_periodic_clock - old_period;
12991f
         lost_clock = cur_clock - last_periodic_clock;
12991f
         assert(lost_clock >= 0);
12991f
+    }
12991f
 
12991f
+    /*
12991f
+     * s->irq_coalesced can change for two reasons:
12991f
+     *
12991f
+     * a) if one or more periodic timer interrupts have been lost,
12991f
+     *    lost_clock will be more that a period.
12991f
+     *
12991f
+     * b) when the period may be reconfigured, we expect the OS to
12991f
+     *    treat delayed tick as the new period.  So, when switching
12991f
+     *    from a shorter to a longer period, scale down the missing,
12991f
+     *    because the OS will treat past delayed ticks as longer
12991f
+     *    (leftovers are put back into lost_clock).  When switching
12991f
+     *    to a shorter period, scale up the missing ticks since the
12991f
+     *    OS handler will treat past delayed ticks as shorter.
12991f
+     */
12991f
+    if (s->lost_tick_policy == LOST_TICK_POLICY_SLEW) {
12991f
+        uint32_t old_irq_coalesced = s->irq_coalesced;
12991f
+
12991f
+        s->period = period;
12991f
+        lost_clock += old_irq_coalesced * old_period;
12991f
+        s->irq_coalesced = lost_clock / s->period;
12991f
+        lost_clock %= s->period;
12991f
+        if (old_irq_coalesced != s->irq_coalesced ||
12991f
+            old_period != s->period) {
12991f
+            DPRINTF_C("cmos: coalesced irqs scaled from %d to %d, "
12991f
+                      "period scaled from %d to %d\n", old_irq_coalesced,
12991f
+                      s->irq_coalesced, old_period, s->period);
12991f
+            rtc_coalesced_timer_update(s);
12991f
+        }
12991f
+    } else {
12991f
         /*
12991f
-         * s->irq_coalesced can change for two reasons:
12991f
-         *
12991f
-         * a) if one or more periodic timer interrupts have been lost,
12991f
-         *    lost_clock will be more that a period.
12991f
-         *
12991f
-         * b) when the period may be reconfigured, we expect the OS to
12991f
-         *    treat delayed tick as the new period.  So, when switching
12991f
-         *    from a shorter to a longer period, scale down the missing,
12991f
-         *    because the OS will treat past delayed ticks as longer
12991f
-         *    (leftovers are put back into lost_clock).  When switching
12991f
-         *    to a shorter period, scale up the missing ticks since the
12991f
-         *    OS handler will treat past delayed ticks as shorter.
12991f
+         * no way to compensate the interrupt if LOST_TICK_POLICY_SLEW
12991f
+         * is not used, we should make the time progress anyway.
12991f
          */
12991f
-        if (s->lost_tick_policy == LOST_TICK_POLICY_SLEW) {
12991f
-            uint32_t old_irq_coalesced = s->irq_coalesced;
12991f
-
12991f
-            s->period = period;
12991f
-            lost_clock += old_irq_coalesced * old_period;
12991f
-            s->irq_coalesced = lost_clock / s->period;
12991f
-            lost_clock %= s->period;
12991f
-            if (old_irq_coalesced != s->irq_coalesced ||
12991f
-                old_period != s->period) {
12991f
-                DPRINTF_C("cmos: coalesced irqs scaled from %d to %d, "
12991f
-                          "period scaled from %d to %d\n", old_irq_coalesced,
12991f
-                          s->irq_coalesced, old_period, s->period);
12991f
-                rtc_coalesced_timer_update(s);
12991f
-            }
12991f
-        } else {
12991f
-            /*
12991f
-             * no way to compensate the interrupt if LOST_TICK_POLICY_SLEW
12991f
-             * is not used, we should make the time progress anyway.
12991f
-             */
12991f
-            lost_clock = MIN(lost_clock, period);
12991f
-        }
12991f
+        lost_clock = MIN(lost_clock, period);
12991f
     }
12991f
 
12991f
     assert(lost_clock >= 0 && lost_clock <= period);
12991f
-- 
12991f
1.8.3.1
12991f