From: Ben-Ami Yassour Subject: Re: [PATCH 3/8] KVM: Handle device assignment to guests Date: Thu, 17 Jul 2008 20:40:43 +0300 Message-ID: <1216316443.31546.355.camel@cluwyn.haifa.ibm.com> References: <1216214225-18030-1-git-send-email-benami@il.ibm.com> <1216214225-18030-2-git-send-email-benami@il.ibm.com> <1216214225-18030-3-git-send-email-benami@il.ibm.com> <1216214225-18030-4-git-send-email-benami@il.ibm.com> <487E0E10.4000009@qumranet.com> <1216287258.31546.337.camel@cluwyn.haifa.ibm.com> <487F15CE.5050204@qumranet.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: amit.shah@qumranet.com, kvm@vger.kernel.org, Muli Ben-Yehuda , weidong.han@intel.com, anthony@codemonkey.ws To: Avi Kivity Return-path: Received: from mtagate5.de.ibm.com ([195.212.29.154]:1899 "EHLO mtagate5.de.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760597AbYGQRlZ (ORCPT ); Thu, 17 Jul 2008 13:41:25 -0400 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate5.de.ibm.com (8.13.8/8.13.8) with ESMTP id m6HHejJj068416 for ; Thu, 17 Jul 2008 17:40:45 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v9.0) with ESMTP id m6HHejTK2773136 for ; Thu, 17 Jul 2008 19:40:45 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m6HHei7r007009 for ; Thu, 17 Jul 2008 19:40:45 +0200 In-Reply-To: <487F15CE.5050204@qumranet.com> Sender: kvm-owner@vger.kernel.org List-ID: On Thu, 2008-07-17 at 12:50 +0300, Avi Kivity wrote: > Ben-Ami Yassour wrote: > > On Wed, 2008-07-16 at 18:04 +0300, Avi Kivity wrote: > > =20 >=20 > If a level triggered interrupt remains active after the eoi, the ioap= ic=20 > has to inject it. This is used to support shared interrupts, or when= =20 > the device has re-raised the line by the time the ack arrives. >=20 > I don't see why it should behave differently for assigned devices. >=20 The difference is that for emulated devices, qemu is resetting the irr bit. For assigned devices it does not, and that's the difference. The first chance that we can clear the irr bit for real devices is the eoi function, and actually this is what the ack notify handler is doing (by calling =EF=BB=BF=EF=BB=BFpci_set_irq(kvm,irq,0) ). I was able to remove the code in ioapic by calling the ack notify handler before the irr check, and it seems to work fine. (to make it work, I also had to remove the queuing of the ack handler which was not necessary, as you mentioned in earlier comment) The eoi function now looks like this: static void __kvm_ioapic_update_eoi(struct kvm_ioapic *ioapic, int gsi) { union ioapic_redir_entry *ent; ent =3D &ioapic->redirtbl[gsi]; ASSERT(ent->fields.trig_mode =3D=3D IOAPIC_LEVEL_TRIG); ent->fields.remote_irr =3D 0; if (ioapic->ack_notifier) ioapic->ack_notifier(ioapic->kvm, gsi); if (!ent->fields.mask && (ioapic->irr & (1 << gsi))) ioapic_service(ioapic, gsi); } Any comments on such an approach? Thanks, Ben