From: Christoffer Dall <christoffer.dall@linaro.org> To: Alexander Graf <agraf@suse.de> Cc: kvm@vger.kernel.org, Marc Zyngier <marc.zyngier@arm.com>, linux-arm-kernel@lists.infradead.org, Paolo Bonzini <pbonzini@redhat.com>, kvmarm@lists.cs.columbia.edu Subject: [PATCH 1/3] KVM: arm/arm64: Cleanup the arch timer code's irqchip checking Date: Tue, 27 Sep 2016 21:08:04 +0200 [thread overview] Message-ID: <20160927190806.22988-2-christoffer.dall@linaro.org> (raw) In-Reply-To: <20160927190806.22988-1-christoffer.dall@linaro.org> Currently we check if we have an in-kernel irqchip and if the vgic was properly implemented several places in the arch timer code. But, we already predicate our enablement of the arm timers on having a valid and initialized gic, so we can simply check if the timers are enabled or not. This also gets rid of the ugly "error that's not an error but used to signal that the timer shouldn't poke the gic" construct we have. Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org> --- virt/kvm/arm/arch_timer.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index 27a1f63..824ed26 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -171,8 +171,6 @@ static void kvm_timer_update_irq(struct kvm_vcpu *vcpu, bool new_level) int ret; struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; - BUG_ON(!vgic_initialized(vcpu->kvm)); - timer->active_cleared_last = false; timer->irq.level = new_level; trace_kvm_timer_update_irq(vcpu->vcpu_id, timer->irq.irq, @@ -187,7 +185,7 @@ static void kvm_timer_update_irq(struct kvm_vcpu *vcpu, bool new_level) * Check if there was a change in the timer state (should we raise or lower * the line level to the GIC). */ -static int kvm_timer_update_state(struct kvm_vcpu *vcpu) +static void kvm_timer_update_state(struct kvm_vcpu *vcpu) { struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; @@ -197,13 +195,11 @@ static int kvm_timer_update_state(struct kvm_vcpu *vcpu) * because the guest would never see the interrupt. Instead wait * until we call this function from kvm_timer_flush_hwstate. */ - if (!vgic_initialized(vcpu->kvm) || !timer->enabled) - return -ENODEV; + if (!timer->enabled) + return; if (kvm_timer_should_fire(vcpu) != timer->irq.level) kvm_timer_update_irq(vcpu, !timer->irq.level); - - return 0; } /* @@ -255,9 +251,11 @@ void kvm_timer_flush_hwstate(struct kvm_vcpu *vcpu) bool phys_active; int ret; - if (kvm_timer_update_state(vcpu)) + if (unlikely(!timer->enabled)) return; + kvm_timer_update_state(vcpu); + /* * If we enter the guest with the virtual input level to the VGIC * asserted, then we have already told the VGIC what we need to, and -- 2.9.0
WARNING: multiple messages have this Message-ID (diff)
From: christoffer.dall@linaro.org (Christoffer Dall) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/3] KVM: arm/arm64: Cleanup the arch timer code's irqchip checking Date: Tue, 27 Sep 2016 21:08:04 +0200 [thread overview] Message-ID: <20160927190806.22988-2-christoffer.dall@linaro.org> (raw) In-Reply-To: <20160927190806.22988-1-christoffer.dall@linaro.org> Currently we check if we have an in-kernel irqchip and if the vgic was properly implemented several places in the arch timer code. But, we already predicate our enablement of the arm timers on having a valid and initialized gic, so we can simply check if the timers are enabled or not. This also gets rid of the ugly "error that's not an error but used to signal that the timer shouldn't poke the gic" construct we have. Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org> --- virt/kvm/arm/arch_timer.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index 27a1f63..824ed26 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -171,8 +171,6 @@ static void kvm_timer_update_irq(struct kvm_vcpu *vcpu, bool new_level) int ret; struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; - BUG_ON(!vgic_initialized(vcpu->kvm)); - timer->active_cleared_last = false; timer->irq.level = new_level; trace_kvm_timer_update_irq(vcpu->vcpu_id, timer->irq.irq, @@ -187,7 +185,7 @@ static void kvm_timer_update_irq(struct kvm_vcpu *vcpu, bool new_level) * Check if there was a change in the timer state (should we raise or lower * the line level to the GIC). */ -static int kvm_timer_update_state(struct kvm_vcpu *vcpu) +static void kvm_timer_update_state(struct kvm_vcpu *vcpu) { struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; @@ -197,13 +195,11 @@ static int kvm_timer_update_state(struct kvm_vcpu *vcpu) * because the guest would never see the interrupt. Instead wait * until we call this function from kvm_timer_flush_hwstate. */ - if (!vgic_initialized(vcpu->kvm) || !timer->enabled) - return -ENODEV; + if (!timer->enabled) + return; if (kvm_timer_should_fire(vcpu) != timer->irq.level) kvm_timer_update_irq(vcpu, !timer->irq.level); - - return 0; } /* @@ -255,9 +251,11 @@ void kvm_timer_flush_hwstate(struct kvm_vcpu *vcpu) bool phys_active; int ret; - if (kvm_timer_update_state(vcpu)) + if (unlikely(!timer->enabled)) return; + kvm_timer_update_state(vcpu); + /* * If we enter the guest with the virtual input level to the VGIC * asserted, then we have already told the VGIC what we need to, and -- 2.9.0
next prev parent reply other threads:[~2016-09-27 19:08 UTC|newest] Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-09-27 19:08 [PATCH 0/3] Support userspace irqchip with arch timers Christoffer Dall 2016-09-27 19:08 ` Christoffer Dall 2016-09-27 19:08 ` Christoffer Dall [this message] 2016-09-27 19:08 ` [PATCH 1/3] KVM: arm/arm64: Cleanup the arch timer code's irqchip checking Christoffer Dall 2016-09-27 19:08 ` [PATCH 2/3] KVM: arm/arm64: Add ARM arch timer interrupts ABI Christoffer Dall 2016-09-27 19:08 ` Christoffer Dall 2016-11-01 11:26 ` Peter Maydell 2016-11-01 11:26 ` Peter Maydell 2016-11-01 14:50 ` Christoffer Dall 2016-11-01 14:50 ` Christoffer Dall 2016-11-01 14:54 ` Peter Maydell 2016-11-01 14:54 ` Peter Maydell 2016-11-01 15:32 ` Christoffer Dall 2016-11-01 15:32 ` Christoffer Dall 2016-11-01 16:56 ` Marc Zyngier 2016-11-01 16:56 ` Marc Zyngier 2016-11-01 16:56 ` Marc Zyngier 2016-09-27 19:08 ` [PATCH 3/3] KVM: arm/arm64: Support arch timers with a userspace gic Christoffer Dall 2016-09-27 19:08 ` Christoffer Dall 2016-09-29 15:11 ` [PATCH 0/3] Support userspace irqchip with arch timers Alexander Graf 2016-09-29 15:11 ` Alexander Graf 2016-09-30 14:54 ` Alexander Graf 2016-09-30 14:54 ` Alexander Graf 2016-09-30 15:38 ` Alexander Graf 2016-09-30 15:38 ` Alexander Graf 2016-09-30 15:43 ` Christoffer Dall 2016-09-30 15:43 ` Christoffer Dall 2016-09-30 15:55 ` Alexander Graf 2016-09-30 15:55 ` Alexander Graf 2016-09-30 19:31 ` Alexander Graf 2016-09-30 19:31 ` Alexander Graf 2016-10-28 14:38 ` Marc Zyngier 2016-10-28 14:38 ` Marc Zyngier 2016-10-28 15:52 ` Alexander Graf 2016-10-28 15:52 ` Alexander Graf 2016-10-28 15:57 ` Marc Zyngier 2016-10-28 15:57 ` Marc Zyngier 2016-10-28 20:25 ` Alexander Graf 2016-10-28 20:25 ` Alexander Graf 2016-10-29 13:19 ` Paolo Bonzini 2016-10-29 13:19 ` Paolo Bonzini 2016-10-29 18:55 ` Alexander Graf 2016-10-29 18:55 ` Alexander Graf
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20160927190806.22988-2-christoffer.dall@linaro.org \ --to=christoffer.dall@linaro.org \ --cc=agraf@suse.de \ --cc=kvm@vger.kernel.org \ --cc=kvmarm@lists.cs.columbia.edu \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=marc.zyngier@arm.com \ --cc=pbonzini@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.