From patchwork Fri Mar 13 17:02:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 45798 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f200.google.com (mail-we0-f200.google.com [74.125.82.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 360EC214BF for ; Fri, 13 Mar 2015 17:03:21 +0000 (UTC) Received: by wesq59 with SMTP id q59sf17661453wes.1 for ; Fri, 13 Mar 2015 10:03:20 -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:cc:subject:date:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=9In5CQ44HxPh1CeHB6bLFdAYpcsnKV2g/tejAiYzYlE=; b=SXZ0rGY/0o7hyx87QrD10Ce+PWtUW4QWGdfZfSfyMWuySNDcoGDaryjWp3j6SpKNZi xH1hna87q5NGrq9NLVAjN0qPXGbkkVYLPqAUF+rY5xEuGUCAaiA/bXixuMLZDWTld4t/ kL+bRScUmX/jcFJXaNPZW+dCIqqQjyZ7KOvocANWMmDZVHrkR+Pi30ur655yCHbZ58/v M6h9NOlJhwuyLxGH3GN6/yGJLQ19+Ss3ZMwMujtr6rCX3XMbYqSR8putPMl6lGijhUXS jJvO43+XLbF5XNPjXXdQQbOdJxX7CYiiE3ysoybQXKtxmKPutj6rUzqdc66dh9lNLUC8 4VQA== X-Gm-Message-State: ALoCoQkn8MTXRCk8R2NOp/0oqSe0sqP6bLRvxpi4lfrW5m1y0OLcbWdLlaBIi6ad7R/PczsJPtTJ X-Received: by 10.180.208.12 with SMTP id ma12mr5173766wic.6.1426266200509; Fri, 13 Mar 2015 10:03:20 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.137 with SMTP id s9ls439480las.72.gmail; Fri, 13 Mar 2015 10:03:20 -0700 (PDT) X-Received: by 10.112.114.164 with SMTP id jh4mr44345038lbb.21.1426266200314; Fri, 13 Mar 2015 10:03:20 -0700 (PDT) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id s1si1800432lbh.13.2015.03.13.10.03.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Mar 2015 10:03:20 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by labgd6 with SMTP id gd6so23947340lab.3 for ; Fri, 13 Mar 2015 10:03:20 -0700 (PDT) X-Received: by 10.112.130.100 with SMTP id od4mr21489458lbb.86.1426266200208; Fri, 13 Mar 2015 10:03:20 -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.35.133 with SMTP id h5csp1048067lbj; Fri, 13 Mar 2015 10:03:19 -0700 (PDT) X-Received: by 10.66.100.138 with SMTP id ey10mr99288756pab.142.1426266198408; Fri, 13 Mar 2015 10:03:18 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id pq9si5074706pdb.223.2015.03.13.10.03.17; Fri, 13 Mar 2015 10:03:18 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753488AbbCMRDL (ORCPT + 28 others); Fri, 13 Mar 2015 13:03:11 -0400 Received: from static.88-198-71-155.clients.your-server.de ([88.198.71.155]:45954 "EHLO socrates.bennee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750774AbbCMRDI (ORCPT ); Fri, 13 Mar 2015 13:03:08 -0400 Received: from localhost ([127.0.0.1] helo=zen.linaroharston) by socrates.bennee.com with esmtp (Exim 4.80) (envelope-from ) id 1YWU0y-0006Tj-4L; Fri, 13 Mar 2015 19:08:52 +0100 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org, marc.zyngier@arm.com Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Gleb Natapov , Paolo Bonzini , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 2/5] arm/arm64: KVM: add a common vgic_queue_irq_to_lr fn Date: Fri, 13 Mar 2015 17:02:53 +0000 Message-Id: <1426266176-14933-3-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.3.2 In-Reply-To: <1426266176-14933-1-git-send-email-alex.bennee@linaro.org> References: <1426266176-14933-1-git-send-email-alex.bennee@linaro.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: alex.bennee@linaro.org X-SA-Exim-Scanned: No (on socrates.bennee.com); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: alex.bennee@linaro.org 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.47 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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This helps re-factor away some of the repetitive code and makes the code flow more nicely. Signed-off-by: Alex Bennée --- v3 - Move to before the un-queue active patch diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index 0cc6ab6..6682d58 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -949,6 +949,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. @@ -976,8 +990,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; } } @@ -994,11 +1007,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; }