From: Marcelo Tosatti <mtosatti@redhat.com>
To: Gleb Natapov <gleb@redhat.com>
Cc: avi@redhat.com, kvm@vger.kernel.org
Subject: Re: [PATCH 1/3] Make kvm_apic_set_irq() deliver all kinds of interrupts.
Date: Wed, 4 Mar 2009 14:48:32 -0300 [thread overview]
Message-ID: <20090304174832.GA28180@amt.cnet> (raw)
In-Reply-To: <20090304133010.18081.25499.stgit@dhcp-1-237.tlv.redhat.com>
Hi Gleb,
On Wed, Mar 04, 2009 at 03:30:11PM +0200, Gleb Natapov wrote:
> Get rid of ioapic_inj_irq() and ioapic_inj_nmi() functions.
>
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> ---
>
> index afc59b2..d58268f 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -196,20 +196,30 @@ int kvm_lapic_find_highest_irr(struct kvm_vcpu *vcpu)
> }
> EXPORT_SYMBOL_GPL(kvm_lapic_find_highest_irr);
>
> -int kvm_apic_set_irq(struct kvm_vcpu *vcpu, u8 vec, u8 trig)
> +static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
> + int vector, int level, int trig_mode);
> +
> +int kvm_apic_set_irq(struct kvm_vcpu *vcpu, u8 vec, u8 dmode, u8 trig)
> {
> struct kvm_lapic *apic = vcpu->arch.apic;
> + int lapic_dmode;
>
> - if (!apic_test_and_set_irr(vec, apic)) {
> - /* a new pending irq is set in IRR */
> - if (trig)
> - apic_set_vector(vec, apic->regs + APIC_TMR);
> - else
> - apic_clear_vector(vec, apic->regs + APIC_TMR);
> - kvm_vcpu_kick(apic->vcpu);
> - return 1;
> + switch(dmode) {
> + case IOAPIC_LOWEST_PRIORITY:
> + lapic_dmode = APIC_DM_LOWEST;
> + break;
> + case IOAPIC_FIXED:
> + lapic_dmode = APIC_DM_FIXED;
> + break;
> + case IOAPIC_NMI:
> + lapic_dmode = APIC_DM_NMI;
> + break;
> + default:
> + printk(KERN_DEBUG"Ignoring delivery mode %d\n", dmode);
> + return 0;
> + break;
> }
> - return 0;
> + return __apic_accept_irq(apic, lapic_dmode, vec, 1, trig);
The FIXED/LOWEST handling in __apic_accept_irqs is not as straightforward
as the old kvm_apic_set_irq. Perhaps replace
orig_irr = apic_test_and_set_irr(vector, apic);
if (orig_irr && trig_mode) {
apic_debug("level trig mode repeatedly for vector %d",
vector);
break;
}
if (trig_mode) {
apic_debug("level trig mode for vector %d", vector);
apic_set_vector(vector, apic->regs + APIC_TMR);
} else
apic_clear_vector(vector, apic->regs + APIC_TMR);
kvm_vcpu_kick(vcpu);
With the old
> - if (!apic_test_and_set_irr(vec, apic)) {
> - /* a new pending irq is set in IRR */
> - if (trig)
> - apic_set_vector(vec, apic->regs + APIC_TMR);
> - else
> - apic_clear_vector(vec, apic->regs + APIC_TMR);
> - kvm_vcpu_kick(apic->vcpu);
Note they are slightly different. The first version will update APIC_TMR
even if the IRR was already set, for trig_mode == 0.
Otherwise looks very nice, I've updated Sheng's "KVM: Merge
kvm_ioapic_get_delivery_bitmask into kvm_get_intr_delivery_bitmask",
so please rebase against that.
git://git.kernel.org/pub/scm/linux/kernel/git/marcelo/kvm.git kvm-devel
branch, will push in a few minutes.
next prev parent reply other threads:[~2009-03-04 17:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-04 13:30 [PATCH 0/3] ioapic/lapic/msi cleanup Gleb Natapov
2009-03-04 13:30 ` [PATCH 1/3] Make kvm_apic_set_irq() deliver all kinds of interrupts Gleb Natapov
2009-03-04 17:48 ` Marcelo Tosatti [this message]
2009-03-04 13:30 ` [PATCH 2/3] ioapic/msi interrupt delivery consolidation Gleb Natapov
2009-03-04 13:30 ` [PATCH 3/3] Consolidate ioapic/ipi interrupt delivery logic Gleb Natapov
2009-03-04 18:01 ` Marcelo Tosatti
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=20090304174832.GA28180@amt.cnet \
--to=mtosatti@redhat.com \
--cc=avi@redhat.com \
--cc=gleb@redhat.com \
--cc=kvm@vger.kernel.org \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox