From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8BF90C433F5 for ; Tue, 12 Apr 2022 13:17:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2a1aJj3naj8mrC/VWycpuvlAyYfLOyEuinRwU4k5Vb0=; b=WHcBYT5+e5HzX3 EMYKESD+sNqxx2zxw73vfOSAL05H/SU+Tk0YMRAk91+TJb/OH5vzatWtJGZzMVWIBJZb0rPVy3p+N mSu37w64bBRnN/c+xv/fcvJQkLI8plhw4fT5xCku8iQ5rbuzaXh7qxvyu1xv/myyVvKqO9BVhDTnI qexn+zsBdVQRx08UhnbKRthrlwkKXVP4aUxsWzS2sxf8cFznVXxEciOx6JkkysxB/2lP+RQo6pJiq gKJ7TLAY0yRaiU4HcqT2jMq8oLbWhglmuAeidodl39RwQJbH08kaXlHwcxM7TGtMTii2KydU4GxRz sTWrUIqKwQe0trJW8A2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1neGNT-00EUVx-9O; Tue, 12 Apr 2022 13:16:15 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1neGLG-00ETTz-Ok for linux-arm-kernel@lists.infradead.org; Tue, 12 Apr 2022 13:14:02 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8324AB81D07; Tue, 12 Apr 2022 13:13:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 124A3C385AD; Tue, 12 Apr 2022 13:13:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649769234; bh=oQRTKlELBR9tC/Xp7BPIS5voj097Bi1ZLaUJHVChP6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=axgCf/Y+uEov9odiuV3T5IncomHJYx0lWYKa0imV7kiy3lxDKvsMKquP/kLKixmmW RjXKYAmBwQQGEbAsszXM80ruru3tB+KJmbHidxhbRKO8S+WS4Rh0QzJwzvoENLXLCl U3LFcoe/t/RV+AEm3UVNmASBzBrDqjJ8Ksls/lJrPbQyy/NZo+DxiYUajpxoJ1A01u BArj+3HmswBAa9z94mCkz+0O9f9Xdczppw8/SJPfpyHp8ixgUgsBtyMtf0uYlh72PL FXquJTYXSehRlYyV9lIyHgWLLUzn7aw3rPHnu1CtqiO4ZCWY+UNLeMPi2sgi8RKQpl KsLO3ObeIf07w== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1neGLA-003mvX-0z; Tue, 12 Apr 2022 14:13:52 +0100 From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Mark Rutland , James Morse , Suzuki K Poulose , Alexandru Elisei , kernel-team@android.com Subject: [PATCH 04/10] KVM: arm64: Introduce kvm_counter_compute_delta() helper Date: Tue, 12 Apr 2022 14:12:57 +0100 Message-Id: <20220412131303.504690-5-maz@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220412131303.504690-1-maz@kernel.org> References: <20220412131303.504690-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, james.morse@arm.com, suzuki.poulose@arm.com, alexandru.elisei@arm.com, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220412_061359_076160_B7B4D860 X-CRM114-Status: GOOD ( 13.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Refactor kvm_timer_compute_delta() and extract a helper that compute the delta (in ns) between a given timer and an arbitrary value. No functional change expected. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/arch_timer.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c index 16dda1a383a6..c92a68190f6a 100644 --- a/arch/arm64/kvm/arch_timer.c +++ b/arch/arm64/kvm/arch_timer.c @@ -208,18 +208,16 @@ static irqreturn_t kvm_arch_timer_handler(int irq, void *dev_id) return IRQ_HANDLED; } -static u64 kvm_timer_compute_delta(struct arch_timer_context *timer_ctx) +static u64 kvm_counter_compute_delta(struct arch_timer_context *timer_ctx, + u64 val) { - u64 cval, now; - - cval = timer_get_cval(timer_ctx); - now = kvm_phys_timer_read() - timer_get_offset(timer_ctx); + u64 now = kvm_phys_timer_read() - timer_get_offset(timer_ctx); - if (now < cval) { + if (now < val) { u64 ns; ns = cyclecounter_cyc2ns(timecounter->cc, - cval - now, + val - now, timecounter->mask, &timecounter->frac); return ns; @@ -228,6 +226,11 @@ static u64 kvm_timer_compute_delta(struct arch_timer_context *timer_ctx) return 0; } +static u64 kvm_timer_compute_delta(struct arch_timer_context *timer_ctx) +{ + return kvm_counter_compute_delta(timer_ctx, timer_get_cval(timer_ctx)); +} + static bool kvm_timer_irq_can_fire(struct arch_timer_context *timer_ctx) { WARN_ON(timer_ctx && timer_ctx->loaded); -- 2.34.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel