Re: [Qemu-devel] [PATCH 3/4] Add support for HPET periodic timer.

2007-09-03 Thread GUERRAZ Francois
Hello,

Can you confirm to me that if I have only one periodic timer on my
motherboard I can only have one qemu-instance running using hpet?

Thanks.

François.

Le mardi 21 août 2007 à 21:40 +0200, Luca a écrit :
 On 8/21/07, Matthew Kent [EMAIL PROTECTED] wrote:
  On Sat, 2007-18-08 at 01:11 +0200, Luca Tettamanti wrote:
   plain text document attachment (clock-hpet)
   Linux operates the HPET timer in legacy replacement mode, which means that
   the periodic interrupt of the CMOS RTC is not delivered (qemu won't be 
   able
   to use /dev/rtc). Add support for HPET (/dev/hpet) as a replacement for 
   the
   RTC; the periodic interrupt is delivered via SIGIO and is handled in the
   same way as the RTC timer.
  
   Signed-off-by: Luca Tettamanti [EMAIL PROTECTED]
 
  I must be missing something silly here.. should I be able to open more
  than one instance of qemu with -clock hpet? Because upon invoking a
  second instance of qemu HPET_IE_ON fails.
 
 It depends on your hardware. Theoretically it's possible, but I've yet
 to see a motherboard with more than one periodic timer.
 
 dmesg | grep hpet should tell you something like:
 
 hpet0: 3 64-bit timers, 14318180 Hz
 
 Luca
 
 
 





Re: [kvm-devel] [Qemu-devel] [PATCH 3/4] Add support for HPET periodic timer.

2007-08-25 Thread Dan Kenigsberg
On Fri, Aug 24, 2007 at 10:18:47PM +0200, Luca wrote:
 On 8/23/07, Dan Kenigsberg [EMAIL PROTECTED] wrote:
  On Thu, Aug 23, 2007 at 12:09:47AM +0200, Andi Kleen wrote:
$ dmesg |grep -i hpet
ACPI: HPET 7D5B6AE0, 0038 (r1 A M I  OEMHPET   5000708 MSFT   97)
ACPI: HPET id: 0x8086a301 base: 0xfed0
hpet0: at MMIO 0xfed0, IRQs 2, 8, 0, 0
hpet0: 4 64-bit timers, 14318180 Hz
hpet_resources: 0xfed0 is busy
  
   What kernel version was that? There was a bug that caused this pre .22
  
 
  I have vanilla 2.6.22.3 on that machine.
 
 Try:
 cat /sys/devices/system/clocksource/clocksource0/available_clocksource
 
 do you see HPET listed twice?
 
No, only once. Is that wrong?

# cat /sys/devices/system/clocksource/clocksource0/available_clocksource
hpet acpi_pm jiffies tsc 

# cat /sys/devices/system/clocksource/clocksource0/current_clocksource 
tsc 

Dan.




Re: [kvm-devel] [Qemu-devel] [PATCH 3/4] Add support for HPET periodic timer.

2007-08-24 Thread Luca
On 8/23/07, Dan Kenigsberg [EMAIL PROTECTED] wrote:
 On Thu, Aug 23, 2007 at 12:09:47AM +0200, Andi Kleen wrote:
   $ dmesg |grep -i hpet
   ACPI: HPET 7D5B6AE0, 0038 (r1 A M I  OEMHPET   5000708 MSFT   97)
   ACPI: HPET id: 0x8086a301 base: 0xfed0
   hpet0: at MMIO 0xfed0, IRQs 2, 8, 0, 0
   hpet0: 4 64-bit timers, 14318180 Hz
   hpet_resources: 0xfed0 is busy
 
  What kernel version was that? There was a bug that caused this pre .22
 

 I have vanilla 2.6.22.3 on that machine.

Try:
cat /sys/devices/system/clocksource/clocksource0/available_clocksource

do you see HPET listed twice?

Luca




Re: [kvm-devel] [Qemu-devel] [PATCH 3/4] Add support for HPET periodic timer.

2007-08-23 Thread Dan Kenigsberg
On Thu, Aug 23, 2007 at 12:09:47AM +0200, Andi Kleen wrote:
  $ dmesg |grep -i hpet
  ACPI: HPET 7D5B6AE0, 0038 (r1 A M I  OEMHPET   5000708 MSFT   97)
  ACPI: HPET id: 0x8086a301 base: 0xfed0
  hpet0: at MMIO 0xfed0, IRQs 2, 8, 0, 0
  hpet0: 4 64-bit timers, 14318180 Hz
  hpet_resources: 0xfed0 is busy
 
 What kernel version was that? There was a bug that caused this pre .22
 

