qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] timer: drop HPET and RTC
Date: Tue, 31 May 2011 18:33:15 +0200	[thread overview]
Message-ID: <4DE5184B.6090606@redhat.com> (raw)
In-Reply-To: <1306857227-15434-1-git-send-email-aliguori@us.ibm.com>

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,&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");
> -        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;

      reply	other threads:[~2011-05-31 18:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-31 15:53 [Qemu-devel] [PATCH] timer: drop HPET and RTC Anthony Liguori
2011-05-31 16:33 ` Paolo Bonzini [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DE5184B.6090606@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).