HPET and IRQs


Tomasz Bursztyka
 

Hi,

I am currently trying to fix an issue with Zephyr running as UOS.

The default configuration of Zephyr for acrn enables the LOAPIC timer,
but there does not seem to be any mention of such timer in acrn. Unless
I am missing something.
When running zephyr with such timer, the timing get all bogus. 60
seconds looks like 5 seconds, etc... Timings are all off.

As HPET is supported by acrn, I switched the timer to HPET. But now I
have a new issue, acrn-dm displays:

hpet t0 configured invalid irq 2, allowed_irqs 0xff000000

And nothing proceeds, since acrn defaults to 0, zephyr isr for hpet is
never called.

Indeed Zephyr sets HPET IRQ to 2, which seems to be wrong then for acrn
.

Which IRQ should HPET timer be configured to use on UOS side then?


Thanks,

Tomasz


Yan, Like
 

Hi Tomasz,

Please find my response inline.
One question, are you running Zephyr on standard VM or RT VM?

Thanks,
Like

-----Original Message-----
From: acrn-users@lists.projectacrn.org <acrn-users@lists.projectacrn.org> On
Behalf Of Tomasz Bursztyka
Sent: Tuesday, April 28, 2020 8:19 PM
To: acrn-users@lists.projectacrn.org
Subject: [acrn-users] HPET and IRQs

Hi,

I am currently trying to fix an issue with Zephyr running as UOS.

The default configuration of Zephyr for acrn enables the LOAPIC timer, but
there does not seem to be any mention of such timer in acrn. Unless I am
missing something.
[Like] LOAPIC is short for local APIC, right? In ACRN, we use LAPIC instead.

When running zephyr with such timer, the timing get all bogus. 60 seconds
looks like 5 seconds, etc... Timings are all off.
[Like] As I know, zephyr won't do runtime timer calibration. You may need to do the calibration manually, and update the code to the correct timer frequency.


As HPET is supported by acrn, I switched the timer to HPET. But now I have a
new issue, acrn-dm displays:

hpet t0 configured invalid irq 2, allowed_irqs 0xff000000

And nothing proceeds, since acrn defaults to 0, zephyr isr for hpet is never
called.

Indeed Zephyr sets HPET IRQ to 2, which seems to be wrong then for acrn .

Which IRQ should HPET timer be configured to use on UOS side then?
[Like] HPET may use IRQ 24~31. As well, HPET calibration is needed, so we recommend you to use the LAPIC timer.




Thanks,

Tomasz



Tomasz Bursztyka
 

Hi Like,

VM or RT VM, I don't know. It did not occur to me there was an actual
difference, I just used the launcher script for zephyr. I'll check.

I could get LAPIC (which we indeed call LOAPIC) to work using --
lapic_pt option to acrn-dm. But then I am unable to stop/reset/delete
the VM for some reason (even with --force on stop, it always returns
-1).

I'll still investigate about HPET. It "should" work, and if Zephyr is
missing some support - runtime calibration that is - then it will be
worth adding it.

Thanks for the inputs,

Tomasz


Chen, Zide
 

Hi Tomasz,

Additional to Like's comments, to calibrate the timer, if you have serial HV console, you can get the TSC frequency from the log. For example:
calibrate_tsc, tsc_khz=1593600

Then you need to change the Zephyr code accordingly. In this example, set CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=1593600000
https://github.com/zephyrproject-rtos/zephyr/blob/master/boards/x86/acrn/acrn_defconfig#L13

Best Regards,
Zide

-----Original Message-----
From: acrn-users@lists.projectacrn.org <acrn-users@lists.projectacrn.org> On Behalf Of Tomasz Bursztyka
Sent: Tuesday, April 28, 2020 5:19 AM
To: acrn-users@lists.projectacrn.org
Subject: [acrn-users] HPET and IRQs

Hi,

I am currently trying to fix an issue with Zephyr running as UOS.

The default configuration of Zephyr for acrn enables the LOAPIC timer,
but there does not seem to be any mention of such timer in acrn. Unless
I am missing something.
When running zephyr with such timer, the timing get all bogus. 60
seconds looks like 5 seconds, etc... Timings are all off.

As HPET is supported by acrn, I switched the timer to HPET. But now I
have a new issue, acrn-dm displays:

hpet t0 configured invalid irq 2, allowed_irqs 0xff000000

