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@xxxxxxxxxx> > --- > > 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. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html