I have vanilla 2.6.22.3 on that machine.

Thanks,
Dan.




Re: [kvm-devel] [Qemu-devel] [PATCH 3/4] Add support for HPET periodic timer.

2007-08-22 Thread Dan Kenigsberg
On Tue, Aug 21, 2007 at 01:15:22PM -0700, Matthew Kent wrote:
 On Tue, 2007-21-08 at 21:40 +0200, Luca wrote:
  On 8/21/07, Matthew Kent [EMAIL PROTECTED] wrote:
   On Sat, 2007-18-08 at 01:11 +0200, Luca Tettamanti wrote:
plain text document attachment (clock-hpet)
Linux operates the HPET timer in legacy replacement mode, which means 
that
the periodic interrupt of the CMOS RTC is not delivered (qemu won't be 
able
to use /dev/rtc). Add support for HPET (/dev/hpet) as a replacement for 
the
RTC; the periodic interrupt is delivered via SIGIO and is handled in the
same way as the RTC timer.
   
Signed-off-by: Luca Tettamanti [EMAIL PROTECTED]
  
   I must be missing something silly here.. should I be able to open more
   than one instance of qemu with -clock hpet? Because upon invoking a
   second instance of qemu HPET_IE_ON fails.
  
  It depends on your hardware. Theoretically it's possible, but I've yet
  to see a motherboard with more than one periodic timer.
 
 Ah thank you, after re-reading the docs I think I better understand
 this.

In a risk of being off-topic, maybe you can help me try the hpet support.
When I try the hpet Documentation demo I get

# ./hpet poll /dev/hpet 1 1000
-hpet: executing poll
hpet_poll: info.hi_flags 0x0
hpet_poll, HPET_IE_ON failed

while I have

$ dmesg|grep -i HPET
ACPI: HPET 7D5B6AE0, 0038 (r1 A M I  OEMHPET   5000708 MSFT   97)
ACPI: HPET id: 0x8086a301 base: 0xfed0
hpet0: at MMIO 0xfed0, IRQs 2, 8, 0, 0
hpet0: 4 64-bit timers, 14318180 Hz
hpet_resources: 0xfed0 is busy
Time: hpet clocksource has been installed.

Any idea what I am misconfiguring?

Thanks,

Dan.




Re: [kvm-devel] [Qemu-devel] [PATCH 3/4] Add support for HPET periodic timer.

2007-08-22 Thread Avi Kivity
Dan Kenigsberg wrote:
 On Tue, Aug 21, 2007 at 01:15:22PM -0700, Matthew Kent wrote:
   
 On Tue, 2007-21-08 at 21:40 +0200, Luca wrote:
 
 On 8/21/07, Matthew Kent [EMAIL PROTECTED] wrote:
   
 On Sat, 2007-18-08 at 01:11 +0200, Luca Tettamanti wrote:
 
 plain text document attachment (clock-hpet)
 Linux operates the HPET timer in legacy replacement mode, which means that
 the periodic interrupt of the CMOS RTC is not delivered (qemu won't be 
 able
 to use /dev/rtc). Add support for HPET (/dev/hpet) as a replacement for 
 the
 RTC; the periodic interrupt is delivered via SIGIO and is handled in the
 same way as the RTC timer.

 Signed-off-by: Luca Tettamanti [EMAIL PROTECTED]
   
 I must be missing something silly here.. should I be able to open more
 than one instance of qemu with -clock hpet? Because upon invoking a
 second instance of qemu HPET_IE_ON fails.
 
 It depends on your hardware. Theoretically it's possible, but I've yet
 to see a motherboard with more than one periodic timer.
   
 Ah thank you, after re-reading the docs I think I better understand
 this.
 

 In a risk of being off-topic, maybe you can help me try the hpet support.
 When I try the hpet Documentation demo I get

 # ./hpet poll /dev/hpet 1 1000
 -hpet: executing poll
 hpet_poll: info.hi_flags 0x0
 hpet_poll, HPET_IE_ON failed

 while I have

 $ dmesg|grep -i HPET
 ACPI: HPET 7D5B6AE0, 0038 (r1 A M I  OEMHPET   5000708 MSFT   97)
 ACPI: HPET id: 0x8086a301 base: 0xfed0
 hpet0: at MMIO 0xfed0, IRQs 2, 8, 0, 0
 hpet0: 4 64-bit timers, 14318180 Hz
 hpet_resources: 0xfed0 is busy
 Time: hpet clocksource has been installed.

 Any idea what I am misconfiguring?
   

