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: 10055349 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 0D25060586 for ; Mon, 13 Nov 2017 09:19:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 125AD28FAE for ; Mon, 13 Nov 2017 09:19:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 070AD291CE; Mon, 13 Nov 2017 09:19:39 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0C3F28FAE for ; Mon, 13 Nov 2017 09:19:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752430AbdKMJS2 (ORCPT ); Mon, 13 Nov 2017 04:18:28 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:34802 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752409AbdKMJSZ (ORCPT ); Mon, 13 Nov 2017 04:18:25 -0500 Received: by mail-wm0-f68.google.com with SMTP id n74so13230959wmi.1 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=raHv+41/OCkjViM78WvB57Xrn7uloCz+IeNIxF8hEFO9/79nvD99Drih5CVXI8gtK7 jAmg3VOBoFB8VXbSkL3uMKBbmzSh6eA+MiQxW7AK/P//5de9VD3mMUCpOe+t9ca3TZR4 f8bltmSGOFl2FxWdsgV7h5udjsNlVS+fkkJsBTTJon/AbyY4pB6mK5Y/OnjlqWr8KOaf Ud0erMNdPH7vNvKlga34MbElXdMigOBdL10+nye6TCqQqeKcjPHPUEIqL8TG/9/M20Rd BQOofUttDLGmhIh5H67MULxenJpuzkv7hl79jgAj3SK8RZmOEdI+wVGAkfTQTTZjlUgN QHcQ== X-Gm-Message-State: AJaThX6TPIwtRWg+p6P8Cc2eRQp7HY6PhCfkgJd+VwiqdidgFgr0GRS9 blkrpGQjUWwL2vv5+0JITecX0A== 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?= Cc: Marc Zyngier , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Christoffer Dall 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.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); + } +}