And nothing proceeds, since acrn defaults to 0, zephyr isr for hpet is
never called.

Indeed Zephyr sets HPET IRQ to 2, which seems to be wrong then for acrn
.

Which IRQ should HPET timer be configured to use on UOS side then?


Thanks,

Tomasz



Yan, Like
 

Hi Tomasz,

If you launched VM with --lapic_pt, then it's a RT VM.
An RT VM is only allowed to be powered-off/reset when initiated inside the RT VM. The design principle here is that the other VMs (even the SOS VM) should not interfere RT VM to guarantee the RT performance.
And there are some limitations as to RT VM, legacy devices are not supported, such as vHPET.
Here are 2 documents for RT VM:
https://projectacrn.github.io/latest/tutorials/rtvm_workload_design_guideline.html
https://projectacrn.github.io/latest/tutorials/rtvm_performance_tips.html

Thanks,
Like

-----Original Message-----
From: acrn-users@lists.projectacrn.org <acrn-users@lists.projectacrn.org> On
Behalf Of Tomasz Bursztyka
Sent: Wednesday, April 29, 2020 2:37 PM
To: acrn-users@lists.projectacrn.org
Subject: Re: [acrn-users] HPET and IRQs

Hi Like,

VM or RT VM, I don't know. It did not occur to me there was an actual
difference, I just used the launcher script for zephyr. I'll check.

I could get LAPIC (which we indeed call LOAPIC) to work using -- lapic_pt
option to acrn-dm. But then I am unable to stop/reset/delete the VM for
some reason (even with --force on stop, it always returns -1).

I'll still investigate about HPET. It "should" work, and if Zephyr is missing
some support - runtime calibration that is - then it will be worth adding it.

Thanks for the inputs,

Tomasz




Geoffroy Van Cutsem
 

-----Original Message-----
From: acrn-users@lists.projectacrn.org <acrn-users@lists.projectacrn.org>
On Behalf Of Yan, Like
Sent: Wednesday, April 29, 2020 5:24 PM
To: acrn-users@lists.projectacrn.org
Subject: Re: [acrn-users] HPET and IRQs

Hi Tomasz,

If you launched VM with --lapic_pt, then it's a RT VM.
An RT VM is only allowed to be powered-off/reset when initiated inside the
RT VM. The design principle here is that the other VMs (even the SOS VM)
should not interfere RT VM to guarantee the RT performance.
And there are some limitations as to RT VM, legacy devices are not
supported, such as vHPET.
Here are 2 documents for RT VM:
https://projectacrn.github.io/latest/tutorials/rtvm_workload_design_guideli
ne.html
https://projectacrn.github.io/latest/tutorials/rtvm_performance_tips.html
Thanks for the information Like. I was suspecting this but couldn't find a good reference about this in our documentation. The couple of documents you referenced above provide some good background information and useful tips on how to run RTVMs on ACRN. It does not really talk about what this limitation for example. It would be great to have some High-Level Design Guide that talk more extensively about the different types of User VMs: i.e. pre-launched, post-launched and RTVM vs. "normal" User VMs.

Is this something we can plan to add?

Thanks,
Geoffroy



Thanks,
Like

-----Original Message-----
From: acrn-users@lists.projectacrn.org
<acrn-users@lists.projectacrn.org> On Behalf Of Tomasz Bursztyka
Sent: Wednesday, April 29, 2020 2:37 PM
To: acrn-users@lists.projectacrn.org
Subject: Re: [acrn-users] HPET and IRQs

Hi Like,

VM or RT VM, I don't know. It did not occur to me there was an actual
difference, I just used the launcher script for zephyr. I'll check.

I could get LAPIC (which we indeed call LOAPIC) to work using --
lapic_pt option to acrn-dm. But then I am unable to stop/reset/delete
the VM for some reason (even with --force on stop, it always returns -1).

I'll still investigate about HPET. It "should" work, and if Zephyr is
missing some support - runtime calibration that is - then it will be worth
adding it.

Thanks for the inputs,

Tomasz





Yan, Like
 

I thought we have a document talking about the VM type definitions and constraints.
Let me check first, we will add one if it's not there.

-----Original Message-----
From: acrn-users@lists.projectacrn.org <acrn-users@lists.projectacrn.org> On
Behalf Of Geoffroy Van Cutsem
Sent: Thursday, April 30, 2020 4:36 PM
To: acrn-users@lists.projectacrn.org
Subject: Re: [acrn-users] HPET and IRQs



