All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ulrich Obergfell <uobergfe@redhat.com>
To: qemu-devel@nongnu.org
Cc: kvm@vger.kernel.org, uobergfe@redhat.com, gcosta@redhat.com,
	avi@redhat.com, mtosatti@redhat.com, zamsden@redhat.com,
	aliguori@us.ibm.com, jan.kiszka@siemens.com
Subject: [PATCH v5 3/5] hpet 'driftfix': add fields to HPETTimer and VMStateDescription
Date: Fri, 20 May 2011 09:13:21 +0200	[thread overview]
Message-ID: <1305875603-3104-4-git-send-email-uobergfe@redhat.com> (raw)
In-Reply-To: <1305875603-3104-1-git-send-email-uobergfe@redhat.com>

The new fields in HPETTimer are covered by a separate VMStateDescription
which is a subsection of 'vmstate_hpet_timer'. They are only migrated if

    -global hpet.driftfix=on

Signed-off-by: Ulrich Obergfell <uobergfe@redhat.com>
---
 hw/hpet.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/hw/hpet.c b/hw/hpet.c
index 7513065..dba9370 100644
--- a/hw/hpet.c
+++ b/hw/hpet.c
@@ -55,6 +55,19 @@ typedef struct HPETTimer {  /* timers */
     uint8_t wrap_flag;      /* timer pop will indicate wrap for one-shot 32-bit
                              * mode. Next pop will be actual timer expiration.
                              */
+    /* driftfix state */
+    uint64_t prev_period;            /* needed when the guest o/s changes the
+                                      * comparator value */
+    uint64_t ticks_not_accounted;    /* ticks for which no interrupts have been
+                                      * delivered to the guest o/s yet */
+    uint32_t irq_rate;               /* rate at which interrupts are delivered
+                                      * to the guest o/s during one period
+                                      * interval; if rate is greater than 1,
+                                      * additional interrupts are delivered
+                                      * to compensate missed interrupts */
+    uint32_t divisor;                /* needed to determine when the next
+                                      * timer callback should occur while
+                                      * rate is greater than 1 */
 } HPETTimer;
 
 typedef struct HPETState {
@@ -246,6 +259,27 @@ static int hpet_post_load(void *opaque, int version_id)
     return 0;
 }
 
