From patchwork Wed Apr 5 09:28:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9663615 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 9B0796021C for ; Wed, 5 Apr 2017 09:57:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8880227F9F for ; Wed, 5 Apr 2017 09:57:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B97D28395; Wed, 5 Apr 2017 09:57:29 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID 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 2E02027F9F for ; Wed, 5 Apr 2017 09:57:29 +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=G6DT3HzI0cuubAUtPFaKGwjHF7Lcvu9A0FaGjgL2QXM=; b=N0/pYwNAsXca8nkgFKfcex7ozC IJxuMSPBxAij8WsmwSYBTCEFzqo5S25V8w+wqaGJzSlCrgUo+b3ygXh5rKTFvVa8p1E3pKdSNe4Yl 6KxHGEmrJGSvg5v1TJu1J6rKm1xMu2gu0ZRLBf1zf8WrBfm7VMeAtFyP+mxPVOpP+mlqhx7olcWqh irer9bPYDvsRVYUoupxOz3VL0M5hYOKU89aXebqnHK5mmc14ebiibZU56PcIkVEcdbwZGtp4U49tF Dxn6yCn97imxFrAJ1C5w5ZJkJpljzX+sPy/KbmIcKZ/ED2YutxcTzIEFfD+8LfSqyQOhymTuHg8tG FkQmQCew==; 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 1cvhgt-0000Cn-4P; Wed, 05 Apr 2017 09:57:27 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cvhgp-0008Fh-Bt for linux-arm-kernel@bombadil.infradead.org; Wed, 05 Apr 2017 09:57:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=j6YjldhjiBNO2F9vObVCDikHvjFLCKjNh1sN0i5ey1E=; b=UzdpMIfcx0ZlBprdjjv6FMdS7 AphhDG62mIVDjEAnBrRa9i9umUytAbC/AXMOEyb1io+qgH7la9I6cglZndaXssFUmhvU57KEM2rYK kySrcia0gHjZVUlMaNQYH+ssgLy46F4NgDOaA6B/tadefl6MHVJh+erhJb71uC5elNFOlVpGrTfOT 8ym7qZ/v/hxwQ9vv+NCXo0UvjRcfyzQFyBCjQI3iQjbRWPq9ud0HuNPC6pln1HdhMIftH9xfo1Zju 9Smy+uGIJ21KmTQPoHV+v/R4mIqFU4Zhuf+q7fNzuD5oyoG34kYKETKnRUwp2+b+o8eLMcQr335Qj 1zK/qtjkA==; Received: from mail-wm0-f43.google.com ([74.125.82.43]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cvhEz-0006vX-T8 for linux-arm-kernel@lists.infradead.org; Wed, 05 Apr 2017 09:28:40 +0000 Received: by mail-wm0-f43.google.com with SMTP id x124so8482787wmf.0 for ; Wed, 05 Apr 2017 02:28:17 -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=j6YjldhjiBNO2F9vObVCDikHvjFLCKjNh1sN0i5ey1E=; b=kjoTRBsPRzRX3M3jj1D4Ey/LyyI70qMdfSUosJzDE7VBmwiTs/2KklKkwvQYbhTcqj XFniw0FJGLUlgEpyeWK7Ypkcw9Y2L0NKxEbAePSRR/p+HK5LIJvgbMqk87pwRAoKREMf 0avqrSCSch7RlHep3DBpQI8J+N4jVbTH9lQYQ= 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=j6YjldhjiBNO2F9vObVCDikHvjFLCKjNh1sN0i5ey1E=; b=YEg+IyaE+81TOCobqdZAl4x4kh5Xto1H35iJxP8rmsd3ikyk1ppr6zKD8mLyQPDuKT 3Gv5vEkkarvGcH3+zwiJyAcUIkg24q3IRCRIqPV4jW8U83FNDrQDmnAs5fEP68tnhj0S Z3hIUDmlDAOmsVTRa923mrgE94Rtm79TQj2vqWUnwSwGZ6GymeXKPYFaLMvar5tZNeU8 2vjcy//GY4NrfaU1dQm2EgfS+/iSMAVOFF8mHn+ddrjbr/7f2s3Ra7F+Dak8nE4oS4sM e2affcy4mcQWYUTTCYzZV71/ajQ0kEeDgswJUe1iNk1bI/ZUNG5SfXZhCCnldG3cIIuj APIw== X-Gm-Message-State: AFeK/H24MekGJ1GHCDnRzMdEF2juh+bQgQlK+H8mF7VtfpFu/2UaIUVM jpmFuAph+XFukRsO X-Received: by 10.28.129.83 with SMTP id c80mr17347872wmd.82.1491384496304; Wed, 05 Apr 2017 02:28:16 -0700 (PDT) Received: from localhost.localdomain (xd93ddc2d.cust.hiper.dk. [217.61.220.45]) by smtp.gmail.com with ESMTPSA id g23sm21578135wme.8.2017.04.05.02.28.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 05 Apr 2017 02:28:15 -0700 (PDT) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 1/5] KVM: arm/arm64: Cleanup the arch timer code's irqchip checking Date: Wed, 5 Apr 2017 11:28:11 +0200 Message-Id: <20170405092815.22503-2-cdall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170405092815.22503-1-cdall@linaro.org> References: <20170405092815.22503-1-cdall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170405_102838_009799_0CC745D7 X-CRM114-Status: GOOD ( 18.62 ) 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: Peter Maydell , kvm@vger.kernel.org, Marc Zyngier , Alexander Graf , Pekka Enberg , Christoffer Dall 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 From: Christoffer Dall Currently we check if we have an in-kernel irqchip and if the vgic was properly implemented several places in the arch timer code. But, we already predicate our enablement of the arm timers on having a valid and initialized gic, so we can simply check if the timers are enabled or not. This also gets rid of the ugly "error that's not an error but used to signal that the timer shouldn't poke the gic" construct we have. Signed-off-by: Christoffer Dall --- virt/kvm/arm/arch_timer.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index 35d7100..363f0d2 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -189,8 +189,6 @@ static void kvm_timer_update_irq(struct kvm_vcpu *vcpu, bool new_level, { int ret; - BUG_ON(!vgic_initialized(vcpu->kvm)); - timer_ctx->active_cleared_last = false; timer_ctx->irq.level = new_level; trace_kvm_timer_update_irq(vcpu->vcpu_id, timer_ctx->irq.irq, @@ -205,7 +203,7 @@ static void kvm_timer_update_irq(struct kvm_vcpu *vcpu, bool new_level, * Check if there was a change in the timer state (should we raise or lower * the line level to the GIC). */ -static int kvm_timer_update_state(struct kvm_vcpu *vcpu) +static void kvm_timer_update_state(struct kvm_vcpu *vcpu) { struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; struct arch_timer_context *vtimer = vcpu_vtimer(vcpu); @@ -217,16 +215,14 @@ static int kvm_timer_update_state(struct kvm_vcpu *vcpu) * because the guest would never see the interrupt. Instead wait * until we call this function from kvm_timer_flush_hwstate. */ - if (!vgic_initialized(vcpu->kvm) || !timer->enabled) - return -ENODEV; + if (!timer->enabled) + return; if (kvm_timer_should_fire(vtimer) != vtimer->irq.level) kvm_timer_update_irq(vcpu, !vtimer->irq.level, vtimer); if (kvm_timer_should_fire(ptimer) != ptimer->irq.level) kvm_timer_update_irq(vcpu, !ptimer->irq.level, ptimer); - - return 0; } /* Schedule the background timer for the emulated timer. */ @@ -295,13 +291,16 @@ void kvm_timer_unschedule(struct kvm_vcpu *vcpu) */ void kvm_timer_flush_hwstate(struct kvm_vcpu *vcpu) { + struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; struct arch_timer_context *vtimer = vcpu_vtimer(vcpu); bool phys_active; int ret; - if (kvm_timer_update_state(vcpu)) + if (unlikely(!timer->enabled)) return; + kvm_timer_update_state(vcpu); + /* Set the background timer for the physical timer emulation. */ kvm_timer_emulate(vcpu, vcpu_ptimer(vcpu));