From patchwork Mon Nov 13 09:17:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10055371 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 98C1060586 for ; Mon, 13 Nov 2017 09:21:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99DAB28EA4 for ; Mon, 13 Nov 2017 09:21:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D338291DC; Mon, 13 Nov 2017 09:21:43 +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 1763F28EA4 for ; Mon, 13 Nov 2017 09:21:43 +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=lmkNDKqYF40o1/nNC8jrSQffTRNx79ccCVXd6FY7Ro8=; b=un/5gCsrdgHrfFq8hEvR23BHnv cyuZ1BGjzdM9dAUy6lk3n6S8qwECzD0iI5uc5CUudh5D68S051U6dSOoPjzSHy5g10Rrhp3okIj6/ GpdV8PI7BeXSBhoSXYvnRKfSVvTppVbW8tlVXCj4SWz1puZDH+W64THH1+1/3ugEZxb41MChBYqvz 0ziugIldfYpzcskilLbKymOJccY8rqyqmUUyG6MKXwDUeKaLNL5cbbW96dueYaqkTrK9+i45A3wxc 3RtJTc2tMkD+FkhIN6pOZAVi/XgMVhKGhKmdKwgJ9AZi7/n8tEJ9p5BPYI4kIy+6QMJGDKH8+DfJ2 hT9nydLA==; 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 1eEAw2-0006MN-2h; Mon, 13 Nov 2017 09:21:42 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eEAt9-0002Mr-VP for linux-arm-kernel@lists.infradead.org; Mon, 13 Nov 2017 09:18:51 +0000 Received: by mail-wm0-x243.google.com with SMTP id r68so13278606wmr.0 for ; Mon, 13 Nov 2017 01:18:25 -0800 (PST) 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=IlBLhVP9WnAFPzSJc47iLQ0zQS1HkVHN0yAhOBKcp80=; b=g9KQ2TfTLBsyPTPnmU5pnA/lv0RfFFWi9fpNPlc0Vi0XwrAb7ky0VT5rHsjkGrrxDG ln7oRxLUYOIUEYxOZNspwc4Vg4Gb9bX8kZu+7Uoq2rtKFPwyEnlMIwcRQNbC2f/hfdHe SrfLNAIl/TKbF4oM1xcaeycU+XTkymoKkh/as= 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=IlBLhVP9WnAFPzSJc47iLQ0zQS1HkVHN0yAhOBKcp80=; b=FEj5TWisAfgzyZHP6118M6tDvwRSZlmOj0WmyadhEv8j8VX1gyzjfRrCv87OcfXIHM YiVnO7MdH36/0Bp9x5/GAMaCKf09q31pars588XQdeUYa1w15uoZ4cynxKWNj9fElX1e dvB9u3hSCZHSSINQVGR/aATUyQWNtKa/qwdLZcFnrf0/SStJLQve9L2E08W0c3NHT1Fy 7L+a45T8JiUBChn3Nhz/KgV7l4haGrSTemoTSNIAGEH550BzXGNJkriwn94f5ZK2bucO 2m8aVbpefY3jz5MZX9Y5JJqc/0rNxDYB4EwKtwN1wRYkeUx0+8B2zmReRX6oS6bGM3v/ IuLg== X-Gm-Message-State: AJaThX4Bhi70FOY7aguk3qNKbr8Raivsw1OfVI6wHiesDV7uFnBGpEBJ LqD4myfNv68PDo+BfhA113offg== X-Google-Smtp-Source: AGs4zMZmU2J56ij8RIzP+7cdnVIyS6ge+oMkJayFrV5kQV0UA9HPuLnp5f/NgpBriRZjouQDSau/RA== X-Received: by 10.28.145.199 with SMTP id t190mr3580576wmd.40.1510564704516; Mon, 13 Nov 2017 01:18:24 -0800 (PST) Received: from localhost.localdomain (xd93dd96b.cust.hiper.dk. [217.61.217.107]) by smtp.gmail.com with ESMTPSA id x63sm9651399wma.39.2017.11.13.01.18.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Nov 2017 01:18:23 -0800 (PST) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL 19/27] KVM: arm/arm64: GICv4: Use the doorbell interrupt as an unblocking source Date: Mon, 13 Nov 2017 10:17:44 +0100 Message-Id: <20171113091752.10663-20-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171113091752.10663-1-christoffer.dall@linaro.org> References: <20171113091752.10663-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171113_011844_450407_EA738A52 X-CRM114-Status: GOOD ( 13.28 ) 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: Marc Zyngier , Christoffer Dall , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org 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: Marc Zyngier The doorbell interrupt is only useful if the vcpu is blocked on WFI. In all other cases, recieving a doorbell interrupt is just a waste of cycles. So let's only enable the doorbell if a vcpu is getting blocked, and disable it when it is unblocked. This is very similar to what we're doing for the background timer. Reviewed-by: Christoffer Dall Reviewed-by: Eric Auger Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- include/kvm/arm_vgic.h | 3 +++ virt/kvm/arm/arm.c | 2 ++ virt/kvm/arm/vgic/vgic-v4.c | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h index 2f750c770bf2..8c896540a72c 100644 --- a/include/kvm/arm_vgic.h +++ b/include/kvm/arm_vgic.h @@ -381,4 +381,7 @@ int kvm_vgic_v4_set_forwarding(struct kvm *kvm, int irq, int kvm_vgic_v4_unset_forwarding(struct kvm *kvm, int irq, struct kvm_kernel_irq_routing_entry *irq_entry); +void kvm_vgic_v4_enable_doorbell(struct kvm_vcpu *vcpu); +void kvm_vgic_v4_disable_doorbell(struct kvm_vcpu *vcpu); + #endif /* __KVM_ARM_VGIC_H */ diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c index 34a15c0c65ab..01e575b9f78b 100644 --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c @@ -315,11 +315,13 @@ int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu) void kvm_arch_vcpu_blocking(struct kvm_vcpu *vcpu) { kvm_timer_schedule(vcpu); + kvm_vgic_v4_enable_doorbell(vcpu); } void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu) { kvm_timer_unschedule(vcpu); + kvm_vgic_v4_disable_doorbell(vcpu); } int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) diff --git a/virt/kvm/arm/vgic/vgic-v4.c b/virt/kvm/arm/vgic/vgic-v4.c index 796e00c77903..1375a53054b9 100644 --- a/virt/kvm/arm/vgic/vgic-v4.c +++ b/virt/kvm/arm/vgic/vgic-v4.c @@ -233,3 +233,21 @@ int kvm_vgic_v4_unset_forwarding(struct kvm *kvm, int virq, mutex_unlock(&its->its_lock); return ret; } + +void kvm_vgic_v4_enable_doorbell(struct kvm_vcpu *vcpu) +{ + if (vgic_supports_direct_msis(vcpu->kvm)) { + int irq = vcpu->arch.vgic_cpu.vgic_v3.its_vpe.irq; + if (irq) + enable_irq(irq); + } +} + +void kvm_vgic_v4_disable_doorbell(struct kvm_vcpu *vcpu) +{ + if (vgic_supports_direct_msis(vcpu->kvm)) { + int irq = vcpu->arch.vgic_cpu.vgic_v3.its_vpe.irq; + if (irq) + disable_irq(irq); + } +}