[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 16/17] mc146818rtc: simplify check_update_timer
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 16/17] mc146818rtc: simplify check_update_timer |
Date: |
Tue, 1 Aug 2017 18:17:24 +0200 |
Move all the optimized cases together, since they all have UF=1 in
common.
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/timer/mc146818rtc.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
index 1b8d3d7..ffb2c6a 100644
--- a/hw/timer/mc146818rtc.c
+++ b/hw/timer/mc146818rtc.c
@@ -291,26 +291,14 @@ static void check_update_timer(RTCState *s)
/* From the data sheet: "Holding the dividers in reset prevents
* interrupts from operating, while setting the SET bit allows"
- * them to occur. However, it will prevent an alarm interrupt
- * from occurring, because the time of day is not updated.
+ * them to occur.
*/
if ((s->cmos_data[RTC_REG_A] & 0x60) == 0x60) {
timer_del(s->update_timer);
return;
}
- if ((s->cmos_data[RTC_REG_C] & REG_C_UF) &&
- (s->cmos_data[RTC_REG_B] & REG_B_SET)) {
- timer_del(s->update_timer);
- return;
- }
- if ((s->cmos_data[RTC_REG_C] & REG_C_UF) &&
- (s->cmos_data[RTC_REG_C] & REG_C_AF)) {
- timer_del(s->update_timer);
- return;
- }
guest_nsec = get_guest_rtc_ns(s) % NANOSECONDS_PER_SECOND;
- /* if UF is clear, reprogram to next second */
next_update_time = qemu_clock_get_ns(rtc_clock)
+ NANOSECONDS_PER_SECOND - guest_nsec;
@@ -321,7 +309,17 @@ static void check_update_timer(RTCState *s)
s->next_alarm_time = next_update_time +
(next_alarm_sec - 1) * NANOSECONDS_PER_SECOND;
+ /* If UF is already set, we might be able to optimize. */
if (s->cmos_data[RTC_REG_C] & REG_C_UF) {
+ /* If AF cannot change (i.e. either it is set already, or
+ * SET=1 and then the time is not updated), nothing to do.
+ */
+ if ((s->cmos_data[RTC_REG_B] & REG_B_SET) ||
+ (s->cmos_data[RTC_REG_C] & REG_C_AF)) {
+ timer_del(s->update_timer);
+ return;
+ }
+
/* UF is set, but AF is clear. Program the timer to target
* the alarm time. */
next_update_time = s->next_alarm_time;
--
1.8.3.1
- [Qemu-devel] [PULL 03/17] accel: cleanup error output, (continued)
- [Qemu-devel] [PULL 03/17] accel: cleanup error output, Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 06/17] docs: document deprecation policy & deprecated features in appendix, Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 08/17] exec: Add lock parameter to qemu_ram_ptr_length, Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 09/17] bt: stop the sdp memory allocation craziness, Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 10/17] qemu-options: document existance of versioned machine types, Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 11/17] migration: optimize the downtime, Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 12/17] hw/scsi/vmw_pvscsi: Remove the dead error handling, Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 13/17] hw/scsi/vmw_pvscsi: Convert to realize, Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 14/17] rtc-test: cleanup register_b_set_flag test, Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 15/17] rtc-test: introduce more update tests, Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 16/17] mc146818rtc: simplify check_update_timer,
Paolo Bonzini <=
- [Qemu-devel] [PULL 17/17] mc146818rtc: implement UIP latching as intended, Paolo Bonzini, 2017/08/01
- [Qemu-devel] [PULL 07/17] target-i386: kvm_get/put_vcpu_events don't handle sipi_vector, Paolo Bonzini, 2017/08/01
- Re: [Qemu-devel] [PULL 00/17] Misc changes for QEMU 2.10-rc1 (?), no-reply, 2017/08/01
Re: [Qemu-devel] [PULL 00/17] Misc changes for QEMU 2.10-rc1 (?), Peter Maydell, 2017/08/01