From nobody Tue Feb 10 06:27:36 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; dkim=fail; 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 1518407244434114.34997344716237; Sun, 11 Feb 2018 19:47:24 -0800 (PST) Received: from localhost ([::1]:34112 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1el55P-0003vh-Gv for importer@patchew.org; Sun, 11 Feb 2018 22:47:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45015) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1el4zO-0007jW-A4 for qemu-devel@nongnu.org; Sun, 11 Feb 2018 22:41:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1el4zL-0006Be-C8 for qemu-devel@nongnu.org; Sun, 11 Feb 2018 22:41:10 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:49155) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1el4zK-00068D-Pi; Sun, 11 Feb 2018 22:41:07 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3zfrzt5gt9z9t3m; Mon, 12 Feb 2018 14:40:58 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1518406858; bh=+JybuRhAidvl5vpjurSmS63KCg9ZTzG6HT6IEyK0rhk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XsZC9M4Swmp7b+KjIaVZH+bpGd9h2n8N1++jeb3oLCp+tcwVLA1m/Rqf2HFWtUoHL hIdbnY8QjVD19V0n4Nv6W/TdQn+y9HPct7AhiK2fNY64cFK535O/uQn5bWf9vNAAKc XdlAhFnQ12rn5JwQYkCcCyBgCcgmjGtdeYVnL8ko= From: David Gibson To: peter.maydell@linaro.org Date: Mon, 12 Feb 2018 14:40:50 +1100 Message-Id: <20180212034054.23441-9-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180212034054.23441-1-david@gibson.dropbear.id.au> References: <20180212034054.23441-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 08/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: , Cc: lvivier@redhat.com, mark.cave-ayland@ilande.co.uk, groug@kaod.org, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Mark Cave-Ayland Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: David Gibson --- 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 d4a52fbddb..729905236c 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.14.3