-----Original Message-----
From: acrn-users@lists.projectacrn.org
<acrn-users@lists.projectacrn.org>
On Behalf Of Yan, Like
Sent: Wednesday, April 29, 2020 5:24 PM
To: acrn-users@lists.projectacrn.org
Subject: Re: [acrn-users] HPET and IRQs

Hi Tomasz,

If you launched VM with --lapic_pt, then it's a RT VM.
An RT VM is only allowed to be powered-off/reset when initiated inside
the RT VM. The design principle here is that the other VMs (even the
SOS VM) should not interfere RT VM to guarantee the RT performance.
And there are some limitations as to RT VM, legacy devices are not
supported, such as vHPET.
Here are 2 documents for RT VM:
https://projectacrn.github.io/latest/tutorials/rtvm_workload_design_gu
ideli
ne.html
https://projectacrn.github.io/latest/tutorials/rtvm_performance_tips.h
tml
Thanks for the information Like. I was suspecting this but couldn't find a
good reference about this in our documentation. The couple of documents
you referenced above provide some good background information and
useful tips on how to run RTVMs on ACRN. It does not really talk about what
this limitation for example. It would be great to have some High-Level Design
Guide that talk more extensively about the different types of User VMs: i.e.
pre-launched, post-launched and RTVM vs. "normal" User VMs.

Is this something we can plan to add?

Thanks,
Geoffroy



Thanks,
Like

-----Original Message-----
From: acrn-users@lists.projectacrn.org
<acrn-users@lists.projectacrn.org> On Behalf Of Tomasz Bursztyka
Sent: Wednesday, April 29, 2020 2:37 PM
To: acrn-users@lists.projectacrn.org
Subject: Re: [acrn-users] HPET and IRQs

Hi Like,

VM or RT VM, I don't know. It did not occur to me there was an
actual difference, I just used the launcher script for zephyr. I'll check.

I could get LAPIC (which we indeed call LOAPIC) to work using --
lapic_pt option to acrn-dm. But then I am unable to
stop/reset/delete the VM for some reason (even with --force on stop, it
always returns -1).

I'll still investigate about HPET. It "should" work, and if Zephyr
is missing some support - runtime calibration that is - then it will
be worth
adding it.

Thanks for the inputs,

Tomasz






Tomasz Bursztyka
 

Hi Zide,

From which log? From kernel's one at least I get this:
[ 0.000000] tsc: Detected 1094.000 MHz processor
[ 0.000054] tsc: Detected 1094.400 MHz TSC, current tsc:18670612749

So far my attempts to tweak the sys clock config option did not change
the result.

Br,

Tomasz

Hi Tomasz,

Additional to Like's comments, to calibrate the timer, if you have
serial HV console, you can get the TSC frequency from the log. For
example:
calibrate_tsc, tsc_khz=1593600

Then you need to change the Zephyr code accordingly. In this example,
set CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=1593600000
https://github.com/zephyrproject-rtos/zephyr/blob/master/boards/x86/acrn/acrn_defconfig#L13

Best Regards,
Zide

-----Original Message-----
From: acrn-users@lists.projectacrn.org <
acrn-users@lists.projectacrn.org> On Behalf Of Tomasz Bursztyka
Sent: Tuesday, April 28, 2020 5:19 AM
To: acrn-users@lists.projectacrn.org
Subject: [acrn-users] HPET and IRQs

Hi,

I am currently trying to fix an issue with Zephyr running as UOS.

The default configuration of Zephyr for acrn enables the LOAPIC
timer,
but there does not seem to be any mention of such timer in acrn.
Unless
I am missing something.
When running zephyr with such timer, the timing get all bogus. 60
seconds looks like 5 seconds, etc... Timings are all off.

As HPET is supported by acrn, I switched the timer to HPET. But now
I
have a new issue, acrn-dm displays:

hpet t0 configured invalid irq 2, allowed_irqs 0xff000000

And nothing proceeds, since acrn defaults to 0, zephyr isr for hpet
is
never called.

Indeed Zephyr sets HPET IRQ to 2, which seems to be wrong then for
acrn
.

Which IRQ should HPET timer be configured to use on UOS side then?


Thanks,

Tomasz