From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:42075) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QRTYg-00074o-HM for qemu-devel@nongnu.org; Tue, 31 May 2011 14:20:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QRTYe-0007WK-Bn for qemu-devel@nongnu.org; Tue, 31 May 2011 14:20:50 -0400 Received: from mail-pv0-f173.google.com ([74.125.83.173]:44883) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QRTYd-0007Vy-DW for qemu-devel@nongnu.org; Tue, 31 May 2011 14:20:48 -0400 Received: by pvg3 with SMTP id 3so2326600pvg.4 for ; Tue, 31 May 2011 11:20:46 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4DE5184B.6090606@redhat.com> Date: Tue, 31 May 2011 18:33:15 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1306857227-15434-1-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1306857227-15434-1-git-send-email-aliguori@us.ibm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] timer: drop HPET and RTC List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org On 05/31/2011 05:53 PM, Anthony Liguori wrote: > dynticks will provide equally good timer granularity on all modern Linux > systems. This is more or less dead code these days. > > Signed-off-by: Anthony Liguori Acked-by: Paolo Bonzini Bonus points for making a dynticks version of setitimer. Paolo > diff --git a/qemu-timer.c b/qemu-timer.c > index 4141b6e..72066c7 100644 > --- a/qemu-timer.c > +++ b/qemu-timer.c > @@ -39,15 +39,6 @@ > #include > #endif > > -#ifdef __linux__ > -#include > -#include > -/* For the benefit of older linux systems which don't supply it, > - we use a local copy of hpet.h. */ > -/* #include */ > -#include "hpet.h" > -#endif > - > #ifdef _WIN32 > #include > #include > @@ -234,12 +225,6 @@ static int dynticks_start_timer(struct qemu_alarm_timer *t); > static void dynticks_stop_timer(struct qemu_alarm_timer *t); > static void dynticks_rearm_timer(struct qemu_alarm_timer *t); > > -static int hpet_start_timer(struct qemu_alarm_timer *t); > -static void hpet_stop_timer(struct qemu_alarm_timer *t); > - > -static int rtc_start_timer(struct qemu_alarm_timer *t); > -static void rtc_stop_timer(struct qemu_alarm_timer *t); > - > #endif /* __linux__ */ > > #endif /* _WIN32 */ > @@ -304,10 +289,6 @@ static struct qemu_alarm_timer alarm_timers[] = { > #ifdef __linux__ > {"dynticks", dynticks_start_timer, > dynticks_stop_timer, dynticks_rearm_timer}, > - /* HPET - if available - is preferred */ > - {"hpet", hpet_start_timer, hpet_stop_timer, NULL}, > - /* ...otherwise try RTC */ > - {"rtc", rtc_start_timer, rtc_stop_timer, NULL}, > #endif > {"unix", unix_start_timer, unix_stop_timer, NULL}, > #else > @@ -822,107 +803,6 @@ static int64_t qemu_next_alarm_deadline(void) > > #if defined(__linux__) > > -#define RTC_FREQ 1024 > - > -static void enable_sigio_timer(int fd) > -{ > - struct sigaction act; > - > - /* timer signal */ > - sigfillset(&act.sa_mask); > - act.sa_flags = 0; > - act.sa_handler = host_alarm_handler; > - > - sigaction(SIGIO,&act, NULL); > - fcntl_setfl(fd, O_ASYNC); > - fcntl(fd, F_SETOWN, getpid()); > -} > - > -static int hpet_start_timer(struct qemu_alarm_timer *t) > -{ > - struct hpet_info info; > - int r, fd; > - > - fd = qemu_open("/dev/hpet", O_RDONLY); > - if (fd< 0) > - return -1; > - > - /* Set frequency */ > - r = ioctl(fd, HPET_IRQFREQ, RTC_FREQ); > - if (r< 0) { > - fprintf(stderr, "Could not configure '/dev/hpet' to have a 1024Hz timer. This is not a fatal\n" > - "error, but for better emulation accuracy type:\n" > - "'echo 1024> /proc/sys/dev/hpet/max-user-freq' as root.\n"); > - goto fail; > - } > - > - /* Check capabilities */ > - r = ioctl(fd, HPET_INFO,&info); > - if (r< 0) > - goto fail; > - > - /* Enable periodic mode */ > - r = ioctl(fd, HPET_EPI, 0); > - if (info.hi_flags&& (r< 0)) > - goto fail; > - > - /* Enable interrupt */ > - r = ioctl(fd, HPET_IE_ON, 0); > - if (r< 0) > - goto fail; > - > - enable_sigio_timer(fd); > - t->fd = fd; > - > - return 0; > -fail: > - close(fd); > - return -1; > -} > - > -static void hpet_stop_timer(struct qemu_alarm_timer *t) > -{ > - int fd = t->fd; > - > - close(fd); > -} > - > -static int rtc_start_timer(struct qemu_alarm_timer *t) > -{ > - int rtc_fd; > - unsigned long current_rtc_freq = 0; > - > - TFR(rtc_fd = qemu_open("/dev/rtc", O_RDONLY)); > - if (rtc_fd< 0) > - return -1; > - ioctl(rtc_fd, RTC_IRQP_READ,¤t_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"); > - goto fail; > - } > - if (ioctl(rtc_fd, RTC_PIE_ON, 0)< 0) { > - fail: > - close(rtc_fd); > - return -1; > - } > - > - enable_sigio_timer(rtc_fd); > - > - t->fd = rtc_fd; > - > - return 0; > -} > - > -static void rtc_stop_timer(struct qemu_alarm_timer *t) > -{ > - int rtc_fd = t->fd; > - > - close(rtc_fd); > -} > - > static int dynticks_start_timer(struct qemu_alarm_timer *t) > { > struct sigevent ev;