From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756174AbdKGVqH (ORCPT ); Tue, 7 Nov 2017 16:46:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42598 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752980AbdKGVqD (ORCPT ); Tue, 7 Nov 2017 16:46:03 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8E99C25C25 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=eric.auger@redhat.com Subject: Re: [PATCH v5 20/26] KVM: arm/arm64: GICv4: Use the doorbell interrupt as an unblocking source To: Marc Zyngier , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20171027142855.21584-1-marc.zyngier@arm.com> <20171027142855.21584-21-marc.zyngier@arm.com> Cc: Mark Rutland , Christoffer Dall , Andre Przywara , Shameerali Kolothum Thodi , Christoffer Dall , Shanker Donthineni From: Auger Eric Message-ID: Date: Tue, 7 Nov 2017 22:45:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20171027142855.21584-21-marc.zyngier@arm.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 07 Nov 2017 21:46:03 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 27/10/2017 16:28, Marc Zyngier wrote: > 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 > Signed-off-by: Marc Zyngier Reviewed-by: Eric Auger Eric > --- > 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 8388c1cc23f6..092a4ec03e57 100644 > --- a/virt/kvm/arm/arm.c > +++ b/virt/kvm/arm/arm.c > @@ -316,11 +316,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 ea898af1a7a9..1a2f2fcdfa67 100644 > --- a/virt/kvm/arm/vgic/vgic-v4.c > +++ b/virt/kvm/arm/vgic/vgic-v4.c > @@ -237,3 +237,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); > + } > +} >