+static bool hpet_timer_driftfix_vmstate_needed(void *opaque)
+{
+    HPETTimer *t = opaque;
+
+    return (t->state->driftfix != 0);
+}
+
+static const VMStateDescription vmstate_hpet_timer_driftfix = {
+    .name = "hpet_timer_driftfix",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields      = (VMStateField []) {
+        VMSTATE_UINT64(prev_period, HPETTimer),
+        VMSTATE_UINT64(ticks_not_accounted, HPETTimer),
+        VMSTATE_UINT32(irq_rate, HPETTimer),
+        VMSTATE_UINT32(divisor, HPETTimer),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 static const VMStateDescription vmstate_hpet_timer = {
     .name = "hpet_timer",
     .version_id = 1,
@@ -260,6 +294,14 @@ static const VMStateDescription vmstate_hpet_timer = {
         VMSTATE_UINT8(wrap_flag, HPETTimer),
         VMSTATE_TIMER(qemu_timer, HPETTimer),
         VMSTATE_END_OF_LIST()
+    },
+    .subsections = (VMStateSubsection []) {
+        {
+            .vmsd = &vmstate_hpet_timer_driftfix,
+            .needed = hpet_timer_driftfix_vmstate_needed,
+        }, {
+            /* empty */
+        }
     }
 };
 
-- 
1.6.2.5


WARNING: multiple messages have this Message-ID
From: Ulrich Obergfell <uobergfe@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com, mtosatti@redhat.com, kvm@vger.kernel.org,
	jan.kiszka@siemens.com, zamsden@redhat.com, uobergfe@redhat.com,
	gcosta@redhat.com, avi@redhat.com
Subject: [Qemu-devel] [PATCH v5 3/5] hpet 'driftfix': add fields to HPETTimer and VMStateDescription
Date: Fri, 20 May 2011 09:13:21 +0200	[thread overview]
Message-ID: <1305875603-3104-4-git-send-email-uobergfe@redhat.com> (raw)
In-Reply-To: <1305875603-3104-1-git-send-email-uobergfe@redhat.com>

The new fields in HPETTimer are covered by a separate VMStateDescription
which is a subsection of 'vmstate_hpet_timer'. They are only migrated if

    -global hpet.driftfix=on

Signed-off-by: Ulrich Obergfell <uobergfe@redhat.com>
---
 hw/hpet.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/hw/hpet.c b/hw/hpet.c
index 7513065..dba9370 100644
--- a/hw/hpet.c
+++ b/hw/hpet.c
@@ -55,6 +55,19 @@ typedef struct HPETTimer {  /* timers */
     uint8_t wrap_flag;      /* timer pop will indicate wrap for one-shot 32-bit
                              * mode. Next pop will be actual timer expiration.
                              */
+    /* driftfix state */
+    uint64_t prev_period;            /* needed when the guest o/s changes the
+                                      * comparator value */
+    uint64_t ticks_not_accounted;    /* ticks for which no interrupts have been
+                                      * delivered to the guest o/s yet */
+    uint32_t irq_rate;               /* rate at which interrupts are delivered
+                                      * to the guest o/s during one period
+                                      * interval; if rate is greater than 1,
+                                      * additional interrupts are delivered
+                                      * to compensate missed interrupts */
+    uint32_t divisor;                /* needed to determine when the next
+                                      * timer callback should occur while
+                                      * rate is greater than 1 */
 } HPETTimer;
 
 typedef struct HPETState {
@@ -246,6 +259,27 @@ static int hpet_post_load(void *opaque, int version_id)
     return 0;
 }
 
+static bool hpet_timer_driftfix_vmstate_needed(void *opaque)
+{
+    HPETTimer *t = opaque;
+
+    return (t->state->driftfix != 0);
+}
+
+static const VMStateDescription vmstate_hpet_timer_driftfix = {
+    .name = "hpet_timer_driftfix",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields      = (VMStateField []) {
+        VMSTATE_UINT64(prev_period, HPETTimer),
+        VMSTATE_UINT64(ticks_not_accounted, HPETTimer),
+        VMSTATE_UINT32(irq_rate, HPETTimer),
+        VMSTATE_UINT32(divisor, HPETTimer),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 static const VMStateDescription vmstate_hpet_timer = {
     .name = "hpet_timer",
     .version_id = 1,
@@ -260,6 +294,14 @@ static const VMStateDescription vmstate_hpet_timer = {
         VMSTATE_UINT8(wrap_flag, HPETTimer),
         VMSTATE_TIMER(qemu_timer, HPETTimer),
         VMSTATE_END_OF_LIST()
+    },
+    .subsections = (VMStateSubsection []) {
+        {
+            .vmsd = &vmstate_hpet_timer_driftfix,
+            .needed = hpet_timer_driftfix_vmstate_needed,
+        }, {
+            /* empty */
+        }
     }
 };
 
-- 
1.6.2.5

  parent reply	other threads:[~2011-05-20  7:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-20  7:13 [PATCH v5 0/5] hpet 'driftfix': alleviate time drift with HPET periodic timers Ulrich Obergfell
2011-05-20  7:13 ` [Qemu-devel] " Ulrich Obergfell
2011-05-20  7:13 ` [PATCH v5 1/5] hpet 'driftfix': add hooks required to detect coalesced interrupts (x86 apic only) Ulrich Obergfell
2011-05-20  7:13   ` [Qemu-devel] " Ulrich Obergfell
2011-05-20  7:13 ` [PATCH v5 2/5] hpet 'driftfix': add driftfix property to HPETState and DeviceInfo Ulrich Obergfell
2011-05-20  7:13   ` [Qemu-devel] " Ulrich Obergfell
2011-05-20  7:13 ` Ulrich Obergfell [this message]
2011-05-20  7:13   ` [Qemu-devel] [PATCH v5 3/5] hpet 'driftfix': add fields to HPETTimer and VMStateDescription Ulrich Obergfell
2011-05-20  7:13 ` [PATCH v5 4/5] hpet 'driftfix': add code in update_irq() to detect coalesced interrupts (x86 apic only) Ulrich Obergfell
2011-05-20  7:13   ` [Qemu-devel] " Ulrich Obergfell
2011-05-20  7:13 ` [PATCH v5 5/5] hpet 'driftfix': add code in hpet_timer() to compensate delayed callbacks and coalesced interrupts Ulrich Obergfell
2011-05-20  7:13   ` [Qemu-devel] " Ulrich Obergfell

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=1305875603-3104-4-git-send-email-uobergfe@redhat.com \
    --to=uobergfe@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=avi@redhat.com \
    --cc=gcosta@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=zamsden@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.