Maybe the kernel is using the timer, so userspace can't.  Just a guess.


-- 
Do not meddle in the internals of kernels, for they are subtle and quick to 
panic.





Re: [kvm-devel] [Qemu-devel] [PATCH 3/4] Add support for HPET periodic timer.

2007-08-22 Thread Andi Kleen
On Wed, Aug 22, 2007 at 10:03:32AM +0300, Avi Kivity wrote:
 Maybe the kernel is using the timer, so userspace can't.  Just a guess.

HPET has multiple timers (variable, but typically 2 or 4). The kernel
only uses timer 0. It's possible someone else in user space is using
it though. Try lsof /dev/hpet

-Andi




Re: [kvm-devel] [Qemu-devel] [PATCH 3/4] Add support for HPET periodic timer.

2007-08-22 Thread Dan Kenigsberg
On Wed, Aug 22, 2007 at 02:34:24PM +0200, Andi Kleen wrote:
 On Wed, Aug 22, 2007 at 10:03:32AM +0300, Avi Kivity wrote:
  Maybe the kernel is using the timer, so userspace can't.  Just a guess.
 
 HPET has multiple timers (variable, but typically 2 or 4). The kernel
 only uses timer 0. It's possible someone else in user space is using
 it though. Try lsof /dev/hpet

Thanks for the ideas; however even after I made the kernel use tsc as
time source, and made sure that no one opens /dev/hpet, I fail to use
HPET (with same errors as before)

I now have

$ dmesg |grep -i hpet
ACPI: HPET 7D5B6AE0, 0038 (r1 A M I  OEMHPET   5000708 MSFT   97)
ACPI: HPET id: 0x8086a301 base: 0xfed0
hpet0: at MMIO 0xfed0, IRQs 2, 8, 0, 0
hpet0: 4 64-bit timers, 14318180 Hz
hpet_resources: 0xfed0 is busy

Any other idea?

Dan.




Re: [kvm-devel] [Qemu-devel] [PATCH 3/4] Add support for HPET periodic timer.

2007-08-22 Thread Andi Kleen
 $ dmesg |grep -i hpet
 ACPI: HPET 7D5B6AE0, 0038 (r1 A M I  OEMHPET   5000708 MSFT   97)
 ACPI: HPET id: 0x8086a301 base: 0xfed0
 hpet0: at MMIO 0xfed0, IRQs 2, 8, 0, 0
 hpet0: 4 64-bit timers, 14318180 Hz
 hpet_resources: 0xfed0 is busy

What kernel version was that? There was a bug that caused this pre .22

-Andi




Re: [Qemu-devel] [PATCH 3/4] Add support for HPET periodic timer.

2007-08-21 Thread Matthew Kent
On Sat, 2007-18-08 at 01:11 +0200, Luca Tettamanti wrote:
 plain text document attachment (clock-hpet)
 Linux operates the HPET timer in legacy replacement mode, which means that
 the periodic interrupt of the CMOS RTC is not delivered (qemu won't be able
 to use /dev/rtc). Add support for HPET (/dev/hpet) as a replacement for the
 RTC; the periodic interrupt is delivered via SIGIO and is handled in the
 same way as the RTC timer.
 
 Signed-off-by: Luca Tettamanti [EMAIL PROTECTED]

I must be missing something silly here.. should I be able to open more
than one instance of qemu with -clock hpet? Because upon invoking a
second instance of qemu HPET_IE_ON fails.

I also tried running the example in the kernel docs under
Documentation/hpet.txt

[EMAIL PROTECTED] [/home/mkent]# ./demo poll /dev/hpet 1 1000
-hpet: executing poll
hpet_poll: info.hi_flags 0x0
hpet_poll: expired time = 0x8
hpet_poll: revents = 0x1
hpet_poll: data 0x1

in another term
[EMAIL PROTECTED] [/home/mkent]# ./demo poll /dev/hpet 1 1000
-hpet: executing poll
hpet_poll: info.hi_flags 0x0
hpet_poll, HPET_IE_ON failed

This is on 2.6.23-rc3 x86_64 with the patch-2.6.23-rc3-hrt2.patch
hrtimers patch.
-- 
Matthew Kent [EMAIL PROTECTED]
http://magoazul.com





