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

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