From nobody Tue Feb 10 12:58:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518202597786125.52347351887215; Fri, 9 Feb 2018 10:56:37 -0800 (PST) Received: from localhost ([::1]:56920 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekDqZ-0004sG-UG for importer@patchew.org; Fri, 09 Feb 2018 13:56:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43374) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekDmF-0001Kj-Rb for qemu-devel@nongnu.org; Fri, 09 Feb 2018 13:52:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ekDmD-0004dG-OO for qemu-devel@nongnu.org; Fri, 09 Feb 2018 13:52:03 -0500 Received: from chuckie.co.uk ([82.165.15.123]:49626 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ekDmD-0004cu-JA; Fri, 09 Feb 2018 13:52:01 -0500 Received: from host109-156-184-151.range109-156.btcentralplus.com ([109.156.184.151] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1ekDmO-0004RR-Ul; Fri, 09 Feb 2018 18:52:13 +0000 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, david@gibson.dropbear.id.au, lvivier@redhat.com Date: Fri, 9 Feb 2018 18:51:36 +0000 Message-Id: <20180209185142.17151-7-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180209185142.17151-1-mark.cave-ayland@ilande.co.uk> References: <20180209185142.17151-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 109.156.184.151 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCHv2 06/12] cuda: minor cosmetic tidy-ups to get_next_irq_time() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 232b7f61aa..408858e688 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); } =20 -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; =20 /* current counter value */ - d =3D muldiv64(current_time - s->load_time, + d =3D 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 <=3D (s->counter_value + 1)) { - counter =3D (s->counter_value - d) & 0xffff; + if (d <=3D (ti->counter_value + 1)) { + counter =3D (ti->counter_value - d) & 0xffff; } else { - counter =3D (d - (s->counter_value + 1)) % (s->latch + 2); - counter =3D (s->latch - counter) & 0xffff; + counter =3D (d - (ti->counter_value + 1)) % (ti->latch + 2); + counter =3D (ti->latch - counter) & 0xffff; } =20 /* Note: we consider the irq is raised on 0 */ if (counter =3D=3D 0xffff) { - next_time =3D d + s->latch + 1; + next_time =3D d + ti->latch + 1; } else if (counter =3D=3D 0) { - next_time =3D d + s->latch + 2; + next_time =3D d + ti->latch + 2; } else { next_time =3D d + counter; } CUDA_DPRINTF("latch=3D%d counter=3D%" PRId64 " delta_next=3D%" PRId64 = "\n", - s->latch, d, next_time - d); + ti->latch, d, next_time - d); next_time =3D muldiv64(next_time, NANOSECONDS_PER_SECOND, CUDA_TIMER_F= REQ) + - s->load_time; - if (next_time <=3D current_time) + ti->load_time; + if (next_time <=3D current_time) { next_time =3D current_time + 1; + } return next_time; } =20 --=20 2.11.0