Re: [Qemu-devel] [PATCH 3/4] Add support for HPET periodic timer.

2007-08-21 Thread Luca
On 8/21/07, Matthew Kent [EMAIL PROTECTED] wrote:
 On Sat, 2007-18-08 at 01:11 +0200, Luca Tettamanti wrote:
  plain text document attachment (clock-hpet)
  Linux operates the HPET timer in legacy replacement mode, which means that
  the periodic interrupt of the CMOS RTC is not delivered (qemu won't be able
  to use /dev/rtc). Add support for HPET (/dev/hpet) as a replacement for the
  RTC; the periodic interrupt is delivered via SIGIO and is handled in the
  same way as the RTC timer.
 
  Signed-off-by: Luca Tettamanti [EMAIL PROTECTED]

 I must be missing something silly here.. should I be able to open more
 than one instance of qemu with -clock hpet? Because upon invoking a
 second instance of qemu HPET_IE_ON fails.

It depends on your hardware. Theoretically it's possible, but I've yet
to see a motherboard with more than one periodic timer.

dmesg | grep hpet should tell you something like:

hpet0: 3 64-bit timers, 14318180 Hz

Luca




Re: [Qemu-devel] [PATCH 3/4] Add support for HPET periodic timer.

2007-08-21 Thread Matthew Kent
On Tue, 2007-21-08 at 21:40 +0200, Luca wrote:
 On 8/21/07, Matthew Kent [EMAIL PROTECTED] wrote:
  On Sat, 2007-18-08 at 01:11 +0200, Luca Tettamanti wrote:
   plain text document attachment (clock-hpet)
   Linux operates the HPET timer in legacy replacement mode, which means that
   the periodic interrupt of the CMOS RTC is not delivered (qemu won't be 
   able
   to use /dev/rtc). Add support for HPET (/dev/hpet) as a replacement for 
   the
   RTC; the periodic interrupt is delivered via SIGIO and is handled in the
   same way as the RTC timer.
  
   Signed-off-by: Luca Tettamanti [EMAIL PROTECTED]
 
  I must be missing something silly here.. should I be able to open more
  than one instance of qemu with -clock hpet? Because upon invoking a
  second instance of qemu HPET_IE_ON fails.
 
 It depends on your hardware. Theoretically it's possible, but I've yet
 to see a motherboard with more than one periodic timer.

Ah thank you, after re-reading the docs I think I better understand
this.
-- 
Matthew Kent [EMAIL PROTECTED]
http://magoazul.com





[Qemu-devel] [PATCH 3/4] Add support for HPET periodic timer.

2007-08-17 Thread Luca Tettamanti
Linux operates the HPET timer in legacy replacement mode, which means that
the periodic interrupt of the CMOS RTC is not delivered (qemu won't be able
to use /dev/rtc). Add support for HPET (/dev/hpet) as a replacement for the
RTC; the periodic interrupt is delivered via SIGIO and is handled in the
same way as the RTC timer.

Signed-off-by: Luca Tettamanti [EMAIL PROTECTED]

---
 vl.c |   57 -
 1 file changed, 56 insertions(+), 1 deletion(-)

Index: qemu/vl.c
===
--- qemu.orig/vl.c  2007-08-17 17:39:21.0 +0200
+++ qemu/vl.c   2007-08-18 00:40:16.0 +0200
@@ -56,6 +56,7 @@
 #include pty.h
 #include malloc.h
 #include linux/rtc.h
+#include linux/hpet.h
 #include linux/ppdev.h
 #include linux/parport.h
 #else
@@ -809,6 +810,9 @@
 
 #ifdef __linux__
 
+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);
 
@@ -818,7 +822,9 @@
 
 static struct qemu_alarm_timer alarm_timers[] = {
 #ifdef __linux__
-/* RTC - if available - is preferred */
+/* 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
 #ifndef _WIN32
@@ -1153,6 +1159,55 @@
 fcntl(fd, F_SETOWN, getpid());
 }
 
+static int hpet_start_timer(struct qemu_alarm_timer *t)
+{
+struct hpet_info info;
+int r, fd;
+
+fd = 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-priv = (void *)fd;
+
+return 0;
+fail:
+close(fd);
+return -1;
+}
+
+static void hpet_stop_timer(struct qemu_alarm_timer *t)
+{
+int fd = (int)t-priv;
+
+close(fd);
+}
+
 static int rtc_start_timer(struct qemu_alarm_timer *t)
 {
 int rtc_fd;

--