From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Williamson Subject: Re: [PATCH v4 3/9] KVM: Clear assigned guest IRQ on release Date: Tue, 09 Nov 2010 11:36:19 -0700 Message-ID: <1289327779.14321.43.camel@x201> References: <4CD92950.1070309@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: Jan Kiszka , Marcelo Tosatti , kvm , "Michael S. Tsirkin" To: Avi Kivity Return-path: Received: from mx1.redhat.com ([209.132.183.28]:32234 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754439Ab0KISgY (ORCPT ); Tue, 9 Nov 2010 13:36:24 -0500 In-Reply-To: <4CD92950.1070309@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, 2010-11-09 at 12:58 +0200, Avi Kivity wrote: > On 11/08/2010 01:21 PM, Jan Kiszka wrote: > > When we deassign a guest IRQ, clear the potentially asserted guest line. > > There might be no chance for the guest to do this, specifically if we > > switch from INTx to MSI mode. > > > > Signed-off-by: Jan Kiszka > > --- > > virt/kvm/assigned-dev.c | 3 +++ > > 1 files changed, 3 insertions(+), 0 deletions(-) > > > > diff --git a/virt/kvm/assigned-dev.c b/virt/kvm/assigned-dev.c > > index 7c98928..ecc4419 100644 > > --- a/virt/kvm/assigned-dev.c > > +++ b/virt/kvm/assigned-dev.c > > @@ -141,6 +141,9 @@ static void deassign_guest_irq(struct kvm *kvm, > > kvm_unregister_irq_ack_notifier(kvm,&assigned_dev->ack_notifier); > > assigned_dev->ack_notifier.gsi = -1; > > > > + kvm_set_irq(assigned_dev->kvm, assigned_dev->irq_source_id, > > + assigned_dev->guest_irq, 0); > > + > > if (assigned_dev->irq_source_id != -1) > > kvm_free_irq_source_id(kvm, assigned_dev->irq_source_id); > > assigned_dev->irq_source_id = -1; > > I guess this can't hurt. Did you see it happen in practice? > > Note: all this kvm_set_irq(..., [01]) is incorrect as it doesn't account > for polarity. Currently the qemu-emulated chipset uses level high pci > interrupts, but that's not a given from kvm's point of view. > > I think vfio fixes this by only routing msi interrupts via the kernel, > and routing level interrupts through userspace, which can adjust > polarity. Alex/Michael? The latest patches will route legacy interrupts via irqfd if available too. We do have the issue that KVM pulses interrupts injected this way, but it seems to work nonetheless. I was thinking about proposing a level flag for set_irqfd to only set it, allowing the ack notifier to deassert it. Perhaps we also need a flag to toggle the polarity. Alex