All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
To: qemu-devel@nongnu.org, lvivier@redhat.com
Subject: [Qemu-devel] [PATCH 06/10] cuda: minor cosmetic tidy-ups to get_next_irq_time()
Date: Sat,  3 Feb 2018 10:37:23 +0000	[thread overview]
Message-ID: <20180203103727.26457-7-mark.cave-ayland@ilande.co.uk> (raw)
In-Reply-To: <20180203103727.26457-1-mark.cave-ayland@ilande.co.uk>

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/misc/macio/cuda.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c
index a200320e7d..3336ed46b2 100644
--- a/hw/misc/macio/cuda.c
+++ b/hw/misc/macio/cuda.c
@@ -184,36 +184,37 @@ static void set_counter(CUDAState *s, CUDATimer *ti, unsigned int val)
     cuda_timer_update(s, ti, ti->load_time);
 }
 
-static int64_t get_next_irq_time(CUDATimer *s, int64_t current_time)
+static int64_t get_next_irq_time(CUDATimer *ti, int64_t current_time)
 {
     int64_t d, next_time;
     unsigned int counter;
 
     /* current counter value */
-    d = muldiv64(current_time - s->load_time,
+    d = muldiv64(current_time - ti->load_time,
                  CUDA_TIMER_FREQ, NANOSECONDS_PER_SECOND);
     /* the timer goes down from latch to -1 (period of latch + 2) */
-    if (d <= (s->counter_value + 1)) {
-        counter = (s->counter_value - d) & 0xffff;
+    if (d <= (ti->counter_value + 1)) {
+        counter = (ti->counter_value - d) & 0xffff;
     } else {
-        counter = (d - (s->counter_value + 1)) % (s->latch + 2);
-        counter = (s->latch - counter) & 0xffff;
+        counter = (d - (ti->counter_value + 1)) % (ti->latch + 2);
+        counter = (ti->latch - counter) & 0xffff;
     }
 
     /* Note: we consider the irq is raised on 0 */
     if (counter == 0xffff) {
-        next_time = d + s->latch + 1;
+        next_time = d + ti->latch + 1;
     } else if (counter == 0) {
-        next_time = d + s->latch + 2;
+        next_time = d + ti->latch + 2;
     } else {
         next_time = d + counter;
     }
     CUDA_DPRINTF("latch=%d counter=%" PRId64 " delta_next=%" PRId64 "\n",
-                 s->latch, d, next_time - d);
+                 ti->latch, d, next_time - d);
     next_time = muldiv64(next_time, NANOSECONDS_PER_SECOND, CUDA_TIMER_FREQ) +
-        s->load_time;
-    if (next_time <= current_time)
+                         ti->load_time;
+    if (next_time <= current_time) {
         next_time = current_time + 1;
+    }
     return next_time;
 }
 
-- 
2.11.0

  parent reply	other threads:[~2018-02-03 10:37 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-03 10:37 [Qemu-devel] [PATCH 00/10] cuda: various fixes, and move 6522 to separate device Mark Cave-Ayland
2018-02-03 10:37 ` [Qemu-devel] [PATCH 01/10] cuda: do not use old_mmio accesses Mark Cave-Ayland
2018-02-05 14:17   ` Laurent Vivier
2018-02-06 21:40     ` Mark Cave-Ayland
2018-02-03 10:37 ` [Qemu-devel] [PATCH 02/10] cuda: don't allow writes to port output pins Mark Cave-Ayland
2018-02-05 14:27   ` Laurent Vivier
2018-02-05 19:53   ` Philippe Mathieu-Daudé
2018-02-03 10:37 ` [Qemu-devel] [PATCH 03/10] cuda: don't call cuda_update() when writing to ACR register Mark Cave-Ayland
2018-02-03 10:37 ` [Qemu-devel] [PATCH 04/10] cuda: introduce CUDAState parameter to get_counter() Mark Cave-Ayland
2018-02-05 19:44   ` Philippe Mathieu-Daudé
2018-02-03 10:37 ` [Qemu-devel] [PATCH 05/10] cuda: rename frequency property to tb_frequency Mark Cave-Ayland
2018-02-05 19:45   ` Philippe Mathieu-Daudé
2018-02-03 10:37 ` Mark Cave-Ayland [this message]
2018-02-05 19:39   ` [Qemu-devel] [PATCH 06/10] cuda: minor cosmetic tidy-ups to get_next_irq_time() Philippe Mathieu-Daudé
2018-02-03 10:37 ` [Qemu-devel] [PATCH 07/10] cuda: set timer 1 frequency property to CUDA_TIMER_FREQ Mark Cave-Ayland
2018-02-03 10:37 ` [Qemu-devel] [PATCH 08/10] cuda: factor out timebase-derived counter value and load time Mark Cave-Ayland
2018-02-05 19:44   ` Philippe Mathieu-Daudé
2018-02-06 21:44     ` Mark Cave-Ayland
2018-02-03 10:37 ` [Qemu-devel] [PATCH 09/10] misc: introduce new mos6522 VIA device and enable it for ppc builds Mark Cave-Ayland
2018-02-03 10:37 ` [Qemu-devel] [PATCH 10/10] cuda: convert to use the shared mos6522 device Mark Cave-Ayland
2018-02-03 11:11 ` [Qemu-devel] [PATCH 00/10] cuda: various fixes, and move 6522 to separate device no-reply
2018-02-03 11:14   ` Mark Cave-Ayland

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=20180203103727.26457-7-mark.cave-ayland@ilande.co.uk \
    --to=mark.cave-ayland@ilande.co.uk \
    --cc=lvivier@redhat.com \
    --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.