From patchwork Thu Apr 2 10:05:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 46718 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 66CEF216D1 for ; Thu, 2 Apr 2015 10:42:26 +0000 (UTC) Received: by lbfb1 with SMTP id b1sf16587459lbf.2 for ; Thu, 02 Apr 2015 03:42:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:mime-version:cc:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=5ftUGsnrfUZ5ydq0//t96tWhU37U/QjmvPudUHCX99U=; b=mFcbkIfCLn0KmRwXDpqw2sMslM2LDYX+BwK41DZZwjOk0xi4vAiPT08uj+XKa2rLIb N36lgi+bdDDtg0oHGlpApJncwGk1LWR6Xmbff3njPom9XmHylXn36F0YKP1fXF7EzfrN /bV6BN8LtX0Ybf8FhogsB7O1GifwUmaFL3t0oFP2TUHxhcSjFJVNwouyMQy/Zz0zmg0D Y0N8KhcM95duYWMl0iIYcdd71LO7BrBoh1FUpyIjejbfDfyx1HnsDazmGvRloWCVgwvG +ovZb9Jl6suH1j/MZycG37At0fDZhLAxcqF222Dfi4ESvVZnzhJtC7fcFVDjY0BFq2Pt thlg== X-Gm-Message-State: ALoCoQkjIPkuoMCGHn2hKKNF3KMeX6xsiKbVPyczp4eW6ef7L7VmrSRybAn4OIiAE1vol9br2MXF X-Received: by 10.112.180.74 with SMTP id dm10mr10831602lbc.11.1427971345282; Thu, 02 Apr 2015 03:42:25 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.9.38 with SMTP id w6ls195238laa.13.gmail; Thu, 02 Apr 2015 03:42:25 -0700 (PDT) X-Received: by 10.152.5.134 with SMTP id s6mr30666410las.6.1427971344980; Thu, 02 Apr 2015 03:42:24 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id j9si3932423lbc.32.2015.04.02.03.42.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Apr 2015 03:42:24 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by lagg8 with SMTP id g8so57083978lag.1 for ; Thu, 02 Apr 2015 03:42:24 -0700 (PDT) X-Received: by 10.152.197.34 with SMTP id ir2mr13447156lac.36.1427971344761; Thu, 02 Apr 2015 03:42:24 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.57.201 with SMTP id k9csp1246404lbq; Thu, 2 Apr 2015 03:42:23 -0700 (PDT) X-Received: by 10.70.94.101 with SMTP id db5mr86493672pdb.62.1427971340910; Thu, 02 Apr 2015 03:42:20 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id oz10si6993511pdb.15.2015.04.02.03.42.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Apr 2015 03:42:20 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YdcWw-0003Wb-9F; Thu, 02 Apr 2015 10:39:22 +0000 Received: from inca-roads.misterjones.org ([213.251.177.50]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YdcLF-0002DV-Et for linux-arm-kernel@lists.infradead.org; Thu, 02 Apr 2015 10:27:18 +0000 Received: from dab-yat1-h-1-5.dab.02.net ([82.132.213.233] helo=why.wild-wind.fr.eu.org) by cheepnis.misterjones.org with esmtpsa (TLSv1.2:AES128-SHA256:128) (Exim 4.80) (envelope-from ) id 1Ydc07-0006QV-KI; Thu, 02 Apr 2015 12:05:27 +0200 From: Marc Zyngier To: Paolo Bonzini , Marcelo Tosatti Subject: [PATCH 13/27] arm/arm64: KVM: add a common vgic_queue_irq_to_lr fn Date: Thu, 2 Apr 2015 11:05:17 +0100 Message-Id: <1427969131-8445-14-git-send-email-marc.zyngier@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1427969131-8445-1-git-send-email-marc.zyngier@arm.com> References: <1427969131-8445-1-git-send-email-marc.zyngier@arm.com> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 82.132.213.233 X-SA-Exim-Rcpt-To: pbonzini@redhat.com, mtosatti@redhat.com, alex.bennee@linaro.org, christoffer.dall@linaro.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, eric.auger@linaro.org, n.nikolaev@virtualopensystems.com, andre.przywara@arm.com X-SA-Exim-Mail-From: marc.zyngier@arm.com X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150402_032717_708058_4C987538 X-CRM114-Status: GOOD ( 12.81 ) X-Spam-Score: 1.6 (+) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (1.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.6 RCVD_IN_SORBS_WEB RBL: SORBS: sender is an abusable web server [82.132.213.233 listed in dnsbl.sorbs.net] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) Cc: Mark Rutland , kvm@vger.kernel.org, Eric Auger , Andre Przywara , Nikolay Nikolaev , Christoffer Dall , =?UTF-8?q?Alex=20Benn=C3=A9e?= , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: marc.zyngier@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Alex Bennée This helps re-factor away some of the repetitive code and makes the code flow more nicely. Signed-off-by: Alex Bennée Signed-off-by: Christoffer Dall --- virt/kvm/arm/vgic.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index c000e97..697ce17 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -950,6 +950,20 @@ static void vgic_retire_disabled_irqs(struct kvm_vcpu *vcpu) } } +static void vgic_queue_irq_to_lr(struct kvm_vcpu *vcpu, int irq, + int lr_nr, struct vgic_lr vlr) +{ + if (vgic_dist_irq_is_pending(vcpu, irq)) { + vlr.state |= LR_STATE_PENDING; + kvm_debug("Set pending: 0x%x\n", vlr.state); + } + + if (!vgic_irq_is_edge(vcpu, irq)) + vlr.state |= LR_EOI_INT; + + vgic_set_lr(vcpu, lr_nr, vlr); +} + /* * Queue an interrupt to a CPU virtual interface. Return true on success, * or false if it wasn't possible to queue it. @@ -977,8 +991,7 @@ bool vgic_queue_irq(struct kvm_vcpu *vcpu, u8 sgi_source_id, int irq) if (vlr.source == sgi_source_id) { kvm_debug("LR%d piggyback for IRQ%d\n", lr, vlr.irq); BUG_ON(!test_bit(lr, vgic_cpu->lr_used)); - vlr.state |= LR_STATE_PENDING; - vgic_set_lr(vcpu, lr, vlr); + vgic_queue_irq_to_lr(vcpu, irq, lr, vlr); return true; } } @@ -995,11 +1008,8 @@ bool vgic_queue_irq(struct kvm_vcpu *vcpu, u8 sgi_source_id, int irq) vlr.irq = irq; vlr.source = sgi_source_id; - vlr.state = LR_STATE_PENDING; - if (!vgic_irq_is_edge(vcpu, irq)) - vlr.state |= LR_EOI_INT; - - vgic_set_lr(vcpu, lr, vlr); + vlr.state = 0; + vgic_queue_irq_to_lr(vcpu, irq, lr, vlr); return true; }