[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 11/12] Revert "mc146818rtc: fix timer interrupt reinjection"
From: |
Paolo Bonzini |
Subject: |
[PULL 11/12] Revert "mc146818rtc: fix timer interrupt reinjection" |
Date: |
Tue, 19 Nov 2019 17:08:47 +0100 |
This reverts commit b429de730174b388ea5760e3debb0d542ea3c261, except
that the reversal of the outer "if (period)" is left in.
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/rtc/mc146818rtc.c | 67 ++++++++++++++++++++++++++--------------------------
1 file changed, 33 insertions(+), 34 deletions(-)
diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c
index ee6bf82..9869dc5 100644
--- a/hw/rtc/mc146818rtc.c
+++ b/hw/rtc/mc146818rtc.c
@@ -174,7 +174,6 @@ periodic_timer_update(RTCState *s, int64_t current_time,
uint32_t old_period)
int64_t cur_clock, next_irq_clock, lost_clock = 0;
period = rtc_periodic_clock_ticks(s);
-
if (!period) {
s->irq_coalesced = 0;
timer_del(s->periodic_timer);
@@ -197,42 +196,42 @@ periodic_timer_update(RTCState *s, int64_t current_time,
uint32_t old_period)
last_periodic_clock = next_periodic_clock - old_period;
lost_clock = cur_clock - last_periodic_clock;
assert(lost_clock >= 0);
+ }
+ /*
+ * s->irq_coalesced can change for two reasons:
+ *
+ * a) if one or more periodic timer interrupts have been lost,
+ * lost_clock will be more that a period.
+ *
+ * b) when the period may be reconfigured, we expect the OS to
+ * treat delayed tick as the new period. So, when switching
+ * from a shorter to a longer period, scale down the missing,
+ * because the OS will treat past delayed ticks as longer
+ * (leftovers are put back into lost_clock). When switching
+ * to a shorter period, scale up the missing ticks since the
+ * OS handler will treat past delayed ticks as shorter.
+ */
+ if (s->lost_tick_policy == LOST_TICK_POLICY_SLEW) {
+ uint32_t old_irq_coalesced = s->irq_coalesced;
+
+ s->period = period;
+ lost_clock += old_irq_coalesced * old_period;
+ s->irq_coalesced = lost_clock / s->period;
+ lost_clock %= s->period;
+ if (old_irq_coalesced != s->irq_coalesced ||
+ old_period != s->period) {
+ DPRINTF_C("cmos: coalesced irqs scaled from %d to %d, "
+ "period scaled from %d to %d\n", old_irq_coalesced,
+ s->irq_coalesced, old_period, s->period);
+ rtc_coalesced_timer_update(s);
+ }
+ } else {
/*
- * s->irq_coalesced can change for two reasons:
- *
- * a) if one or more periodic timer interrupts have been lost,
- * lost_clock will be more that a period.
- *
- * b) when the period may be reconfigured, we expect the OS to
- * treat delayed tick as the new period. So, when switching
- * from a shorter to a longer period, scale down the missing,
- * because the OS will treat past delayed ticks as longer
- * (leftovers are put back into lost_clock). When switching
- * to a shorter period, scale up the missing ticks since the
- * OS handler will treat past delayed ticks as shorter.
+ * no way to compensate the interrupt if LOST_TICK_POLICY_SLEW
+ * is not used, we should make the time progress anyway.
*/
- if (s->lost_tick_policy == LOST_TICK_POLICY_SLEW) {
- uint32_t old_irq_coalesced = s->irq_coalesced;
-
- s->period = period;
- lost_clock += old_irq_coalesced * old_period;
- s->irq_coalesced = lost_clock / s->period;
- lost_clock %= s->period;
- if (old_irq_coalesced != s->irq_coalesced ||
- old_period != s->period) {
- DPRINTF_C("cmos: coalesced irqs scaled from %d to %d, "
- "period scaled from %d to %d\n", old_irq_coalesced,
- s->irq_coalesced, old_period, s->period);
- rtc_coalesced_timer_update(s);
- }
- } else {
- /*
- * no way to compensate the interrupt if LOST_TICK_POLICY_SLEW
- * is not used, we should make the time progress anyway.
- */
- lost_clock = MIN(lost_clock, period);
- }
+ lost_clock = MIN(lost_clock, period);
}
assert(lost_clock >= 0 && lost_clock <= period);
--
1.8.3.1
- [PULL 02/12] microvm: fix memory leak in microvm_fix_kernel_cmdline, (continued)
- [PULL 02/12] microvm: fix memory leak in microvm_fix_kernel_cmdline, Paolo Bonzini, 2019/11/19
- [PULL 01/12] scripts: Detect git worktrees for get_maintainer.pl --git, Paolo Bonzini, 2019/11/19
- [PULL 03/12] target/i386: add PSCHANGE_NO bit for the ARCH_CAPABILITIES MSR, Paolo Bonzini, 2019/11/19
- [PULL 04/12] target/i386: Export TAA_NO bit to guests, Paolo Bonzini, 2019/11/19
- [PULL 05/12] hw/i386: Fix compiler warning when CONFIG_IDE_ISA is disabled, Paolo Bonzini, 2019/11/19
- [PULL 06/12] vfio: vfio-pci requires EDID, Paolo Bonzini, 2019/11/19
- [PULL 07/12] docs/microvm.rst: fix alignment in "Limitations", Paolo Bonzini, 2019/11/19
- [PULL 08/12] docs/microvm.rst: add instructions for shutting down the guest, Paolo Bonzini, 2019/11/19
- [PULL 09/12] hw/i386: Move save_tsc_khz from PCMachineClass to X86MachineClass, Paolo Bonzini, 2019/11/19
- [PULL 10/12] scsi: deprecate scsi-disk, Paolo Bonzini, 2019/11/19
- [PULL 11/12] Revert "mc146818rtc: fix timer interrupt reinjection",
Paolo Bonzini <=
- [PULL 12/12] mc146818rtc: fix timer interrupt reinjection again, Paolo Bonzini, 2019/11/19
- Re: [PULL 00/12] Misc patches for QEMU 4.2-rc, Peter Maydell, 2019/11/19
- Re: [PULL 00/12] Misc patches for QEMU 4.2-rc, no-reply, 2019/11/19