* [PATCH 1/2] qemu-kvm: pc: Factor out apic_next_timer
@ 2011-09-08 10:51 Jan Kiszka
2011-09-09 17:05 ` Marcelo Tosatti
0 siblings, 1 reply; 2+ messages in thread
From: Jan Kiszka @ 2011-09-08 10:51 UTC (permalink / raw)
To: Avi Kivity, Marcelo Tosatti; +Cc: kvm
Factor out apic_next_timer from apic_timer_update. The former can then
be used to update next_timer without actually starting the qemu timer.
KVM's in-kernel APIC model will make use of it.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
hw/apic.c | 45 ++++++++++++++++++++++++++++-----------------
1 files changed, 28 insertions(+), 17 deletions(-)
diff --git a/hw/apic.c b/hw/apic.c
index 96173ac..b3044aa 100644
--- a/hw/apic.c
+++ b/hw/apic.c
@@ -661,27 +661,38 @@ static uint32_t apic_get_current_count(APICState *s)
return val;
}
-static void apic_timer_update(APICState *s, int64_t current_time)
+static bool apic_next_timer(APICState *s, int64_t current_time)
{
- int64_t next_time, d;
-
- if (!(s->lvt[APIC_LVT_TIMER] & APIC_LVT_MASKED)) {
- d = (current_time - s->initial_count_load_time) >>
- s->count_shift;
- if (s->lvt[APIC_LVT_TIMER] & APIC_LVT_TIMER_PERIODIC) {
- if (!s->initial_count)
- goto no_timer;
- d = ((d / ((uint64_t)s->initial_count + 1)) + 1) * ((uint64_t)s->initial_count + 1);
- } else {
- if (d >= s->initial_count)
- goto no_timer;
- d = (uint64_t)s->initial_count + 1;
+ int64_t d;
+
+ if (s->lvt[APIC_LVT_TIMER] & APIC_LVT_MASKED) {
+ return false;
+ }
+
+ d = (current_time - s->initial_count_load_time) >> s->count_shift;
+
+ if (s->lvt[APIC_LVT_TIMER] & APIC_LVT_TIMER_PERIODIC) {
+ if (!s->initial_count) {
+ return false;
}
- next_time = s->initial_count_load_time + (d << s->count_shift);
- qemu_mod_timer(s->timer, next_time);
- s->next_time = next_time;
+ d = ((d / ((uint64_t)s->initial_count + 1)) + 1) *
+ ((uint64_t)s->initial_count + 1);
+ } else {
+ if (d >= s->initial_count) {
+ return false;
+ }
+ d = (uint64_t)s->initial_count + 1;
+ }
+ s->next_time = s->initial_count_load_time + (d << s->count_shift);
+
+ return true;
+}
+
+static void apic_timer_update(APICState *s, int64_t current_time)
+{
+ if (apic_next_timer(s, current_time)) {
+ qemu_mod_timer(s->timer, s->next_time);
} else {
- no_timer:
qemu_del_timer(s->timer);
}
}
--
1.7.3.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/2] qemu-kvm: pc: Factor out apic_next_timer
2011-09-08 10:51 [PATCH 1/2] qemu-kvm: pc: Factor out apic_next_timer Jan Kiszka
@ 2011-09-09 17:05 ` Marcelo Tosatti
0 siblings, 0 replies; 2+ messages in thread
From: Marcelo Tosatti @ 2011-09-09 17:05 UTC (permalink / raw)
To: Jan Kiszka; +Cc: Avi Kivity, kvm
On Thu, Sep 08, 2011 at 12:51:31PM +0200, Jan Kiszka wrote:
> Factor out apic_next_timer from apic_timer_update. The former can then
> be used to update next_timer without actually starting the qemu timer.
> KVM's in-kernel APIC model will make use of it.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Applied both, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-09-09 18:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-08 10:51 [PATCH 1/2] qemu-kvm: pc: Factor out apic_next_timer Jan Kiszka
2011-09-09 17:05 ` Marcelo Tosatti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox