From patchwork Fri Oct 27 08:34:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10029397 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 20F9C6039A for ; Fri, 27 Oct 2017 08:37:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FAE128F50 for ; Fri, 27 Oct 2017 08:37:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 049E328F5E; Fri, 27 Oct 2017 08:37:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9ECDE28F50 for ; Fri, 27 Oct 2017 08:37:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752343AbdJ0IhU (ORCPT ); Fri, 27 Oct 2017 04:37:20 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:51174 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752438AbdJ0Igc (ORCPT ); Fri, 27 Oct 2017 04:36:32 -0400 Received: by mail-lf0-f65.google.com with SMTP id a132so6539936lfa.7 for ; Fri, 27 Oct 2017 01:36:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Vi0mN+F7zMygpUrEWZSjEJcyjo94sxpjBVC7qtHzlv8=; b=AMQJ3e6RtW6Qwz7i8ftFm29KlC4/xLfcHmIaK/dI62jXbFWgymOK6HDolOjH6TeExz gTQ0szB1nJykVlB35o484BaFsmlvA+mw0kGyQxXg+0KP4c1PPrnOvaLcS2xjdU11a4PT qPvor190Ywqbj+eu7goRDoLltQ06g0JjDSP88= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Vi0mN+F7zMygpUrEWZSjEJcyjo94sxpjBVC7qtHzlv8=; b=KU1KwBYva9UYCNEDrQBcwutqukfcrOtqjnoJKEUqHc0aaWskj0w+kMK1dBr0ven++k nm1I4HWXRBOLGDpPMY7dbU5cXWVblcoHu+Dfw3MlHQPw886ePHs/I9dFPLyGB/maIFH8 zBoCyvIOkkC+EOw61C7TdQukpbxS34D64M+vhMNXtG+G8l/CSXhN3pV3jgSd7NA3OA4+ Mk8jJO3DwWF4yiW1o0GZGS3dG2JnfSqkQCcdXnSPHirHLSiLTAAd1twcEx/OMkA3vAYe IVVe5OtWtf4bSIp1lZOfnQOJuqIiKrs9565DYoD1ppOeIAJKTPJ7Z49XQ95sGalnMrvT dpKw== X-Gm-Message-State: AMCzsaUQ9RxiFON32MMWN9N7/wz2hoLuvnw2evfbTaj3wHEGZExKsvva inXrWOE7ah73THERvJU5qNOElQ== X-Google-Smtp-Source: ABhQp+SeuXl/UmFdn67e8WRgFA2NJ9r56EKp938y9SxsBCaXGt2H8qbolWcYF7LQiNXORhmEhgXb4A== X-Received: by 10.25.92.21 with SMTP id q21mr8675649lfb.141.1509093390746; Fri, 27 Oct 2017 01:36:30 -0700 (PDT) Received: from localhost.localdomain (212.27.17.163.bredband.3.dk. [212.27.17.163]) by smtp.gmail.com with ESMTPSA id d204sm1471957lfe.73.2017.10.27.01.36.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Oct 2017 01:36:29 -0700 (PDT) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Cc: Marc Zyngier , Eric Auger , kvm@vger.kernel.org, Catalin Marinas , Will Deacon , Christoffer Dall Subject: [PATCH v5 17/20] KVM: arm/arm64: Move phys_timer_emulate function Date: Fri, 27 Oct 2017 10:34:38 +0200 Message-Id: <1509093281-15225-18-git-send-email-cdall@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509093281-15225-1-git-send-email-cdall@linaro.org> References: <1509093281-15225-1-git-send-email-cdall@linaro.org> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We are about to call phys_timer_emulate() from kvm_timer_update_state() and modify phys_timer_emulate() at the same time. Moving the function and modifying it in a single patch makes the diff hard to read, so do this separately first. No functional change. Signed-off-by: Christoffer Dall Acked-by: Marc Zyngier --- virt/kvm/arm/arch_timer.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index d1a6fb1..7f4f12d 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -255,6 +255,22 @@ static void kvm_timer_update_irq(struct kvm_vcpu *vcpu, bool new_level, } } +/* Schedule the background timer for the emulated timer. */ +static void phys_timer_emulate(struct kvm_vcpu *vcpu, + struct arch_timer_context *timer_ctx) +{ + struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; + + if (kvm_timer_should_fire(timer_ctx)) + return; + + if (!kvm_timer_irq_can_fire(timer_ctx)) + return; + + /* The timer has not yet expired, schedule a background timer */ + soft_timer_start(&timer->phys_timer, kvm_timer_compute_delta(timer_ctx)); +} + /* * Check if there was a change in the timer state (should we raise or lower * the line level to the GIC). @@ -281,22 +297,6 @@ static void kvm_timer_update_state(struct kvm_vcpu *vcpu) kvm_timer_update_irq(vcpu, !ptimer->irq.level, ptimer); } -/* Schedule the background timer for the emulated timer. */ -static void phys_timer_emulate(struct kvm_vcpu *vcpu, - struct arch_timer_context *timer_ctx) -{ - struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; - - if (kvm_timer_should_fire(timer_ctx)) - return; - - if (!kvm_timer_irq_can_fire(timer_ctx)) - return; - - /* The timer has not yet expired, schedule a background timer */ - soft_timer_start(&timer->phys_timer, kvm_timer_compute_delta(timer_ctx)); -} - static void vtimer_save_state(struct kvm_vcpu *vcpu) { struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu;