All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	qemu-block@nongnu.org, "Corey Minyard" <minyard@acm.org>,
	"David Hildenbrand" <david@redhat.com>,
	"Andrew Jeffery" <andrew@aj.id.au>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Max Reitz" <mreitz@redhat.com>,
	qemu-arm@nongnu.org, "Joel Stanley" <joel@jms.id.au>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Cédric Le Goater" <clg@kaod.org>
Subject: [PATCH 6/7] hw/ipmi/ipmi_bmc_extern: Reduce timer precision to milli-second
Date: Tue, 16 Jun 2020 09:51:20 +0200	[thread overview]
Message-ID: <20200616075121.12837-7-f4bug@amsat.org> (raw)
In-Reply-To: <20200616075121.12837-1-f4bug@amsat.org>

The current implementation uses nano-second precision, while
the device can not be more precise than a milli-second.
Simplify by using a milli-second based timer.
Rename the timer 'extern_timer_ms' to have the unit explicit.

Inspired-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/ipmi/ipmi_bmc_extern.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c
index f9a13e0a44..441d3ed18e 100644
--- a/hw/ipmi/ipmi_bmc_extern.c
+++ b/hw/ipmi/ipmi_bmc_extern.c
@@ -81,7 +81,7 @@ typedef struct IPMIBmcExtern {
     unsigned int outpos;
     unsigned int outlen;
 
-    struct QEMUTimer *extern_timer;
+    QEMUTimer *extern_timer_ms;
 
     /* A reset event is pending to be sent upstream. */
     bool send_reset;
@@ -112,8 +112,8 @@ static void continue_send(IPMIBmcExtern *ibe)
     }
     if (ibe->outpos < ibe->outlen) {
         /* Not fully transmitted, try again in a 10ms */
-        timer_mod_ns(ibe->extern_timer,
-                     qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 10000000);
+        timer_mod(ibe->extern_timer_ms,
+                  qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 10);
     } else {
         /* Sent */
         ibe->outlen = 0;
@@ -137,8 +137,8 @@ static void continue_send(IPMIBmcExtern *ibe)
 
         if (ibe->waiting_rsp) {
             /* Make sure we get a response within 4 seconds. */
-            timer_mod_ns(ibe->extern_timer,
-                         qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 4000000000ULL);
+            timer_mod(ibe->extern_timer_ms,
+                      qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 4 * 1000);
         }
     }
     return;
@@ -303,7 +303,7 @@ static void handle_msg(IPMIBmcExtern *ibe)
         ibe->inpos--; /* Remove checkum */
     }
 
-    timer_del(ibe->extern_timer);
+    timer_del(ibe->extern_timer_ms);
     ibe->waiting_rsp = false;
     k->handle_rsp(ibe->parent.intf, ibe->inbuf[0], ibe->inbuf + 1, ibe->inpos - 1);
 }
@@ -502,7 +502,8 @@ static void ipmi_bmc_extern_init(Object *obj)
 {
     IPMIBmcExtern *ibe = IPMI_BMC_EXTERN(obj);
 
-    ibe->extern_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, extern_timeout, ibe);
+    ibe->extern_timer_ms = timer_new_ms(QEMU_CLOCK_VIRTUAL,
+                                        extern_timeout, ibe);
     vmstate_register(NULL, 0, &vmstate_ipmi_bmc_extern, ibe);
 }
 
@@ -510,8 +511,8 @@ static void ipmi_bmc_extern_finalize(Object *obj)
 {
     IPMIBmcExtern *ibe = IPMI_BMC_EXTERN(obj);
 
-    timer_del(ibe->extern_timer);
-    timer_free(ibe->extern_timer);
+    timer_del(ibe->extern_timer_ms);
+    timer_free(ibe->extern_timer_ms);
 }
 
 static Property ipmi_bmc_extern_properties[] = {
-- 
2.21.3



  parent reply	other threads:[~2020-06-16  7:54 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-16  7:51 [PATCH 0/7] misc: Reduce QEMUTimer pressure by using lower precision when possible Philippe Mathieu-Daudé
2020-06-16  7:51 ` [PATCH 1/7] qemu-common: Briefly document qemu_timedate_diff() unit Philippe Mathieu-Daudé
2020-06-18  5:47   ` Markus Armbruster
2020-06-22  8:50     ` Philippe Mathieu-Daudé
2020-06-16  7:51 ` [PATCH 2/7] block/qcow2: Document cache_clean_interval field holds seconds Philippe Mathieu-Daudé
2020-06-16  7:51 ` [PATCH 3/7] block/curl: Reduce timer precision to milli-second Philippe Mathieu-Daudé
2020-06-16  7:51 ` [PATCH 4/7] hw/virtio/virtio-balloon: Rename timer field including 'ms' unit Philippe Mathieu-Daudé
2020-06-16  7:57   ` David Hildenbrand
2020-06-16  7:51 ` [PATCH 5/7] hw/rtc/m48t59: Reduce timer precision to milli-second Philippe Mathieu-Daudé
2020-07-08 23:39   ` Richard Henderson
2020-06-16  7:51 ` Philippe Mathieu-Daudé [this message]
2020-06-16  7:51 ` [PATCH 7/7] hw/watchdog/wdt_aspeed: Reduce timer precision to micro-second Philippe Mathieu-Daudé
2020-06-17  1:18   ` Andrew Jeffery
2020-06-17  3:41     ` Philippe Mathieu-Daudé
2020-06-22  0:21       ` Andrew Jeffery
2020-06-22  8:43         ` Philippe Mathieu-Daudé
2020-06-22 23:45           ` Andrew Jeffery
2020-07-08 23:40   ` Richard Henderson
2020-06-18 12:23 ` [PATCH 0/7] misc: Reduce QEMUTimer pressure by using lower precision when possible Paolo Bonzini
2020-06-18 12:26   ` Philippe Mathieu-Daudé
2020-06-18 12:42     ` Paolo Bonzini
2020-07-08 23:37 ` Richard Henderson

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=20200616075121.12837-7-f4bug@amsat.org \
    --to=f4bug@amsat.org \
    --cc=andrew@aj.id.au \
    --cc=clg@kaod.org \
    --cc=david@redhat.com \
    --cc=joel@jms.id.au \
    --cc=kwolf@redhat.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=minyard@acm.org \
    --cc=mreitz@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-block@nongnu.org \
    --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 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.