Skip to contentSkip to conversation

Do not set RTC frequency if already set

PATCH New Aurelien Jarno 1 participant 1 message Jan 28, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Do not set RTC frequency if already set

Do not set RTC frequency to 1024 or warn about this if it has already been set to the correct value.

---
 vl.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
vl.c +4 -1
index 8c63ad9..2d494c5 100644
@@ -1307,11 +1307,14 @@ static void hpet_stop_timer(struct qemu_alarm_timer *t)
 static int rtc_start_timer(struct qemu_alarm_timer *t)
 {
     int rtc_fd;
+    unsigned long current_rtc_freq = 0;
 
     TFR(rtc_fd = open("/dev/rtc", O_RDONLY));
     if (rtc_fd < 0)
         return -1;
-    if (ioctl(rtc_fd, RTC_IRQP_SET, RTC_FREQ) < 0) {
+    ioctl(rtc_fd, RTC_IRQP_READ, &current_rtc_freq);
+    if (current_rtc_freq != RTC_FREQ &&
+        ioctl(rtc_fd, RTC_IRQP_SET, RTC_FREQ) < 0) {
         fprintf(stderr, "Could not configure '/dev/rtc' to have a 1024 Hz timer. This is not a fatal\n"
                 "error, but for better emulation accuracy either use a 2.6 host Linux kernel or\n"
                 "type 'echo 1024 > /proc/sys/dev/rtc/max-user-freq' as root.\n");
Signature · 4 lines
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   [email protected]         | [email protected]
   `-    people.debian.org/~aurel32 | www.aurel32.net