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: 10029423 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 981E6602D6 for ; Fri, 27 Oct 2017 08:45:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8794128F64 for ; Fri, 27 Oct 2017 08:45:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C80628F68; Fri, 27 Oct 2017 08:45:01 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 07B4328F64 for ; Fri, 27 Oct 2017 08:45:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=6yosYtQeGHJ3WsEK56+Zz4gGzcLdISp39yCrQ+XCQME=; b=qUR0FpwSJBXNtWSdGDFwglK9pi Jiu7v6UXGG4GmDjYK9WgRuFvvR9UfVKVZCUY30+F8VeGXRzHwKq24lGEzBph5oo61tFLM/djoPDFQ GoIMvhjX4cbo6l5QjWNAf5ewj4JNLNGlFdo9d+IT8YJvF1BCRdhZDqfXZBx0K8a3FO8wO/JpbbFbJ NKbKJSiYZpHc0MTMZxgj5ewkFj/RJfyz3IYTxnJ/W6NptxGLZAp3umA/bVHNaHvh2KAEw4ys1+7YW 4asFvTeWPxvVP3P5/AzN+TfvucAIgS0/wDwnaiyZqL6IJDzspuwUJO9bo4Wr2MC2pgH0D0oX+I8j/ 2Ns4ZsaQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e80GB-00061x-8j; Fri, 27 Oct 2017 08:44:59 +0000 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e808K-0000td-FT for linux-arm-kernel@lists.infradead.org; Fri, 27 Oct 2017 08:37:35 +0000 Received: by mail-lf0-x241.google.com with SMTP id k40so6542627lfi.4 for ; Fri, 27 Oct 2017 01:36:32 -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=P4oLCsmvLFaGx75D29LSOb/4YWHUMILoCXiER7aW6Sp6Eyxi6EQwqeyjF5NOYw29TP 5uaZdF6HEkC462hmHYxLCaUwoGhXYq4jju0RGAmxNU0vw1HYD25qgAv44JNMSiOAxHkx CaEjOsAkhtGdUYNQGHNShDW3/j+GEPf01UTpSD6baDyIGAWwfGhefFxRLa62IDofO2ym hSORYDxtu7Biezh3fYtFITOwpwb4MpHK8/9pmRJvB/qDzVZSsgbbv3aV71Y1OzzCOh9I ySStImgTwhSWqOe+Kl4g+1qRatGr8iFKy8yQsoo+xkmtbWf1SWBEWZlPS9KrTCbeJFL0 /rxg== X-Gm-Message-State: AMCzsaU7VSdGKo7pcx0tmNo2lqbsRD+nDMXFndtCp9Jsnx9+oAfLdXhc sL8Cs1H0sDJPkLnwJgJ5iYAwOA== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171027_013653_476834_3B6DECA3 X-CRM114-Status: GOOD ( 12.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christoffer Dall , kvm@vger.kernel.org, Marc Zyngier , Catalin Marinas , Will Deacon , Eric Auger MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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;