* [Qemu-devel] [PATCH] timer: drop HPET and RTC
@ 2011-05-31 15:53 Anthony Liguori
2011-05-31 16:33 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Anthony Liguori @ 2011-05-31 15:53 UTC (permalink / raw)
To: qemu-devel; +Cc: Anthony Liguori
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 <aliguori@us.ibm.com>
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 <sys/param.h>
#endif
-#ifdef __linux__
-#include <sys/ioctl.h>
-#include <linux/rtc.h>
-/* For the benefit of older linux systems which don't supply it,
- we use a local copy of hpet.h. */
-/* #include <linux/hpet.h> */
-#include "hpet.h"
-#endif
-
#ifdef _WIN32
#include <windows.h>
#include <mmsystem.h>
@@ -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;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] timer: drop HPET and RTC
2011-05-31 15:53 [Qemu-devel] [PATCH] timer: drop HPET and RTC Anthony Liguori
@ 2011-05-31 16:33 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2011-05-31 16:33 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-devel
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<aliguori@us.ibm.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
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<sys/param.h>
> #endif
>
> -#ifdef __linux__
> -#include<sys/ioctl.h>
> -#include<linux/rtc.h>
> -/* For the benefit of older linux systems which don't supply it,
> - we use a local copy of hpet.h. */
> -/* #include<linux/hpet.h> */
> -#include "hpet.h"
> -#endif
> -
> #ifdef _WIN32
> #include<windows.h>
> #include<mmsystem.h>
> @@ -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;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-05-31 18:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-31 15:53 [Qemu-devel] [PATCH] timer: drop HPET and RTC Anthony Liguori
2011-05-31 16:33 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).